babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. /**
  409. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  688. static readonly GEQUAL: number;
  689. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1199. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1200. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1201. /** @hidden */
  1202. export class ShaderCodeTestNode extends ShaderCodeNode {
  1203. testExpression: ShaderDefineExpression;
  1204. isValid(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1210. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1211. /** @hidden */
  1212. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1213. define: string;
  1214. not: boolean;
  1215. constructor(define: string, not?: boolean);
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1236. leftOperand: ShaderDefineExpression;
  1237. rightOperand: ShaderDefineExpression;
  1238. isTrue(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module "babylonjs/Offline/IOfflineProvider" {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module "babylonjs/Misc/filesInputStore" {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module "babylonjs/Misc/retryStrategy" {
  1308. import { WebRequest } from "babylonjs/Misc/webRequest";
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module "babylonjs/Misc/baseError" {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/fileTools" {
  1332. import { WebRequest } from "babylonjs/Misc/webRequest";
  1333. import { Nullable } from "babylonjs/types";
  1334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1335. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1336. import { BaseError } from "babylonjs/Misc/baseError";
  1337. /** @ignore */
  1338. export class LoadFileError extends BaseError {
  1339. request?: WebRequest;
  1340. file?: File;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. * @param file defines the optional file
  1346. */
  1347. constructor(message: string, object?: WebRequest | File);
  1348. }
  1349. /** @ignore */
  1350. export class RequestFileError extends BaseError {
  1351. request: WebRequest;
  1352. /**
  1353. * Creates a new LoadFileError
  1354. * @param message defines the message of the error
  1355. * @param request defines the optional web request
  1356. */
  1357. constructor(message: string, request: WebRequest);
  1358. }
  1359. /** @ignore */
  1360. export class ReadFileError extends BaseError {
  1361. file: File;
  1362. /**
  1363. * Creates a new ReadFileError
  1364. * @param message defines the message of the error
  1365. * @param file defines the optional file
  1366. */
  1367. constructor(message: string, file: File);
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export class FileTools {
  1373. /**
  1374. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1375. */
  1376. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1377. /**
  1378. * Gets or sets the base URL to use to load assets
  1379. */
  1380. static BaseUrl: string;
  1381. /**
  1382. * Default behaviour for cors in the application.
  1383. * It can be a string if the expected behavior is identical in the entire app.
  1384. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1385. */
  1386. static CorsBehavior: string | ((url: string | string[]) => string);
  1387. /**
  1388. * Gets or sets a function used to pre-process url before using them to load assets
  1389. */
  1390. static PreprocessUrl: (url: string) => string;
  1391. /**
  1392. * Removes unwanted characters from an url
  1393. * @param url defines the url to clean
  1394. * @returns the cleaned url
  1395. */
  1396. private static _CleanUrl;
  1397. /**
  1398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1399. * @param url define the url we are trying
  1400. * @param element define the dom element where to configure the cors policy
  1401. */
  1402. static SetCorsBehavior(url: string | string[], element: {
  1403. crossOrigin: string | null;
  1404. }): void;
  1405. /**
  1406. * Loads an image as an HTMLImageElement.
  1407. * @param input url string, ArrayBuffer, or Blob to load
  1408. * @param onLoad callback called when the image successfully loads
  1409. * @param onError callback called when the image fails to load
  1410. * @param offlineProvider offline provider for caching
  1411. * @param mimeType optional mime type
  1412. * @returns the HTMLImageElement of the loaded image
  1413. */
  1414. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1415. /**
  1416. * Reads a file from a File object
  1417. * @param file defines the file to load
  1418. * @param onSuccess defines the callback to call when data is loaded
  1419. * @param onProgress defines the callback to call during loading process
  1420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1421. * @param onError defines the callback to call when an error occurs
  1422. * @returns a file request object
  1423. */
  1424. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file from a url
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param offlineProvider defines the offline provider for caching
  1431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1432. * @param onError callback called when the file fails to load
  1433. * @returns a file request object
  1434. */
  1435. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1436. /**
  1437. * Loads a file
  1438. * @param url url to load
  1439. * @param onSuccess callback called when the file successfully loads
  1440. * @param onProgress callback called while file is loading (if the server supports this mode)
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @param onOpened callback called when the web request is opened
  1444. * @returns a file request object
  1445. */
  1446. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1447. /**
  1448. * Checks if the loaded document was accessed via `file:`-Protocol.
  1449. * @returns boolean
  1450. */
  1451. static IsFileURL(): boolean;
  1452. }
  1453. }
  1454. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1455. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1456. import { WebRequest } from "babylonjs/Misc/webRequest";
  1457. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1459. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1460. /** @hidden */
  1461. export class ShaderProcessor {
  1462. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1463. private static _ProcessPrecision;
  1464. private static _ExtractOperation;
  1465. private static _BuildSubExpression;
  1466. private static _BuildExpression;
  1467. private static _MoveCursorWithinIf;
  1468. private static _MoveCursor;
  1469. private static _EvaluatePreProcessors;
  1470. private static _PreparePreProcessors;
  1471. private static _ProcessShaderConversion;
  1472. private static _ProcessIncludes;
  1473. /**
  1474. * Loads a file from a url
  1475. * @param url url to load
  1476. * @param onSuccess callback called when the file successfully loads
  1477. * @param onProgress callback called while file is loading (if the server supports this mode)
  1478. * @param offlineProvider defines the offline provider for caching
  1479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1480. * @param onError callback called when the file fails to load
  1481. * @returns a file request object
  1482. * @hidden
  1483. */
  1484. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1485. }
  1486. }
  1487. declare module "babylonjs/Maths/math.like" {
  1488. import { float, int, DeepImmutable } from "babylonjs/types";
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IColor4Like {
  1493. r: float;
  1494. g: float;
  1495. b: float;
  1496. a: float;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor3Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IVector4Like {
  1510. x: float;
  1511. y: float;
  1512. z: float;
  1513. w: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector3Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector2Like {
  1527. x: float;
  1528. y: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IMatrixLike {
  1534. toArray(): DeepImmutable<Float32Array>;
  1535. updateFlag: int;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IViewportLike {
  1541. x: float;
  1542. y: float;
  1543. width: float;
  1544. height: float;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IPlaneLike {
  1550. normal: IVector3Like;
  1551. d: float;
  1552. normalize(): void;
  1553. }
  1554. }
  1555. declare module "babylonjs/Materials/iEffectFallbacks" {
  1556. import { Effect } from "babylonjs/Materials/effect";
  1557. /**
  1558. * Interface used to define common properties for effect fallbacks
  1559. */
  1560. export interface IEffectFallbacks {
  1561. /**
  1562. * Removes the defines that should be removed when falling back.
  1563. * @param currentDefines defines the current define statements for the shader.
  1564. * @param effect defines the current effect we try to compile
  1565. * @returns The resulting defines with defines of the current rank removed.
  1566. */
  1567. reduce(currentDefines: string, effect: Effect): string;
  1568. /**
  1569. * Removes the fallback from the bound mesh.
  1570. */
  1571. unBindMesh(): void;
  1572. /**
  1573. * Checks to see if more fallbacks are still availible.
  1574. */
  1575. hasMoreFallbacks: boolean;
  1576. }
  1577. }
  1578. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1579. /**
  1580. * Class used to evalaute queries containing `and` and `or` operators
  1581. */
  1582. export class AndOrNotEvaluator {
  1583. /**
  1584. * Evaluate a query
  1585. * @param query defines the query to evaluate
  1586. * @param evaluateCallback defines the callback used to filter result
  1587. * @returns true if the query matches
  1588. */
  1589. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1590. private static _HandleParenthesisContent;
  1591. private static _SimplifyNegation;
  1592. }
  1593. }
  1594. declare module "babylonjs/Misc/tags" {
  1595. /**
  1596. * Class used to store custom tags
  1597. */
  1598. export class Tags {
  1599. /**
  1600. * Adds support for tags on the given object
  1601. * @param obj defines the object to use
  1602. */
  1603. static EnableFor(obj: any): void;
  1604. /**
  1605. * Removes tags support
  1606. * @param obj defines the object to use
  1607. */
  1608. static DisableFor(obj: any): void;
  1609. /**
  1610. * Gets a boolean indicating if the given object has tags
  1611. * @param obj defines the object to use
  1612. * @returns a boolean
  1613. */
  1614. static HasTags(obj: any): boolean;
  1615. /**
  1616. * Gets the tags available on a given object
  1617. * @param obj defines the object to use
  1618. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1619. * @returns the tags
  1620. */
  1621. static GetTags(obj: any, asString?: boolean): any;
  1622. /**
  1623. * Adds tags to an object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1626. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1627. */
  1628. static AddTagsTo(obj: any, tagsString: string): void;
  1629. /**
  1630. * @hidden
  1631. */
  1632. static _AddTagTo(obj: any, tag: string): void;
  1633. /**
  1634. * Removes specific tags from a specific object
  1635. * @param obj defines the object to use
  1636. * @param tagsString defines the tags to remove
  1637. */
  1638. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1639. /**
  1640. * @hidden
  1641. */
  1642. static _RemoveTagFrom(obj: any, tag: string): void;
  1643. /**
  1644. * Defines if tags hosted on an object match a given query
  1645. * @param obj defines the object to use
  1646. * @param tagsQuery defines the tag query
  1647. * @returns a boolean
  1648. */
  1649. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1650. }
  1651. }
  1652. declare module "babylonjs/Maths/math.scalar" {
  1653. /**
  1654. * Scalar computation library
  1655. */
  1656. export class Scalar {
  1657. /**
  1658. * Two pi constants convenient for computation.
  1659. */
  1660. static TwoPi: number;
  1661. /**
  1662. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. * @param a number
  1664. * @param b number
  1665. * @param epsilon (default = 1.401298E-45)
  1666. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. */
  1668. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1669. /**
  1670. * Returns a string : the upper case translation of the number i to hexadecimal.
  1671. * @param i number
  1672. * @returns the upper case translation of the number i to hexadecimal.
  1673. */
  1674. static ToHex(i: number): string;
  1675. /**
  1676. * Returns -1 if value is negative and +1 is value is positive.
  1677. * @param value the value
  1678. * @returns the value itself if it's equal to zero.
  1679. */
  1680. static Sign(value: number): number;
  1681. /**
  1682. * Returns the value itself if it's between min and max.
  1683. * Returns min if the value is lower than min.
  1684. * Returns max if the value is greater than max.
  1685. * @param value the value to clmap
  1686. * @param min the min value to clamp to (default: 0)
  1687. * @param max the max value to clamp to (default: 1)
  1688. * @returns the clamped value
  1689. */
  1690. static Clamp(value: number, min?: number, max?: number): number;
  1691. /**
  1692. * the log2 of value.
  1693. * @param value the value to compute log2 of
  1694. * @returns the log2 of value.
  1695. */
  1696. static Log2(value: number): number;
  1697. /**
  1698. * Loops the value, so that it is never larger than length and never smaller than 0.
  1699. *
  1700. * This is similar to the modulo operator but it works with floating point numbers.
  1701. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1702. * With t = 5 and length = 2.5, the result would be 0.0.
  1703. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1704. * @param value the value
  1705. * @param length the length
  1706. * @returns the looped value
  1707. */
  1708. static Repeat(value: number, length: number): number;
  1709. /**
  1710. * Normalize the value between 0.0 and 1.0 using min and max values
  1711. * @param value value to normalize
  1712. * @param min max to normalize between
  1713. * @param max min to normalize between
  1714. * @returns the normalized value
  1715. */
  1716. static Normalize(value: number, min: number, max: number): number;
  1717. /**
  1718. * Denormalize the value from 0.0 and 1.0 using min and max values
  1719. * @param normalized value to denormalize
  1720. * @param min max to denormalize between
  1721. * @param max min to denormalize between
  1722. * @returns the denormalized value
  1723. */
  1724. static Denormalize(normalized: number, min: number, max: number): number;
  1725. /**
  1726. * Calculates the shortest difference between two given angles given in degrees.
  1727. * @param current current angle in degrees
  1728. * @param target target angle in degrees
  1729. * @returns the delta
  1730. */
  1731. static DeltaAngle(current: number, target: number): number;
  1732. /**
  1733. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1734. * @param tx value
  1735. * @param length length
  1736. * @returns The returned value will move back and forth between 0 and length
  1737. */
  1738. static PingPong(tx: number, length: number): number;
  1739. /**
  1740. * Interpolates between min and max with smoothing at the limits.
  1741. *
  1742. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1743. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1744. * @param from from
  1745. * @param to to
  1746. * @param tx value
  1747. * @returns the smooth stepped value
  1748. */
  1749. static SmoothStep(from: number, to: number, tx: number): number;
  1750. /**
  1751. * Moves a value current towards target.
  1752. *
  1753. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1754. * Negative values of maxDelta pushes the value away from target.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting value
  1759. */
  1760. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1763. *
  1764. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1765. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1766. * @param current current value
  1767. * @param target target value
  1768. * @param maxDelta max distance to move
  1769. * @returns resulting angle
  1770. */
  1771. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1772. /**
  1773. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1774. * @param start start value
  1775. * @param end target value
  1776. * @param amount amount to lerp between
  1777. * @returns the lerped value
  1778. */
  1779. static Lerp(start: number, end: number, amount: number): number;
  1780. /**
  1781. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static LerpAngle(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1791. * @param a start value
  1792. * @param b target value
  1793. * @param value value between a and b
  1794. * @returns the inverseLerp value
  1795. */
  1796. static InverseLerp(a: number, b: number, value: number): number;
  1797. /**
  1798. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1799. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1800. * @param value1 spline value
  1801. * @param tangent1 spline value
  1802. * @param value2 spline value
  1803. * @param tangent2 spline value
  1804. * @param amount input value
  1805. * @returns hermite result
  1806. */
  1807. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1808. /**
  1809. * Returns a random float number between and min and max values
  1810. * @param min min value of random
  1811. * @param max max value of random
  1812. * @returns random value
  1813. */
  1814. static RandomRange(min: number, max: number): number;
  1815. /**
  1816. * This function returns percentage of a number in a given range.
  1817. *
  1818. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1819. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1820. * @param number to convert to percentage
  1821. * @param min min range
  1822. * @param max max range
  1823. * @returns the percentage
  1824. */
  1825. static RangeToPercent(number: number, min: number, max: number): number;
  1826. /**
  1827. * This function returns number that corresponds to the percentage in a given range.
  1828. *
  1829. * PercentToRange(0.34,0,100) will return 34.
  1830. * @param percent to convert to number
  1831. * @param min min range
  1832. * @param max max range
  1833. * @returns the number
  1834. */
  1835. static PercentToRange(percent: number, min: number, max: number): number;
  1836. /**
  1837. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1838. * @param angle The angle to normalize in radian.
  1839. * @return The converted angle.
  1840. */
  1841. static NormalizeRadians(angle: number): number;
  1842. }
  1843. }
  1844. declare module "babylonjs/Maths/math.constants" {
  1845. /**
  1846. * Constant used to convert a value to gamma space
  1847. * @ignorenaming
  1848. */
  1849. export const ToGammaSpace: number;
  1850. /**
  1851. * Constant used to convert a value to linear space
  1852. * @ignorenaming
  1853. */
  1854. export const ToLinearSpace = 2.2;
  1855. /**
  1856. * Constant used to define the minimal number value in Babylon.js
  1857. * @ignorenaming
  1858. */
  1859. let Epsilon: number;
  1860. export { Epsilon };
  1861. }
  1862. declare module "babylonjs/Maths/math.viewport" {
  1863. /**
  1864. * Class used to represent a viewport on screen
  1865. */
  1866. export class Viewport {
  1867. /** viewport left coordinate */
  1868. x: number;
  1869. /** viewport top coordinate */
  1870. y: number;
  1871. /**viewport width */
  1872. width: number;
  1873. /** viewport height */
  1874. height: number;
  1875. /**
  1876. * Creates a Viewport object located at (x, y) and sized (width, height)
  1877. * @param x defines viewport left coordinate
  1878. * @param y defines viewport top coordinate
  1879. * @param width defines the viewport width
  1880. * @param height defines the viewport height
  1881. */
  1882. constructor(
  1883. /** viewport left coordinate */
  1884. x: number,
  1885. /** viewport top coordinate */
  1886. y: number,
  1887. /**viewport width */
  1888. width: number,
  1889. /** viewport height */
  1890. height: number);
  1891. /**
  1892. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @returns a new Viewport
  1896. */
  1897. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1898. /**
  1899. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @param ref defines the target viewport
  1903. * @returns the current viewport
  1904. */
  1905. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1906. /**
  1907. * Returns a new Viewport copied from the current one
  1908. * @returns a new Viewport
  1909. */
  1910. clone(): Viewport;
  1911. }
  1912. }
  1913. declare module "babylonjs/Misc/arrayTools" {
  1914. /**
  1915. * Class containing a set of static utilities functions for arrays.
  1916. */
  1917. export class ArrayTools {
  1918. /**
  1919. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1920. * @param size the number of element to construct and put in the array
  1921. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1922. * @returns a new array filled with new objects
  1923. */
  1924. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1925. }
  1926. }
  1927. declare module "babylonjs/Maths/math.vector" {
  1928. import { Viewport } from "babylonjs/Maths/math.viewport";
  1929. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1930. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1931. /**
  1932. * Class representing a vector containing 2 coordinates
  1933. */
  1934. export class Vector2 {
  1935. /** defines the first coordinate */
  1936. x: number;
  1937. /** defines the second coordinate */
  1938. y: number;
  1939. /**
  1940. * Creates a new Vector2 from the given x and y coordinates
  1941. * @param x defines the first coordinate
  1942. * @param y defines the second coordinate
  1943. */
  1944. constructor(
  1945. /** defines the first coordinate */
  1946. x?: number,
  1947. /** defines the second coordinate */
  1948. y?: number);
  1949. /**
  1950. * Gets a string with the Vector2 coordinates
  1951. * @returns a string with the Vector2 coordinates
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Gets class name
  1956. * @returns the string "Vector2"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Gets current vector hash code
  1961. * @returns the Vector2 hash code as a number
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1966. * @param array defines the source array
  1967. * @param index defines the offset in source array
  1968. * @returns the current Vector2
  1969. */
  1970. toArray(array: FloatArray, index?: number): Vector2;
  1971. /**
  1972. * Copy the current vector to an array
  1973. * @returns a new array with 2 elements: the Vector2 coordinates.
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1978. * @param source defines the source Vector2
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFromFloats(x: number, y: number): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. set(x: number, y: number): Vector2;
  1996. /**
  1997. * Add another vector with the current one
  1998. * @param otherVector defines the other vector
  1999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2000. */
  2001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @param result defines the target vector
  2006. * @returns the unmodified current Vector2
  2007. */
  2008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2009. /**
  2010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2011. * @param otherVector defines the other vector
  2012. * @returns the current updated Vector2
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2015. /**
  2016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2
  2019. */
  2020. addVector3(otherVector: Vector3): Vector2;
  2021. /**
  2022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2023. * @param otherVector defines the other vector
  2024. * @returns a new Vector2
  2025. */
  2026. subtract(otherVector: Vector2): Vector2;
  2027. /**
  2028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2029. * @param otherVector defines the other vector
  2030. * @param result defines the target vector
  2031. * @returns the unmodified current Vector2
  2032. */
  2033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2034. /**
  2035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns the current updated Vector2
  2038. */
  2039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2040. /**
  2041. * Multiplies in place the current Vector2 coordinates by the given ones
  2042. * @param otherVector defines the other vector
  2043. * @returns the current updated Vector2
  2044. */
  2045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2046. /**
  2047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @returns a new Vector2
  2050. */
  2051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2054. * @param otherVector defines the other vector
  2055. * @param result defines the target vector
  2056. * @returns the unmodified current Vector2
  2057. */
  2058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2059. /**
  2060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. * @returns a new Vector2
  2064. */
  2065. multiplyByFloats(x: number, y: number): Vector2;
  2066. /**
  2067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2068. * @param otherVector defines the other vector
  2069. * @returns a new Vector2
  2070. */
  2071. divide(otherVector: Vector2): Vector2;
  2072. /**
  2073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2074. * @param otherVector defines the other vector
  2075. * @param result defines the target vector
  2076. * @returns the unmodified current Vector2
  2077. */
  2078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2079. /**
  2080. * Divides the current Vector2 coordinates by the given ones
  2081. * @param otherVector defines the other vector
  2082. * @returns the current updated Vector2
  2083. */
  2084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2085. /**
  2086. * Gets a new Vector2 with current Vector2 negated coordinates
  2087. * @returns a new Vector2
  2088. */
  2089. negate(): Vector2;
  2090. /**
  2091. * Negate this vector in place
  2092. * @returns this
  2093. */
  2094. negateInPlace(): Vector2;
  2095. /**
  2096. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2097. * @param result defines the Vector3 object where to store the result
  2098. * @returns the current Vector2
  2099. */
  2100. negateToRef(result: Vector2): Vector2;
  2101. /**
  2102. * Multiply the Vector2 coordinates by scale
  2103. * @param scale defines the scaling factor
  2104. * @returns the current updated Vector2
  2105. */
  2106. scaleInPlace(scale: number): Vector2;
  2107. /**
  2108. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2109. * @param scale defines the scaling factor
  2110. * @returns a new Vector2
  2111. */
  2112. scale(scale: number): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Gets a boolean if two vectors are equals
  2129. * @param otherVector defines the other vector
  2130. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2131. */
  2132. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2133. /**
  2134. * Gets a boolean if two vectors are equals (using an epsilon value)
  2135. * @param otherVector defines the other vector
  2136. * @param epsilon defines the minimal distance to consider equality
  2137. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2138. */
  2139. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2140. /**
  2141. * Gets a new Vector2 from current Vector2 floored values
  2142. * @returns a new Vector2
  2143. */
  2144. floor(): Vector2;
  2145. /**
  2146. * Gets a new Vector2 from current Vector2 floored values
  2147. * @returns a new Vector2
  2148. */
  2149. fract(): Vector2;
  2150. /**
  2151. * Gets the length of the vector
  2152. * @returns the vector length (float)
  2153. */
  2154. length(): number;
  2155. /**
  2156. * Gets the vector squared length
  2157. * @returns the vector squared length (float)
  2158. */
  2159. lengthSquared(): number;
  2160. /**
  2161. * Normalize the vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. normalize(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 copied from the Vector2
  2167. * @returns a new Vector2
  2168. */
  2169. clone(): Vector2;
  2170. /**
  2171. * Gets a new Vector2(0, 0)
  2172. * @returns a new Vector2
  2173. */
  2174. static Zero(): Vector2;
  2175. /**
  2176. * Gets a new Vector2(1, 1)
  2177. * @returns a new Vector2
  2178. */
  2179. static One(): Vector2;
  2180. /**
  2181. * Gets a new Vector2 set from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @returns a new Vector2
  2185. */
  2186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2187. /**
  2188. * Sets "result" from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @param result defines the target vector
  2192. */
  2193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2194. /**
  2195. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2196. * @param value1 defines 1st point of control
  2197. * @param value2 defines 2nd point of control
  2198. * @param value3 defines 3rd point of control
  2199. * @param value4 defines 4th point of control
  2200. * @param amount defines the interpolation factor
  2201. * @returns a new Vector2
  2202. */
  2203. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2204. /**
  2205. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2206. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2207. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2208. * @param value defines the value to clamp
  2209. * @param min defines the lower limit
  2210. * @param max defines the upper limit
  2211. * @returns a new Vector2
  2212. */
  2213. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2216. * @param value1 defines the 1st control point
  2217. * @param tangent1 defines the outgoing tangent
  2218. * @param value2 defines the 2nd control point
  2219. * @param tangent2 defines the incoming tangent
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2226. * @param start defines the start vector
  2227. * @param end defines the end vector
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Gets the dot product of the vector "left" and the vector "right"
  2234. * @param left defines first vector
  2235. * @param right defines second vector
  2236. * @returns the dot product (float)
  2237. */
  2238. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2239. /**
  2240. * Returns a new Vector2 equal to the normalized given vector
  2241. * @param vector defines the vector to normalize
  2242. * @returns a new Vector2
  2243. */
  2244. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @returns a new Vector2
  2264. */
  2265. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2266. /**
  2267. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @param result defines the target vector
  2271. */
  2272. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2273. /**
  2274. * Determines if a given vector is included in a triangle
  2275. * @param p defines the vector to test
  2276. * @param p0 defines 1st triangle point
  2277. * @param p1 defines 2nd triangle point
  2278. * @param p2 defines 3rd triangle point
  2279. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2280. */
  2281. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2282. /**
  2283. * Gets the distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the distance between vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Returns the squared distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the squared distance between vectors
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns a new Vector2
  2301. */
  2302. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2303. /**
  2304. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2305. * @param p defines the middle point
  2306. * @param segA defines one point of the segment
  2307. * @param segB defines the other point of the segment
  2308. * @returns the shortest distance
  2309. */
  2310. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2311. }
  2312. /**
  2313. * Class used to store (x,y,z) vector representation
  2314. * A Vector3 is the main object used in 3D geometry
  2315. * It can represent etiher the coordinates of a point the space, either a direction
  2316. * Reminder: js uses a left handed forward facing system
  2317. */
  2318. export class Vector3 {
  2319. /**
  2320. * Defines the first coordinates (on X axis)
  2321. */
  2322. x: number;
  2323. /**
  2324. * Defines the second coordinates (on Y axis)
  2325. */
  2326. y: number;
  2327. /**
  2328. * Defines the third coordinates (on Z axis)
  2329. */
  2330. z: number;
  2331. private static _UpReadOnly;
  2332. private static _ZeroReadOnly;
  2333. /**
  2334. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2335. * @param x defines the first coordinates (on X axis)
  2336. * @param y defines the second coordinates (on Y axis)
  2337. * @param z defines the third coordinates (on Z axis)
  2338. */
  2339. constructor(
  2340. /**
  2341. * Defines the first coordinates (on X axis)
  2342. */
  2343. x?: number,
  2344. /**
  2345. * Defines the second coordinates (on Y axis)
  2346. */
  2347. y?: number,
  2348. /**
  2349. * Defines the third coordinates (on Z axis)
  2350. */
  2351. z?: number);
  2352. /**
  2353. * Creates a string representation of the Vector3
  2354. * @returns a string with the Vector3 coordinates.
  2355. */
  2356. toString(): string;
  2357. /**
  2358. * Gets the class name
  2359. * @returns the string "Vector3"
  2360. */
  2361. getClassName(): string;
  2362. /**
  2363. * Creates the Vector3 hash code
  2364. * @returns a number which tends to be unique between Vector3 instances
  2365. */
  2366. getHashCode(): number;
  2367. /**
  2368. * Creates an array containing three elements : the coordinates of the Vector3
  2369. * @returns a new array of numbers
  2370. */
  2371. asArray(): number[];
  2372. /**
  2373. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2374. * @param array defines the destination array
  2375. * @param index defines the offset in the destination array
  2376. * @returns the current Vector3
  2377. */
  2378. toArray(array: FloatArray, index?: number): Vector3;
  2379. /**
  2380. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2381. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2382. */
  2383. toQuaternion(): Quaternion;
  2384. /**
  2385. * Adds the given vector to the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Adds the given coordinates to the current Vector3
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2400. * @param otherVector defines the second operand
  2401. * @returns the resulting Vector3
  2402. */
  2403. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2404. /**
  2405. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2406. * @param otherVector defines the second operand
  2407. * @param result defines the Vector3 object where to store the result
  2408. * @returns the current Vector3
  2409. */
  2410. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2411. /**
  2412. * Subtract the given vector from the current Vector3
  2413. * @param otherVector defines the second operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2417. /**
  2418. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2425. * @param otherVector defines the second operand
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @returns the resulting Vector3
  2436. */
  2437. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2438. /**
  2439. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2447. /**
  2448. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2449. * @returns a new Vector3
  2450. */
  2451. negate(): Vector3;
  2452. /**
  2453. * Negate this vector in place
  2454. * @returns this
  2455. */
  2456. negateInPlace(): Vector3;
  2457. /**
  2458. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. negateToRef(result: Vector3): Vector3;
  2463. /**
  2464. * Multiplies the Vector3 coordinates by the float "scale"
  2465. * @param scale defines the multiplier factor
  2466. * @returns the current updated Vector3
  2467. */
  2468. scaleInPlace(scale: number): Vector3;
  2469. /**
  2470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2471. * @param scale defines the multiplier factor
  2472. * @returns a new Vector3
  2473. */
  2474. scale(scale: number): Vector3;
  2475. /**
  2476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2477. * @param scale defines the multiplier factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. scaleToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the unmodified current Vector3
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2491. * @param otherVector defines the second operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2497. * @param otherVector defines the second operand
  2498. * @param epsilon defines the minimal distance to define values as equals
  2499. * @returns true if both vectors are distant less than epsilon
  2500. */
  2501. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 coordinates equals the given floats
  2504. * @param x defines the x coordinate of the operand
  2505. * @param y defines the y coordinate of the operand
  2506. * @param z defines the z coordinate of the operand
  2507. * @returns true if both vectors are equals
  2508. */
  2509. equalsToFloats(x: number, y: number, z: number): boolean;
  2510. /**
  2511. * Multiplies the current Vector3 coordinates by the given ones
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2516. /**
  2517. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2531. * @param x defines the x coordinate of the operand
  2532. * @param y defines the y coordinate of the operand
  2533. * @param z defines the z coordinate of the operand
  2534. * @returns the new Vector3
  2535. */
  2536. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2537. /**
  2538. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2539. * @param otherVector defines the second operand
  2540. * @returns the new Vector3
  2541. */
  2542. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones.
  2552. * @param otherVector defines the second operand
  2553. * @returns the current updated Vector3
  2554. */
  2555. divideInPlace(otherVector: Vector3): Vector3;
  2556. /**
  2557. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2558. * @param other defines the second operand
  2559. * @returns the current updated Vector3
  2560. */
  2561. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2564. * @param other defines the second operand
  2565. * @returns the current updated Vector3
  2566. */
  2567. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2568. /**
  2569. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2570. * @param x defines the x coordinate of the operand
  2571. * @param y defines the y coordinate of the operand
  2572. * @param z defines the z coordinate of the operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2576. /**
  2577. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2586. * Check if is non uniform within a certain amount of decimal places to account for this
  2587. * @param epsilon the amount the values can differ
  2588. * @returns if the the vector is non uniform to a certain number of decimal places
  2589. */
  2590. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2591. /**
  2592. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2593. */
  2594. get isNonUniform(): boolean;
  2595. /**
  2596. * Gets a new Vector3 from current Vector3 floored values
  2597. * @returns a new Vector3
  2598. */
  2599. floor(): Vector3;
  2600. /**
  2601. * Gets a new Vector3 from current Vector3 floored values
  2602. * @returns a new Vector3
  2603. */
  2604. fract(): Vector3;
  2605. /**
  2606. * Gets the length of the Vector3
  2607. * @returns the length of the Vector3
  2608. */
  2609. length(): number;
  2610. /**
  2611. * Gets the squared length of the Vector3
  2612. * @returns squared length of the Vector3
  2613. */
  2614. lengthSquared(): number;
  2615. /**
  2616. * Normalize the current Vector3.
  2617. * Please note that this is an in place operation.
  2618. * @returns the current updated Vector3
  2619. */
  2620. normalize(): Vector3;
  2621. /**
  2622. * Reorders the x y z properties of the vector in place
  2623. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2624. * @returns the current updated vector
  2625. */
  2626. reorderInPlace(order: string): this;
  2627. /**
  2628. * Rotates the vector around 0,0,0 by a quaternion
  2629. * @param quaternion the rotation quaternion
  2630. * @param result vector to store the result
  2631. * @returns the resulting vector
  2632. */
  2633. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2634. /**
  2635. * Rotates a vector around a given point
  2636. * @param quaternion the rotation quaternion
  2637. * @param point the point to rotate around
  2638. * @param result vector to store the result
  2639. * @returns the resulting vector
  2640. */
  2641. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2642. /**
  2643. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2644. * The cross product is then orthogonal to both current and "other"
  2645. * @param other defines the right operand
  2646. * @returns the cross product
  2647. */
  2648. cross(other: Vector3): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 with the given input length.
  2651. * Please note that this is an in place operation.
  2652. * @param len the length of the vector
  2653. * @returns the current updated Vector3
  2654. */
  2655. normalizeFromLength(len: number): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 to a new vector
  2658. * @returns the new Vector3
  2659. */
  2660. normalizeToNew(): Vector3;
  2661. /**
  2662. * Normalize the current Vector3 to the reference
  2663. * @param reference define the Vector3 to update
  2664. * @returns the updated Vector3
  2665. */
  2666. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Creates a new Vector3 copied from the current Vector3
  2669. * @returns the new Vector3
  2670. */
  2671. clone(): Vector3;
  2672. /**
  2673. * Copies the given vector coordinates to the current Vector3 ones
  2674. * @param source defines the source Vector3
  2675. * @returns the current updated Vector3
  2676. */
  2677. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Copies the given floats to the current Vector3 coordinates
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns the current updated Vector3
  2684. */
  2685. copyFromFloats(x: number, y: number, z: number): Vector3;
  2686. /**
  2687. * Copies the given floats to the current Vector3 coordinates
  2688. * @param x defines the x coordinate of the operand
  2689. * @param y defines the y coordinate of the operand
  2690. * @param z defines the z coordinate of the operand
  2691. * @returns the current updated Vector3
  2692. */
  2693. set(x: number, y: number, z: number): Vector3;
  2694. /**
  2695. * Copies the given float to the current Vector3 coordinates
  2696. * @param v defines the x, y and z coordinates of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. setAll(v: number): Vector3;
  2700. /**
  2701. * Get the clip factor between two vectors
  2702. * @param vector0 defines the first operand
  2703. * @param vector1 defines the second operand
  2704. * @param axis defines the axis to use
  2705. * @param size defines the size along the axis
  2706. * @returns the clip factor
  2707. */
  2708. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2709. /**
  2710. * Get angle between two vectors
  2711. * @param vector0 angle between vector0 and vector1
  2712. * @param vector1 angle between vector0 and vector1
  2713. * @param normal direction of the normal
  2714. * @return the angle between vector0 and vector1
  2715. */
  2716. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. * @deprecated Please use FromArray instead.
  2730. */
  2731. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. * @deprecated Please use FromArrayToRef instead.
  2745. */
  2746. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2747. /**
  2748. * Sets the given vector "result" with the given floats.
  2749. * @param x defines the x coordinate of the source
  2750. * @param y defines the y coordinate of the source
  2751. * @param z defines the z coordinate of the source
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2757. * @returns a new empty Vector3
  2758. */
  2759. static Zero(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2762. * @returns a new unit Vector3
  2763. */
  2764. static One(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2767. * @returns a new up Vector3
  2768. */
  2769. static Up(): Vector3;
  2770. /**
  2771. * Gets a up Vector3 that must not be updated
  2772. */
  2773. static get UpReadOnly(): DeepImmutable<Vector3>;
  2774. /**
  2775. * Gets a zero Vector3 that must not be updated
  2776. */
  2777. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2780. * @returns a new down Vector3
  2781. */
  2782. static Down(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2785. * @returns a new forward Vector3
  2786. */
  2787. static Forward(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2790. * @returns a new forward Vector3
  2791. */
  2792. static Backward(): Vector3;
  2793. /**
  2794. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2795. * @returns a new right Vector3
  2796. */
  2797. static Right(): Vector3;
  2798. /**
  2799. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2800. * @returns a new left Vector3
  2801. */
  2802. static Left(): Vector3;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2805. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the transformed Vector3
  2809. */
  2810. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2813. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2821. * This method computes tranformed coordinates only, not transformed direction vectors
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2831. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2832. * @param vector defines the Vector3 to transform
  2833. * @param transformation defines the transformation matrix
  2834. * @returns the new Vector3
  2835. */
  2836. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2837. /**
  2838. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2839. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2840. * @param vector defines the Vector3 to transform
  2841. * @param transformation defines the transformation matrix
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2848. * @param x define the x coordinate of the source vector
  2849. * @param y define the y coordinate of the source vector
  2850. * @param z define the z coordinate of the source vector
  2851. * @param transformation defines the transformation matrix
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2857. * @param value1 defines the first control point
  2858. * @param value2 defines the second control point
  2859. * @param value3 defines the third control point
  2860. * @param value4 defines the fourth control point
  2861. * @param amount defines the amount on the spline to use
  2862. * @returns the new Vector3
  2863. */
  2864. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2865. /**
  2866. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2867. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2868. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2869. * @param value defines the current value
  2870. * @param min defines the lower range value
  2871. * @param max defines the upper range value
  2872. * @returns the new Vector3
  2873. */
  2874. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2875. /**
  2876. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2877. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2878. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2879. * @param value defines the current value
  2880. * @param min defines the lower range value
  2881. * @param max defines the upper range value
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2885. /**
  2886. * Checks if a given vector is inside a specific range
  2887. * @param v defines the vector to test
  2888. * @param min defines the minimum range
  2889. * @param max defines the maximum range
  2890. */
  2891. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2894. * @param value1 defines the first control point
  2895. * @param tangent1 defines the first tangent vector
  2896. * @param value2 defines the second control point
  2897. * @param tangent2 defines the second tangent vector
  2898. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2899. * @returns the new Vector3
  2900. */
  2901. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2902. /**
  2903. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2904. * @param start defines the start value
  2905. * @param end defines the end value
  2906. * @param amount max defines amount between both (between 0 and 1)
  2907. * @returns the new Vector3
  2908. */
  2909. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2910. /**
  2911. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2912. * @param start defines the start value
  2913. * @param end defines the end value
  2914. * @param amount max defines amount between both (between 0 and 1)
  2915. * @param result defines the Vector3 where to store the result
  2916. */
  2917. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2918. /**
  2919. * Returns the dot product (float) between the vectors "left" and "right"
  2920. * @param left defines the left operand
  2921. * @param right defines the right operand
  2922. * @returns the dot product
  2923. */
  2924. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2925. /**
  2926. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2927. * The cross product is then orthogonal to both "left" and "right"
  2928. * @param left defines the left operand
  2929. * @param right defines the right operand
  2930. * @returns the cross product
  2931. */
  2932. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2933. /**
  2934. * Sets the given vector "result" with the cross product of "left" and "right"
  2935. * The cross product is then orthogonal to both "left" and "right"
  2936. * @param left defines the left operand
  2937. * @param right defines the right operand
  2938. * @param result defines the Vector3 where to store the result
  2939. */
  2940. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2941. /**
  2942. * Returns a new Vector3 as the normalization of the given vector
  2943. * @param vector defines the Vector3 to normalize
  2944. * @returns the new Vector3
  2945. */
  2946. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" with the normalization of the given first vector
  2949. * @param vector defines the Vector3 to normalize
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2953. /**
  2954. * Project a Vector3 onto screen space
  2955. * @param vector defines the Vector3 to project
  2956. * @param world defines the world matrix to use
  2957. * @param transform defines the transform (view x projection) matrix to use
  2958. * @param viewport defines the screen viewport to use
  2959. * @returns the new Vector3
  2960. */
  2961. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2962. /** @hidden */
  2963. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param transform defines the transform (view x projection) matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @returns the new Vector3
  2983. */
  2984. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param source defines the screen space Vector3 to use
  2988. * @param viewportWidth defines the current width of the viewport
  2989. * @param viewportHeight defines the current height of the viewport
  2990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2991. * @param view defines the view matrix to use
  2992. * @param projection defines the projection matrix to use
  2993. * @param result defines the Vector3 where to store the result
  2994. */
  2995. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2996. /**
  2997. * Unproject from screen space to object space
  2998. * @param sourceX defines the screen space x coordinate to use
  2999. * @param sourceY defines the screen space y coordinate to use
  3000. * @param sourceZ defines the screen space z coordinate to use
  3001. * @param viewportWidth defines the current width of the viewport
  3002. * @param viewportHeight defines the current height of the viewport
  3003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3004. * @param view defines the view matrix to use
  3005. * @param projection defines the projection matrix to use
  3006. * @param result defines the Vector3 where to store the result
  3007. */
  3008. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3009. /**
  3010. * Gets the minimal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Gets the maximal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Returns the distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the distance
  3028. */
  3029. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns the squared distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the squared distance
  3035. */
  3036. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns a new Vector3 located at the center between "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the new Vector3
  3042. */
  3043. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3046. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3047. * to something in order to rotate it from its local system to the given target system
  3048. * Note: axis1, axis2 and axis3 are normalized during this operation
  3049. * @param axis1 defines the first axis
  3050. * @param axis2 defines the second axis
  3051. * @param axis3 defines the third axis
  3052. * @returns a new Vector3
  3053. */
  3054. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3057. * @param axis1 defines the first axis
  3058. * @param axis2 defines the second axis
  3059. * @param axis3 defines the third axis
  3060. * @param ref defines the Vector3 where to store the result
  3061. */
  3062. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3063. }
  3064. /**
  3065. * Vector4 class created for EulerAngle class conversion to Quaternion
  3066. */
  3067. export class Vector4 {
  3068. /** x value of the vector */
  3069. x: number;
  3070. /** y value of the vector */
  3071. y: number;
  3072. /** z value of the vector */
  3073. z: number;
  3074. /** w value of the vector */
  3075. w: number;
  3076. /**
  3077. * Creates a Vector4 object from the given floats.
  3078. * @param x x value of the vector
  3079. * @param y y value of the vector
  3080. * @param z z value of the vector
  3081. * @param w w value of the vector
  3082. */
  3083. constructor(
  3084. /** x value of the vector */
  3085. x: number,
  3086. /** y value of the vector */
  3087. y: number,
  3088. /** z value of the vector */
  3089. z: number,
  3090. /** w value of the vector */
  3091. w: number);
  3092. /**
  3093. * Returns the string with the Vector4 coordinates.
  3094. * @returns a string containing all the vector values
  3095. */
  3096. toString(): string;
  3097. /**
  3098. * Returns the string "Vector4".
  3099. * @returns "Vector4"
  3100. */
  3101. getClassName(): string;
  3102. /**
  3103. * Returns the Vector4 hash code.
  3104. * @returns a unique hash code
  3105. */
  3106. getHashCode(): number;
  3107. /**
  3108. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3109. * @returns the resulting array
  3110. */
  3111. asArray(): number[];
  3112. /**
  3113. * Populates the given array from the given index with the Vector4 coordinates.
  3114. * @param array array to populate
  3115. * @param index index of the array to start at (default: 0)
  3116. * @returns the Vector4.
  3117. */
  3118. toArray(array: FloatArray, index?: number): Vector4;
  3119. /**
  3120. * Adds the given vector to the current Vector4.
  3121. * @param otherVector the vector to add
  3122. * @returns the updated Vector4.
  3123. */
  3124. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3127. * @param otherVector the vector to add
  3128. * @returns the resulting vector
  3129. */
  3130. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3133. * @param otherVector the vector to add
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Subtract in place the given vector from the current Vector4.
  3140. * @param otherVector the vector to subtract
  3141. * @returns the updated Vector4.
  3142. */
  3143. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3146. * @param otherVector the vector to add
  3147. * @returns the new vector with the result
  3148. */
  3149. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3152. * @param otherVector the vector to subtract
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3159. */
  3160. /**
  3161. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3162. * @param x value to subtract
  3163. * @param y value to subtract
  3164. * @param z value to subtract
  3165. * @param w value to subtract
  3166. * @returns new vector containing the result
  3167. */
  3168. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3169. /**
  3170. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @param result the vector to store the result in
  3176. * @returns the current Vector4.
  3177. */
  3178. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3181. * @returns a new vector with the negated values
  3182. */
  3183. negate(): Vector4;
  3184. /**
  3185. * Negate this vector in place
  3186. * @returns this
  3187. */
  3188. negateInPlace(): Vector4;
  3189. /**
  3190. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3191. * @param result defines the Vector3 object where to store the result
  3192. * @returns the current Vector4
  3193. */
  3194. negateToRef(result: Vector4): Vector4;
  3195. /**
  3196. * Multiplies the current Vector4 coordinates by scale (float).
  3197. * @param scale the number to scale with
  3198. * @returns the updated Vector4.
  3199. */
  3200. scaleInPlace(scale: number): Vector4;
  3201. /**
  3202. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3203. * @param scale the number to scale with
  3204. * @returns a new vector with the result
  3205. */
  3206. scale(scale: number): Vector4;
  3207. /**
  3208. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3209. * @param scale the number to scale with
  3210. * @param result a vector to store the result in
  3211. * @returns the current Vector4.
  3212. */
  3213. scaleToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3216. * @param scale defines the scale factor
  3217. * @param result defines the Vector4 object where to store the result
  3218. * @returns the unmodified current Vector4
  3219. */
  3220. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3223. * @param otherVector the vector to compare against
  3224. * @returns true if they are equal
  3225. */
  3226. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3227. /**
  3228. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3229. * @param otherVector vector to compare against
  3230. * @param epsilon (Default: very small number)
  3231. * @returns true if they are equal
  3232. */
  3233. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3234. /**
  3235. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3236. * @param x x value to compare against
  3237. * @param y y value to compare against
  3238. * @param z z value to compare against
  3239. * @param w w value to compare against
  3240. * @returns true if equal
  3241. */
  3242. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3243. /**
  3244. * Multiplies in place the current Vector4 by the given one.
  3245. * @param otherVector vector to multiple with
  3246. * @returns the updated Vector4.
  3247. */
  3248. multiplyInPlace(otherVector: Vector4): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3251. * @param otherVector vector to multiple with
  3252. * @returns resulting new vector
  3253. */
  3254. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3257. * @param otherVector vector to multiple with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3264. * @param x x value multiply with
  3265. * @param y y value multiply with
  3266. * @param z z value multiply with
  3267. * @param w w value multiply with
  3268. * @returns resulting new vector
  3269. */
  3270. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3273. * @param otherVector vector to devide with
  3274. * @returns resulting new vector
  3275. */
  3276. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3279. * @param otherVector vector to devide with
  3280. * @param result vector to store the result
  3281. * @returns the current Vector4.
  3282. */
  3283. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3284. /**
  3285. * Divides the current Vector3 coordinates by the given ones.
  3286. * @param otherVector vector to devide with
  3287. * @returns the updated Vector3.
  3288. */
  3289. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3290. /**
  3291. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3292. * @param other defines the second operand
  3293. * @returns the current updated Vector4
  3294. */
  3295. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3298. * @param other defines the second operand
  3299. * @returns the current updated Vector4
  3300. */
  3301. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Gets a new Vector4 from current Vector4 floored values
  3304. * @returns a new Vector4
  3305. */
  3306. floor(): Vector4;
  3307. /**
  3308. * Gets a new Vector4 from current Vector3 floored values
  3309. * @returns a new Vector4
  3310. */
  3311. fract(): Vector4;
  3312. /**
  3313. * Returns the Vector4 length (float).
  3314. * @returns the length
  3315. */
  3316. length(): number;
  3317. /**
  3318. * Returns the Vector4 squared length (float).
  3319. * @returns the length squared
  3320. */
  3321. lengthSquared(): number;
  3322. /**
  3323. * Normalizes in place the Vector4.
  3324. * @returns the updated Vector4.
  3325. */
  3326. normalize(): Vector4;
  3327. /**
  3328. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3329. * @returns this converted to a new vector3
  3330. */
  3331. toVector3(): Vector3;
  3332. /**
  3333. * Returns a new Vector4 copied from the current one.
  3334. * @returns the new cloned vector
  3335. */
  3336. clone(): Vector4;
  3337. /**
  3338. * Updates the current Vector4 with the given one coordinates.
  3339. * @param source the source vector to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to copy from
  3346. * @param y float to copy from
  3347. * @param z float to copy from
  3348. * @param w float to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to set from
  3355. * @param y float to set from
  3356. * @param z float to set from
  3357. * @param w float to set from
  3358. * @returns the updated Vector4.
  3359. */
  3360. set(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Copies the given float to the current Vector3 coordinates
  3363. * @param v defines the x, y, z and w coordinates of the operand
  3364. * @returns the current updated Vector3
  3365. */
  3366. setAll(v: number): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @returns the new vector
  3372. */
  3373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3374. /**
  3375. * Updates the given vector "result" from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @param result the vector to store the result in
  3379. */
  3380. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given Float32Array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" coordinates from the given floats.
  3390. * @param x float to set from
  3391. * @param y float to set from
  3392. * @param z float to set from
  3393. * @param w float to set from
  3394. * @param result the vector to the floats in
  3395. */
  3396. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3397. /**
  3398. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3399. * @returns the new vector
  3400. */
  3401. static Zero(): Vector4;
  3402. /**
  3403. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3404. * @returns the new vector
  3405. */
  3406. static One(): Vector4;
  3407. /**
  3408. * Returns a new normalized Vector4 from the given one.
  3409. * @param vector the vector to normalize
  3410. * @returns the vector
  3411. */
  3412. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" from the normalization of the given one.
  3415. * @param vector the vector to normalize
  3416. * @param result the vector to store the result in
  3417. */
  3418. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3419. /**
  3420. * Returns a vector with the minimum values from the left and right vectors
  3421. * @param left left vector to minimize
  3422. * @param right right vector to minimize
  3423. * @returns a new vector with the minimum of the left and right vector values
  3424. */
  3425. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns a vector with the maximum values from the left and right vectors
  3428. * @param left left vector to maximize
  3429. * @param right right vector to maximize
  3430. * @returns a new vector with the maximum of the left and right vector values
  3431. */
  3432. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns the distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors
  3438. */
  3439. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors squared
  3445. */
  3446. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the center between
  3450. * @param value2 value to calulate the center between
  3451. * @return the center between the two vectors
  3452. */
  3453. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3456. * This methods computes transformed normalized direction vectors only.
  3457. * @param vector the vector to transform
  3458. * @param transformation the transformation matrix to apply
  3459. * @returns the new vector
  3460. */
  3461. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3462. /**
  3463. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3464. * This methods computes transformed normalized direction vectors only.
  3465. * @param vector the vector to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the result in
  3468. */
  3469. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3472. * This methods computes transformed normalized direction vectors only.
  3473. * @param x value to transform
  3474. * @param y value to transform
  3475. * @param z value to transform
  3476. * @param w value to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @param result the vector to store the results in
  3479. */
  3480. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3481. /**
  3482. * Creates a new Vector4 from a Vector3
  3483. * @param source defines the source data
  3484. * @param w defines the 4th component (default is 0)
  3485. * @returns a new Vector4
  3486. */
  3487. static FromVector3(source: Vector3, w?: number): Vector4;
  3488. }
  3489. /**
  3490. * Class used to store quaternion data
  3491. * @see https://en.wikipedia.org/wiki/Quaternion
  3492. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3493. */
  3494. export class Quaternion {
  3495. /** defines the first component (0 by default) */
  3496. x: number;
  3497. /** defines the second component (0 by default) */
  3498. y: number;
  3499. /** defines the third component (0 by default) */
  3500. z: number;
  3501. /** defines the fourth component (1.0 by default) */
  3502. w: number;
  3503. /**
  3504. * Creates a new Quaternion from the given floats
  3505. * @param x defines the first component (0 by default)
  3506. * @param y defines the second component (0 by default)
  3507. * @param z defines the third component (0 by default)
  3508. * @param w defines the fourth component (1.0 by default)
  3509. */
  3510. constructor(
  3511. /** defines the first component (0 by default) */
  3512. x?: number,
  3513. /** defines the second component (0 by default) */
  3514. y?: number,
  3515. /** defines the third component (0 by default) */
  3516. z?: number,
  3517. /** defines the fourth component (1.0 by default) */
  3518. w?: number);
  3519. /**
  3520. * Gets a string representation for the current quaternion
  3521. * @returns a string with the Quaternion coordinates
  3522. */
  3523. toString(): string;
  3524. /**
  3525. * Gets the class name of the quaternion
  3526. * @returns the string "Quaternion"
  3527. */
  3528. getClassName(): string;
  3529. /**
  3530. * Gets a hash code for this quaternion
  3531. * @returns the quaternion hash code
  3532. */
  3533. getHashCode(): number;
  3534. /**
  3535. * Copy the quaternion to an array
  3536. * @returns a new array populated with 4 elements from the quaternion coordinates
  3537. */
  3538. asArray(): number[];
  3539. /**
  3540. * Check if two quaternions are equals
  3541. * @param otherQuaternion defines the second operand
  3542. * @return true if the current quaternion and the given one coordinates are strictly equals
  3543. */
  3544. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3545. /**
  3546. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3547. * @param otherQuaternion defines the other quaternion
  3548. * @param epsilon defines the minimal distance to consider equality
  3549. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3550. */
  3551. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3552. /**
  3553. * Clone the current quaternion
  3554. * @returns a new quaternion copied from the current one
  3555. */
  3556. clone(): Quaternion;
  3557. /**
  3558. * Copy a quaternion to the current one
  3559. * @param other defines the other quaternion
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Updates the current quaternion with the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Updates the current quaternion from the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. set(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Adds two quaternions
  3583. * @param other defines the second operand
  3584. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3585. */
  3586. add(other: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Add a quaternion to the current one
  3589. * @param other defines the quaternion to add
  3590. * @returns the current quaternion
  3591. */
  3592. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3593. /**
  3594. * Subtract two quaternions
  3595. * @param other defines the second operand
  3596. * @returns a new quaternion as the subtraction result of the given one from the current one
  3597. */
  3598. subtract(other: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies the current quaternion by a scale factor
  3601. * @param value defines the scale factor
  3602. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3603. */
  3604. scale(value: number): Quaternion;
  3605. /**
  3606. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3607. * @param scale defines the scale factor
  3608. * @param result defines the Quaternion object where to store the result
  3609. * @returns the unmodified current quaternion
  3610. */
  3611. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3612. /**
  3613. * Multiplies in place the current quaternion by a scale factor
  3614. * @param value defines the scale factor
  3615. * @returns the current modified quaternion
  3616. */
  3617. scaleInPlace(value: number): Quaternion;
  3618. /**
  3619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3620. * @param scale defines the scale factor
  3621. * @param result defines the Quaternion object where to store the result
  3622. * @returns the unmodified current quaternion
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3625. /**
  3626. * Multiplies two quaternions
  3627. * @param q1 defines the second operand
  3628. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3629. */
  3630. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3631. /**
  3632. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @param result defines the target quaternion
  3635. * @returns the current quaternion
  3636. */
  3637. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3638. /**
  3639. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @returns the currentupdated quaternion
  3642. */
  3643. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3644. /**
  3645. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3646. * @param ref defines the target quaternion
  3647. * @returns the current quaternion
  3648. */
  3649. conjugateToRef(ref: Quaternion): Quaternion;
  3650. /**
  3651. * Conjugates in place (1-q) the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. conjugateInPlace(): Quaternion;
  3655. /**
  3656. * Conjugates in place (1-q) the current quaternion
  3657. * @returns a new quaternion
  3658. */
  3659. conjugate(): Quaternion;
  3660. /**
  3661. * Gets length of current quaternion
  3662. * @returns the quaternion length (float)
  3663. */
  3664. length(): number;
  3665. /**
  3666. * Normalize in place the current quaternion
  3667. * @returns the current updated quaternion
  3668. */
  3669. normalize(): Quaternion;
  3670. /**
  3671. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns a new Vector3 containing the Euler angles
  3674. */
  3675. toEulerAngles(order?: string): Vector3;
  3676. /**
  3677. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3678. * @param result defines the vector which will be filled with the Euler angles
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns the current unchanged quaternion
  3681. */
  3682. toEulerAnglesToRef(result: Vector3): Quaternion;
  3683. /**
  3684. * Updates the given rotation matrix with the current quaternion values
  3685. * @param result defines the target matrix
  3686. * @returns the current unchanged quaternion
  3687. */
  3688. toRotationMatrix(result: Matrix): Quaternion;
  3689. /**
  3690. * Updates the current quaternion from the given rotation matrix values
  3691. * @param matrix defines the source matrix
  3692. * @returns the current updated quaternion
  3693. */
  3694. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3695. /**
  3696. * Creates a new quaternion from a rotation matrix
  3697. * @param matrix defines the source matrix
  3698. * @returns a new quaternion created from the given rotation matrix values
  3699. */
  3700. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3701. /**
  3702. * Updates the given quaternion with the given rotation matrix values
  3703. * @param matrix defines the source matrix
  3704. * @param result defines the target quaternion
  3705. */
  3706. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3707. /**
  3708. * Returns the dot product (float) between the quaternions "left" and "right"
  3709. * @param left defines the left operand
  3710. * @param right defines the right operand
  3711. * @returns the dot product
  3712. */
  3713. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3714. /**
  3715. * Checks if the two quaternions are close to each other
  3716. * @param quat0 defines the first quaternion to check
  3717. * @param quat1 defines the second quaternion to check
  3718. * @returns true if the two quaternions are close to each other
  3719. */
  3720. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates an empty quaternion
  3723. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3724. */
  3725. static Zero(): Quaternion;
  3726. /**
  3727. * Inverse a given quaternion
  3728. * @param q defines the source quaternion
  3729. * @returns a new quaternion as the inverted current quaternion
  3730. */
  3731. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Inverse a given quaternion
  3734. * @param q defines the source quaternion
  3735. * @param result the quaternion the result will be stored in
  3736. * @returns the result quaternion
  3737. */
  3738. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates an identity quaternion
  3741. * @returns the identity quaternion
  3742. */
  3743. static Identity(): Quaternion;
  3744. /**
  3745. * Gets a boolean indicating if the given quaternion is identity
  3746. * @param quaternion defines the quaternion to check
  3747. * @returns true if the quaternion is identity
  3748. */
  3749. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3750. /**
  3751. * Creates a quaternion from a rotation around an axis
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3755. */
  3756. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3757. /**
  3758. * Creates a rotation around an axis and stores it into the given quaternion
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @param result defines the target quaternion
  3762. * @returns the target quaternion
  3763. */
  3764. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from data stored into an array
  3767. * @param array defines the data source
  3768. * @param offset defines the offset in the source array where the data starts
  3769. * @returns a new quaternion
  3770. */
  3771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3772. /**
  3773. * Updates the given quaternion "result" from the starting index of the given array.
  3774. * @param array the array to pull values from
  3775. * @param offset the offset into the array to start at
  3776. * @param result the quaternion to store the result in
  3777. */
  3778. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4415. /**
  4416. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4417. * This function works in left handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4958. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. _getVertexShaderCode(): string | null;
  7245. _getFragmentShaderCode(): string | null;
  7246. }
  7247. }
  7248. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7249. import { FloatArray, Nullable } from "babylonjs/types";
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. module "babylonjs/Engines/thinEngine" {
  7253. interface ThinEngine {
  7254. /**
  7255. * Create an uniform buffer
  7256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7257. * @param elements defines the content of the uniform buffer
  7258. * @returns the webGL uniform buffer
  7259. */
  7260. createUniformBuffer(elements: FloatArray): DataBuffer;
  7261. /**
  7262. * Create a dynamic uniform buffer
  7263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7264. * @param elements defines the content of the uniform buffer
  7265. * @returns the webGL uniform buffer
  7266. */
  7267. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7268. /**
  7269. * Update an existing uniform buffer
  7270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7271. * @param uniformBuffer defines the target uniform buffer
  7272. * @param elements defines the content to update
  7273. * @param offset defines the offset in the uniform buffer where update should start
  7274. * @param count defines the size of the data to update
  7275. */
  7276. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7277. /**
  7278. * Bind an uniform buffer to the current webGL context
  7279. * @param buffer defines the buffer to bind
  7280. */
  7281. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7282. /**
  7283. * Bind a buffer to the current webGL context at a given location
  7284. * @param buffer defines the buffer to bind
  7285. * @param location defines the index where to bind the buffer
  7286. */
  7287. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7288. /**
  7289. * Bind a specific block at a given index in a specific shader program
  7290. * @param pipelineContext defines the pipeline context to use
  7291. * @param blockName defines the block name
  7292. * @param index defines the index where to bind the block
  7293. */
  7294. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7295. }
  7296. }
  7297. }
  7298. declare module "babylonjs/Materials/uniformBuffer" {
  7299. import { Nullable, FloatArray } from "babylonjs/types";
  7300. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7301. import { Engine } from "babylonjs/Engines/engine";
  7302. import { Effect } from "babylonjs/Materials/effect";
  7303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7304. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7305. import { Color3 } from "babylonjs/Maths/math.color";
  7306. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7307. /**
  7308. * Uniform buffer objects.
  7309. *
  7310. * Handles blocks of uniform on the GPU.
  7311. *
  7312. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7313. *
  7314. * For more information, please refer to :
  7315. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7316. */
  7317. export class UniformBuffer {
  7318. private _engine;
  7319. private _buffer;
  7320. private _data;
  7321. private _bufferData;
  7322. private _dynamic?;
  7323. private _uniformLocations;
  7324. private _uniformSizes;
  7325. private _uniformLocationPointer;
  7326. private _needSync;
  7327. private _noUBO;
  7328. private _currentEffect;
  7329. /** @hidden */
  7330. _alreadyBound: boolean;
  7331. private static _MAX_UNIFORM_SIZE;
  7332. private static _tempBuffer;
  7333. /**
  7334. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7339. /**
  7340. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7345. /**
  7346. * Lambda to Update a single float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat: (name: string, x: number) => void;
  7351. /**
  7352. * Lambda to Update a vec2 of float in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7357. /**
  7358. * Lambda to Update a vec3 of float in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7363. /**
  7364. * Lambda to Update a vec4 of float in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7369. /**
  7370. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateMatrix: (name: string, mat: Matrix) => void;
  7375. /**
  7376. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateVector3: (name: string, vector: Vector3) => void;
  7381. /**
  7382. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateVector4: (name: string, vector: Vector4) => void;
  7387. /**
  7388. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7389. * This is dynamic to allow compat with webgl 1 and 2.
  7390. * You will need to pass the name of the uniform as well as the value.
  7391. */
  7392. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7393. /**
  7394. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7395. * This is dynamic to allow compat with webgl 1 and 2.
  7396. * You will need to pass the name of the uniform as well as the value.
  7397. */
  7398. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7399. /**
  7400. * Instantiates a new Uniform buffer objects.
  7401. *
  7402. * Handles blocks of uniform on the GPU.
  7403. *
  7404. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7405. *
  7406. * For more information, please refer to :
  7407. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7408. * @param engine Define the engine the buffer is associated with
  7409. * @param data Define the data contained in the buffer
  7410. * @param dynamic Define if the buffer is updatable
  7411. */
  7412. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7413. /**
  7414. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7415. * or just falling back on setUniformXXX calls.
  7416. */
  7417. get useUbo(): boolean;
  7418. /**
  7419. * Indicates if the WebGL underlying uniform buffer is in sync
  7420. * with the javascript cache data.
  7421. */
  7422. get isSync(): boolean;
  7423. /**
  7424. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7425. * Also, a dynamic UniformBuffer will disable cache verification and always
  7426. * update the underlying WebGL uniform buffer to the GPU.
  7427. * @returns if Dynamic, otherwise false
  7428. */
  7429. isDynamic(): boolean;
  7430. /**
  7431. * The data cache on JS side.
  7432. * @returns the underlying data as a float array
  7433. */
  7434. getData(): Float32Array;
  7435. /**
  7436. * The underlying WebGL Uniform buffer.
  7437. * @returns the webgl buffer
  7438. */
  7439. getBuffer(): Nullable<DataBuffer>;
  7440. /**
  7441. * std140 layout specifies how to align data within an UBO structure.
  7442. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7443. * for specs.
  7444. */
  7445. private _fillAlignment;
  7446. /**
  7447. * Adds an uniform in the buffer.
  7448. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7449. * for the layout to be correct !
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. * @param size Data size, or data directly.
  7452. */
  7453. addUniform(name: string, size: number | number[]): void;
  7454. /**
  7455. * Adds a Matrix 4x4 to the uniform buffer.
  7456. * @param name Name of the uniform, as used in the uniform block in the shader.
  7457. * @param mat A 4x4 matrix.
  7458. */
  7459. addMatrix(name: string, mat: Matrix): void;
  7460. /**
  7461. * Adds a vec2 to the uniform buffer.
  7462. * @param name Name of the uniform, as used in the uniform block in the shader.
  7463. * @param x Define the x component value of the vec2
  7464. * @param y Define the y component value of the vec2
  7465. */
  7466. addFloat2(name: string, x: number, y: number): void;
  7467. /**
  7468. * Adds a vec3 to the uniform buffer.
  7469. * @param name Name of the uniform, as used in the uniform block in the shader.
  7470. * @param x Define the x component value of the vec3
  7471. * @param y Define the y component value of the vec3
  7472. * @param z Define the z component value of the vec3
  7473. */
  7474. addFloat3(name: string, x: number, y: number, z: number): void;
  7475. /**
  7476. * Adds a vec3 to the uniform buffer.
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param color Define the vec3 from a Color
  7479. */
  7480. addColor3(name: string, color: Color3): void;
  7481. /**
  7482. * Adds a vec4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param color Define the rgb components from a Color
  7485. * @param alpha Define the a component of the vec4
  7486. */
  7487. addColor4(name: string, color: Color3, alpha: number): void;
  7488. /**
  7489. * Adds a vec3 to the uniform buffer.
  7490. * @param name Name of the uniform, as used in the uniform block in the shader.
  7491. * @param vector Define the vec3 components from a Vector
  7492. */
  7493. addVector3(name: string, vector: Vector3): void;
  7494. /**
  7495. * Adds a Matrix 3x3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. */
  7498. addMatrix3x3(name: string): void;
  7499. /**
  7500. * Adds a Matrix 2x2 to the uniform buffer.
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. */
  7503. addMatrix2x2(name: string): void;
  7504. /**
  7505. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7506. */
  7507. create(): void;
  7508. /** @hidden */
  7509. _rebuild(): void;
  7510. /**
  7511. * Updates the WebGL Uniform Buffer on the GPU.
  7512. * If the `dynamic` flag is set to true, no cache comparison is done.
  7513. * Otherwise, the buffer will be updated only if the cache differs.
  7514. */
  7515. update(): void;
  7516. /**
  7517. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7518. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7519. * @param data Define the flattened data
  7520. * @param size Define the size of the data.
  7521. */
  7522. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7523. private _valueCache;
  7524. private _cacheMatrix;
  7525. private _updateMatrix3x3ForUniform;
  7526. private _updateMatrix3x3ForEffect;
  7527. private _updateMatrix2x2ForEffect;
  7528. private _updateMatrix2x2ForUniform;
  7529. private _updateFloatForEffect;
  7530. private _updateFloatForUniform;
  7531. private _updateFloat2ForEffect;
  7532. private _updateFloat2ForUniform;
  7533. private _updateFloat3ForEffect;
  7534. private _updateFloat3ForUniform;
  7535. private _updateFloat4ForEffect;
  7536. private _updateFloat4ForUniform;
  7537. private _updateMatrixForEffect;
  7538. private _updateMatrixForUniform;
  7539. private _updateVector3ForEffect;
  7540. private _updateVector3ForUniform;
  7541. private _updateVector4ForEffect;
  7542. private _updateVector4ForUniform;
  7543. private _updateColor3ForEffect;
  7544. private _updateColor3ForUniform;
  7545. private _updateColor4ForEffect;
  7546. private _updateColor4ForUniform;
  7547. /**
  7548. * Sets a sampler uniform on the effect.
  7549. * @param name Define the name of the sampler.
  7550. * @param texture Define the texture to set in the sampler
  7551. */
  7552. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7553. /**
  7554. * Directly updates the value of the uniform in the cache AND on the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. */
  7558. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7559. /**
  7560. * Binds this uniform buffer to an effect.
  7561. * @param effect Define the effect to bind the buffer to
  7562. * @param name Name of the uniform block in the shader.
  7563. */
  7564. bindToEffect(effect: Effect, name: string): void;
  7565. /**
  7566. * Disposes the uniform buffer.
  7567. */
  7568. dispose(): void;
  7569. }
  7570. }
  7571. declare module "babylonjs/Misc/iInspectable" {
  7572. /**
  7573. * Enum that determines the text-wrapping mode to use.
  7574. */
  7575. export enum InspectableType {
  7576. /**
  7577. * Checkbox for booleans
  7578. */
  7579. Checkbox = 0,
  7580. /**
  7581. * Sliders for numbers
  7582. */
  7583. Slider = 1,
  7584. /**
  7585. * Vector3
  7586. */
  7587. Vector3 = 2,
  7588. /**
  7589. * Quaternions
  7590. */
  7591. Quaternion = 3,
  7592. /**
  7593. * Color3
  7594. */
  7595. Color3 = 4,
  7596. /**
  7597. * String
  7598. */
  7599. String = 5
  7600. }
  7601. /**
  7602. * Interface used to define custom inspectable properties.
  7603. * This interface is used by the inspector to display custom property grids
  7604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7605. */
  7606. export interface IInspectable {
  7607. /**
  7608. * Gets the label to display
  7609. */
  7610. label: string;
  7611. /**
  7612. * Gets the name of the property to edit
  7613. */
  7614. propertyName: string;
  7615. /**
  7616. * Gets the type of the editor to use
  7617. */
  7618. type: InspectableType;
  7619. /**
  7620. * Gets the minimum value of the property when using in "slider" mode
  7621. */
  7622. min?: number;
  7623. /**
  7624. * Gets the maximum value of the property when using in "slider" mode
  7625. */
  7626. max?: number;
  7627. /**
  7628. * Gets the setp to use when using in "slider" mode
  7629. */
  7630. step?: number;
  7631. }
  7632. }
  7633. declare module "babylonjs/Misc/timingTools" {
  7634. /**
  7635. * Class used to provide helper for timing
  7636. */
  7637. export class TimingTools {
  7638. /**
  7639. * Polyfill for setImmediate
  7640. * @param action defines the action to execute after the current execution block
  7641. */
  7642. static SetImmediate(action: () => void): void;
  7643. }
  7644. }
  7645. declare module "babylonjs/Misc/instantiationTools" {
  7646. /**
  7647. * Class used to enable instatition of objects by class name
  7648. */
  7649. export class InstantiationTools {
  7650. /**
  7651. * Use this object to register external classes like custom textures or material
  7652. * to allow the laoders to instantiate them
  7653. */
  7654. static RegisteredExternalClasses: {
  7655. [key: string]: Object;
  7656. };
  7657. /**
  7658. * Tries to instantiate a new object from a given class name
  7659. * @param className defines the class name to instantiate
  7660. * @returns the new object or null if the system was not able to do the instantiation
  7661. */
  7662. static Instantiate(className: string): any;
  7663. }
  7664. }
  7665. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7666. /**
  7667. * Define options used to create a depth texture
  7668. */
  7669. export class DepthTextureCreationOptions {
  7670. /** Specifies whether or not a stencil should be allocated in the texture */
  7671. generateStencil?: boolean;
  7672. /** Specifies whether or not bilinear filtering is enable on the texture */
  7673. bilinearFiltering?: boolean;
  7674. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7675. comparisonFunction?: number;
  7676. /** Specifies if the created texture is a cube texture */
  7677. isCube?: boolean;
  7678. }
  7679. }
  7680. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7681. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7682. import { Nullable } from "babylonjs/types";
  7683. import { Scene } from "babylonjs/scene";
  7684. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7685. module "babylonjs/Engines/thinEngine" {
  7686. interface ThinEngine {
  7687. /**
  7688. * Creates a depth stencil cube texture.
  7689. * This is only available in WebGL 2.
  7690. * @param size The size of face edge in the cube texture.
  7691. * @param options The options defining the cube texture.
  7692. * @returns The cube texture
  7693. */
  7694. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7695. /**
  7696. * Creates a cube texture
  7697. * @param rootUrl defines the url where the files to load is located
  7698. * @param scene defines the current scene
  7699. * @param files defines the list of files to load (1 per face)
  7700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7701. * @param onLoad defines an optional callback raised when the texture is loaded
  7702. * @param onError defines an optional callback raised if there is an issue to load the texture
  7703. * @param format defines the format of the data
  7704. * @param forcedExtension defines the extension to use to pick the right loader
  7705. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7706. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7707. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7708. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets the global Hue value.
  8023. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8024. */
  8025. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets the global Saturation value.
  8045. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8046. */
  8047. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation value.
  8050. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets the global Exposure value.
  8055. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8056. */
  8057. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets the highlights Hue value.
  8069. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8070. */
  8071. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets the highlights Saturation value.
  8091. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8092. */
  8093. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation value.
  8096. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets the highlights Exposure value.
  8101. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8102. */
  8103. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets the midtones Hue value.
  8115. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8116. */
  8117. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets the midtones Saturation value.
  8137. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8138. */
  8139. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation value.
  8142. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets the midtones Exposure value.
  8147. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8148. */
  8149. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets the shadows Hue value.
  8161. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8162. */
  8163. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets the shadows Saturation value.
  8183. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8184. */
  8185. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation value.
  8188. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets the shadows Exposure value.
  8193. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8194. */
  8195. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8662. * panning
  8663. */
  8664. invertRotation: boolean;
  8665. /**
  8666. * Speed multiplier for inverse camera panning
  8667. */
  8668. inverseRotationSpeed: number;
  8669. /**
  8670. * Define the current target of the camera as an object or a position.
  8671. */
  8672. lockedTarget: any;
  8673. /** @hidden */
  8674. _currentTarget: Vector3;
  8675. /** @hidden */
  8676. _initialFocalDistance: number;
  8677. /** @hidden */
  8678. _viewMatrix: Matrix;
  8679. /** @hidden */
  8680. _camMatrix: Matrix;
  8681. /** @hidden */
  8682. _cameraTransformMatrix: Matrix;
  8683. /** @hidden */
  8684. _cameraRotationMatrix: Matrix;
  8685. /** @hidden */
  8686. _referencePoint: Vector3;
  8687. /** @hidden */
  8688. _transformedReferencePoint: Vector3;
  8689. protected _globalCurrentTarget: Vector3;
  8690. protected _globalCurrentUpVector: Vector3;
  8691. /** @hidden */
  8692. _reset: () => void;
  8693. private _defaultUp;
  8694. /**
  8695. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8696. * This is the base of the follow, arc rotate cameras and Free camera
  8697. * @see http://doc.babylonjs.com/features/cameras
  8698. * @param name Defines the name of the camera in the scene
  8699. * @param position Defines the start position of the camera in the scene
  8700. * @param scene Defines the scene the camera belongs to
  8701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8702. */
  8703. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8704. /**
  8705. * Gets the position in front of the camera at a given distance.
  8706. * @param distance The distance from the camera we want the position to be
  8707. * @returns the position
  8708. */
  8709. getFrontPosition(distance: number): Vector3;
  8710. /** @hidden */
  8711. _getLockedTargetPosition(): Nullable<Vector3>;
  8712. private _storedPosition;
  8713. private _storedRotation;
  8714. private _storedRotationQuaternion;
  8715. /**
  8716. * Store current camera state of the camera (fov, position, rotation, etc..)
  8717. * @returns the camera
  8718. */
  8719. storeState(): Camera;
  8720. /**
  8721. * Restored camera state. You must call storeState() first
  8722. * @returns whether it was successful or not
  8723. * @hidden
  8724. */
  8725. _restoreStateValues(): boolean;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _updateCache(ignoreParentClass?: boolean): void;
  8730. /** @hidden */
  8731. _isSynchronizedViewMatrix(): boolean;
  8732. /** @hidden */
  8733. _computeLocalCameraSpeed(): number;
  8734. /**
  8735. * Defines the target the camera should look at.
  8736. * @param target Defines the new target as a Vector or a mesh
  8737. */
  8738. setTarget(target: Vector3): void;
  8739. /**
  8740. * Return the current target position of the camera. This value is expressed in local space.
  8741. * @returns the target position
  8742. */
  8743. getTarget(): Vector3;
  8744. /** @hidden */
  8745. _decideIfNeedsToMove(): boolean;
  8746. /** @hidden */
  8747. _updatePosition(): void;
  8748. /** @hidden */
  8749. _checkInputs(): void;
  8750. protected _updateCameraRotationMatrix(): void;
  8751. /**
  8752. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8753. * @returns the current camera
  8754. */
  8755. private _rotateUpVectorWithCameraRotationMatrix;
  8756. private _cachedRotationZ;
  8757. private _cachedQuaternionRotationZ;
  8758. /** @hidden */
  8759. _getViewMatrix(): Matrix;
  8760. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8761. /**
  8762. * @hidden
  8763. */
  8764. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8765. /**
  8766. * @hidden
  8767. */
  8768. _updateRigCameras(): void;
  8769. private _getRigCamPositionAndTarget;
  8770. /**
  8771. * Gets the current object class name.
  8772. * @return the class name
  8773. */
  8774. getClassName(): string;
  8775. }
  8776. }
  8777. declare module "babylonjs/Events/keyboardEvents" {
  8778. /**
  8779. * Gather the list of keyboard event types as constants.
  8780. */
  8781. export class KeyboardEventTypes {
  8782. /**
  8783. * The keydown event is fired when a key becomes active (pressed).
  8784. */
  8785. static readonly KEYDOWN: number;
  8786. /**
  8787. * The keyup event is fired when a key has been released.
  8788. */
  8789. static readonly KEYUP: number;
  8790. }
  8791. /**
  8792. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8793. */
  8794. export class KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Instantiates a new keyboard info.
  8805. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8806. * @param type Defines the type of event (KeyboardEventTypes)
  8807. * @param event Defines the related dom event
  8808. */
  8809. constructor(
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number,
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent);
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8821. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8822. */
  8823. export class KeyboardInfoPre extends KeyboardInfo {
  8824. /**
  8825. * Defines the type of event (KeyboardEventTypes)
  8826. */
  8827. type: number;
  8828. /**
  8829. * Defines the related dom event
  8830. */
  8831. event: KeyboardEvent;
  8832. /**
  8833. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8834. */
  8835. skipOnPointerObservable: boolean;
  8836. /**
  8837. * Instantiates a new keyboard pre info.
  8838. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8839. * @param type Defines the type of event (KeyboardEventTypes)
  8840. * @param event Defines the related dom event
  8841. */
  8842. constructor(
  8843. /**
  8844. * Defines the type of event (KeyboardEventTypes)
  8845. */
  8846. type: number,
  8847. /**
  8848. * Defines the related dom event
  8849. */
  8850. event: KeyboardEvent);
  8851. }
  8852. }
  8853. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8854. import { Nullable } from "babylonjs/types";
  8855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8857. /**
  8858. * Manage the keyboard inputs to control the movement of a free camera.
  8859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8860. */
  8861. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8862. /**
  8863. * Defines the camera the input is attached to.
  8864. */
  8865. camera: FreeCamera;
  8866. /**
  8867. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8868. */
  8869. keysUp: number[];
  8870. /**
  8871. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8872. */
  8873. keysDown: number[];
  8874. /**
  8875. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8876. */
  8877. keysLeft: number[];
  8878. /**
  8879. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8880. */
  8881. keysRight: number[];
  8882. private _keys;
  8883. private _onCanvasBlurObserver;
  8884. private _onKeyboardObserver;
  8885. private _engine;
  8886. private _scene;
  8887. /**
  8888. * Attach the input controls to a specific dom element to get the input from.
  8889. * @param element Defines the element the controls should be listened from
  8890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8891. */
  8892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8893. /**
  8894. * Detach the current controls from the specified dom element.
  8895. * @param element Defines the element to stop listening the inputs from
  8896. */
  8897. detachControl(element: Nullable<HTMLElement>): void;
  8898. /**
  8899. * Update the current camera state depending on the inputs that have been used this frame.
  8900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8901. */
  8902. checkInputs(): void;
  8903. /**
  8904. * Gets the class name of the current intput.
  8905. * @returns the class name
  8906. */
  8907. getClassName(): string;
  8908. /** @hidden */
  8909. _onLostFocus(): void;
  8910. /**
  8911. * Get the friendly name associated with the input class.
  8912. * @returns the input friendly name
  8913. */
  8914. getSimpleName(): string;
  8915. }
  8916. }
  8917. declare module "babylonjs/Lights/shadowLight" {
  8918. import { Camera } from "babylonjs/Cameras/camera";
  8919. import { Scene } from "babylonjs/scene";
  8920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8922. import { Light } from "babylonjs/Lights/light";
  8923. /**
  8924. * Interface describing all the common properties and methods a shadow light needs to implement.
  8925. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8926. * as well as binding the different shadow properties to the effects.
  8927. */
  8928. export interface IShadowLight extends Light {
  8929. /**
  8930. * The light id in the scene (used in scene.findLighById for instance)
  8931. */
  8932. id: string;
  8933. /**
  8934. * The position the shdow will be casted from.
  8935. */
  8936. position: Vector3;
  8937. /**
  8938. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8939. */
  8940. direction: Vector3;
  8941. /**
  8942. * The transformed position. Position of the light in world space taking parenting in account.
  8943. */
  8944. transformedPosition: Vector3;
  8945. /**
  8946. * The transformed direction. Direction of the light in world space taking parenting in account.
  8947. */
  8948. transformedDirection: Vector3;
  8949. /**
  8950. * The friendly name of the light in the scene.
  8951. */
  8952. name: string;
  8953. /**
  8954. * Defines the shadow projection clipping minimum z value.
  8955. */
  8956. shadowMinZ: number;
  8957. /**
  8958. * Defines the shadow projection clipping maximum z value.
  8959. */
  8960. shadowMaxZ: number;
  8961. /**
  8962. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8963. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8964. */
  8965. computeTransformedInformation(): boolean;
  8966. /**
  8967. * Gets the scene the light belongs to.
  8968. * @returns The scene
  8969. */
  8970. getScene(): Scene;
  8971. /**
  8972. * Callback defining a custom Projection Matrix Builder.
  8973. * This can be used to override the default projection matrix computation.
  8974. */
  8975. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8976. /**
  8977. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8978. * @param matrix The materix to updated with the projection information
  8979. * @param viewMatrix The transform matrix of the light
  8980. * @param renderList The list of mesh to render in the map
  8981. * @returns The current light
  8982. */
  8983. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8984. /**
  8985. * Gets the current depth scale used in ESM.
  8986. * @returns The scale
  8987. */
  8988. getDepthScale(): number;
  8989. /**
  8990. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8991. * @returns true if a cube texture needs to be use
  8992. */
  8993. needCube(): boolean;
  8994. /**
  8995. * Detects if the projection matrix requires to be recomputed this frame.
  8996. * @returns true if it requires to be recomputed otherwise, false.
  8997. */
  8998. needProjectionMatrixCompute(): boolean;
  8999. /**
  9000. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9001. */
  9002. forceProjectionMatrixCompute(): void;
  9003. /**
  9004. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9005. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9006. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9007. */
  9008. getShadowDirection(faceIndex?: number): Vector3;
  9009. /**
  9010. * Gets the minZ used for shadow according to both the scene and the light.
  9011. * @param activeCamera The camera we are returning the min for
  9012. * @returns the depth min z
  9013. */
  9014. getDepthMinZ(activeCamera: Camera): number;
  9015. /**
  9016. * Gets the maxZ used for shadow according to both the scene and the light.
  9017. * @param activeCamera The camera we are returning the max for
  9018. * @returns the depth max z
  9019. */
  9020. getDepthMaxZ(activeCamera: Camera): number;
  9021. }
  9022. /**
  9023. * Base implementation IShadowLight
  9024. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9025. */
  9026. export abstract class ShadowLight extends Light implements IShadowLight {
  9027. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9028. protected _position: Vector3;
  9029. protected _setPosition(value: Vector3): void;
  9030. /**
  9031. * Sets the position the shadow will be casted from. Also use as the light position for both
  9032. * point and spot lights.
  9033. */
  9034. get position(): Vector3;
  9035. /**
  9036. * Sets the position the shadow will be casted from. Also use as the light position for both
  9037. * point and spot lights.
  9038. */
  9039. set position(value: Vector3);
  9040. protected _direction: Vector3;
  9041. protected _setDirection(value: Vector3): void;
  9042. /**
  9043. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9044. * Also use as the light direction on spot and directional lights.
  9045. */
  9046. get direction(): Vector3;
  9047. /**
  9048. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9049. * Also use as the light direction on spot and directional lights.
  9050. */
  9051. set direction(value: Vector3);
  9052. protected _shadowMinZ: number;
  9053. /**
  9054. * Gets the shadow projection clipping minimum z value.
  9055. */
  9056. get shadowMinZ(): number;
  9057. /**
  9058. * Sets the shadow projection clipping minimum z value.
  9059. */
  9060. set shadowMinZ(value: number);
  9061. protected _shadowMaxZ: number;
  9062. /**
  9063. * Sets the shadow projection clipping maximum z value.
  9064. */
  9065. get shadowMaxZ(): number;
  9066. /**
  9067. * Gets the shadow projection clipping maximum z value.
  9068. */
  9069. set shadowMaxZ(value: number);
  9070. /**
  9071. * Callback defining a custom Projection Matrix Builder.
  9072. * This can be used to override the default projection matrix computation.
  9073. */
  9074. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9075. /**
  9076. * The transformed position. Position of the light in world space taking parenting in account.
  9077. */
  9078. transformedPosition: Vector3;
  9079. /**
  9080. * The transformed direction. Direction of the light in world space taking parenting in account.
  9081. */
  9082. transformedDirection: Vector3;
  9083. private _needProjectionMatrixCompute;
  9084. /**
  9085. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9086. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9087. */
  9088. computeTransformedInformation(): boolean;
  9089. /**
  9090. * Return the depth scale used for the shadow map.
  9091. * @returns the depth scale.
  9092. */
  9093. getDepthScale(): number;
  9094. /**
  9095. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9096. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9097. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9098. */
  9099. getShadowDirection(faceIndex?: number): Vector3;
  9100. /**
  9101. * Returns the ShadowLight absolute position in the World.
  9102. * @returns the position vector in world space
  9103. */
  9104. getAbsolutePosition(): Vector3;
  9105. /**
  9106. * Sets the ShadowLight direction toward the passed target.
  9107. * @param target The point to target in local space
  9108. * @returns the updated ShadowLight direction
  9109. */
  9110. setDirectionToTarget(target: Vector3): Vector3;
  9111. /**
  9112. * Returns the light rotation in euler definition.
  9113. * @returns the x y z rotation in local space.
  9114. */
  9115. getRotation(): Vector3;
  9116. /**
  9117. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9118. * @returns true if a cube texture needs to be use
  9119. */
  9120. needCube(): boolean;
  9121. /**
  9122. * Detects if the projection matrix requires to be recomputed this frame.
  9123. * @returns true if it requires to be recomputed otherwise, false.
  9124. */
  9125. needProjectionMatrixCompute(): boolean;
  9126. /**
  9127. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9128. */
  9129. forceProjectionMatrixCompute(): void;
  9130. /** @hidden */
  9131. _initCache(): void;
  9132. /** @hidden */
  9133. _isSynchronized(): boolean;
  9134. /**
  9135. * Computes the world matrix of the node
  9136. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9137. * @returns the world matrix
  9138. */
  9139. computeWorldMatrix(force?: boolean): Matrix;
  9140. /**
  9141. * Gets the minZ used for shadow according to both the scene and the light.
  9142. * @param activeCamera The camera we are returning the min for
  9143. * @returns the depth min z
  9144. */
  9145. getDepthMinZ(activeCamera: Camera): number;
  9146. /**
  9147. * Gets the maxZ used for shadow according to both the scene and the light.
  9148. * @param activeCamera The camera we are returning the max for
  9149. * @returns the depth max z
  9150. */
  9151. getDepthMaxZ(activeCamera: Camera): number;
  9152. /**
  9153. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9154. * @param matrix The materix to updated with the projection information
  9155. * @param viewMatrix The transform matrix of the light
  9156. * @param renderList The list of mesh to render in the map
  9157. * @returns The current light
  9158. */
  9159. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9160. }
  9161. }
  9162. declare module "babylonjs/Materials/effectFallbacks" {
  9163. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9164. import { Effect } from "babylonjs/Materials/effect";
  9165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9166. /**
  9167. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9168. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9169. */
  9170. export class EffectFallbacks implements IEffectFallbacks {
  9171. private _defines;
  9172. private _currentRank;
  9173. private _maxRank;
  9174. private _mesh;
  9175. /**
  9176. * Removes the fallback from the bound mesh.
  9177. */
  9178. unBindMesh(): void;
  9179. /**
  9180. * Adds a fallback on the specified property.
  9181. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9182. * @param define The name of the define in the shader
  9183. */
  9184. addFallback(rank: number, define: string): void;
  9185. /**
  9186. * Sets the mesh to use CPU skinning when needing to fallback.
  9187. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9188. * @param mesh The mesh to use the fallbacks.
  9189. */
  9190. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9191. /**
  9192. * Checks to see if more fallbacks are still availible.
  9193. */
  9194. get hasMoreFallbacks(): boolean;
  9195. /**
  9196. * Removes the defines that should be removed when falling back.
  9197. * @param currentDefines defines the current define statements for the shader.
  9198. * @param effect defines the current effect we try to compile
  9199. * @returns The resulting defines with defines of the current rank removed.
  9200. */
  9201. reduce(currentDefines: string, effect: Effect): string;
  9202. }
  9203. }
  9204. declare module "babylonjs/Materials/materialHelper" {
  9205. import { Nullable } from "babylonjs/types";
  9206. import { Scene } from "babylonjs/scene";
  9207. import { Engine } from "babylonjs/Engines/engine";
  9208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9209. import { Light } from "babylonjs/Lights/light";
  9210. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9211. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9213. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9214. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9215. /**
  9216. * "Static Class" containing the most commonly used helper while dealing with material for
  9217. * rendering purpose.
  9218. *
  9219. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9220. *
  9221. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9222. */
  9223. export class MaterialHelper {
  9224. /**
  9225. * Bind the current view position to an effect.
  9226. * @param effect The effect to be bound
  9227. * @param scene The scene the eyes position is used from
  9228. */
  9229. static BindEyePosition(effect: Effect, scene: Scene): void;
  9230. /**
  9231. * Helps preparing the defines values about the UVs in used in the effect.
  9232. * UVs are shared as much as we can accross channels in the shaders.
  9233. * @param texture The texture we are preparing the UVs for
  9234. * @param defines The defines to update
  9235. * @param key The channel key "diffuse", "specular"... used in the shader
  9236. */
  9237. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9238. /**
  9239. * Binds a texture matrix value to its corrsponding uniform
  9240. * @param texture The texture to bind the matrix for
  9241. * @param uniformBuffer The uniform buffer receivin the data
  9242. * @param key The channel key "diffuse", "specular"... used in the shader
  9243. */
  9244. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9245. /**
  9246. * Gets the current status of the fog (should it be enabled?)
  9247. * @param mesh defines the mesh to evaluate for fog support
  9248. * @param scene defines the hosting scene
  9249. * @returns true if fog must be enabled
  9250. */
  9251. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9252. /**
  9253. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9254. * @param mesh defines the current mesh
  9255. * @param scene defines the current scene
  9256. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9257. * @param pointsCloud defines if point cloud rendering has to be turned on
  9258. * @param fogEnabled defines if fog has to be turned on
  9259. * @param alphaTest defines if alpha testing has to be turned on
  9260. * @param defines defines the current list of defines
  9261. */
  9262. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9263. /**
  9264. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9265. * @param scene defines the current scene
  9266. * @param engine defines the current engine
  9267. * @param defines specifies the list of active defines
  9268. * @param useInstances defines if instances have to be turned on
  9269. * @param useClipPlane defines if clip plane have to be turned on
  9270. */
  9271. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9272. /**
  9273. * Prepares the defines for bones
  9274. * @param mesh The mesh containing the geometry data we will draw
  9275. * @param defines The defines to update
  9276. */
  9277. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9278. /**
  9279. * Prepares the defines for morph targets
  9280. * @param mesh The mesh containing the geometry data we will draw
  9281. * @param defines The defines to update
  9282. */
  9283. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9284. /**
  9285. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9286. * @param mesh The mesh containing the geometry data we will draw
  9287. * @param defines The defines to update
  9288. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9289. * @param useBones Precise whether bones should be used or not (override mesh info)
  9290. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9291. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9292. * @returns false if defines are considered not dirty and have not been checked
  9293. */
  9294. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9295. /**
  9296. * Prepares the defines related to multiview
  9297. * @param scene The scene we are intending to draw
  9298. * @param defines The defines to update
  9299. */
  9300. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9301. /**
  9302. * Prepares the defines related to the light information passed in parameter
  9303. * @param scene The scene we are intending to draw
  9304. * @param mesh The mesh the effect is compiling for
  9305. * @param light The light the effect is compiling for
  9306. * @param lightIndex The index of the light
  9307. * @param defines The defines to update
  9308. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9309. * @param state Defines the current state regarding what is needed (normals, etc...)
  9310. */
  9311. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9312. needNormals: boolean;
  9313. needRebuild: boolean;
  9314. shadowEnabled: boolean;
  9315. specularEnabled: boolean;
  9316. lightmapMode: boolean;
  9317. }): void;
  9318. /**
  9319. * Prepares the defines related to the light information passed in parameter
  9320. * @param scene The scene we are intending to draw
  9321. * @param mesh The mesh the effect is compiling for
  9322. * @param defines The defines to update
  9323. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9324. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9325. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9326. * @returns true if normals will be required for the rest of the effect
  9327. */
  9328. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9329. /**
  9330. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9331. * @param lightIndex defines the light index
  9332. * @param uniformsList The uniform list
  9333. * @param samplersList The sampler list
  9334. * @param projectedLightTexture defines if projected texture must be used
  9335. * @param uniformBuffersList defines an optional list of uniform buffers
  9336. */
  9337. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9338. /**
  9339. * Prepares the uniforms and samplers list to be used in the effect
  9340. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9341. * @param samplersList The sampler list
  9342. * @param defines The defines helping in the list generation
  9343. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9344. */
  9345. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9346. /**
  9347. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9348. * @param defines The defines to update while falling back
  9349. * @param fallbacks The authorized effect fallbacks
  9350. * @param maxSimultaneousLights The maximum number of lights allowed
  9351. * @param rank the current rank of the Effect
  9352. * @returns The newly affected rank
  9353. */
  9354. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9355. private static _TmpMorphInfluencers;
  9356. /**
  9357. * Prepares the list of attributes required for morph targets according to the effect defines.
  9358. * @param attribs The current list of supported attribs
  9359. * @param mesh The mesh to prepare the morph targets attributes for
  9360. * @param influencers The number of influencers
  9361. */
  9362. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9363. /**
  9364. * Prepares the list of attributes required for morph targets according to the effect defines.
  9365. * @param attribs The current list of supported attribs
  9366. * @param mesh The mesh to prepare the morph targets attributes for
  9367. * @param defines The current Defines of the effect
  9368. */
  9369. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9370. /**
  9371. * Prepares the list of attributes required for bones according to the effect defines.
  9372. * @param attribs The current list of supported attribs
  9373. * @param mesh The mesh to prepare the bones attributes for
  9374. * @param defines The current Defines of the effect
  9375. * @param fallbacks The current efffect fallback strategy
  9376. */
  9377. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9378. /**
  9379. * Check and prepare the list of attributes required for instances according to the effect defines.
  9380. * @param attribs The current list of supported attribs
  9381. * @param defines The current MaterialDefines of the effect
  9382. */
  9383. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9384. /**
  9385. * Add the list of attributes required for instances to the attribs array.
  9386. * @param attribs The current list of supported attribs
  9387. */
  9388. static PushAttributesForInstances(attribs: string[]): void;
  9389. /**
  9390. * Binds the light information to the effect.
  9391. * @param light The light containing the generator
  9392. * @param effect The effect we are binding the data to
  9393. * @param lightIndex The light index in the effect used to render
  9394. */
  9395. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9396. /**
  9397. * Binds the lights information from the scene to the effect for the given mesh.
  9398. * @param light Light to bind
  9399. * @param lightIndex Light index
  9400. * @param scene The scene where the light belongs to
  9401. * @param effect The effect we are binding the data to
  9402. * @param useSpecular Defines if specular is supported
  9403. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9404. */
  9405. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9406. /**
  9407. * Binds the lights information from the scene to the effect for the given mesh.
  9408. * @param scene The scene the lights belongs to
  9409. * @param mesh The mesh we are binding the information to render
  9410. * @param effect The effect we are binding the data to
  9411. * @param defines The generated defines for the effect
  9412. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9413. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9414. */
  9415. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9416. private static _tempFogColor;
  9417. /**
  9418. * Binds the fog information from the scene to the effect for the given mesh.
  9419. * @param scene The scene the lights belongs to
  9420. * @param mesh The mesh we are binding the information to render
  9421. * @param effect The effect we are binding the data to
  9422. * @param linearSpace Defines if the fog effect is applied in linear space
  9423. */
  9424. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9425. /**
  9426. * Binds the bones information from the mesh to the effect.
  9427. * @param mesh The mesh we are binding the information to render
  9428. * @param effect The effect we are binding the data to
  9429. */
  9430. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9431. /**
  9432. * Binds the morph targets information from the mesh to the effect.
  9433. * @param abstractMesh The mesh we are binding the information to render
  9434. * @param effect The effect we are binding the data to
  9435. */
  9436. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9437. /**
  9438. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9439. * @param defines The generated defines used in the effect
  9440. * @param effect The effect we are binding the data to
  9441. * @param scene The scene we are willing to render with logarithmic scale for
  9442. */
  9443. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9444. /**
  9445. * Binds the clip plane information from the scene to the effect.
  9446. * @param scene The scene the clip plane information are extracted from
  9447. * @param effect The effect we are binding the data to
  9448. */
  9449. static BindClipPlane(effect: Effect, scene: Scene): void;
  9450. }
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9453. /** @hidden */
  9454. export var packingFunctions: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9460. /** @hidden */
  9461. export var clipPlaneFragmentDeclaration: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9467. /** @hidden */
  9468. export var clipPlaneFragment: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9474. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9475. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9476. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9477. /** @hidden */
  9478. export var shadowMapPixelShader: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9484. /** @hidden */
  9485. export var bonesDeclaration: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9491. /** @hidden */
  9492. export var morphTargetsVertexGlobalDeclaration: {
  9493. name: string;
  9494. shader: string;
  9495. };
  9496. }
  9497. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9498. /** @hidden */
  9499. export var morphTargetsVertexDeclaration: {
  9500. name: string;
  9501. shader: string;
  9502. };
  9503. }
  9504. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9505. /** @hidden */
  9506. export var instancesDeclaration: {
  9507. name: string;
  9508. shader: string;
  9509. };
  9510. }
  9511. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9512. /** @hidden */
  9513. export var helperFunctions: {
  9514. name: string;
  9515. shader: string;
  9516. };
  9517. }
  9518. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9519. /** @hidden */
  9520. export var clipPlaneVertexDeclaration: {
  9521. name: string;
  9522. shader: string;
  9523. };
  9524. }
  9525. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9526. /** @hidden */
  9527. export var morphTargetsVertex: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9533. /** @hidden */
  9534. export var instancesVertex: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9540. /** @hidden */
  9541. export var bonesVertex: {
  9542. name: string;
  9543. shader: string;
  9544. };
  9545. }
  9546. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9547. /** @hidden */
  9548. export var clipPlaneVertex: {
  9549. name: string;
  9550. shader: string;
  9551. };
  9552. }
  9553. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9554. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9555. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9556. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9557. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9559. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9561. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9562. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9563. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9564. /** @hidden */
  9565. export var shadowMapVertexShader: {
  9566. name: string;
  9567. shader: string;
  9568. };
  9569. }
  9570. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9571. /** @hidden */
  9572. export var depthBoxBlurPixelShader: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Culling/ray" {
  9578. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9579. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9581. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9582. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9583. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9584. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9585. import { Plane } from "babylonjs/Maths/math.plane";
  9586. /**
  9587. * Class representing a ray with position and direction
  9588. */
  9589. export class Ray {
  9590. /** origin point */
  9591. origin: Vector3;
  9592. /** direction */
  9593. direction: Vector3;
  9594. /** length of the ray */
  9595. length: number;
  9596. private static readonly TmpVector3;
  9597. private _tmpRay;
  9598. /**
  9599. * Creates a new ray
  9600. * @param origin origin point
  9601. * @param direction direction
  9602. * @param length length of the ray
  9603. */
  9604. constructor(
  9605. /** origin point */
  9606. origin: Vector3,
  9607. /** direction */
  9608. direction: Vector3,
  9609. /** length of the ray */
  9610. length?: number);
  9611. /**
  9612. * Checks if the ray intersects a box
  9613. * @param minimum bound of the box
  9614. * @param maximum bound of the box
  9615. * @param intersectionTreshold extra extend to be added to the box in all direction
  9616. * @returns if the box was hit
  9617. */
  9618. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9619. /**
  9620. * Checks if the ray intersects a box
  9621. * @param box the bounding box to check
  9622. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9623. * @returns if the box was hit
  9624. */
  9625. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9626. /**
  9627. * If the ray hits a sphere
  9628. * @param sphere the bounding sphere to check
  9629. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9630. * @returns true if it hits the sphere
  9631. */
  9632. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9633. /**
  9634. * If the ray hits a triange
  9635. * @param vertex0 triangle vertex
  9636. * @param vertex1 triangle vertex
  9637. * @param vertex2 triangle vertex
  9638. * @returns intersection information if hit
  9639. */
  9640. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9641. /**
  9642. * Checks if ray intersects a plane
  9643. * @param plane the plane to check
  9644. * @returns the distance away it was hit
  9645. */
  9646. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9647. /**
  9648. * Calculate the intercept of a ray on a given axis
  9649. * @param axis to check 'x' | 'y' | 'z'
  9650. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9651. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9652. */
  9653. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9654. /**
  9655. * Checks if ray intersects a mesh
  9656. * @param mesh the mesh to check
  9657. * @param fastCheck if only the bounding box should checked
  9658. * @returns picking info of the intersecton
  9659. */
  9660. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9661. /**
  9662. * Checks if ray intersects a mesh
  9663. * @param meshes the meshes to check
  9664. * @param fastCheck if only the bounding box should checked
  9665. * @param results array to store result in
  9666. * @returns Array of picking infos
  9667. */
  9668. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9669. private _comparePickingInfo;
  9670. private static smallnum;
  9671. private static rayl;
  9672. /**
  9673. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9674. * @param sega the first point of the segment to test the intersection against
  9675. * @param segb the second point of the segment to test the intersection against
  9676. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9677. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9678. */
  9679. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9680. /**
  9681. * Update the ray from viewport position
  9682. * @param x position
  9683. * @param y y position
  9684. * @param viewportWidth viewport width
  9685. * @param viewportHeight viewport height
  9686. * @param world world matrix
  9687. * @param view view matrix
  9688. * @param projection projection matrix
  9689. * @returns this ray updated
  9690. */
  9691. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9692. /**
  9693. * Creates a ray with origin and direction of 0,0,0
  9694. * @returns the new ray
  9695. */
  9696. static Zero(): Ray;
  9697. /**
  9698. * Creates a new ray from screen space and viewport
  9699. * @param x position
  9700. * @param y y position
  9701. * @param viewportWidth viewport width
  9702. * @param viewportHeight viewport height
  9703. * @param world world matrix
  9704. * @param view view matrix
  9705. * @param projection projection matrix
  9706. * @returns new ray
  9707. */
  9708. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9709. /**
  9710. * 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
  9711. * transformed to the given world matrix.
  9712. * @param origin The origin point
  9713. * @param end The end point
  9714. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9715. * @returns the new ray
  9716. */
  9717. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9718. /**
  9719. * Transforms a ray by a matrix
  9720. * @param ray ray to transform
  9721. * @param matrix matrix to apply
  9722. * @returns the resulting new ray
  9723. */
  9724. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9725. /**
  9726. * Transforms a ray by a matrix
  9727. * @param ray ray to transform
  9728. * @param matrix matrix to apply
  9729. * @param result ray to store result in
  9730. */
  9731. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9732. /**
  9733. * Unproject a ray from screen space to object space
  9734. * @param sourceX defines the screen space x coordinate to use
  9735. * @param sourceY defines the screen space y coordinate to use
  9736. * @param viewportWidth defines the current width of the viewport
  9737. * @param viewportHeight defines the current height of the viewport
  9738. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9739. * @param view defines the view matrix to use
  9740. * @param projection defines the projection matrix to use
  9741. */
  9742. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9743. }
  9744. /**
  9745. * Type used to define predicate used to select faces when a mesh intersection is detected
  9746. */
  9747. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9748. module "babylonjs/scene" {
  9749. interface Scene {
  9750. /** @hidden */
  9751. _tempPickingRay: Nullable<Ray>;
  9752. /** @hidden */
  9753. _cachedRayForTransform: Ray;
  9754. /** @hidden */
  9755. _pickWithRayInverseMatrix: Matrix;
  9756. /** @hidden */
  9757. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9758. /** @hidden */
  9759. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9760. }
  9761. }
  9762. }
  9763. declare module "babylonjs/sceneComponent" {
  9764. import { Scene } from "babylonjs/scene";
  9765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9766. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9767. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9768. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9769. import { Nullable } from "babylonjs/types";
  9770. import { Camera } from "babylonjs/Cameras/camera";
  9771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9772. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9773. import { AbstractScene } from "babylonjs/abstractScene";
  9774. import { Mesh } from "babylonjs/Meshes/mesh";
  9775. /**
  9776. * Groups all the scene component constants in one place to ease maintenance.
  9777. * @hidden
  9778. */
  9779. export class SceneComponentConstants {
  9780. static readonly NAME_EFFECTLAYER: string;
  9781. static readonly NAME_LAYER: string;
  9782. static readonly NAME_LENSFLARESYSTEM: string;
  9783. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9784. static readonly NAME_PARTICLESYSTEM: string;
  9785. static readonly NAME_GAMEPAD: string;
  9786. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9787. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9788. static readonly NAME_DEPTHRENDERER: string;
  9789. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9790. static readonly NAME_SPRITE: string;
  9791. static readonly NAME_OUTLINERENDERER: string;
  9792. static readonly NAME_PROCEDURALTEXTURE: string;
  9793. static readonly NAME_SHADOWGENERATOR: string;
  9794. static readonly NAME_OCTREE: string;
  9795. static readonly NAME_PHYSICSENGINE: string;
  9796. static readonly NAME_AUDIO: string;
  9797. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9798. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9799. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9800. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9801. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9802. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9803. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9804. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9805. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9806. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9807. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9808. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9809. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9810. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9811. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9812. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9813. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9814. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9815. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9816. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9817. static readonly STEP_AFTERRENDER_AUDIO: number;
  9818. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9819. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9820. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9821. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9822. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9823. static readonly STEP_POINTERMOVE_SPRITE: number;
  9824. static readonly STEP_POINTERDOWN_SPRITE: number;
  9825. static readonly STEP_POINTERUP_SPRITE: number;
  9826. }
  9827. /**
  9828. * This represents a scene component.
  9829. *
  9830. * This is used to decouple the dependency the scene is having on the different workloads like
  9831. * layers, post processes...
  9832. */
  9833. export interface ISceneComponent {
  9834. /**
  9835. * The name of the component. Each component must have a unique name.
  9836. */
  9837. name: string;
  9838. /**
  9839. * The scene the component belongs to.
  9840. */
  9841. scene: Scene;
  9842. /**
  9843. * Register the component to one instance of a scene.
  9844. */
  9845. register(): void;
  9846. /**
  9847. * Rebuilds the elements related to this component in case of
  9848. * context lost for instance.
  9849. */
  9850. rebuild(): void;
  9851. /**
  9852. * Disposes the component and the associated ressources.
  9853. */
  9854. dispose(): void;
  9855. }
  9856. /**
  9857. * This represents a SERIALIZABLE scene component.
  9858. *
  9859. * This extends Scene Component to add Serialization methods on top.
  9860. */
  9861. export interface ISceneSerializableComponent extends ISceneComponent {
  9862. /**
  9863. * Adds all the elements from the container to the scene
  9864. * @param container the container holding the elements
  9865. */
  9866. addFromContainer(container: AbstractScene): void;
  9867. /**
  9868. * Removes all the elements in the container from the scene
  9869. * @param container contains the elements to remove
  9870. * @param dispose if the removed element should be disposed (default: false)
  9871. */
  9872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9873. /**
  9874. * Serializes the component data to the specified json object
  9875. * @param serializationObject The object to serialize to
  9876. */
  9877. serialize(serializationObject: any): void;
  9878. }
  9879. /**
  9880. * Strong typing of a Mesh related stage step action
  9881. */
  9882. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9883. /**
  9884. * Strong typing of a Evaluate Sub Mesh related stage step action
  9885. */
  9886. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9887. /**
  9888. * Strong typing of a Active Mesh related stage step action
  9889. */
  9890. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9891. /**
  9892. * Strong typing of a Camera related stage step action
  9893. */
  9894. export type CameraStageAction = (camera: Camera) => void;
  9895. /**
  9896. * Strong typing of a Camera Frame buffer related stage step action
  9897. */
  9898. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9899. /**
  9900. * Strong typing of a Render Target related stage step action
  9901. */
  9902. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9903. /**
  9904. * Strong typing of a RenderingGroup related stage step action
  9905. */
  9906. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9907. /**
  9908. * Strong typing of a Mesh Render related stage step action
  9909. */
  9910. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9911. /**
  9912. * Strong typing of a simple stage step action
  9913. */
  9914. export type SimpleStageAction = () => void;
  9915. /**
  9916. * Strong typing of a render target action.
  9917. */
  9918. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9919. /**
  9920. * Strong typing of a pointer move action.
  9921. */
  9922. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9923. /**
  9924. * Strong typing of a pointer up/down action.
  9925. */
  9926. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9927. /**
  9928. * Representation of a stage in the scene (Basically a list of ordered steps)
  9929. * @hidden
  9930. */
  9931. export class Stage<T extends Function> extends Array<{
  9932. index: number;
  9933. component: ISceneComponent;
  9934. action: T;
  9935. }> {
  9936. /**
  9937. * Hide ctor from the rest of the world.
  9938. * @param items The items to add.
  9939. */
  9940. private constructor();
  9941. /**
  9942. * Creates a new Stage.
  9943. * @returns A new instance of a Stage
  9944. */
  9945. static Create<T extends Function>(): Stage<T>;
  9946. /**
  9947. * Registers a step in an ordered way in the targeted stage.
  9948. * @param index Defines the position to register the step in
  9949. * @param component Defines the component attached to the step
  9950. * @param action Defines the action to launch during the step
  9951. */
  9952. registerStep(index: number, component: ISceneComponent, action: T): void;
  9953. /**
  9954. * Clears all the steps from the stage.
  9955. */
  9956. clear(): void;
  9957. }
  9958. }
  9959. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9960. import { Nullable } from "babylonjs/types";
  9961. import { Observable } from "babylonjs/Misc/observable";
  9962. import { Scene } from "babylonjs/scene";
  9963. import { Sprite } from "babylonjs/Sprites/sprite";
  9964. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9965. import { Ray } from "babylonjs/Culling/ray";
  9966. import { Camera } from "babylonjs/Cameras/camera";
  9967. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9968. import { ISceneComponent } from "babylonjs/sceneComponent";
  9969. module "babylonjs/scene" {
  9970. interface Scene {
  9971. /** @hidden */
  9972. _pointerOverSprite: Nullable<Sprite>;
  9973. /** @hidden */
  9974. _pickedDownSprite: Nullable<Sprite>;
  9975. /** @hidden */
  9976. _tempSpritePickingRay: Nullable<Ray>;
  9977. /**
  9978. * All of the sprite managers added to this scene
  9979. * @see http://doc.babylonjs.com/babylon101/sprites
  9980. */
  9981. spriteManagers: Array<ISpriteManager>;
  9982. /**
  9983. * An event triggered when sprites rendering is about to start
  9984. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9985. */
  9986. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9987. /**
  9988. * An event triggered when sprites rendering is done
  9989. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9990. */
  9991. onAfterSpritesRenderingObservable: Observable<Scene>;
  9992. /** @hidden */
  9993. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9994. /** Launch a ray to try to pick a sprite in the scene
  9995. * @param x position on screen
  9996. * @param y position on screen
  9997. * @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
  9998. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9999. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10000. * @returns a PickingInfo
  10001. */
  10002. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10003. /** Use the given ray to pick a sprite in the scene
  10004. * @param ray The ray (in world space) to use to pick meshes
  10005. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10006. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10007. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10008. * @returns a PickingInfo
  10009. */
  10010. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10011. /** @hidden */
  10012. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10013. /** Launch a ray to try to pick sprites in the scene
  10014. * @param x position on screen
  10015. * @param y position on screen
  10016. * @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
  10017. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10018. * @returns a PickingInfo array
  10019. */
  10020. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10021. /** Use the given ray to pick sprites in the scene
  10022. * @param ray The ray (in world space) to use to pick meshes
  10023. * @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
  10024. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10025. * @returns a PickingInfo array
  10026. */
  10027. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10028. /**
  10029. * Force the sprite under the pointer
  10030. * @param sprite defines the sprite to use
  10031. */
  10032. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10033. /**
  10034. * Gets the sprite under the pointer
  10035. * @returns a Sprite or null if no sprite is under the pointer
  10036. */
  10037. getPointerOverSprite(): Nullable<Sprite>;
  10038. }
  10039. }
  10040. /**
  10041. * Defines the sprite scene component responsible to manage sprites
  10042. * in a given scene.
  10043. */
  10044. export class SpriteSceneComponent implements ISceneComponent {
  10045. /**
  10046. * The component name helpfull to identify the component in the list of scene components.
  10047. */
  10048. readonly name: string;
  10049. /**
  10050. * The scene the component belongs to.
  10051. */
  10052. scene: Scene;
  10053. /** @hidden */
  10054. private _spritePredicate;
  10055. /**
  10056. * Creates a new instance of the component for the given scene
  10057. * @param scene Defines the scene to register the component in
  10058. */
  10059. constructor(scene: Scene);
  10060. /**
  10061. * Registers the component in a given scene
  10062. */
  10063. register(): void;
  10064. /**
  10065. * Rebuilds the elements related to this component in case of
  10066. * context lost for instance.
  10067. */
  10068. rebuild(): void;
  10069. /**
  10070. * Disposes the component and the associated ressources.
  10071. */
  10072. dispose(): void;
  10073. private _pickSpriteButKeepRay;
  10074. private _pointerMove;
  10075. private _pointerDown;
  10076. private _pointerUp;
  10077. }
  10078. }
  10079. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10080. /** @hidden */
  10081. export var fogFragmentDeclaration: {
  10082. name: string;
  10083. shader: string;
  10084. };
  10085. }
  10086. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10087. /** @hidden */
  10088. export var fogFragment: {
  10089. name: string;
  10090. shader: string;
  10091. };
  10092. }
  10093. declare module "babylonjs/Shaders/sprites.fragment" {
  10094. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10095. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10096. /** @hidden */
  10097. export var spritesPixelShader: {
  10098. name: string;
  10099. shader: string;
  10100. };
  10101. }
  10102. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10103. /** @hidden */
  10104. export var fogVertexDeclaration: {
  10105. name: string;
  10106. shader: string;
  10107. };
  10108. }
  10109. declare module "babylonjs/Shaders/sprites.vertex" {
  10110. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10111. /** @hidden */
  10112. export var spritesVertexShader: {
  10113. name: string;
  10114. shader: string;
  10115. };
  10116. }
  10117. declare module "babylonjs/Sprites/spriteManager" {
  10118. import { IDisposable, Scene } from "babylonjs/scene";
  10119. import { Nullable } from "babylonjs/types";
  10120. import { Observable } from "babylonjs/Misc/observable";
  10121. import { Sprite } from "babylonjs/Sprites/sprite";
  10122. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10123. import { Camera } from "babylonjs/Cameras/camera";
  10124. import { Texture } from "babylonjs/Materials/Textures/texture";
  10125. import "babylonjs/Shaders/sprites.fragment";
  10126. import "babylonjs/Shaders/sprites.vertex";
  10127. import { Ray } from "babylonjs/Culling/ray";
  10128. /**
  10129. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10130. */
  10131. export interface ISpriteManager extends IDisposable {
  10132. /**
  10133. * Restricts the camera to viewing objects with the same layerMask.
  10134. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10135. */
  10136. layerMask: number;
  10137. /**
  10138. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10139. */
  10140. isPickable: boolean;
  10141. /**
  10142. * Specifies the rendering group id for this mesh (0 by default)
  10143. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10144. */
  10145. renderingGroupId: number;
  10146. /**
  10147. * Defines the list of sprites managed by the manager.
  10148. */
  10149. sprites: Array<Sprite>;
  10150. /**
  10151. * Tests the intersection of a sprite with a specific ray.
  10152. * @param ray The ray we are sending to test the collision
  10153. * @param camera The camera space we are sending rays in
  10154. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10155. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10156. * @returns picking info or null.
  10157. */
  10158. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10159. /**
  10160. * Intersects the sprites with a ray
  10161. * @param ray defines the ray to intersect with
  10162. * @param camera defines the current active camera
  10163. * @param predicate defines a predicate used to select candidate sprites
  10164. * @returns null if no hit or a PickingInfo array
  10165. */
  10166. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10167. /**
  10168. * Renders the list of sprites on screen.
  10169. */
  10170. render(): void;
  10171. }
  10172. /**
  10173. * Class used to manage multiple sprites on the same spritesheet
  10174. * @see http://doc.babylonjs.com/babylon101/sprites
  10175. */
  10176. export class SpriteManager implements ISpriteManager {
  10177. /** defines the manager's name */
  10178. name: string;
  10179. /** Gets the list of sprites */
  10180. sprites: Sprite[];
  10181. /** Gets or sets the rendering group id (0 by default) */
  10182. renderingGroupId: number;
  10183. /** Gets or sets camera layer mask */
  10184. layerMask: number;
  10185. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10186. fogEnabled: boolean;
  10187. /** Gets or sets a boolean indicating if the sprites are pickable */
  10188. isPickable: boolean;
  10189. /** Defines the default width of a cell in the spritesheet */
  10190. cellWidth: number;
  10191. /** Defines the default height of a cell in the spritesheet */
  10192. cellHeight: number;
  10193. /** Associative array from JSON sprite data file */
  10194. private _cellData;
  10195. /** Array of sprite names from JSON sprite data file */
  10196. private _spriteMap;
  10197. /** True when packed cell data from JSON file is ready*/
  10198. private _packedAndReady;
  10199. /**
  10200. * An event triggered when the manager is disposed.
  10201. */
  10202. onDisposeObservable: Observable<SpriteManager>;
  10203. private _onDisposeObserver;
  10204. /**
  10205. * Callback called when the manager is disposed
  10206. */
  10207. set onDispose(callback: () => void);
  10208. private _capacity;
  10209. private _fromPacked;
  10210. private _spriteTexture;
  10211. private _epsilon;
  10212. private _scene;
  10213. private _vertexData;
  10214. private _buffer;
  10215. private _vertexBuffers;
  10216. private _indexBuffer;
  10217. private _effectBase;
  10218. private _effectFog;
  10219. /**
  10220. * Gets or sets the spritesheet texture
  10221. */
  10222. get texture(): Texture;
  10223. set texture(value: Texture);
  10224. private _blendMode;
  10225. /**
  10226. * Blend mode use to render the particle, it can be any of
  10227. * the static Constants.ALPHA_x properties provided in this class.
  10228. * Default value is Constants.ALPHA_COMBINE
  10229. */
  10230. get blendMode(): number;
  10231. set blendMode(blendMode: number);
  10232. /** Disables writing to the depth buffer when rendering the sprites.
  10233. * It can be handy to disable depth writing when using textures without alpha channel
  10234. * and setting some specific blend modes.
  10235. */
  10236. disableDepthWrite: boolean;
  10237. /**
  10238. * Creates a new sprite manager
  10239. * @param name defines the manager's name
  10240. * @param imgUrl defines the sprite sheet url
  10241. * @param capacity defines the maximum allowed number of sprites
  10242. * @param cellSize defines the size of a sprite cell
  10243. * @param scene defines the hosting scene
  10244. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10245. * @param samplingMode defines the smapling mode to use with spritesheet
  10246. * @param fromPacked set to false; do not alter
  10247. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10248. */
  10249. constructor(
  10250. /** defines the manager's name */
  10251. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10252. private _makePacked;
  10253. private _appendSpriteVertex;
  10254. /**
  10255. * Intersects the sprites with a ray
  10256. * @param ray defines the ray to intersect with
  10257. * @param camera defines the current active camera
  10258. * @param predicate defines a predicate used to select candidate sprites
  10259. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10260. * @returns null if no hit or a PickingInfo
  10261. */
  10262. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10263. /**
  10264. * Intersects the sprites with a ray
  10265. * @param ray defines the ray to intersect with
  10266. * @param camera defines the current active camera
  10267. * @param predicate defines a predicate used to select candidate sprites
  10268. * @returns null if no hit or a PickingInfo array
  10269. */
  10270. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10271. /**
  10272. * Render all child sprites
  10273. */
  10274. render(): void;
  10275. /**
  10276. * Release associated resources
  10277. */
  10278. dispose(): void;
  10279. }
  10280. }
  10281. declare module "babylonjs/Misc/gradients" {
  10282. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10283. /** Interface used by value gradients (color, factor, ...) */
  10284. export interface IValueGradient {
  10285. /**
  10286. * Gets or sets the gradient value (between 0 and 1)
  10287. */
  10288. gradient: number;
  10289. }
  10290. /** Class used to store color4 gradient */
  10291. export class ColorGradient implements IValueGradient {
  10292. /**
  10293. * Gets or sets the gradient value (between 0 and 1)
  10294. */
  10295. gradient: number;
  10296. /**
  10297. * Gets or sets first associated color
  10298. */
  10299. color1: Color4;
  10300. /**
  10301. * Gets or sets second associated color
  10302. */
  10303. color2?: Color4;
  10304. /**
  10305. * Will get a color picked randomly between color1 and color2.
  10306. * If color2 is undefined then color1 will be used
  10307. * @param result defines the target Color4 to store the result in
  10308. */
  10309. getColorToRef(result: Color4): void;
  10310. }
  10311. /** Class used to store color 3 gradient */
  10312. export class Color3Gradient implements IValueGradient {
  10313. /**
  10314. * Gets or sets the gradient value (between 0 and 1)
  10315. */
  10316. gradient: number;
  10317. /**
  10318. * Gets or sets the associated color
  10319. */
  10320. color: Color3;
  10321. }
  10322. /** Class used to store factor gradient */
  10323. export class FactorGradient implements IValueGradient {
  10324. /**
  10325. * Gets or sets the gradient value (between 0 and 1)
  10326. */
  10327. gradient: number;
  10328. /**
  10329. * Gets or sets first associated factor
  10330. */
  10331. factor1: number;
  10332. /**
  10333. * Gets or sets second associated factor
  10334. */
  10335. factor2?: number;
  10336. /**
  10337. * Will get a number picked randomly between factor1 and factor2.
  10338. * If factor2 is undefined then factor1 will be used
  10339. * @returns the picked number
  10340. */
  10341. getFactor(): number;
  10342. }
  10343. /**
  10344. * Helper used to simplify some generic gradient tasks
  10345. */
  10346. export class GradientHelper {
  10347. /**
  10348. * Gets the current gradient from an array of IValueGradient
  10349. * @param ratio defines the current ratio to get
  10350. * @param gradients defines the array of IValueGradient
  10351. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10352. */
  10353. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10354. }
  10355. }
  10356. declare module "babylonjs/Maths/math.size" {
  10357. /**
  10358. * Interface for the size containing width and height
  10359. */
  10360. export interface ISize {
  10361. /**
  10362. * Width
  10363. */
  10364. width: number;
  10365. /**
  10366. * Heighht
  10367. */
  10368. height: number;
  10369. }
  10370. /**
  10371. * Size containing widht and height
  10372. */
  10373. export class Size implements ISize {
  10374. /**
  10375. * Width
  10376. */
  10377. width: number;
  10378. /**
  10379. * Height
  10380. */
  10381. height: number;
  10382. /**
  10383. * Creates a Size object from the given width and height (floats).
  10384. * @param width width of the new size
  10385. * @param height height of the new size
  10386. */
  10387. constructor(width: number, height: number);
  10388. /**
  10389. * Returns a string with the Size width and height
  10390. * @returns a string with the Size width and height
  10391. */
  10392. toString(): string;
  10393. /**
  10394. * "Size"
  10395. * @returns the string "Size"
  10396. */
  10397. getClassName(): string;
  10398. /**
  10399. * Returns the Size hash code.
  10400. * @returns a hash code for a unique width and height
  10401. */
  10402. getHashCode(): number;
  10403. /**
  10404. * Updates the current size from the given one.
  10405. * @param src the given size
  10406. */
  10407. copyFrom(src: Size): void;
  10408. /**
  10409. * Updates in place the current Size from the given floats.
  10410. * @param width width of the new size
  10411. * @param height height of the new size
  10412. * @returns the updated Size.
  10413. */
  10414. copyFromFloats(width: number, height: number): Size;
  10415. /**
  10416. * Updates in place the current Size from the given floats.
  10417. * @param width width to set
  10418. * @param height height to set
  10419. * @returns the updated Size.
  10420. */
  10421. set(width: number, height: number): Size;
  10422. /**
  10423. * Multiplies the width and height by numbers
  10424. * @param w factor to multiple the width by
  10425. * @param h factor to multiple the height by
  10426. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10427. */
  10428. multiplyByFloats(w: number, h: number): Size;
  10429. /**
  10430. * Clones the size
  10431. * @returns a new Size copied from the given one.
  10432. */
  10433. clone(): Size;
  10434. /**
  10435. * True if the current Size and the given one width and height are strictly equal.
  10436. * @param other the other size to compare against
  10437. * @returns True if the current Size and the given one width and height are strictly equal.
  10438. */
  10439. equals(other: Size): boolean;
  10440. /**
  10441. * The surface of the Size : width * height (float).
  10442. */
  10443. get surface(): number;
  10444. /**
  10445. * Create a new size of zero
  10446. * @returns a new Size set to (0.0, 0.0)
  10447. */
  10448. static Zero(): Size;
  10449. /**
  10450. * Sums the width and height of two sizes
  10451. * @param otherSize size to add to this size
  10452. * @returns a new Size set as the addition result of the current Size and the given one.
  10453. */
  10454. add(otherSize: Size): Size;
  10455. /**
  10456. * Subtracts the width and height of two
  10457. * @param otherSize size to subtract to this size
  10458. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10459. */
  10460. subtract(otherSize: Size): Size;
  10461. /**
  10462. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10463. * @param start starting size to lerp between
  10464. * @param end end size to lerp between
  10465. * @param amount amount to lerp between the start and end values
  10466. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10467. */
  10468. static Lerp(start: Size, end: Size, amount: number): Size;
  10469. }
  10470. }
  10471. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10473. import { Nullable } from "babylonjs/types";
  10474. module "babylonjs/Engines/thinEngine" {
  10475. interface ThinEngine {
  10476. /**
  10477. * Creates a dynamic texture
  10478. * @param width defines the width of the texture
  10479. * @param height defines the height of the texture
  10480. * @param generateMipMaps defines if the engine should generate the mip levels
  10481. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10482. * @returns the dynamic texture inside an InternalTexture
  10483. */
  10484. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10485. /**
  10486. * Update the content of a dynamic texture
  10487. * @param texture defines the texture to update
  10488. * @param canvas defines the canvas containing the source
  10489. * @param invertY defines if data must be stored with Y axis inverted
  10490. * @param premulAlpha defines if alpha is stored as premultiplied
  10491. * @param format defines the format of the data
  10492. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10493. */
  10494. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10495. }
  10496. }
  10497. }
  10498. declare module "babylonjs/Misc/canvasGenerator" {
  10499. /**
  10500. * Helper class used to generate a canvas to manipulate images
  10501. */
  10502. export class CanvasGenerator {
  10503. /**
  10504. * Create a new canvas (or offscreen canvas depending on the context)
  10505. * @param width defines the expected width
  10506. * @param height defines the expected height
  10507. * @return a new canvas or offscreen canvas
  10508. */
  10509. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10510. }
  10511. }
  10512. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10513. import { Scene } from "babylonjs/scene";
  10514. import { Texture } from "babylonjs/Materials/Textures/texture";
  10515. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10516. /**
  10517. * A class extending Texture allowing drawing on a texture
  10518. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10519. */
  10520. export class DynamicTexture extends Texture {
  10521. private _generateMipMaps;
  10522. private _canvas;
  10523. private _context;
  10524. private _engine;
  10525. /**
  10526. * Creates a DynamicTexture
  10527. * @param name defines the name of the texture
  10528. * @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
  10529. * @param scene defines the scene where you want the texture
  10530. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10531. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10532. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10533. */
  10534. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10535. /**
  10536. * Get the current class name of the texture useful for serialization or dynamic coding.
  10537. * @returns "DynamicTexture"
  10538. */
  10539. getClassName(): string;
  10540. /**
  10541. * Gets the current state of canRescale
  10542. */
  10543. get canRescale(): boolean;
  10544. private _recreate;
  10545. /**
  10546. * Scales the texture
  10547. * @param ratio the scale factor to apply to both width and height
  10548. */
  10549. scale(ratio: number): void;
  10550. /**
  10551. * Resizes the texture
  10552. * @param width the new width
  10553. * @param height the new height
  10554. */
  10555. scaleTo(width: number, height: number): void;
  10556. /**
  10557. * Gets the context of the canvas used by the texture
  10558. * @returns the canvas context of the dynamic texture
  10559. */
  10560. getContext(): CanvasRenderingContext2D;
  10561. /**
  10562. * Clears the texture
  10563. */
  10564. clear(): void;
  10565. /**
  10566. * Updates the texture
  10567. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10568. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10569. */
  10570. update(invertY?: boolean, premulAlpha?: boolean): void;
  10571. /**
  10572. * Draws text onto the texture
  10573. * @param text defines the text to be drawn
  10574. * @param x defines the placement of the text from the left
  10575. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10576. * @param font defines the font to be used with font-style, font-size, font-name
  10577. * @param color defines the color used for the text
  10578. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10579. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10580. * @param update defines whether texture is immediately update (default is true)
  10581. */
  10582. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10583. /**
  10584. * Clones the texture
  10585. * @returns the clone of the texture.
  10586. */
  10587. clone(): DynamicTexture;
  10588. /**
  10589. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10590. * @returns a serialized dynamic texture object
  10591. */
  10592. serialize(): any;
  10593. /** @hidden */
  10594. _rebuild(): void;
  10595. }
  10596. }
  10597. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10598. import { Nullable } from "babylonjs/types";
  10599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10600. import { Scene } from "babylonjs/scene";
  10601. module "babylonjs/Engines/engine" {
  10602. interface Engine {
  10603. /**
  10604. * Creates a raw texture
  10605. * @param data defines the data to store in the texture
  10606. * @param width defines the width of the texture
  10607. * @param height defines the height of the texture
  10608. * @param format defines the format of the data
  10609. * @param generateMipMaps defines if the engine should generate the mip levels
  10610. * @param invertY defines if data must be stored with Y axis inverted
  10611. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10612. * @param compression defines the compression used (null by default)
  10613. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10614. * @returns the raw texture inside an InternalTexture
  10615. */
  10616. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10617. /**
  10618. * Update a raw texture
  10619. * @param texture defines the texture to update
  10620. * @param data defines the data to store in the texture
  10621. * @param format defines the format of the data
  10622. * @param invertY defines if data must be stored with Y axis inverted
  10623. */
  10624. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10625. /**
  10626. * Update a raw texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store in the texture
  10629. * @param format defines the format of the data
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. * @param compression defines the compression used (null by default)
  10632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10633. */
  10634. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10635. /**
  10636. * Creates a new raw cube texture
  10637. * @param data defines the array of data to use to create each face
  10638. * @param size defines the size of the textures
  10639. * @param format defines the format of the data
  10640. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10641. * @param generateMipMaps defines if the engine should generate the mip levels
  10642. * @param invertY defines if data must be stored with Y axis inverted
  10643. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10644. * @param compression defines the compression used (null by default)
  10645. * @returns the cube texture as an InternalTexture
  10646. */
  10647. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10648. /**
  10649. * Update a raw cube texture
  10650. * @param texture defines the texture to udpdate
  10651. * @param data defines the data to store
  10652. * @param format defines the data format
  10653. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10654. * @param invertY defines if data must be stored with Y axis inverted
  10655. */
  10656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10657. /**
  10658. * Update a raw cube texture
  10659. * @param texture defines the texture to udpdate
  10660. * @param data defines the data to store
  10661. * @param format defines the data format
  10662. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10663. * @param invertY defines if data must be stored with Y axis inverted
  10664. * @param compression defines the compression used (null by default)
  10665. */
  10666. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10667. /**
  10668. * Update a raw cube texture
  10669. * @param texture defines the texture to udpdate
  10670. * @param data defines the data to store
  10671. * @param format defines the data format
  10672. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10673. * @param invertY defines if data must be stored with Y axis inverted
  10674. * @param compression defines the compression used (null by default)
  10675. * @param level defines which level of the texture to update
  10676. */
  10677. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10678. /**
  10679. * Creates a new raw cube texture from a specified url
  10680. * @param url defines the url where the data is located
  10681. * @param scene defines the current scene
  10682. * @param size defines the size of the textures
  10683. * @param format defines the format of the data
  10684. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10685. * @param noMipmap defines if the engine should avoid generating the mip levels
  10686. * @param callback defines a callback used to extract texture data from loaded data
  10687. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10688. * @param onLoad defines a callback called when texture is loaded
  10689. * @param onError defines a callback called if there is an error
  10690. * @returns the cube texture as an InternalTexture
  10691. */
  10692. 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;
  10693. /**
  10694. * Creates a new raw cube texture from a specified url
  10695. * @param url defines the url where the data is located
  10696. * @param scene defines the current scene
  10697. * @param size defines the size of the textures
  10698. * @param format defines the format of the data
  10699. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10700. * @param noMipmap defines if the engine should avoid generating the mip levels
  10701. * @param callback defines a callback used to extract texture data from loaded data
  10702. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10703. * @param onLoad defines a callback called when texture is loaded
  10704. * @param onError defines a callback called if there is an error
  10705. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10706. * @param invertY defines if data must be stored with Y axis inverted
  10707. * @returns the cube texture as an InternalTexture
  10708. */
  10709. 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;
  10710. /**
  10711. * Creates a new raw 3D texture
  10712. * @param data defines the data used to create the texture
  10713. * @param width defines the width of the texture
  10714. * @param height defines the height of the texture
  10715. * @param depth defines the depth of the texture
  10716. * @param format defines the format of the texture
  10717. * @param generateMipMaps defines if the engine must generate mip levels
  10718. * @param invertY defines if data must be stored with Y axis inverted
  10719. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10720. * @param compression defines the compressed used (can be null)
  10721. * @param textureType defines the compressed used (can be null)
  10722. * @returns a new raw 3D texture (stored in an InternalTexture)
  10723. */
  10724. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10725. /**
  10726. * Update a raw 3D texture
  10727. * @param texture defines the texture to update
  10728. * @param data defines the data to store
  10729. * @param format defines the data format
  10730. * @param invertY defines if data must be stored with Y axis inverted
  10731. */
  10732. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10733. /**
  10734. * Update a raw 3D texture
  10735. * @param texture defines the texture to update
  10736. * @param data defines the data to store
  10737. * @param format defines the data format
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. * @param compression defines the used compression (can be null)
  10740. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10741. */
  10742. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10743. /**
  10744. * Creates a new raw 2D array texture
  10745. * @param data defines the data used to create the texture
  10746. * @param width defines the width of the texture
  10747. * @param height defines the height of the texture
  10748. * @param depth defines the number of layers of the texture
  10749. * @param format defines the format of the texture
  10750. * @param generateMipMaps defines if the engine must generate mip levels
  10751. * @param invertY defines if data must be stored with Y axis inverted
  10752. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10753. * @param compression defines the compressed used (can be null)
  10754. * @param textureType defines the compressed used (can be null)
  10755. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10756. */
  10757. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10758. /**
  10759. * Update a raw 2D array texture
  10760. * @param texture defines the texture to update
  10761. * @param data defines the data to store
  10762. * @param format defines the data format
  10763. * @param invertY defines if data must be stored with Y axis inverted
  10764. */
  10765. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10766. /**
  10767. * Update a raw 2D array texture
  10768. * @param texture defines the texture to update
  10769. * @param data defines the data to store
  10770. * @param format defines the data format
  10771. * @param invertY defines if data must be stored with Y axis inverted
  10772. * @param compression defines the used compression (can be null)
  10773. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10774. */
  10775. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10776. }
  10777. }
  10778. }
  10779. declare module "babylonjs/Materials/Textures/rawTexture" {
  10780. import { Scene } from "babylonjs/scene";
  10781. import { Texture } from "babylonjs/Materials/Textures/texture";
  10782. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10783. /**
  10784. * Raw texture can help creating a texture directly from an array of data.
  10785. * This can be super useful if you either get the data from an uncompressed source or
  10786. * if you wish to create your texture pixel by pixel.
  10787. */
  10788. export class RawTexture extends Texture {
  10789. /**
  10790. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10791. */
  10792. format: number;
  10793. private _engine;
  10794. /**
  10795. * Instantiates a new RawTexture.
  10796. * Raw texture can help creating a texture directly from an array of data.
  10797. * This can be super useful if you either get the data from an uncompressed source or
  10798. * if you wish to create your texture pixel by pixel.
  10799. * @param data define the array of data to use to create the texture
  10800. * @param width define the width of the texture
  10801. * @param height define the height of the texture
  10802. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10803. * @param scene define the scene the texture belongs to
  10804. * @param generateMipMaps define whether mip maps should be generated or not
  10805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10807. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10808. */
  10809. constructor(data: ArrayBufferView, width: number, height: number,
  10810. /**
  10811. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10812. */
  10813. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10814. /**
  10815. * Updates the texture underlying data.
  10816. * @param data Define the new data of the texture
  10817. */
  10818. update(data: ArrayBufferView): void;
  10819. /**
  10820. * Creates a luminance texture from some data.
  10821. * @param data Define the texture data
  10822. * @param width Define the width of the texture
  10823. * @param height Define the height of the texture
  10824. * @param scene Define the scene the texture belongs to
  10825. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10828. * @returns the luminance texture
  10829. */
  10830. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10831. /**
  10832. * Creates a luminance alpha texture from some data.
  10833. * @param data Define the texture data
  10834. * @param width Define the width of the texture
  10835. * @param height Define the height of the texture
  10836. * @param scene Define the scene the texture belongs to
  10837. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10840. * @returns the luminance alpha texture
  10841. */
  10842. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10843. /**
  10844. * Creates an alpha texture from some data.
  10845. * @param data Define the texture data
  10846. * @param width Define the width of the texture
  10847. * @param height Define the height of the texture
  10848. * @param scene Define the scene the texture belongs to
  10849. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10852. * @returns the alpha texture
  10853. */
  10854. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10855. /**
  10856. * Creates a RGB texture from some data.
  10857. * @param data Define the texture data
  10858. * @param width Define the width of the texture
  10859. * @param height Define the height of the texture
  10860. * @param scene Define the scene the texture belongs to
  10861. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10862. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10863. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10864. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10865. * @returns the RGB alpha texture
  10866. */
  10867. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10868. /**
  10869. * Creates a RGBA texture from some data.
  10870. * @param data Define the texture data
  10871. * @param width Define the width of the texture
  10872. * @param height Define the height of the texture
  10873. * @param scene Define the scene the texture belongs to
  10874. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10877. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10878. * @returns the RGBA texture
  10879. */
  10880. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10881. /**
  10882. * Creates a R texture from some data.
  10883. * @param data Define the texture data
  10884. * @param width Define the width of the texture
  10885. * @param height Define the height of the texture
  10886. * @param scene Define the scene the texture belongs to
  10887. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10888. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10889. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10890. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10891. * @returns the R texture
  10892. */
  10893. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10894. }
  10895. }
  10896. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10897. import { Scene } from "babylonjs/scene";
  10898. import { ISceneComponent } from "babylonjs/sceneComponent";
  10899. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10900. module "babylonjs/abstractScene" {
  10901. interface AbstractScene {
  10902. /**
  10903. * The list of procedural textures added to the scene
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10905. */
  10906. proceduralTextures: Array<ProceduralTexture>;
  10907. }
  10908. }
  10909. /**
  10910. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10911. * in a given scene.
  10912. */
  10913. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10914. /**
  10915. * The component name helpfull to identify the component in the list of scene components.
  10916. */
  10917. readonly name: string;
  10918. /**
  10919. * The scene the component belongs to.
  10920. */
  10921. scene: Scene;
  10922. /**
  10923. * Creates a new instance of the component for the given scene
  10924. * @param scene Defines the scene to register the component in
  10925. */
  10926. constructor(scene: Scene);
  10927. /**
  10928. * Registers the component in a given scene
  10929. */
  10930. register(): void;
  10931. /**
  10932. * Rebuilds the elements related to this component in case of
  10933. * context lost for instance.
  10934. */
  10935. rebuild(): void;
  10936. /**
  10937. * Disposes the component and the associated ressources.
  10938. */
  10939. dispose(): void;
  10940. private _beforeClear;
  10941. }
  10942. }
  10943. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10945. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10946. module "babylonjs/Engines/thinEngine" {
  10947. interface ThinEngine {
  10948. /**
  10949. * Creates a new render target cube texture
  10950. * @param size defines the size of the texture
  10951. * @param options defines the options used to create the texture
  10952. * @returns a new render target cube texture stored in an InternalTexture
  10953. */
  10954. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10955. }
  10956. }
  10957. }
  10958. declare module "babylonjs/Shaders/procedural.vertex" {
  10959. /** @hidden */
  10960. export var proceduralVertexShader: {
  10961. name: string;
  10962. shader: string;
  10963. };
  10964. }
  10965. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10966. import { Observable } from "babylonjs/Misc/observable";
  10967. import { Nullable } from "babylonjs/types";
  10968. import { Scene } from "babylonjs/scene";
  10969. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10970. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10971. import { Effect } from "babylonjs/Materials/effect";
  10972. import { Texture } from "babylonjs/Materials/Textures/texture";
  10973. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10974. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10975. import "babylonjs/Shaders/procedural.vertex";
  10976. /**
  10977. * 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.
  10978. * This is the base class of any Procedural texture and contains most of the shareable code.
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10980. */
  10981. export class ProceduralTexture extends Texture {
  10982. isCube: boolean;
  10983. /**
  10984. * Define if the texture is enabled or not (disabled texture will not render)
  10985. */
  10986. isEnabled: boolean;
  10987. /**
  10988. * Define if the texture must be cleared before rendering (default is true)
  10989. */
  10990. autoClear: boolean;
  10991. /**
  10992. * Callback called when the texture is generated
  10993. */
  10994. onGenerated: () => void;
  10995. /**
  10996. * Event raised when the texture is generated
  10997. */
  10998. onGeneratedObservable: Observable<ProceduralTexture>;
  10999. /** @hidden */
  11000. _generateMipMaps: boolean;
  11001. /** @hidden **/
  11002. _effect: Effect;
  11003. /** @hidden */
  11004. _textures: {
  11005. [key: string]: Texture;
  11006. };
  11007. private _size;
  11008. private _currentRefreshId;
  11009. private _frameId;
  11010. private _refreshRate;
  11011. private _vertexBuffers;
  11012. private _indexBuffer;
  11013. private _uniforms;
  11014. private _samplers;
  11015. private _fragment;
  11016. private _floats;
  11017. private _ints;
  11018. private _floatsArrays;
  11019. private _colors3;
  11020. private _colors4;
  11021. private _vectors2;
  11022. private _vectors3;
  11023. private _matrices;
  11024. private _fallbackTexture;
  11025. private _fallbackTextureUsed;
  11026. private _engine;
  11027. private _cachedDefines;
  11028. private _contentUpdateId;
  11029. private _contentData;
  11030. /**
  11031. * Instantiates a new procedural texture.
  11032. * 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.
  11033. * This is the base class of any Procedural texture and contains most of the shareable code.
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11035. * @param name Define the name of the texture
  11036. * @param size Define the size of the texture to create
  11037. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11038. * @param scene Define the scene the texture belongs to
  11039. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11040. * @param generateMipMaps Define if the texture should creates mip maps or not
  11041. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11042. */
  11043. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11044. /**
  11045. * The effect that is created when initializing the post process.
  11046. * @returns The created effect corresponding the the postprocess.
  11047. */
  11048. getEffect(): Effect;
  11049. /**
  11050. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11051. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11052. */
  11053. getContent(): Nullable<ArrayBufferView>;
  11054. private _createIndexBuffer;
  11055. /** @hidden */
  11056. _rebuild(): void;
  11057. /**
  11058. * Resets the texture in order to recreate its associated resources.
  11059. * This can be called in case of context loss
  11060. */
  11061. reset(): void;
  11062. protected _getDefines(): string;
  11063. /**
  11064. * Is the texture ready to be used ? (rendered at least once)
  11065. * @returns true if ready, otherwise, false.
  11066. */
  11067. isReady(): boolean;
  11068. /**
  11069. * Resets the refresh counter of the texture and start bak from scratch.
  11070. * Could be useful to regenerate the texture if it is setup to render only once.
  11071. */
  11072. resetRefreshCounter(): void;
  11073. /**
  11074. * Set the fragment shader to use in order to render the texture.
  11075. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11076. */
  11077. setFragment(fragment: any): void;
  11078. /**
  11079. * Define the refresh rate of the texture or the rendering frequency.
  11080. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11081. */
  11082. get refreshRate(): number;
  11083. set refreshRate(value: number);
  11084. /** @hidden */
  11085. _shouldRender(): boolean;
  11086. /**
  11087. * Get the size the texture is rendering at.
  11088. * @returns the size (texture is always squared)
  11089. */
  11090. getRenderSize(): number;
  11091. /**
  11092. * Resize the texture to new value.
  11093. * @param size Define the new size the texture should have
  11094. * @param generateMipMaps Define whether the new texture should create mip maps
  11095. */
  11096. resize(size: number, generateMipMaps: boolean): void;
  11097. private _checkUniform;
  11098. /**
  11099. * Set a texture in the shader program used to render.
  11100. * @param name Define the name of the uniform samplers as defined in the shader
  11101. * @param texture Define the texture to bind to this sampler
  11102. * @return the texture itself allowing "fluent" like uniform updates
  11103. */
  11104. setTexture(name: string, texture: Texture): ProceduralTexture;
  11105. /**
  11106. * Set a float in the shader.
  11107. * @param name Define the name of the uniform as defined in the shader
  11108. * @param value Define the value to give to the uniform
  11109. * @return the texture itself allowing "fluent" like uniform updates
  11110. */
  11111. setFloat(name: string, value: number): ProceduralTexture;
  11112. /**
  11113. * Set a int in the shader.
  11114. * @param name Define the name of the uniform as defined in the shader
  11115. * @param value Define the value to give to the uniform
  11116. * @return the texture itself allowing "fluent" like uniform updates
  11117. */
  11118. setInt(name: string, value: number): ProceduralTexture;
  11119. /**
  11120. * Set an array of floats in the shader.
  11121. * @param name Define the name of the uniform as defined in the shader
  11122. * @param value Define the value to give to the uniform
  11123. * @return the texture itself allowing "fluent" like uniform updates
  11124. */
  11125. setFloats(name: string, value: number[]): ProceduralTexture;
  11126. /**
  11127. * Set a vec3 in the shader from a Color3.
  11128. * @param name Define the name of the uniform as defined in the shader
  11129. * @param value Define the value to give to the uniform
  11130. * @return the texture itself allowing "fluent" like uniform updates
  11131. */
  11132. setColor3(name: string, value: Color3): ProceduralTexture;
  11133. /**
  11134. * Set a vec4 in the shader from a Color4.
  11135. * @param name Define the name of the uniform as defined in the shader
  11136. * @param value Define the value to give to the uniform
  11137. * @return the texture itself allowing "fluent" like uniform updates
  11138. */
  11139. setColor4(name: string, value: Color4): ProceduralTexture;
  11140. /**
  11141. * Set a vec2 in the shader from a Vector2.
  11142. * @param name Define the name of the uniform as defined in the shader
  11143. * @param value Define the value to give to the uniform
  11144. * @return the texture itself allowing "fluent" like uniform updates
  11145. */
  11146. setVector2(name: string, value: Vector2): ProceduralTexture;
  11147. /**
  11148. * Set a vec3 in the shader from a Vector3.
  11149. * @param name Define the name of the uniform as defined in the shader
  11150. * @param value Define the value to give to the uniform
  11151. * @return the texture itself allowing "fluent" like uniform updates
  11152. */
  11153. setVector3(name: string, value: Vector3): ProceduralTexture;
  11154. /**
  11155. * Set a mat4 in the shader from a MAtrix.
  11156. * @param name Define the name of the uniform as defined in the shader
  11157. * @param value Define the value to give to the uniform
  11158. * @return the texture itself allowing "fluent" like uniform updates
  11159. */
  11160. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11161. /**
  11162. * Render the texture to its associated render target.
  11163. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11164. */
  11165. render(useCameraPostProcess?: boolean): void;
  11166. /**
  11167. * Clone the texture.
  11168. * @returns the cloned texture
  11169. */
  11170. clone(): ProceduralTexture;
  11171. /**
  11172. * Dispose the texture and release its asoociated resources.
  11173. */
  11174. dispose(): void;
  11175. }
  11176. }
  11177. declare module "babylonjs/Particles/baseParticleSystem" {
  11178. import { Nullable } from "babylonjs/types";
  11179. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11181. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11182. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11183. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11184. import { Scene } from "babylonjs/scene";
  11185. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11186. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11187. import { Texture } from "babylonjs/Materials/Textures/texture";
  11188. import { Color4 } from "babylonjs/Maths/math.color";
  11189. import { Animation } from "babylonjs/Animations/animation";
  11190. /**
  11191. * This represents the base class for particle system in Babylon.
  11192. * 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.
  11193. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11194. * @example https://doc.babylonjs.com/babylon101/particles
  11195. */
  11196. export class BaseParticleSystem {
  11197. /**
  11198. * Source color is added to the destination color without alpha affecting the result
  11199. */
  11200. static BLENDMODE_ONEONE: number;
  11201. /**
  11202. * Blend current color and particle color using particle’s alpha
  11203. */
  11204. static BLENDMODE_STANDARD: number;
  11205. /**
  11206. * Add current color and particle color multiplied by particle’s alpha
  11207. */
  11208. static BLENDMODE_ADD: number;
  11209. /**
  11210. * Multiply current color with particle color
  11211. */
  11212. static BLENDMODE_MULTIPLY: number;
  11213. /**
  11214. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11215. */
  11216. static BLENDMODE_MULTIPLYADD: number;
  11217. /**
  11218. * List of animations used by the particle system.
  11219. */
  11220. animations: Animation[];
  11221. /**
  11222. * The id of the Particle system.
  11223. */
  11224. id: string;
  11225. /**
  11226. * The friendly name of the Particle system.
  11227. */
  11228. name: string;
  11229. /**
  11230. * The rendering group used by the Particle system to chose when to render.
  11231. */
  11232. renderingGroupId: number;
  11233. /**
  11234. * The emitter represents the Mesh or position we are attaching the particle system to.
  11235. */
  11236. emitter: Nullable<AbstractMesh | Vector3>;
  11237. /**
  11238. * The maximum number of particles to emit per frame
  11239. */
  11240. emitRate: number;
  11241. /**
  11242. * If you want to launch only a few particles at once, that can be done, as well.
  11243. */
  11244. manualEmitCount: number;
  11245. /**
  11246. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11247. */
  11248. updateSpeed: number;
  11249. /**
  11250. * The amount of time the particle system is running (depends of the overall update speed).
  11251. */
  11252. targetStopDuration: number;
  11253. /**
  11254. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11255. */
  11256. disposeOnStop: boolean;
  11257. /**
  11258. * Minimum power of emitting particles.
  11259. */
  11260. minEmitPower: number;
  11261. /**
  11262. * Maximum power of emitting particles.
  11263. */
  11264. maxEmitPower: number;
  11265. /**
  11266. * Minimum life time of emitting particles.
  11267. */
  11268. minLifeTime: number;
  11269. /**
  11270. * Maximum life time of emitting particles.
  11271. */
  11272. maxLifeTime: number;
  11273. /**
  11274. * Minimum Size of emitting particles.
  11275. */
  11276. minSize: number;
  11277. /**
  11278. * Maximum Size of emitting particles.
  11279. */
  11280. maxSize: number;
  11281. /**
  11282. * Minimum scale of emitting particles on X axis.
  11283. */
  11284. minScaleX: number;
  11285. /**
  11286. * Maximum scale of emitting particles on X axis.
  11287. */
  11288. maxScaleX: number;
  11289. /**
  11290. * Minimum scale of emitting particles on Y axis.
  11291. */
  11292. minScaleY: number;
  11293. /**
  11294. * Maximum scale of emitting particles on Y axis.
  11295. */
  11296. maxScaleY: number;
  11297. /**
  11298. * Gets or sets the minimal initial rotation in radians.
  11299. */
  11300. minInitialRotation: number;
  11301. /**
  11302. * Gets or sets the maximal initial rotation in radians.
  11303. */
  11304. maxInitialRotation: number;
  11305. /**
  11306. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11307. */
  11308. minAngularSpeed: number;
  11309. /**
  11310. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11311. */
  11312. maxAngularSpeed: number;
  11313. /**
  11314. * The texture used to render each particle. (this can be a spritesheet)
  11315. */
  11316. particleTexture: Nullable<Texture>;
  11317. /**
  11318. * The layer mask we are rendering the particles through.
  11319. */
  11320. layerMask: number;
  11321. /**
  11322. * This can help using your own shader to render the particle system.
  11323. * The according effect will be created
  11324. */
  11325. customShader: any;
  11326. /**
  11327. * By default particle system starts as soon as they are created. This prevents the
  11328. * automatic start to happen and let you decide when to start emitting particles.
  11329. */
  11330. preventAutoStart: boolean;
  11331. private _noiseTexture;
  11332. /**
  11333. * Gets or sets a texture used to add random noise to particle positions
  11334. */
  11335. get noiseTexture(): Nullable<ProceduralTexture>;
  11336. set noiseTexture(value: Nullable<ProceduralTexture>);
  11337. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11338. noiseStrength: Vector3;
  11339. /**
  11340. * Callback triggered when the particle animation is ending.
  11341. */
  11342. onAnimationEnd: Nullable<() => void>;
  11343. /**
  11344. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11345. */
  11346. blendMode: number;
  11347. /**
  11348. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11349. * to override the particles.
  11350. */
  11351. forceDepthWrite: boolean;
  11352. /** 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 */
  11353. preWarmCycles: number;
  11354. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11355. preWarmStepOffset: number;
  11356. /**
  11357. * 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)
  11358. */
  11359. spriteCellChangeSpeed: number;
  11360. /**
  11361. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11362. */
  11363. startSpriteCellID: number;
  11364. /**
  11365. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11366. */
  11367. endSpriteCellID: number;
  11368. /**
  11369. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11370. */
  11371. spriteCellWidth: number;
  11372. /**
  11373. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11374. */
  11375. spriteCellHeight: number;
  11376. /**
  11377. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11378. */
  11379. spriteRandomStartCell: boolean;
  11380. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11381. translationPivot: Vector2;
  11382. /** @hidden */
  11383. protected _isAnimationSheetEnabled: boolean;
  11384. /**
  11385. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11386. */
  11387. beginAnimationOnStart: boolean;
  11388. /**
  11389. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11390. */
  11391. beginAnimationFrom: number;
  11392. /**
  11393. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11394. */
  11395. beginAnimationTo: number;
  11396. /**
  11397. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11398. */
  11399. beginAnimationLoop: boolean;
  11400. /**
  11401. * Gets or sets a world offset applied to all particles
  11402. */
  11403. worldOffset: Vector3;
  11404. /**
  11405. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11406. */
  11407. get isAnimationSheetEnabled(): boolean;
  11408. set isAnimationSheetEnabled(value: boolean);
  11409. /**
  11410. * Get hosting scene
  11411. * @returns the scene
  11412. */
  11413. getScene(): Scene;
  11414. /**
  11415. * You can use gravity if you want to give an orientation to your particles.
  11416. */
  11417. gravity: Vector3;
  11418. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11419. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11420. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11421. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11422. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11423. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11424. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11425. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11426. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11427. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11428. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11429. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11430. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11431. /**
  11432. * Defines the delay in milliseconds before starting the system (0 by default)
  11433. */
  11434. startDelay: number;
  11435. /**
  11436. * Gets the current list of drag gradients.
  11437. * You must use addDragGradient and removeDragGradient to udpate this list
  11438. * @returns the list of drag gradients
  11439. */
  11440. getDragGradients(): Nullable<Array<FactorGradient>>;
  11441. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11442. limitVelocityDamping: number;
  11443. /**
  11444. * Gets the current list of limit velocity gradients.
  11445. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11446. * @returns the list of limit velocity gradients
  11447. */
  11448. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11449. /**
  11450. * Gets the current list of color gradients.
  11451. * You must use addColorGradient and removeColorGradient to udpate this list
  11452. * @returns the list of color gradients
  11453. */
  11454. getColorGradients(): Nullable<Array<ColorGradient>>;
  11455. /**
  11456. * Gets the current list of size gradients.
  11457. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11458. * @returns the list of size gradients
  11459. */
  11460. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11461. /**
  11462. * Gets the current list of color remap gradients.
  11463. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11464. * @returns the list of color remap gradients
  11465. */
  11466. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11467. /**
  11468. * Gets the current list of alpha remap gradients.
  11469. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11470. * @returns the list of alpha remap gradients
  11471. */
  11472. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11473. /**
  11474. * Gets the current list of life time gradients.
  11475. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11476. * @returns the list of life time gradients
  11477. */
  11478. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11479. /**
  11480. * Gets the current list of angular speed gradients.
  11481. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11482. * @returns the list of angular speed gradients
  11483. */
  11484. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11485. /**
  11486. * Gets the current list of velocity gradients.
  11487. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11488. * @returns the list of velocity gradients
  11489. */
  11490. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11491. /**
  11492. * Gets the current list of start size gradients.
  11493. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11494. * @returns the list of start size gradients
  11495. */
  11496. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11497. /**
  11498. * Gets the current list of emit rate gradients.
  11499. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11500. * @returns the list of emit rate gradients
  11501. */
  11502. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11503. /**
  11504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11505. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11506. */
  11507. get direction1(): Vector3;
  11508. set direction1(value: Vector3);
  11509. /**
  11510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11511. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11512. */
  11513. get direction2(): Vector3;
  11514. set direction2(value: Vector3);
  11515. /**
  11516. * 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.
  11517. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11518. */
  11519. get minEmitBox(): Vector3;
  11520. set minEmitBox(value: Vector3);
  11521. /**
  11522. * 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.
  11523. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11524. */
  11525. get maxEmitBox(): Vector3;
  11526. set maxEmitBox(value: Vector3);
  11527. /**
  11528. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11529. */
  11530. color1: Color4;
  11531. /**
  11532. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11533. */
  11534. color2: Color4;
  11535. /**
  11536. * Color the particle will have at the end of its lifetime
  11537. */
  11538. colorDead: Color4;
  11539. /**
  11540. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11541. */
  11542. textureMask: Color4;
  11543. /**
  11544. * The particle emitter type defines the emitter used by the particle system.
  11545. * It can be for example box, sphere, or cone...
  11546. */
  11547. particleEmitterType: IParticleEmitterType;
  11548. /** @hidden */
  11549. _isSubEmitter: boolean;
  11550. /**
  11551. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11552. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11553. */
  11554. billboardMode: number;
  11555. protected _isBillboardBased: boolean;
  11556. /**
  11557. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11558. */
  11559. get isBillboardBased(): boolean;
  11560. set isBillboardBased(value: boolean);
  11561. /**
  11562. * The scene the particle system belongs to.
  11563. */
  11564. protected _scene: Scene;
  11565. /**
  11566. * Local cache of defines for image processing.
  11567. */
  11568. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11569. /**
  11570. * Default configuration related to image processing available in the standard Material.
  11571. */
  11572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11573. /**
  11574. * Gets the image processing configuration used either in this material.
  11575. */
  11576. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11577. /**
  11578. * Sets the Default image processing configuration used either in the this material.
  11579. *
  11580. * If sets to null, the scene one is in use.
  11581. */
  11582. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11583. /**
  11584. * Attaches a new image processing configuration to the Standard Material.
  11585. * @param configuration
  11586. */
  11587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11588. /** @hidden */
  11589. protected _reset(): void;
  11590. /** @hidden */
  11591. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11592. /**
  11593. * Instantiates a particle system.
  11594. * 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.
  11595. * @param name The name of the particle system
  11596. */
  11597. constructor(name: string);
  11598. /**
  11599. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11602. * @returns the emitter
  11603. */
  11604. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11605. /**
  11606. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11607. * @param radius The radius of the hemisphere to emit from
  11608. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11609. * @returns the emitter
  11610. */
  11611. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11612. /**
  11613. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11614. * @param radius The radius of the sphere to emit from
  11615. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11616. * @returns the emitter
  11617. */
  11618. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11619. /**
  11620. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11621. * @param radius The radius of the sphere to emit from
  11622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11624. * @returns the emitter
  11625. */
  11626. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11627. /**
  11628. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11629. * @param radius The radius of the emission cylinder
  11630. * @param height The height of the emission cylinder
  11631. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11632. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11633. * @returns the emitter
  11634. */
  11635. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11636. /**
  11637. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11638. * @param radius The radius of the cylinder to emit from
  11639. * @param height The height of the emission cylinder
  11640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11643. * @returns the emitter
  11644. */
  11645. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11646. /**
  11647. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11648. * @param radius The radius of the cone to emit from
  11649. * @param angle The base angle of the cone
  11650. * @returns the emitter
  11651. */
  11652. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11653. /**
  11654. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11657. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11658. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11659. * @returns the emitter
  11660. */
  11661. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11662. }
  11663. }
  11664. declare module "babylonjs/Particles/subEmitter" {
  11665. import { Scene } from "babylonjs/scene";
  11666. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11667. /**
  11668. * Type of sub emitter
  11669. */
  11670. export enum SubEmitterType {
  11671. /**
  11672. * Attached to the particle over it's lifetime
  11673. */
  11674. ATTACHED = 0,
  11675. /**
  11676. * Created when the particle dies
  11677. */
  11678. END = 1
  11679. }
  11680. /**
  11681. * Sub emitter class used to emit particles from an existing particle
  11682. */
  11683. export class SubEmitter {
  11684. /**
  11685. * the particle system to be used by the sub emitter
  11686. */
  11687. particleSystem: ParticleSystem;
  11688. /**
  11689. * Type of the submitter (Default: END)
  11690. */
  11691. type: SubEmitterType;
  11692. /**
  11693. * 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)
  11694. * Note: This only is supported when using an emitter of type Mesh
  11695. */
  11696. inheritDirection: boolean;
  11697. /**
  11698. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11699. */
  11700. inheritedVelocityAmount: number;
  11701. /**
  11702. * Creates a sub emitter
  11703. * @param particleSystem the particle system to be used by the sub emitter
  11704. */
  11705. constructor(
  11706. /**
  11707. * the particle system to be used by the sub emitter
  11708. */
  11709. particleSystem: ParticleSystem);
  11710. /**
  11711. * Clones the sub emitter
  11712. * @returns the cloned sub emitter
  11713. */
  11714. clone(): SubEmitter;
  11715. /**
  11716. * Serialize current object to a JSON object
  11717. * @returns the serialized object
  11718. */
  11719. serialize(): any;
  11720. /** @hidden */
  11721. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11722. /**
  11723. * Creates a new SubEmitter from a serialized JSON version
  11724. * @param serializationObject defines the JSON object to read from
  11725. * @param scene defines the hosting scene
  11726. * @param rootUrl defines the rootUrl for data loading
  11727. * @returns a new SubEmitter
  11728. */
  11729. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11730. /** Release associated resources */
  11731. dispose(): void;
  11732. }
  11733. }
  11734. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11735. /** @hidden */
  11736. export var imageProcessingDeclaration: {
  11737. name: string;
  11738. shader: string;
  11739. };
  11740. }
  11741. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11742. /** @hidden */
  11743. export var imageProcessingFunctions: {
  11744. name: string;
  11745. shader: string;
  11746. };
  11747. }
  11748. declare module "babylonjs/Shaders/particles.fragment" {
  11749. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11750. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11751. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11752. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11753. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11754. /** @hidden */
  11755. export var particlesPixelShader: {
  11756. name: string;
  11757. shader: string;
  11758. };
  11759. }
  11760. declare module "babylonjs/Shaders/particles.vertex" {
  11761. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11762. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11763. /** @hidden */
  11764. export var particlesVertexShader: {
  11765. name: string;
  11766. shader: string;
  11767. };
  11768. }
  11769. declare module "babylonjs/Particles/particleSystem" {
  11770. import { Nullable } from "babylonjs/types";
  11771. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11772. import { Observable } from "babylonjs/Misc/observable";
  11773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11774. import { Effect } from "babylonjs/Materials/effect";
  11775. import { Scene, IDisposable } from "babylonjs/scene";
  11776. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11777. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11778. import { Particle } from "babylonjs/Particles/particle";
  11779. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11780. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11781. import "babylonjs/Shaders/particles.fragment";
  11782. import "babylonjs/Shaders/particles.vertex";
  11783. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11784. /**
  11785. * This represents a particle system in Babylon.
  11786. * 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.
  11787. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11788. * @example https://doc.babylonjs.com/babylon101/particles
  11789. */
  11790. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11791. /**
  11792. * Billboard mode will only apply to Y axis
  11793. */
  11794. static readonly BILLBOARDMODE_Y: number;
  11795. /**
  11796. * Billboard mode will apply to all axes
  11797. */
  11798. static readonly BILLBOARDMODE_ALL: number;
  11799. /**
  11800. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11801. */
  11802. static readonly BILLBOARDMODE_STRETCHED: number;
  11803. /**
  11804. * This function can be defined to provide custom update for active particles.
  11805. * This function will be called instead of regular update (age, position, color, etc.).
  11806. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11807. */
  11808. updateFunction: (particles: Particle[]) => void;
  11809. private _emitterWorldMatrix;
  11810. /**
  11811. * This function can be defined to specify initial direction for every new particle.
  11812. * It by default use the emitterType defined function
  11813. */
  11814. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11815. /**
  11816. * This function can be defined to specify initial position for every new particle.
  11817. * It by default use the emitterType defined function
  11818. */
  11819. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11820. /**
  11821. * @hidden
  11822. */
  11823. _inheritedVelocityOffset: Vector3;
  11824. /**
  11825. * An event triggered when the system is disposed
  11826. */
  11827. onDisposeObservable: Observable<ParticleSystem>;
  11828. private _onDisposeObserver;
  11829. /**
  11830. * Sets a callback that will be triggered when the system is disposed
  11831. */
  11832. set onDispose(callback: () => void);
  11833. private _particles;
  11834. private _epsilon;
  11835. private _capacity;
  11836. private _stockParticles;
  11837. private _newPartsExcess;
  11838. private _vertexData;
  11839. private _vertexBuffer;
  11840. private _vertexBuffers;
  11841. private _spriteBuffer;
  11842. private _indexBuffer;
  11843. private _effect;
  11844. private _customEffect;
  11845. private _cachedDefines;
  11846. private _scaledColorStep;
  11847. private _colorDiff;
  11848. private _scaledDirection;
  11849. private _scaledGravity;
  11850. private _currentRenderId;
  11851. private _alive;
  11852. private _useInstancing;
  11853. private _started;
  11854. private _stopped;
  11855. private _actualFrame;
  11856. private _scaledUpdateSpeed;
  11857. private _vertexBufferSize;
  11858. /** @hidden */
  11859. _currentEmitRateGradient: Nullable<FactorGradient>;
  11860. /** @hidden */
  11861. _currentEmitRate1: number;
  11862. /** @hidden */
  11863. _currentEmitRate2: number;
  11864. /** @hidden */
  11865. _currentStartSizeGradient: Nullable<FactorGradient>;
  11866. /** @hidden */
  11867. _currentStartSize1: number;
  11868. /** @hidden */
  11869. _currentStartSize2: number;
  11870. private readonly _rawTextureWidth;
  11871. private _rampGradientsTexture;
  11872. private _useRampGradients;
  11873. /** Gets or sets a boolean indicating that ramp gradients must be used
  11874. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11875. */
  11876. get useRampGradients(): boolean;
  11877. set useRampGradients(value: boolean);
  11878. /**
  11879. * 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.
  11880. * 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: [])
  11881. */
  11882. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11883. private _subEmitters;
  11884. /**
  11885. * @hidden
  11886. * If the particle systems emitter should be disposed when the particle system is disposed
  11887. */
  11888. _disposeEmitterOnDispose: boolean;
  11889. /**
  11890. * The current active Sub-systems, this property is used by the root particle system only.
  11891. */
  11892. activeSubSystems: Array<ParticleSystem>;
  11893. /**
  11894. * Specifies if the particles are updated in emitter local space or world space
  11895. */
  11896. isLocal: boolean;
  11897. private _rootParticleSystem;
  11898. /**
  11899. * Gets the current list of active particles
  11900. */
  11901. get particles(): Particle[];
  11902. /**
  11903. * Returns the string "ParticleSystem"
  11904. * @returns a string containing the class name
  11905. */
  11906. getClassName(): string;
  11907. /**
  11908. * Instantiates a particle system.
  11909. * 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.
  11910. * @param name The name of the particle system
  11911. * @param capacity The max number of particles alive at the same time
  11912. * @param scene The scene the particle system belongs to
  11913. * @param customEffect a custom effect used to change the way particles are rendered by default
  11914. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11915. * @param epsilon Offset used to render the particles
  11916. */
  11917. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11918. private _addFactorGradient;
  11919. private _removeFactorGradient;
  11920. /**
  11921. * Adds a new life time gradient
  11922. * @param gradient defines the gradient to use (between 0 and 1)
  11923. * @param factor defines the life time factor to affect to the specified gradient
  11924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11925. * @returns the current particle system
  11926. */
  11927. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11928. /**
  11929. * Remove a specific life time gradient
  11930. * @param gradient defines the gradient to remove
  11931. * @returns the current particle system
  11932. */
  11933. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11934. /**
  11935. * Adds a new size gradient
  11936. * @param gradient defines the gradient to use (between 0 and 1)
  11937. * @param factor defines the size factor to affect to the specified gradient
  11938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11939. * @returns the current particle system
  11940. */
  11941. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11942. /**
  11943. * Remove a specific size gradient
  11944. * @param gradient defines the gradient to remove
  11945. * @returns the current particle system
  11946. */
  11947. removeSizeGradient(gradient: number): IParticleSystem;
  11948. /**
  11949. * Adds a new color remap gradient
  11950. * @param gradient defines the gradient to use (between 0 and 1)
  11951. * @param min defines the color remap minimal range
  11952. * @param max defines the color remap maximal range
  11953. * @returns the current particle system
  11954. */
  11955. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11956. /**
  11957. * Remove a specific color remap gradient
  11958. * @param gradient defines the gradient to remove
  11959. * @returns the current particle system
  11960. */
  11961. removeColorRemapGradient(gradient: number): IParticleSystem;
  11962. /**
  11963. * Adds a new alpha remap gradient
  11964. * @param gradient defines the gradient to use (between 0 and 1)
  11965. * @param min defines the alpha remap minimal range
  11966. * @param max defines the alpha remap maximal range
  11967. * @returns the current particle system
  11968. */
  11969. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11970. /**
  11971. * Remove a specific alpha remap gradient
  11972. * @param gradient defines the gradient to remove
  11973. * @returns the current particle system
  11974. */
  11975. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11976. /**
  11977. * Adds a new angular speed gradient
  11978. * @param gradient defines the gradient to use (between 0 and 1)
  11979. * @param factor defines the angular speed to affect to the specified gradient
  11980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11981. * @returns the current particle system
  11982. */
  11983. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11984. /**
  11985. * Remove a specific angular speed gradient
  11986. * @param gradient defines the gradient to remove
  11987. * @returns the current particle system
  11988. */
  11989. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11990. /**
  11991. * Adds a new velocity gradient
  11992. * @param gradient defines the gradient to use (between 0 and 1)
  11993. * @param factor defines the velocity to affect to the specified gradient
  11994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11995. * @returns the current particle system
  11996. */
  11997. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11998. /**
  11999. * Remove a specific velocity gradient
  12000. * @param gradient defines the gradient to remove
  12001. * @returns the current particle system
  12002. */
  12003. removeVelocityGradient(gradient: number): IParticleSystem;
  12004. /**
  12005. * Adds a new limit velocity gradient
  12006. * @param gradient defines the gradient to use (between 0 and 1)
  12007. * @param factor defines the limit velocity value to affect to the specified gradient
  12008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12009. * @returns the current particle system
  12010. */
  12011. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12012. /**
  12013. * Remove a specific limit velocity gradient
  12014. * @param gradient defines the gradient to remove
  12015. * @returns the current particle system
  12016. */
  12017. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12018. /**
  12019. * Adds a new drag gradient
  12020. * @param gradient defines the gradient to use (between 0 and 1)
  12021. * @param factor defines the drag value to affect to the specified gradient
  12022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12023. * @returns the current particle system
  12024. */
  12025. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12026. /**
  12027. * Remove a specific drag gradient
  12028. * @param gradient defines the gradient to remove
  12029. * @returns the current particle system
  12030. */
  12031. removeDragGradient(gradient: number): IParticleSystem;
  12032. /**
  12033. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12034. * @param gradient defines the gradient to use (between 0 and 1)
  12035. * @param factor defines the emit rate value to affect to the specified gradient
  12036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12037. * @returns the current particle system
  12038. */
  12039. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12040. /**
  12041. * Remove a specific emit rate gradient
  12042. * @param gradient defines the gradient to remove
  12043. * @returns the current particle system
  12044. */
  12045. removeEmitRateGradient(gradient: number): IParticleSystem;
  12046. /**
  12047. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12048. * @param gradient defines the gradient to use (between 0 and 1)
  12049. * @param factor defines the start size value to affect to the specified gradient
  12050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12051. * @returns the current particle system
  12052. */
  12053. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12054. /**
  12055. * Remove a specific start size gradient
  12056. * @param gradient defines the gradient to remove
  12057. * @returns the current particle system
  12058. */
  12059. removeStartSizeGradient(gradient: number): IParticleSystem;
  12060. private _createRampGradientTexture;
  12061. /**
  12062. * Gets the current list of ramp gradients.
  12063. * You must use addRampGradient and removeRampGradient to udpate this list
  12064. * @returns the list of ramp gradients
  12065. */
  12066. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12067. /**
  12068. * Adds a new ramp gradient used to remap particle colors
  12069. * @param gradient defines the gradient to use (between 0 and 1)
  12070. * @param color defines the color to affect to the specified gradient
  12071. * @returns the current particle system
  12072. */
  12073. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12074. /**
  12075. * Remove a specific ramp gradient
  12076. * @param gradient defines the gradient to remove
  12077. * @returns the current particle system
  12078. */
  12079. removeRampGradient(gradient: number): ParticleSystem;
  12080. /**
  12081. * Adds a new color gradient
  12082. * @param gradient defines the gradient to use (between 0 and 1)
  12083. * @param color1 defines the color to affect to the specified gradient
  12084. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12085. * @returns this particle system
  12086. */
  12087. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12088. /**
  12089. * Remove a specific color gradient
  12090. * @param gradient defines the gradient to remove
  12091. * @returns this particle system
  12092. */
  12093. removeColorGradient(gradient: number): IParticleSystem;
  12094. private _fetchR;
  12095. protected _reset(): void;
  12096. private _resetEffect;
  12097. private _createVertexBuffers;
  12098. private _createIndexBuffer;
  12099. /**
  12100. * Gets the maximum number of particles active at the same time.
  12101. * @returns The max number of active particles.
  12102. */
  12103. getCapacity(): number;
  12104. /**
  12105. * Gets whether there are still active particles in the system.
  12106. * @returns True if it is alive, otherwise false.
  12107. */
  12108. isAlive(): boolean;
  12109. /**
  12110. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12111. * @returns True if it has been started, otherwise false.
  12112. */
  12113. isStarted(): boolean;
  12114. private _prepareSubEmitterInternalArray;
  12115. /**
  12116. * Starts the particle system and begins to emit
  12117. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12118. */
  12119. start(delay?: number): void;
  12120. /**
  12121. * Stops the particle system.
  12122. * @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.
  12123. */
  12124. stop(stopSubEmitters?: boolean): void;
  12125. /**
  12126. * Remove all active particles
  12127. */
  12128. reset(): void;
  12129. /**
  12130. * @hidden (for internal use only)
  12131. */
  12132. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12133. /**
  12134. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12135. * Its lifetime will start back at 0.
  12136. */
  12137. recycleParticle: (particle: Particle) => void;
  12138. private _stopSubEmitters;
  12139. private _createParticle;
  12140. private _removeFromRoot;
  12141. private _emitFromParticle;
  12142. private _update;
  12143. /** @hidden */
  12144. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12145. /** @hidden */
  12146. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12147. /** @hidden */
  12148. private _getEffect;
  12149. /**
  12150. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12151. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12152. */
  12153. animate(preWarmOnly?: boolean): void;
  12154. private _appendParticleVertices;
  12155. /**
  12156. * Rebuilds the particle system.
  12157. */
  12158. rebuild(): void;
  12159. /**
  12160. * Is this system ready to be used/rendered
  12161. * @return true if the system is ready
  12162. */
  12163. isReady(): boolean;
  12164. private _render;
  12165. /**
  12166. * Renders the particle system in its current state.
  12167. * @returns the current number of particles
  12168. */
  12169. render(): number;
  12170. /**
  12171. * Disposes the particle system and free the associated resources
  12172. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12173. */
  12174. dispose(disposeTexture?: boolean): void;
  12175. /**
  12176. * Clones the particle system.
  12177. * @param name The name of the cloned object
  12178. * @param newEmitter The new emitter to use
  12179. * @returns the cloned particle system
  12180. */
  12181. clone(name: string, newEmitter: any): ParticleSystem;
  12182. /**
  12183. * Serializes the particle system to a JSON object.
  12184. * @returns the JSON object
  12185. */
  12186. serialize(): any;
  12187. /** @hidden */
  12188. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12189. /** @hidden */
  12190. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12191. /**
  12192. * Parses a JSON object to create a particle system.
  12193. * @param parsedParticleSystem The JSON object to parse
  12194. * @param scene The scene to create the particle system in
  12195. * @param rootUrl The root url to use to load external dependencies like texture
  12196. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12197. * @returns the Parsed particle system
  12198. */
  12199. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12200. }
  12201. }
  12202. declare module "babylonjs/Particles/particle" {
  12203. import { Nullable } from "babylonjs/types";
  12204. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12205. import { Color4 } from "babylonjs/Maths/math.color";
  12206. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12207. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12208. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12209. /**
  12210. * A particle represents one of the element emitted by a particle system.
  12211. * This is mainly define by its coordinates, direction, velocity and age.
  12212. */
  12213. export class Particle {
  12214. /**
  12215. * The particle system the particle belongs to.
  12216. */
  12217. particleSystem: ParticleSystem;
  12218. private static _Count;
  12219. /**
  12220. * Unique ID of the particle
  12221. */
  12222. id: number;
  12223. /**
  12224. * The world position of the particle in the scene.
  12225. */
  12226. position: Vector3;
  12227. /**
  12228. * The world direction of the particle in the scene.
  12229. */
  12230. direction: Vector3;
  12231. /**
  12232. * The color of the particle.
  12233. */
  12234. color: Color4;
  12235. /**
  12236. * The color change of the particle per step.
  12237. */
  12238. colorStep: Color4;
  12239. /**
  12240. * Defines how long will the life of the particle be.
  12241. */
  12242. lifeTime: number;
  12243. /**
  12244. * The current age of the particle.
  12245. */
  12246. age: number;
  12247. /**
  12248. * The current size of the particle.
  12249. */
  12250. size: number;
  12251. /**
  12252. * The current scale of the particle.
  12253. */
  12254. scale: Vector2;
  12255. /**
  12256. * The current angle of the particle.
  12257. */
  12258. angle: number;
  12259. /**
  12260. * Defines how fast is the angle changing.
  12261. */
  12262. angularSpeed: number;
  12263. /**
  12264. * Defines the cell index used by the particle to be rendered from a sprite.
  12265. */
  12266. cellIndex: number;
  12267. /**
  12268. * The information required to support color remapping
  12269. */
  12270. remapData: Vector4;
  12271. /** @hidden */
  12272. _randomCellOffset?: number;
  12273. /** @hidden */
  12274. _initialDirection: Nullable<Vector3>;
  12275. /** @hidden */
  12276. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12277. /** @hidden */
  12278. _initialStartSpriteCellID: number;
  12279. /** @hidden */
  12280. _initialEndSpriteCellID: number;
  12281. /** @hidden */
  12282. _currentColorGradient: Nullable<ColorGradient>;
  12283. /** @hidden */
  12284. _currentColor1: Color4;
  12285. /** @hidden */
  12286. _currentColor2: Color4;
  12287. /** @hidden */
  12288. _currentSizeGradient: Nullable<FactorGradient>;
  12289. /** @hidden */
  12290. _currentSize1: number;
  12291. /** @hidden */
  12292. _currentSize2: number;
  12293. /** @hidden */
  12294. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12295. /** @hidden */
  12296. _currentAngularSpeed1: number;
  12297. /** @hidden */
  12298. _currentAngularSpeed2: number;
  12299. /** @hidden */
  12300. _currentVelocityGradient: Nullable<FactorGradient>;
  12301. /** @hidden */
  12302. _currentVelocity1: number;
  12303. /** @hidden */
  12304. _currentVelocity2: number;
  12305. /** @hidden */
  12306. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12307. /** @hidden */
  12308. _currentLimitVelocity1: number;
  12309. /** @hidden */
  12310. _currentLimitVelocity2: number;
  12311. /** @hidden */
  12312. _currentDragGradient: Nullable<FactorGradient>;
  12313. /** @hidden */
  12314. _currentDrag1: number;
  12315. /** @hidden */
  12316. _currentDrag2: number;
  12317. /** @hidden */
  12318. _randomNoiseCoordinates1: Vector3;
  12319. /** @hidden */
  12320. _randomNoiseCoordinates2: Vector3;
  12321. /** @hidden */
  12322. _localPosition?: Vector3;
  12323. /**
  12324. * Creates a new instance Particle
  12325. * @param particleSystem the particle system the particle belongs to
  12326. */
  12327. constructor(
  12328. /**
  12329. * The particle system the particle belongs to.
  12330. */
  12331. particleSystem: ParticleSystem);
  12332. private updateCellInfoFromSystem;
  12333. /**
  12334. * Defines how the sprite cell index is updated for the particle
  12335. */
  12336. updateCellIndex(): void;
  12337. /** @hidden */
  12338. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12339. /** @hidden */
  12340. _inheritParticleInfoToSubEmitters(): void;
  12341. /** @hidden */
  12342. _reset(): void;
  12343. /**
  12344. * Copy the properties of particle to another one.
  12345. * @param other the particle to copy the information to.
  12346. */
  12347. copyTo(other: Particle): void;
  12348. }
  12349. }
  12350. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12351. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12352. import { Effect } from "babylonjs/Materials/effect";
  12353. import { Particle } from "babylonjs/Particles/particle";
  12354. import { Scene } from "babylonjs/scene";
  12355. /**
  12356. * Particle emitter represents a volume emitting particles.
  12357. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12358. */
  12359. export interface IParticleEmitterType {
  12360. /**
  12361. * Called by the particle System when the direction is computed for the created particle.
  12362. * @param worldMatrix is the world matrix of the particle system
  12363. * @param directionToUpdate is the direction vector to update with the result
  12364. * @param particle is the particle we are computed the direction for
  12365. * @param isLocal defines if the direction should be set in local space
  12366. */
  12367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12368. /**
  12369. * Called by the particle System when the position is computed for the created particle.
  12370. * @param worldMatrix is the world matrix of the particle system
  12371. * @param positionToUpdate is the position vector to update with the result
  12372. * @param particle is the particle we are computed the position for
  12373. * @param isLocal defines if the position should be set in local space
  12374. */
  12375. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12376. /**
  12377. * Clones the current emitter and returns a copy of it
  12378. * @returns the new emitter
  12379. */
  12380. clone(): IParticleEmitterType;
  12381. /**
  12382. * Called by the GPUParticleSystem to setup the update shader
  12383. * @param effect defines the update shader
  12384. */
  12385. applyToShader(effect: Effect): void;
  12386. /**
  12387. * Returns a string to use to update the GPU particles update shader
  12388. * @returns the effect defines string
  12389. */
  12390. getEffectDefines(): string;
  12391. /**
  12392. * Returns a string representing the class name
  12393. * @returns a string containing the class name
  12394. */
  12395. getClassName(): string;
  12396. /**
  12397. * Serializes the particle system to a JSON object.
  12398. * @returns the JSON object
  12399. */
  12400. serialize(): any;
  12401. /**
  12402. * Parse properties from a JSON object
  12403. * @param serializationObject defines the JSON object
  12404. * @param scene defines the hosting scene
  12405. */
  12406. parse(serializationObject: any, scene: Scene): void;
  12407. }
  12408. }
  12409. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12410. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12411. import { Effect } from "babylonjs/Materials/effect";
  12412. import { Particle } from "babylonjs/Particles/particle";
  12413. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12414. /**
  12415. * Particle emitter emitting particles from the inside of a box.
  12416. * It emits the particles randomly between 2 given directions.
  12417. */
  12418. export class BoxParticleEmitter implements IParticleEmitterType {
  12419. /**
  12420. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12421. */
  12422. direction1: Vector3;
  12423. /**
  12424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12425. */
  12426. direction2: Vector3;
  12427. /**
  12428. * 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.
  12429. */
  12430. minEmitBox: Vector3;
  12431. /**
  12432. * 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.
  12433. */
  12434. maxEmitBox: Vector3;
  12435. /**
  12436. * Creates a new instance BoxParticleEmitter
  12437. */
  12438. constructor();
  12439. /**
  12440. * Called by the particle System when the direction is computed for the created particle.
  12441. * @param worldMatrix is the world matrix of the particle system
  12442. * @param directionToUpdate is the direction vector to update with the result
  12443. * @param particle is the particle we are computed the direction for
  12444. * @param isLocal defines if the direction should be set in local space
  12445. */
  12446. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12447. /**
  12448. * Called by the particle System when the position is computed for the created particle.
  12449. * @param worldMatrix is the world matrix of the particle system
  12450. * @param positionToUpdate is the position vector to update with the result
  12451. * @param particle is the particle we are computed the position for
  12452. * @param isLocal defines if the position should be set in local space
  12453. */
  12454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12455. /**
  12456. * Clones the current emitter and returns a copy of it
  12457. * @returns the new emitter
  12458. */
  12459. clone(): BoxParticleEmitter;
  12460. /**
  12461. * Called by the GPUParticleSystem to setup the update shader
  12462. * @param effect defines the update shader
  12463. */
  12464. applyToShader(effect: Effect): void;
  12465. /**
  12466. * Returns a string to use to update the GPU particles update shader
  12467. * @returns a string containng the defines string
  12468. */
  12469. getEffectDefines(): string;
  12470. /**
  12471. * Returns the string "BoxParticleEmitter"
  12472. * @returns a string containing the class name
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Serializes the particle system to a JSON object.
  12477. * @returns the JSON object
  12478. */
  12479. serialize(): any;
  12480. /**
  12481. * Parse properties from a JSON object
  12482. * @param serializationObject defines the JSON object
  12483. */
  12484. parse(serializationObject: any): void;
  12485. }
  12486. }
  12487. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12488. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12489. import { Effect } from "babylonjs/Materials/effect";
  12490. import { Particle } from "babylonjs/Particles/particle";
  12491. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12492. /**
  12493. * Particle emitter emitting particles from the inside of a cone.
  12494. * It emits the particles alongside the cone volume from the base to the particle.
  12495. * The emission direction might be randomized.
  12496. */
  12497. export class ConeParticleEmitter implements IParticleEmitterType {
  12498. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12499. directionRandomizer: number;
  12500. private _radius;
  12501. private _angle;
  12502. private _height;
  12503. /**
  12504. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12505. */
  12506. radiusRange: number;
  12507. /**
  12508. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12509. */
  12510. heightRange: number;
  12511. /**
  12512. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12513. */
  12514. emitFromSpawnPointOnly: boolean;
  12515. /**
  12516. * Gets or sets the radius of the emission cone
  12517. */
  12518. get radius(): number;
  12519. set radius(value: number);
  12520. /**
  12521. * Gets or sets the angle of the emission cone
  12522. */
  12523. get angle(): number;
  12524. set angle(value: number);
  12525. private _buildHeight;
  12526. /**
  12527. * Creates a new instance ConeParticleEmitter
  12528. * @param radius the radius of the emission cone (1 by default)
  12529. * @param angle the cone base angle (PI by default)
  12530. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12531. */
  12532. constructor(radius?: number, angle?: number,
  12533. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12534. directionRandomizer?: number);
  12535. /**
  12536. * Called by the particle System when the direction is computed for the created particle.
  12537. * @param worldMatrix is the world matrix of the particle system
  12538. * @param directionToUpdate is the direction vector to update with the result
  12539. * @param particle is the particle we are computed the direction for
  12540. * @param isLocal defines if the direction should be set in local space
  12541. */
  12542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12543. /**
  12544. * Called by the particle System when the position is computed for the created particle.
  12545. * @param worldMatrix is the world matrix of the particle system
  12546. * @param positionToUpdate is the position vector to update with the result
  12547. * @param particle is the particle we are computed the position for
  12548. * @param isLocal defines if the position should be set in local space
  12549. */
  12550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12551. /**
  12552. * Clones the current emitter and returns a copy of it
  12553. * @returns the new emitter
  12554. */
  12555. clone(): ConeParticleEmitter;
  12556. /**
  12557. * Called by the GPUParticleSystem to setup the update shader
  12558. * @param effect defines the update shader
  12559. */
  12560. applyToShader(effect: Effect): void;
  12561. /**
  12562. * Returns a string to use to update the GPU particles update shader
  12563. * @returns a string containng the defines string
  12564. */
  12565. getEffectDefines(): string;
  12566. /**
  12567. * Returns the string "ConeParticleEmitter"
  12568. * @returns a string containing the class name
  12569. */
  12570. getClassName(): string;
  12571. /**
  12572. * Serializes the particle system to a JSON object.
  12573. * @returns the JSON object
  12574. */
  12575. serialize(): any;
  12576. /**
  12577. * Parse properties from a JSON object
  12578. * @param serializationObject defines the JSON object
  12579. */
  12580. parse(serializationObject: any): void;
  12581. }
  12582. }
  12583. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12585. import { Effect } from "babylonjs/Materials/effect";
  12586. import { Particle } from "babylonjs/Particles/particle";
  12587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12588. /**
  12589. * Particle emitter emitting particles from the inside of a cylinder.
  12590. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12591. */
  12592. export class CylinderParticleEmitter implements IParticleEmitterType {
  12593. /**
  12594. * The radius of the emission cylinder.
  12595. */
  12596. radius: number;
  12597. /**
  12598. * The height of the emission cylinder.
  12599. */
  12600. height: number;
  12601. /**
  12602. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12603. */
  12604. radiusRange: number;
  12605. /**
  12606. * How much to randomize the particle direction [0-1].
  12607. */
  12608. directionRandomizer: number;
  12609. /**
  12610. * Creates a new instance CylinderParticleEmitter
  12611. * @param radius the radius of the emission cylinder (1 by default)
  12612. * @param height the height of the emission cylinder (1 by default)
  12613. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12614. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12615. */
  12616. constructor(
  12617. /**
  12618. * The radius of the emission cylinder.
  12619. */
  12620. radius?: number,
  12621. /**
  12622. * The height of the emission cylinder.
  12623. */
  12624. height?: number,
  12625. /**
  12626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12627. */
  12628. radiusRange?: number,
  12629. /**
  12630. * How much to randomize the particle direction [0-1].
  12631. */
  12632. directionRandomizer?: number);
  12633. /**
  12634. * Called by the particle System when the direction is computed for the created particle.
  12635. * @param worldMatrix is the world matrix of the particle system
  12636. * @param directionToUpdate is the direction vector to update with the result
  12637. * @param particle is the particle we are computed the direction for
  12638. * @param isLocal defines if the direction should be set in local space
  12639. */
  12640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12641. /**
  12642. * Called by the particle System when the position is computed for the created particle.
  12643. * @param worldMatrix is the world matrix of the particle system
  12644. * @param positionToUpdate is the position vector to update with the result
  12645. * @param particle is the particle we are computed the position for
  12646. * @param isLocal defines if the position should be set in local space
  12647. */
  12648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12649. /**
  12650. * Clones the current emitter and returns a copy of it
  12651. * @returns the new emitter
  12652. */
  12653. clone(): CylinderParticleEmitter;
  12654. /**
  12655. * Called by the GPUParticleSystem to setup the update shader
  12656. * @param effect defines the update shader
  12657. */
  12658. applyToShader(effect: Effect): void;
  12659. /**
  12660. * Returns a string to use to update the GPU particles update shader
  12661. * @returns a string containng the defines string
  12662. */
  12663. getEffectDefines(): string;
  12664. /**
  12665. * Returns the string "CylinderParticleEmitter"
  12666. * @returns a string containing the class name
  12667. */
  12668. getClassName(): string;
  12669. /**
  12670. * Serializes the particle system to a JSON object.
  12671. * @returns the JSON object
  12672. */
  12673. serialize(): any;
  12674. /**
  12675. * Parse properties from a JSON object
  12676. * @param serializationObject defines the JSON object
  12677. */
  12678. parse(serializationObject: any): void;
  12679. }
  12680. /**
  12681. * Particle emitter emitting particles from the inside of a cylinder.
  12682. * It emits the particles randomly between two vectors.
  12683. */
  12684. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12685. /**
  12686. * The min limit of the emission direction.
  12687. */
  12688. direction1: Vector3;
  12689. /**
  12690. * The max limit of the emission direction.
  12691. */
  12692. direction2: Vector3;
  12693. /**
  12694. * Creates a new instance CylinderDirectedParticleEmitter
  12695. * @param radius the radius of the emission cylinder (1 by default)
  12696. * @param height the height of the emission cylinder (1 by default)
  12697. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12698. * @param direction1 the min limit of the emission direction (up vector by default)
  12699. * @param direction2 the max limit of the emission direction (up vector by default)
  12700. */
  12701. constructor(radius?: number, height?: number, radiusRange?: number,
  12702. /**
  12703. * The min limit of the emission direction.
  12704. */
  12705. direction1?: Vector3,
  12706. /**
  12707. * The max limit of the emission direction.
  12708. */
  12709. direction2?: Vector3);
  12710. /**
  12711. * Called by the particle System when the direction is computed for the created particle.
  12712. * @param worldMatrix is the world matrix of the particle system
  12713. * @param directionToUpdate is the direction vector to update with the result
  12714. * @param particle is the particle we are computed the direction for
  12715. */
  12716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12717. /**
  12718. * Clones the current emitter and returns a copy of it
  12719. * @returns the new emitter
  12720. */
  12721. clone(): CylinderDirectedParticleEmitter;
  12722. /**
  12723. * Called by the GPUParticleSystem to setup the update shader
  12724. * @param effect defines the update shader
  12725. */
  12726. applyToShader(effect: Effect): void;
  12727. /**
  12728. * Returns a string to use to update the GPU particles update shader
  12729. * @returns a string containng the defines string
  12730. */
  12731. getEffectDefines(): string;
  12732. /**
  12733. * Returns the string "CylinderDirectedParticleEmitter"
  12734. * @returns a string containing the class name
  12735. */
  12736. getClassName(): string;
  12737. /**
  12738. * Serializes the particle system to a JSON object.
  12739. * @returns the JSON object
  12740. */
  12741. serialize(): any;
  12742. /**
  12743. * Parse properties from a JSON object
  12744. * @param serializationObject defines the JSON object
  12745. */
  12746. parse(serializationObject: any): void;
  12747. }
  12748. }
  12749. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12750. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12751. import { Effect } from "babylonjs/Materials/effect";
  12752. import { Particle } from "babylonjs/Particles/particle";
  12753. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12754. /**
  12755. * Particle emitter emitting particles from the inside of a hemisphere.
  12756. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12757. */
  12758. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12759. /**
  12760. * The radius of the emission hemisphere.
  12761. */
  12762. radius: number;
  12763. /**
  12764. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12765. */
  12766. radiusRange: number;
  12767. /**
  12768. * How much to randomize the particle direction [0-1].
  12769. */
  12770. directionRandomizer: number;
  12771. /**
  12772. * Creates a new instance HemisphericParticleEmitter
  12773. * @param radius the radius of the emission hemisphere (1 by default)
  12774. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12775. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12776. */
  12777. constructor(
  12778. /**
  12779. * The radius of the emission hemisphere.
  12780. */
  12781. radius?: number,
  12782. /**
  12783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12784. */
  12785. radiusRange?: number,
  12786. /**
  12787. * How much to randomize the particle direction [0-1].
  12788. */
  12789. directionRandomizer?: number);
  12790. /**
  12791. * Called by the particle System when the direction is computed for the created particle.
  12792. * @param worldMatrix is the world matrix of the particle system
  12793. * @param directionToUpdate is the direction vector to update with the result
  12794. * @param particle is the particle we are computed the direction for
  12795. * @param isLocal defines if the direction should be set in local space
  12796. */
  12797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12798. /**
  12799. * Called by the particle System when the position is computed for the created particle.
  12800. * @param worldMatrix is the world matrix of the particle system
  12801. * @param positionToUpdate is the position vector to update with the result
  12802. * @param particle is the particle we are computed the position for
  12803. * @param isLocal defines if the position should be set in local space
  12804. */
  12805. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12806. /**
  12807. * Clones the current emitter and returns a copy of it
  12808. * @returns the new emitter
  12809. */
  12810. clone(): HemisphericParticleEmitter;
  12811. /**
  12812. * Called by the GPUParticleSystem to setup the update shader
  12813. * @param effect defines the update shader
  12814. */
  12815. applyToShader(effect: Effect): void;
  12816. /**
  12817. * Returns a string to use to update the GPU particles update shader
  12818. * @returns a string containng the defines string
  12819. */
  12820. getEffectDefines(): string;
  12821. /**
  12822. * Returns the string "HemisphericParticleEmitter"
  12823. * @returns a string containing the class name
  12824. */
  12825. getClassName(): string;
  12826. /**
  12827. * Serializes the particle system to a JSON object.
  12828. * @returns the JSON object
  12829. */
  12830. serialize(): any;
  12831. /**
  12832. * Parse properties from a JSON object
  12833. * @param serializationObject defines the JSON object
  12834. */
  12835. parse(serializationObject: any): void;
  12836. }
  12837. }
  12838. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12839. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12840. import { Effect } from "babylonjs/Materials/effect";
  12841. import { Particle } from "babylonjs/Particles/particle";
  12842. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12843. /**
  12844. * Particle emitter emitting particles from a point.
  12845. * It emits the particles randomly between 2 given directions.
  12846. */
  12847. export class PointParticleEmitter implements IParticleEmitterType {
  12848. /**
  12849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12850. */
  12851. direction1: Vector3;
  12852. /**
  12853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12854. */
  12855. direction2: Vector3;
  12856. /**
  12857. * Creates a new instance PointParticleEmitter
  12858. */
  12859. constructor();
  12860. /**
  12861. * Called by the particle System when the direction is computed for the created particle.
  12862. * @param worldMatrix is the world matrix of the particle system
  12863. * @param directionToUpdate is the direction vector to update with the result
  12864. * @param particle is the particle we are computed the direction for
  12865. * @param isLocal defines if the direction should be set in local space
  12866. */
  12867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12868. /**
  12869. * Called by the particle System when the position is computed for the created particle.
  12870. * @param worldMatrix is the world matrix of the particle system
  12871. * @param positionToUpdate is the position vector to update with the result
  12872. * @param particle is the particle we are computed the position for
  12873. * @param isLocal defines if the position should be set in local space
  12874. */
  12875. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12876. /**
  12877. * Clones the current emitter and returns a copy of it
  12878. * @returns the new emitter
  12879. */
  12880. clone(): PointParticleEmitter;
  12881. /**
  12882. * Called by the GPUParticleSystem to setup the update shader
  12883. * @param effect defines the update shader
  12884. */
  12885. applyToShader(effect: Effect): void;
  12886. /**
  12887. * Returns a string to use to update the GPU particles update shader
  12888. * @returns a string containng the defines string
  12889. */
  12890. getEffectDefines(): string;
  12891. /**
  12892. * Returns the string "PointParticleEmitter"
  12893. * @returns a string containing the class name
  12894. */
  12895. getClassName(): string;
  12896. /**
  12897. * Serializes the particle system to a JSON object.
  12898. * @returns the JSON object
  12899. */
  12900. serialize(): any;
  12901. /**
  12902. * Parse properties from a JSON object
  12903. * @param serializationObject defines the JSON object
  12904. */
  12905. parse(serializationObject: any): void;
  12906. }
  12907. }
  12908. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12909. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12910. import { Effect } from "babylonjs/Materials/effect";
  12911. import { Particle } from "babylonjs/Particles/particle";
  12912. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12913. /**
  12914. * Particle emitter emitting particles from the inside of a sphere.
  12915. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12916. */
  12917. export class SphereParticleEmitter implements IParticleEmitterType {
  12918. /**
  12919. * The radius of the emission sphere.
  12920. */
  12921. radius: number;
  12922. /**
  12923. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12924. */
  12925. radiusRange: number;
  12926. /**
  12927. * How much to randomize the particle direction [0-1].
  12928. */
  12929. directionRandomizer: number;
  12930. /**
  12931. * Creates a new instance SphereParticleEmitter
  12932. * @param radius the radius of the emission sphere (1 by default)
  12933. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12934. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12935. */
  12936. constructor(
  12937. /**
  12938. * The radius of the emission sphere.
  12939. */
  12940. radius?: number,
  12941. /**
  12942. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12943. */
  12944. radiusRange?: number,
  12945. /**
  12946. * How much to randomize the particle direction [0-1].
  12947. */
  12948. directionRandomizer?: number);
  12949. /**
  12950. * Called by the particle System when the direction is computed for the created particle.
  12951. * @param worldMatrix is the world matrix of the particle system
  12952. * @param directionToUpdate is the direction vector to update with the result
  12953. * @param particle is the particle we are computed the direction for
  12954. * @param isLocal defines if the direction should be set in local space
  12955. */
  12956. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12957. /**
  12958. * Called by the particle System when the position is computed for the created particle.
  12959. * @param worldMatrix is the world matrix of the particle system
  12960. * @param positionToUpdate is the position vector to update with the result
  12961. * @param particle is the particle we are computed the position for
  12962. * @param isLocal defines if the position should be set in local space
  12963. */
  12964. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12965. /**
  12966. * Clones the current emitter and returns a copy of it
  12967. * @returns the new emitter
  12968. */
  12969. clone(): SphereParticleEmitter;
  12970. /**
  12971. * Called by the GPUParticleSystem to setup the update shader
  12972. * @param effect defines the update shader
  12973. */
  12974. applyToShader(effect: Effect): void;
  12975. /**
  12976. * Returns a string to use to update the GPU particles update shader
  12977. * @returns a string containng the defines string
  12978. */
  12979. getEffectDefines(): string;
  12980. /**
  12981. * Returns the string "SphereParticleEmitter"
  12982. * @returns a string containing the class name
  12983. */
  12984. getClassName(): string;
  12985. /**
  12986. * Serializes the particle system to a JSON object.
  12987. * @returns the JSON object
  12988. */
  12989. serialize(): any;
  12990. /**
  12991. * Parse properties from a JSON object
  12992. * @param serializationObject defines the JSON object
  12993. */
  12994. parse(serializationObject: any): void;
  12995. }
  12996. /**
  12997. * Particle emitter emitting particles from the inside of a sphere.
  12998. * It emits the particles randomly between two vectors.
  12999. */
  13000. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13001. /**
  13002. * The min limit of the emission direction.
  13003. */
  13004. direction1: Vector3;
  13005. /**
  13006. * The max limit of the emission direction.
  13007. */
  13008. direction2: Vector3;
  13009. /**
  13010. * Creates a new instance SphereDirectedParticleEmitter
  13011. * @param radius the radius of the emission sphere (1 by default)
  13012. * @param direction1 the min limit of the emission direction (up vector by default)
  13013. * @param direction2 the max limit of the emission direction (up vector by default)
  13014. */
  13015. constructor(radius?: number,
  13016. /**
  13017. * The min limit of the emission direction.
  13018. */
  13019. direction1?: Vector3,
  13020. /**
  13021. * The max limit of the emission direction.
  13022. */
  13023. direction2?: Vector3);
  13024. /**
  13025. * Called by the particle System when the direction is computed for the created particle.
  13026. * @param worldMatrix is the world matrix of the particle system
  13027. * @param directionToUpdate is the direction vector to update with the result
  13028. * @param particle is the particle we are computed the direction for
  13029. */
  13030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13031. /**
  13032. * Clones the current emitter and returns a copy of it
  13033. * @returns the new emitter
  13034. */
  13035. clone(): SphereDirectedParticleEmitter;
  13036. /**
  13037. * Called by the GPUParticleSystem to setup the update shader
  13038. * @param effect defines the update shader
  13039. */
  13040. applyToShader(effect: Effect): void;
  13041. /**
  13042. * Returns a string to use to update the GPU particles update shader
  13043. * @returns a string containng the defines string
  13044. */
  13045. getEffectDefines(): string;
  13046. /**
  13047. * Returns the string "SphereDirectedParticleEmitter"
  13048. * @returns a string containing the class name
  13049. */
  13050. getClassName(): string;
  13051. /**
  13052. * Serializes the particle system to a JSON object.
  13053. * @returns the JSON object
  13054. */
  13055. serialize(): any;
  13056. /**
  13057. * Parse properties from a JSON object
  13058. * @param serializationObject defines the JSON object
  13059. */
  13060. parse(serializationObject: any): void;
  13061. }
  13062. }
  13063. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13064. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13065. import { Effect } from "babylonjs/Materials/effect";
  13066. import { Particle } from "babylonjs/Particles/particle";
  13067. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13068. import { Nullable } from "babylonjs/types";
  13069. /**
  13070. * Particle emitter emitting particles from a custom list of positions.
  13071. */
  13072. export class CustomParticleEmitter implements IParticleEmitterType {
  13073. /**
  13074. * Gets or sets the position generator that will create the inital position of each particle.
  13075. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13076. */
  13077. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13078. /**
  13079. * Gets or sets the destination generator that will create the final destination of each particle.
  13080. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13081. */
  13082. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13083. /**
  13084. * Creates a new instance CustomParticleEmitter
  13085. */
  13086. constructor();
  13087. /**
  13088. * Called by the particle System when the direction is computed for the created particle.
  13089. * @param worldMatrix is the world matrix of the particle system
  13090. * @param directionToUpdate is the direction vector to update with the result
  13091. * @param particle is the particle we are computed the direction for
  13092. * @param isLocal defines if the direction should be set in local space
  13093. */
  13094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13095. /**
  13096. * Called by the particle System when the position is computed for the created particle.
  13097. * @param worldMatrix is the world matrix of the particle system
  13098. * @param positionToUpdate is the position vector to update with the result
  13099. * @param particle is the particle we are computed the position for
  13100. * @param isLocal defines if the position should be set in local space
  13101. */
  13102. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13103. /**
  13104. * Clones the current emitter and returns a copy of it
  13105. * @returns the new emitter
  13106. */
  13107. clone(): CustomParticleEmitter;
  13108. /**
  13109. * Called by the GPUParticleSystem to setup the update shader
  13110. * @param effect defines the update shader
  13111. */
  13112. applyToShader(effect: Effect): void;
  13113. /**
  13114. * Returns a string to use to update the GPU particles update shader
  13115. * @returns a string containng the defines string
  13116. */
  13117. getEffectDefines(): string;
  13118. /**
  13119. * Returns the string "PointParticleEmitter"
  13120. * @returns a string containing the class name
  13121. */
  13122. getClassName(): string;
  13123. /**
  13124. * Serializes the particle system to a JSON object.
  13125. * @returns the JSON object
  13126. */
  13127. serialize(): any;
  13128. /**
  13129. * Parse properties from a JSON object
  13130. * @param serializationObject defines the JSON object
  13131. */
  13132. parse(serializationObject: any): void;
  13133. }
  13134. }
  13135. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13136. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13137. import { Effect } from "babylonjs/Materials/effect";
  13138. import { Particle } from "babylonjs/Particles/particle";
  13139. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13140. import { Nullable } from "babylonjs/types";
  13141. import { Scene } from "babylonjs/scene";
  13142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13143. /**
  13144. * Particle emitter emitting particles from the inside of a box.
  13145. * It emits the particles randomly between 2 given directions.
  13146. */
  13147. export class MeshParticleEmitter implements IParticleEmitterType {
  13148. private _indices;
  13149. private _positions;
  13150. private _normals;
  13151. private _storedNormal;
  13152. private _mesh;
  13153. /**
  13154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13155. */
  13156. direction1: Vector3;
  13157. /**
  13158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13159. */
  13160. direction2: Vector3;
  13161. /**
  13162. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13163. */
  13164. useMeshNormalsForDirection: boolean;
  13165. /** Defines the mesh to use as source */
  13166. get mesh(): Nullable<AbstractMesh>;
  13167. set mesh(value: Nullable<AbstractMesh>);
  13168. /**
  13169. * Creates a new instance MeshParticleEmitter
  13170. * @param mesh defines the mesh to use as source
  13171. */
  13172. constructor(mesh?: Nullable<AbstractMesh>);
  13173. /**
  13174. * Called by the particle System when the direction is computed for the created particle.
  13175. * @param worldMatrix is the world matrix of the particle system
  13176. * @param directionToUpdate is the direction vector to update with the result
  13177. * @param particle is the particle we are computed the direction for
  13178. * @param isLocal defines if the direction should be set in local space
  13179. */
  13180. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13181. /**
  13182. * Called by the particle System when the position is computed for the created particle.
  13183. * @param worldMatrix is the world matrix of the particle system
  13184. * @param positionToUpdate is the position vector to update with the result
  13185. * @param particle is the particle we are computed the position for
  13186. * @param isLocal defines if the position should be set in local space
  13187. */
  13188. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13189. /**
  13190. * Clones the current emitter and returns a copy of it
  13191. * @returns the new emitter
  13192. */
  13193. clone(): MeshParticleEmitter;
  13194. /**
  13195. * Called by the GPUParticleSystem to setup the update shader
  13196. * @param effect defines the update shader
  13197. */
  13198. applyToShader(effect: Effect): void;
  13199. /**
  13200. * Returns a string to use to update the GPU particles update shader
  13201. * @returns a string containng the defines string
  13202. */
  13203. getEffectDefines(): string;
  13204. /**
  13205. * Returns the string "BoxParticleEmitter"
  13206. * @returns a string containing the class name
  13207. */
  13208. getClassName(): string;
  13209. /**
  13210. * Serializes the particle system to a JSON object.
  13211. * @returns the JSON object
  13212. */
  13213. serialize(): any;
  13214. /**
  13215. * Parse properties from a JSON object
  13216. * @param serializationObject defines the JSON object
  13217. * @param scene defines the hosting scene
  13218. */
  13219. parse(serializationObject: any, scene: Scene): void;
  13220. }
  13221. }
  13222. declare module "babylonjs/Particles/EmitterTypes/index" {
  13223. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13224. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13225. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13226. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13227. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13228. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13229. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13230. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13231. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13232. }
  13233. declare module "babylonjs/Particles/IParticleSystem" {
  13234. import { Nullable } from "babylonjs/types";
  13235. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13236. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13239. import { Texture } from "babylonjs/Materials/Textures/texture";
  13240. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13241. import { Scene } from "babylonjs/scene";
  13242. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13243. import { Animation } from "babylonjs/Animations/animation";
  13244. /**
  13245. * Interface representing a particle system in Babylon.js.
  13246. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13247. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13248. */
  13249. export interface IParticleSystem {
  13250. /**
  13251. * List of animations used by the particle system.
  13252. */
  13253. animations: Animation[];
  13254. /**
  13255. * The id of the Particle system.
  13256. */
  13257. id: string;
  13258. /**
  13259. * The name of the Particle system.
  13260. */
  13261. name: string;
  13262. /**
  13263. * The emitter represents the Mesh or position we are attaching the particle system to.
  13264. */
  13265. emitter: Nullable<AbstractMesh | Vector3>;
  13266. /**
  13267. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13268. */
  13269. isBillboardBased: boolean;
  13270. /**
  13271. * The rendering group used by the Particle system to chose when to render.
  13272. */
  13273. renderingGroupId: number;
  13274. /**
  13275. * The layer mask we are rendering the particles through.
  13276. */
  13277. layerMask: number;
  13278. /**
  13279. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13280. */
  13281. updateSpeed: number;
  13282. /**
  13283. * The amount of time the particle system is running (depends of the overall update speed).
  13284. */
  13285. targetStopDuration: number;
  13286. /**
  13287. * The texture used to render each particle. (this can be a spritesheet)
  13288. */
  13289. particleTexture: Nullable<Texture>;
  13290. /**
  13291. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13292. */
  13293. blendMode: number;
  13294. /**
  13295. * Minimum life time of emitting particles.
  13296. */
  13297. minLifeTime: number;
  13298. /**
  13299. * Maximum life time of emitting particles.
  13300. */
  13301. maxLifeTime: number;
  13302. /**
  13303. * Minimum Size of emitting particles.
  13304. */
  13305. minSize: number;
  13306. /**
  13307. * Maximum Size of emitting particles.
  13308. */
  13309. maxSize: number;
  13310. /**
  13311. * Minimum scale of emitting particles on X axis.
  13312. */
  13313. minScaleX: number;
  13314. /**
  13315. * Maximum scale of emitting particles on X axis.
  13316. */
  13317. maxScaleX: number;
  13318. /**
  13319. * Minimum scale of emitting particles on Y axis.
  13320. */
  13321. minScaleY: number;
  13322. /**
  13323. * Maximum scale of emitting particles on Y axis.
  13324. */
  13325. maxScaleY: number;
  13326. /**
  13327. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13328. */
  13329. color1: Color4;
  13330. /**
  13331. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13332. */
  13333. color2: Color4;
  13334. /**
  13335. * Color the particle will have at the end of its lifetime.
  13336. */
  13337. colorDead: Color4;
  13338. /**
  13339. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13340. */
  13341. emitRate: number;
  13342. /**
  13343. * You can use gravity if you want to give an orientation to your particles.
  13344. */
  13345. gravity: Vector3;
  13346. /**
  13347. * Minimum power of emitting particles.
  13348. */
  13349. minEmitPower: number;
  13350. /**
  13351. * Maximum power of emitting particles.
  13352. */
  13353. maxEmitPower: number;
  13354. /**
  13355. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13356. */
  13357. minAngularSpeed: number;
  13358. /**
  13359. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13360. */
  13361. maxAngularSpeed: number;
  13362. /**
  13363. * Gets or sets the minimal initial rotation in radians.
  13364. */
  13365. minInitialRotation: number;
  13366. /**
  13367. * Gets or sets the maximal initial rotation in radians.
  13368. */
  13369. maxInitialRotation: number;
  13370. /**
  13371. * The particle emitter type defines the emitter used by the particle system.
  13372. * It can be for example box, sphere, or cone...
  13373. */
  13374. particleEmitterType: Nullable<IParticleEmitterType>;
  13375. /**
  13376. * Defines the delay in milliseconds before starting the system (0 by default)
  13377. */
  13378. startDelay: number;
  13379. /**
  13380. * 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
  13381. */
  13382. preWarmCycles: number;
  13383. /**
  13384. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13385. */
  13386. preWarmStepOffset: number;
  13387. /**
  13388. * 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)
  13389. */
  13390. spriteCellChangeSpeed: number;
  13391. /**
  13392. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13393. */
  13394. startSpriteCellID: number;
  13395. /**
  13396. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13397. */
  13398. endSpriteCellID: number;
  13399. /**
  13400. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13401. */
  13402. spriteCellWidth: number;
  13403. /**
  13404. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13405. */
  13406. spriteCellHeight: number;
  13407. /**
  13408. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13409. */
  13410. spriteRandomStartCell: boolean;
  13411. /**
  13412. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13413. */
  13414. isAnimationSheetEnabled: boolean;
  13415. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13416. translationPivot: Vector2;
  13417. /**
  13418. * Gets or sets a texture used to add random noise to particle positions
  13419. */
  13420. noiseTexture: Nullable<BaseTexture>;
  13421. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13422. noiseStrength: Vector3;
  13423. /**
  13424. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13425. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13426. */
  13427. billboardMode: number;
  13428. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13429. limitVelocityDamping: number;
  13430. /**
  13431. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13432. */
  13433. beginAnimationOnStart: boolean;
  13434. /**
  13435. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13436. */
  13437. beginAnimationFrom: number;
  13438. /**
  13439. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13440. */
  13441. beginAnimationTo: number;
  13442. /**
  13443. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13444. */
  13445. beginAnimationLoop: boolean;
  13446. /**
  13447. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13448. */
  13449. disposeOnStop: boolean;
  13450. /**
  13451. * Specifies if the particles are updated in emitter local space or world space
  13452. */
  13453. isLocal: boolean;
  13454. /**
  13455. * Gets the maximum number of particles active at the same time.
  13456. * @returns The max number of active particles.
  13457. */
  13458. getCapacity(): number;
  13459. /**
  13460. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13461. * @returns True if it has been started, otherwise false.
  13462. */
  13463. isStarted(): boolean;
  13464. /**
  13465. * Animates the particle system for this frame.
  13466. */
  13467. animate(): void;
  13468. /**
  13469. * Renders the particle system in its current state.
  13470. * @returns the current number of particles
  13471. */
  13472. render(): number;
  13473. /**
  13474. * Dispose the particle system and frees its associated resources.
  13475. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13476. */
  13477. dispose(disposeTexture?: boolean): void;
  13478. /**
  13479. * Clones the particle system.
  13480. * @param name The name of the cloned object
  13481. * @param newEmitter The new emitter to use
  13482. * @returns the cloned particle system
  13483. */
  13484. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13485. /**
  13486. * Serializes the particle system to a JSON object.
  13487. * @returns the JSON object
  13488. */
  13489. serialize(): any;
  13490. /**
  13491. * Rebuild the particle system
  13492. */
  13493. rebuild(): void;
  13494. /**
  13495. * Starts the particle system and begins to emit
  13496. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13497. */
  13498. start(delay?: number): void;
  13499. /**
  13500. * Stops the particle system.
  13501. */
  13502. stop(): void;
  13503. /**
  13504. * Remove all active particles
  13505. */
  13506. reset(): void;
  13507. /**
  13508. * Is this system ready to be used/rendered
  13509. * @return true if the system is ready
  13510. */
  13511. isReady(): boolean;
  13512. /**
  13513. * Returns the string "ParticleSystem"
  13514. * @returns a string containing the class name
  13515. */
  13516. getClassName(): string;
  13517. /**
  13518. * Adds a new color gradient
  13519. * @param gradient defines the gradient to use (between 0 and 1)
  13520. * @param color1 defines the color to affect to the specified gradient
  13521. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13522. * @returns the current particle system
  13523. */
  13524. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13525. /**
  13526. * Remove a specific color gradient
  13527. * @param gradient defines the gradient to remove
  13528. * @returns the current particle system
  13529. */
  13530. removeColorGradient(gradient: number): IParticleSystem;
  13531. /**
  13532. * Adds a new size gradient
  13533. * @param gradient defines the gradient to use (between 0 and 1)
  13534. * @param factor defines the size factor to affect to the specified gradient
  13535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13536. * @returns the current particle system
  13537. */
  13538. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13539. /**
  13540. * Remove a specific size gradient
  13541. * @param gradient defines the gradient to remove
  13542. * @returns the current particle system
  13543. */
  13544. removeSizeGradient(gradient: number): IParticleSystem;
  13545. /**
  13546. * Gets the current list of color gradients.
  13547. * You must use addColorGradient and removeColorGradient to udpate this list
  13548. * @returns the list of color gradients
  13549. */
  13550. getColorGradients(): Nullable<Array<ColorGradient>>;
  13551. /**
  13552. * Gets the current list of size gradients.
  13553. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13554. * @returns the list of size gradients
  13555. */
  13556. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13557. /**
  13558. * Gets the current list of angular speed gradients.
  13559. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13560. * @returns the list of angular speed gradients
  13561. */
  13562. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13563. /**
  13564. * Adds a new angular speed gradient
  13565. * @param gradient defines the gradient to use (between 0 and 1)
  13566. * @param factor defines the angular speed to affect to the specified gradient
  13567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13568. * @returns the current particle system
  13569. */
  13570. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13571. /**
  13572. * Remove a specific angular speed gradient
  13573. * @param gradient defines the gradient to remove
  13574. * @returns the current particle system
  13575. */
  13576. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13577. /**
  13578. * Gets the current list of velocity gradients.
  13579. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13580. * @returns the list of velocity gradients
  13581. */
  13582. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13583. /**
  13584. * Adds a new velocity gradient
  13585. * @param gradient defines the gradient to use (between 0 and 1)
  13586. * @param factor defines the velocity to affect to the specified gradient
  13587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13588. * @returns the current particle system
  13589. */
  13590. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13591. /**
  13592. * Remove a specific velocity gradient
  13593. * @param gradient defines the gradient to remove
  13594. * @returns the current particle system
  13595. */
  13596. removeVelocityGradient(gradient: number): IParticleSystem;
  13597. /**
  13598. * Gets the current list of limit velocity gradients.
  13599. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13600. * @returns the list of limit velocity gradients
  13601. */
  13602. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13603. /**
  13604. * Adds a new limit velocity gradient
  13605. * @param gradient defines the gradient to use (between 0 and 1)
  13606. * @param factor defines the limit velocity to affect to the specified gradient
  13607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13608. * @returns the current particle system
  13609. */
  13610. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13611. /**
  13612. * Remove a specific limit velocity gradient
  13613. * @param gradient defines the gradient to remove
  13614. * @returns the current particle system
  13615. */
  13616. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13617. /**
  13618. * Adds a new drag gradient
  13619. * @param gradient defines the gradient to use (between 0 and 1)
  13620. * @param factor defines the drag to affect to the specified gradient
  13621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13622. * @returns the current particle system
  13623. */
  13624. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13625. /**
  13626. * Remove a specific drag gradient
  13627. * @param gradient defines the gradient to remove
  13628. * @returns the current particle system
  13629. */
  13630. removeDragGradient(gradient: number): IParticleSystem;
  13631. /**
  13632. * Gets the current list of drag gradients.
  13633. * You must use addDragGradient and removeDragGradient to udpate this list
  13634. * @returns the list of drag gradients
  13635. */
  13636. getDragGradients(): Nullable<Array<FactorGradient>>;
  13637. /**
  13638. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13639. * @param gradient defines the gradient to use (between 0 and 1)
  13640. * @param factor defines the emit rate to affect to the specified gradient
  13641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13642. * @returns the current particle system
  13643. */
  13644. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13645. /**
  13646. * Remove a specific emit rate gradient
  13647. * @param gradient defines the gradient to remove
  13648. * @returns the current particle system
  13649. */
  13650. removeEmitRateGradient(gradient: number): IParticleSystem;
  13651. /**
  13652. * Gets the current list of emit rate gradients.
  13653. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13654. * @returns the list of emit rate gradients
  13655. */
  13656. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13657. /**
  13658. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13659. * @param gradient defines the gradient to use (between 0 and 1)
  13660. * @param factor defines the start size to affect to the specified gradient
  13661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13662. * @returns the current particle system
  13663. */
  13664. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13665. /**
  13666. * Remove a specific start size gradient
  13667. * @param gradient defines the gradient to remove
  13668. * @returns the current particle system
  13669. */
  13670. removeStartSizeGradient(gradient: number): IParticleSystem;
  13671. /**
  13672. * Gets the current list of start size gradients.
  13673. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13674. * @returns the list of start size gradients
  13675. */
  13676. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13677. /**
  13678. * Adds a new life time gradient
  13679. * @param gradient defines the gradient to use (between 0 and 1)
  13680. * @param factor defines the life time factor to affect to the specified gradient
  13681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13682. * @returns the current particle system
  13683. */
  13684. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13685. /**
  13686. * Remove a specific life time gradient
  13687. * @param gradient defines the gradient to remove
  13688. * @returns the current particle system
  13689. */
  13690. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13691. /**
  13692. * Gets the current list of life time gradients.
  13693. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13694. * @returns the list of life time gradients
  13695. */
  13696. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13697. /**
  13698. * Gets the current list of color gradients.
  13699. * You must use addColorGradient and removeColorGradient to udpate this list
  13700. * @returns the list of color gradients
  13701. */
  13702. getColorGradients(): Nullable<Array<ColorGradient>>;
  13703. /**
  13704. * Adds a new ramp gradient used to remap particle colors
  13705. * @param gradient defines the gradient to use (between 0 and 1)
  13706. * @param color defines the color to affect to the specified gradient
  13707. * @returns the current particle system
  13708. */
  13709. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13710. /**
  13711. * Gets the current list of ramp gradients.
  13712. * You must use addRampGradient and removeRampGradient to udpate this list
  13713. * @returns the list of ramp gradients
  13714. */
  13715. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13716. /** Gets or sets a boolean indicating that ramp gradients must be used
  13717. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13718. */
  13719. useRampGradients: boolean;
  13720. /**
  13721. * Adds a new color remap gradient
  13722. * @param gradient defines the gradient to use (between 0 and 1)
  13723. * @param min defines the color remap minimal range
  13724. * @param max defines the color remap maximal range
  13725. * @returns the current particle system
  13726. */
  13727. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13728. /**
  13729. * Gets the current list of color remap gradients.
  13730. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13731. * @returns the list of color remap gradients
  13732. */
  13733. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13734. /**
  13735. * Adds a new alpha remap gradient
  13736. * @param gradient defines the gradient to use (between 0 and 1)
  13737. * @param min defines the alpha remap minimal range
  13738. * @param max defines the alpha remap maximal range
  13739. * @returns the current particle system
  13740. */
  13741. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13742. /**
  13743. * Gets the current list of alpha remap gradients.
  13744. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13745. * @returns the list of alpha remap gradients
  13746. */
  13747. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13748. /**
  13749. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13752. * @returns the emitter
  13753. */
  13754. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13755. /**
  13756. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13757. * @param radius The radius of the hemisphere to emit from
  13758. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13759. * @returns the emitter
  13760. */
  13761. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13762. /**
  13763. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13764. * @param radius The radius of the sphere to emit from
  13765. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13766. * @returns the emitter
  13767. */
  13768. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13769. /**
  13770. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13771. * @param radius The radius of the sphere to emit from
  13772. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13773. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13774. * @returns the emitter
  13775. */
  13776. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13777. /**
  13778. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13779. * @param radius The radius of the emission cylinder
  13780. * @param height The height of the emission cylinder
  13781. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13782. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13783. * @returns the emitter
  13784. */
  13785. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13786. /**
  13787. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13788. * @param radius The radius of the cylinder to emit from
  13789. * @param height The height of the emission cylinder
  13790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13791. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13792. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13793. * @returns the emitter
  13794. */
  13795. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13796. /**
  13797. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13798. * @param radius The radius of the cone to emit from
  13799. * @param angle The base angle of the cone
  13800. * @returns the emitter
  13801. */
  13802. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13803. /**
  13804. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13805. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13806. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13807. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13808. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13809. * @returns the emitter
  13810. */
  13811. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13812. /**
  13813. * Get hosting scene
  13814. * @returns the scene
  13815. */
  13816. getScene(): Scene;
  13817. }
  13818. }
  13819. declare module "babylonjs/Meshes/transformNode" {
  13820. import { DeepImmutable } from "babylonjs/types";
  13821. import { Observable } from "babylonjs/Misc/observable";
  13822. import { Nullable } from "babylonjs/types";
  13823. import { Camera } from "babylonjs/Cameras/camera";
  13824. import { Scene } from "babylonjs/scene";
  13825. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13826. import { Node } from "babylonjs/node";
  13827. import { Bone } from "babylonjs/Bones/bone";
  13828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13829. import { Space } from "babylonjs/Maths/math.axis";
  13830. /**
  13831. * 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.
  13832. * @see https://doc.babylonjs.com/how_to/transformnode
  13833. */
  13834. export class TransformNode extends Node {
  13835. /**
  13836. * Object will not rotate to face the camera
  13837. */
  13838. static BILLBOARDMODE_NONE: number;
  13839. /**
  13840. * Object will rotate to face the camera but only on the x axis
  13841. */
  13842. static BILLBOARDMODE_X: number;
  13843. /**
  13844. * Object will rotate to face the camera but only on the y axis
  13845. */
  13846. static BILLBOARDMODE_Y: number;
  13847. /**
  13848. * Object will rotate to face the camera but only on the z axis
  13849. */
  13850. static BILLBOARDMODE_Z: number;
  13851. /**
  13852. * Object will rotate to face the camera
  13853. */
  13854. static BILLBOARDMODE_ALL: number;
  13855. /**
  13856. * Object will rotate to face the camera's position instead of orientation
  13857. */
  13858. static BILLBOARDMODE_USE_POSITION: number;
  13859. private _forward;
  13860. private _forwardInverted;
  13861. private _up;
  13862. private _right;
  13863. private _rightInverted;
  13864. private _position;
  13865. private _rotation;
  13866. private _rotationQuaternion;
  13867. protected _scaling: Vector3;
  13868. protected _isDirty: boolean;
  13869. private _transformToBoneReferal;
  13870. private _isAbsoluteSynced;
  13871. private _billboardMode;
  13872. /**
  13873. * Gets or sets the billboard mode. Default is 0.
  13874. *
  13875. * | Value | Type | Description |
  13876. * | --- | --- | --- |
  13877. * | 0 | BILLBOARDMODE_NONE | |
  13878. * | 1 | BILLBOARDMODE_X | |
  13879. * | 2 | BILLBOARDMODE_Y | |
  13880. * | 4 | BILLBOARDMODE_Z | |
  13881. * | 7 | BILLBOARDMODE_ALL | |
  13882. *
  13883. */
  13884. get billboardMode(): number;
  13885. set billboardMode(value: number);
  13886. private _preserveParentRotationForBillboard;
  13887. /**
  13888. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13889. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13890. */
  13891. get preserveParentRotationForBillboard(): boolean;
  13892. set preserveParentRotationForBillboard(value: boolean);
  13893. /**
  13894. * 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
  13895. */
  13896. scalingDeterminant: number;
  13897. private _infiniteDistance;
  13898. /**
  13899. * Gets or sets the distance of the object to max, often used by skybox
  13900. */
  13901. get infiniteDistance(): boolean;
  13902. set infiniteDistance(value: boolean);
  13903. /**
  13904. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13905. * By default the system will update normals to compensate
  13906. */
  13907. ignoreNonUniformScaling: boolean;
  13908. /**
  13909. * 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
  13910. */
  13911. reIntegrateRotationIntoRotationQuaternion: boolean;
  13912. /** @hidden */
  13913. _poseMatrix: Nullable<Matrix>;
  13914. /** @hidden */
  13915. _localMatrix: Matrix;
  13916. private _usePivotMatrix;
  13917. private _absolutePosition;
  13918. private _absoluteScaling;
  13919. private _absoluteRotationQuaternion;
  13920. private _pivotMatrix;
  13921. private _pivotMatrixInverse;
  13922. protected _postMultiplyPivotMatrix: boolean;
  13923. protected _isWorldMatrixFrozen: boolean;
  13924. /** @hidden */
  13925. _indexInSceneTransformNodesArray: number;
  13926. /**
  13927. * An event triggered after the world matrix is updated
  13928. */
  13929. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13930. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13931. /**
  13932. * Gets a string identifying the name of the class
  13933. * @returns "TransformNode" string
  13934. */
  13935. getClassName(): string;
  13936. /**
  13937. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13938. */
  13939. get position(): Vector3;
  13940. set position(newPosition: Vector3);
  13941. /**
  13942. * 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)).
  13943. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13944. */
  13945. get rotation(): Vector3;
  13946. set rotation(newRotation: Vector3);
  13947. /**
  13948. * 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)).
  13949. */
  13950. get scaling(): Vector3;
  13951. set scaling(newScaling: Vector3);
  13952. /**
  13953. * 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).
  13954. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13955. */
  13956. get rotationQuaternion(): Nullable<Quaternion>;
  13957. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13958. /**
  13959. * The forward direction of that transform in world space.
  13960. */
  13961. get forward(): Vector3;
  13962. /**
  13963. * The up direction of that transform in world space.
  13964. */
  13965. get up(): Vector3;
  13966. /**
  13967. * The right direction of that transform in world space.
  13968. */
  13969. get right(): Vector3;
  13970. /**
  13971. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13972. * @param matrix the matrix to copy the pose from
  13973. * @returns this TransformNode.
  13974. */
  13975. updatePoseMatrix(matrix: Matrix): TransformNode;
  13976. /**
  13977. * Returns the mesh Pose matrix.
  13978. * @returns the pose matrix
  13979. */
  13980. getPoseMatrix(): Matrix;
  13981. /** @hidden */
  13982. _isSynchronized(): boolean;
  13983. /** @hidden */
  13984. _initCache(): void;
  13985. /**
  13986. * Flag the transform node as dirty (Forcing it to update everything)
  13987. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13988. * @returns this transform node
  13989. */
  13990. markAsDirty(property: string): TransformNode;
  13991. /**
  13992. * Returns the current mesh absolute position.
  13993. * Returns a Vector3.
  13994. */
  13995. get absolutePosition(): Vector3;
  13996. /**
  13997. * Returns the current mesh absolute scaling.
  13998. * Returns a Vector3.
  13999. */
  14000. get absoluteScaling(): Vector3;
  14001. /**
  14002. * Returns the current mesh absolute rotation.
  14003. * Returns a Quaternion.
  14004. */
  14005. get absoluteRotationQuaternion(): Quaternion;
  14006. /**
  14007. * Sets a new matrix to apply before all other transformation
  14008. * @param matrix defines the transform matrix
  14009. * @returns the current TransformNode
  14010. */
  14011. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14012. /**
  14013. * Sets a new pivot matrix to the current node
  14014. * @param matrix defines the new pivot matrix to use
  14015. * @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
  14016. * @returns the current TransformNode
  14017. */
  14018. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14019. /**
  14020. * Returns the mesh pivot matrix.
  14021. * Default : Identity.
  14022. * @returns the matrix
  14023. */
  14024. getPivotMatrix(): Matrix;
  14025. /**
  14026. * Instantiate (when possible) or clone that node with its hierarchy
  14027. * @param newParent defines the new parent to use for the instance (or clone)
  14028. * @param options defines options to configure how copy is done
  14029. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14030. * @returns an instance (or a clone) of the current node with its hiearchy
  14031. */
  14032. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14033. doNotInstantiate: boolean;
  14034. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14035. /**
  14036. * Prevents the World matrix to be computed any longer
  14037. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14038. * @returns the TransformNode.
  14039. */
  14040. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14041. /**
  14042. * Allows back the World matrix computation.
  14043. * @returns the TransformNode.
  14044. */
  14045. unfreezeWorldMatrix(): this;
  14046. /**
  14047. * True if the World matrix has been frozen.
  14048. */
  14049. get isWorldMatrixFrozen(): boolean;
  14050. /**
  14051. * Retuns the mesh absolute position in the World.
  14052. * @returns a Vector3.
  14053. */
  14054. getAbsolutePosition(): Vector3;
  14055. /**
  14056. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14057. * @param absolutePosition the absolute position to set
  14058. * @returns the TransformNode.
  14059. */
  14060. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14061. /**
  14062. * Sets the mesh position in its local space.
  14063. * @param vector3 the position to set in localspace
  14064. * @returns the TransformNode.
  14065. */
  14066. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14067. /**
  14068. * Returns the mesh position in the local space from the current World matrix values.
  14069. * @returns a new Vector3.
  14070. */
  14071. getPositionExpressedInLocalSpace(): Vector3;
  14072. /**
  14073. * Translates the mesh along the passed Vector3 in its local space.
  14074. * @param vector3 the distance to translate in localspace
  14075. * @returns the TransformNode.
  14076. */
  14077. locallyTranslate(vector3: Vector3): TransformNode;
  14078. private static _lookAtVectorCache;
  14079. /**
  14080. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14081. * @param targetPoint the position (must be in same space as current mesh) to look at
  14082. * @param yawCor optional yaw (y-axis) correction in radians
  14083. * @param pitchCor optional pitch (x-axis) correction in radians
  14084. * @param rollCor optional roll (z-axis) correction in radians
  14085. * @param space the choosen space of the target
  14086. * @returns the TransformNode.
  14087. */
  14088. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14089. /**
  14090. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14091. * This Vector3 is expressed in the World space.
  14092. * @param localAxis axis to rotate
  14093. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14094. */
  14095. getDirection(localAxis: Vector3): Vector3;
  14096. /**
  14097. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14098. * localAxis is expressed in the mesh local space.
  14099. * result is computed in the Wordl space from the mesh World matrix.
  14100. * @param localAxis axis to rotate
  14101. * @param result the resulting transformnode
  14102. * @returns this TransformNode.
  14103. */
  14104. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14105. /**
  14106. * Sets this transform node rotation to the given local axis.
  14107. * @param localAxis the axis in local space
  14108. * @param yawCor optional yaw (y-axis) correction in radians
  14109. * @param pitchCor optional pitch (x-axis) correction in radians
  14110. * @param rollCor optional roll (z-axis) correction in radians
  14111. * @returns this TransformNode
  14112. */
  14113. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14114. /**
  14115. * Sets a new pivot point to the current node
  14116. * @param point defines the new pivot point to use
  14117. * @param space defines if the point is in world or local space (local by default)
  14118. * @returns the current TransformNode
  14119. */
  14120. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14121. /**
  14122. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14123. * @returns the pivot point
  14124. */
  14125. getPivotPoint(): Vector3;
  14126. /**
  14127. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14128. * @param result the vector3 to store the result
  14129. * @returns this TransformNode.
  14130. */
  14131. getPivotPointToRef(result: Vector3): TransformNode;
  14132. /**
  14133. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14134. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14135. */
  14136. getAbsolutePivotPoint(): Vector3;
  14137. /**
  14138. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14139. * @param result vector3 to store the result
  14140. * @returns this TransformNode.
  14141. */
  14142. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14143. /**
  14144. * Defines the passed node as the parent of the current node.
  14145. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14146. * @see https://doc.babylonjs.com/how_to/parenting
  14147. * @param node the node ot set as the parent
  14148. * @returns this TransformNode.
  14149. */
  14150. setParent(node: Nullable<Node>): TransformNode;
  14151. private _nonUniformScaling;
  14152. /**
  14153. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14154. */
  14155. get nonUniformScaling(): boolean;
  14156. /** @hidden */
  14157. _updateNonUniformScalingState(value: boolean): boolean;
  14158. /**
  14159. * Attach the current TransformNode to another TransformNode associated with a bone
  14160. * @param bone Bone affecting the TransformNode
  14161. * @param affectedTransformNode TransformNode associated with the bone
  14162. * @returns this object
  14163. */
  14164. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14165. /**
  14166. * Detach the transform node if its associated with a bone
  14167. * @returns this object
  14168. */
  14169. detachFromBone(): TransformNode;
  14170. private static _rotationAxisCache;
  14171. /**
  14172. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14173. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14174. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14175. * The passed axis is also normalized.
  14176. * @param axis the axis to rotate around
  14177. * @param amount the amount to rotate in radians
  14178. * @param space Space to rotate in (Default: local)
  14179. * @returns the TransformNode.
  14180. */
  14181. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14182. /**
  14183. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14184. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14185. * The passed axis is also normalized. .
  14186. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14187. * @param point the point to rotate around
  14188. * @param axis the axis to rotate around
  14189. * @param amount the amount to rotate in radians
  14190. * @returns the TransformNode
  14191. */
  14192. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14193. /**
  14194. * Translates the mesh along the axis vector for the passed distance in the given space.
  14195. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14196. * @param axis the axis to translate in
  14197. * @param distance the distance to translate
  14198. * @param space Space to rotate in (Default: local)
  14199. * @returns the TransformNode.
  14200. */
  14201. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14202. /**
  14203. * Adds a rotation step to the mesh current rotation.
  14204. * x, y, z are Euler angles expressed in radians.
  14205. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14206. * This means this rotation is made in the mesh local space only.
  14207. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14208. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14209. * ```javascript
  14210. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14211. * ```
  14212. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14213. * 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.
  14214. * @param x Rotation to add
  14215. * @param y Rotation to add
  14216. * @param z Rotation to add
  14217. * @returns the TransformNode.
  14218. */
  14219. addRotation(x: number, y: number, z: number): TransformNode;
  14220. /**
  14221. * @hidden
  14222. */
  14223. protected _getEffectiveParent(): Nullable<Node>;
  14224. /**
  14225. * Computes the world matrix of the node
  14226. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14227. * @returns the world matrix
  14228. */
  14229. computeWorldMatrix(force?: boolean): Matrix;
  14230. /**
  14231. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14232. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14233. */
  14234. resetLocalMatrix(independentOfChildren?: boolean): void;
  14235. protected _afterComputeWorldMatrix(): void;
  14236. /**
  14237. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14238. * @param func callback function to add
  14239. *
  14240. * @returns the TransformNode.
  14241. */
  14242. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14243. /**
  14244. * Removes a registered callback function.
  14245. * @param func callback function to remove
  14246. * @returns the TransformNode.
  14247. */
  14248. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14249. /**
  14250. * Gets the position of the current mesh in camera space
  14251. * @param camera defines the camera to use
  14252. * @returns a position
  14253. */
  14254. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14255. /**
  14256. * Returns the distance from the mesh to the active camera
  14257. * @param camera defines the camera to use
  14258. * @returns the distance
  14259. */
  14260. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14261. /**
  14262. * Clone the current transform node
  14263. * @param name Name of the new clone
  14264. * @param newParent New parent for the clone
  14265. * @param doNotCloneChildren Do not clone children hierarchy
  14266. * @returns the new transform node
  14267. */
  14268. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14269. /**
  14270. * Serializes the objects information.
  14271. * @param currentSerializationObject defines the object to serialize in
  14272. * @returns the serialized object
  14273. */
  14274. serialize(currentSerializationObject?: any): any;
  14275. /**
  14276. * Returns a new TransformNode object parsed from the source provided.
  14277. * @param parsedTransformNode is the source.
  14278. * @param scene the scne the object belongs to
  14279. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14280. * @returns a new TransformNode object parsed from the source provided.
  14281. */
  14282. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14283. /**
  14284. * Get all child-transformNodes of this node
  14285. * @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
  14286. * @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
  14287. * @returns an array of TransformNode
  14288. */
  14289. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14290. /**
  14291. * Releases resources associated with this transform node.
  14292. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14293. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14294. */
  14295. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14296. /**
  14297. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14298. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14299. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14300. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14301. * @returns the current mesh
  14302. */
  14303. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14304. private _syncAbsoluteScalingAndRotation;
  14305. }
  14306. }
  14307. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14308. /**
  14309. * Class used to override all child animations of a given target
  14310. */
  14311. export class AnimationPropertiesOverride {
  14312. /**
  14313. * Gets or sets a value indicating if animation blending must be used
  14314. */
  14315. enableBlending: boolean;
  14316. /**
  14317. * Gets or sets the blending speed to use when enableBlending is true
  14318. */
  14319. blendingSpeed: number;
  14320. /**
  14321. * Gets or sets the default loop mode to use
  14322. */
  14323. loopMode: number;
  14324. }
  14325. }
  14326. declare module "babylonjs/Bones/bone" {
  14327. import { Skeleton } from "babylonjs/Bones/skeleton";
  14328. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14329. import { Nullable } from "babylonjs/types";
  14330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14331. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14332. import { Node } from "babylonjs/node";
  14333. import { Space } from "babylonjs/Maths/math.axis";
  14334. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14335. /**
  14336. * Class used to store bone information
  14337. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14338. */
  14339. export class Bone extends Node {
  14340. /**
  14341. * defines the bone name
  14342. */
  14343. name: string;
  14344. private static _tmpVecs;
  14345. private static _tmpQuat;
  14346. private static _tmpMats;
  14347. /**
  14348. * Gets the list of child bones
  14349. */
  14350. children: Bone[];
  14351. /** Gets the animations associated with this bone */
  14352. animations: import("babylonjs/Animations/animation").Animation[];
  14353. /**
  14354. * Gets or sets bone length
  14355. */
  14356. length: number;
  14357. /**
  14358. * @hidden Internal only
  14359. * Set this value to map this bone to a different index in the transform matrices
  14360. * Set this value to -1 to exclude the bone from the transform matrices
  14361. */
  14362. _index: Nullable<number>;
  14363. private _skeleton;
  14364. private _localMatrix;
  14365. private _restPose;
  14366. private _baseMatrix;
  14367. private _absoluteTransform;
  14368. private _invertedAbsoluteTransform;
  14369. private _parent;
  14370. private _scalingDeterminant;
  14371. private _worldTransform;
  14372. private _localScaling;
  14373. private _localRotation;
  14374. private _localPosition;
  14375. private _needToDecompose;
  14376. private _needToCompose;
  14377. /** @hidden */
  14378. _linkedTransformNode: Nullable<TransformNode>;
  14379. /** @hidden */
  14380. _waitingTransformNodeId: Nullable<string>;
  14381. /** @hidden */
  14382. get _matrix(): Matrix;
  14383. /** @hidden */
  14384. set _matrix(value: Matrix);
  14385. /**
  14386. * Create a new bone
  14387. * @param name defines the bone name
  14388. * @param skeleton defines the parent skeleton
  14389. * @param parentBone defines the parent (can be null if the bone is the root)
  14390. * @param localMatrix defines the local matrix
  14391. * @param restPose defines the rest pose matrix
  14392. * @param baseMatrix defines the base matrix
  14393. * @param index defines index of the bone in the hiearchy
  14394. */
  14395. constructor(
  14396. /**
  14397. * defines the bone name
  14398. */
  14399. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14400. /**
  14401. * Gets the current object class name.
  14402. * @return the class name
  14403. */
  14404. getClassName(): string;
  14405. /**
  14406. * Gets the parent skeleton
  14407. * @returns a skeleton
  14408. */
  14409. getSkeleton(): Skeleton;
  14410. /**
  14411. * Gets parent bone
  14412. * @returns a bone or null if the bone is the root of the bone hierarchy
  14413. */
  14414. getParent(): Nullable<Bone>;
  14415. /**
  14416. * Returns an array containing the root bones
  14417. * @returns an array containing the root bones
  14418. */
  14419. getChildren(): Array<Bone>;
  14420. /**
  14421. * Gets the node index in matrix array generated for rendering
  14422. * @returns the node index
  14423. */
  14424. getIndex(): number;
  14425. /**
  14426. * Sets the parent bone
  14427. * @param parent defines the parent (can be null if the bone is the root)
  14428. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14429. */
  14430. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14431. /**
  14432. * Gets the local matrix
  14433. * @returns a matrix
  14434. */
  14435. getLocalMatrix(): Matrix;
  14436. /**
  14437. * Gets the base matrix (initial matrix which remains unchanged)
  14438. * @returns a matrix
  14439. */
  14440. getBaseMatrix(): Matrix;
  14441. /**
  14442. * Gets the rest pose matrix
  14443. * @returns a matrix
  14444. */
  14445. getRestPose(): Matrix;
  14446. /**
  14447. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14448. */
  14449. getWorldMatrix(): Matrix;
  14450. /**
  14451. * Sets the local matrix to rest pose matrix
  14452. */
  14453. returnToRest(): void;
  14454. /**
  14455. * Gets the inverse of the absolute transform matrix.
  14456. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14457. * @returns a matrix
  14458. */
  14459. getInvertedAbsoluteTransform(): Matrix;
  14460. /**
  14461. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14462. * @returns a matrix
  14463. */
  14464. getAbsoluteTransform(): Matrix;
  14465. /**
  14466. * Links with the given transform node.
  14467. * The local matrix of this bone is copied from the transform node every frame.
  14468. * @param transformNode defines the transform node to link to
  14469. */
  14470. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14471. /**
  14472. * Gets the node used to drive the bone's transformation
  14473. * @returns a transform node or null
  14474. */
  14475. getTransformNode(): Nullable<TransformNode>;
  14476. /** Gets or sets current position (in local space) */
  14477. get position(): Vector3;
  14478. set position(newPosition: Vector3);
  14479. /** Gets or sets current rotation (in local space) */
  14480. get rotation(): Vector3;
  14481. set rotation(newRotation: Vector3);
  14482. /** Gets or sets current rotation quaternion (in local space) */
  14483. get rotationQuaternion(): Quaternion;
  14484. set rotationQuaternion(newRotation: Quaternion);
  14485. /** Gets or sets current scaling (in local space) */
  14486. get scaling(): Vector3;
  14487. set scaling(newScaling: Vector3);
  14488. /**
  14489. * Gets the animation properties override
  14490. */
  14491. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14492. private _decompose;
  14493. private _compose;
  14494. /**
  14495. * Update the base and local matrices
  14496. * @param matrix defines the new base or local matrix
  14497. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14498. * @param updateLocalMatrix defines if the local matrix should be updated
  14499. */
  14500. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14501. /** @hidden */
  14502. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14503. /**
  14504. * Flag the bone as dirty (Forcing it to update everything)
  14505. */
  14506. markAsDirty(): void;
  14507. /** @hidden */
  14508. _markAsDirtyAndCompose(): void;
  14509. private _markAsDirtyAndDecompose;
  14510. /**
  14511. * Translate the bone in local or world space
  14512. * @param vec The amount to translate the bone
  14513. * @param space The space that the translation is in
  14514. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14515. */
  14516. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14517. /**
  14518. * Set the postion of the bone in local or world space
  14519. * @param position The position to set the bone
  14520. * @param space The space that the position is in
  14521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14522. */
  14523. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14524. /**
  14525. * Set the absolute position of the bone (world space)
  14526. * @param position The position to set the bone
  14527. * @param mesh The mesh that this bone is attached to
  14528. */
  14529. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14530. /**
  14531. * Scale the bone on the x, y and z axes (in local space)
  14532. * @param x The amount to scale the bone on the x axis
  14533. * @param y The amount to scale the bone on the y axis
  14534. * @param z The amount to scale the bone on the z axis
  14535. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14536. */
  14537. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14538. /**
  14539. * Set the bone scaling in local space
  14540. * @param scale defines the scaling vector
  14541. */
  14542. setScale(scale: Vector3): void;
  14543. /**
  14544. * Gets the current scaling in local space
  14545. * @returns the current scaling vector
  14546. */
  14547. getScale(): Vector3;
  14548. /**
  14549. * Gets the current scaling in local space and stores it in a target vector
  14550. * @param result defines the target vector
  14551. */
  14552. getScaleToRef(result: Vector3): void;
  14553. /**
  14554. * Set the yaw, pitch, and roll of the bone in local or world space
  14555. * @param yaw The rotation of the bone on the y axis
  14556. * @param pitch The rotation of the bone on the x axis
  14557. * @param roll The rotation of the bone on the z axis
  14558. * @param space The space that the axes of rotation are in
  14559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14560. */
  14561. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14562. /**
  14563. * Add a rotation to the bone on an axis in local or world space
  14564. * @param axis The axis to rotate the bone on
  14565. * @param amount The amount to rotate the bone
  14566. * @param space The space that the axis is in
  14567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14568. */
  14569. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14570. /**
  14571. * Set the rotation of the bone to a particular axis angle in local or world space
  14572. * @param axis The axis to rotate the bone on
  14573. * @param angle The angle that the bone should be rotated to
  14574. * @param space The space that the axis is in
  14575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14576. */
  14577. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14578. /**
  14579. * Set the euler rotation of the bone in local of world space
  14580. * @param rotation The euler rotation that the bone should be set to
  14581. * @param space The space that the rotation is in
  14582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14583. */
  14584. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14585. /**
  14586. * Set the quaternion rotation of the bone in local of world space
  14587. * @param quat The quaternion rotation that the bone should be set to
  14588. * @param space The space that the rotation is in
  14589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14590. */
  14591. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14592. /**
  14593. * Set the rotation matrix of the bone in local of world space
  14594. * @param rotMat The rotation matrix that the bone should be set to
  14595. * @param space The space that the rotation is in
  14596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14597. */
  14598. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14599. private _rotateWithMatrix;
  14600. private _getNegativeRotationToRef;
  14601. /**
  14602. * Get the position of the bone in local or world space
  14603. * @param space The space that the returned position is in
  14604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14605. * @returns The position of the bone
  14606. */
  14607. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14608. /**
  14609. * Copy the position of the bone to a vector3 in local or world space
  14610. * @param space The space that the returned position is in
  14611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14612. * @param result The vector3 to copy the position to
  14613. */
  14614. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14615. /**
  14616. * Get the absolute position of the bone (world space)
  14617. * @param mesh The mesh that this bone is attached to
  14618. * @returns The absolute position of the bone
  14619. */
  14620. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14621. /**
  14622. * Copy the absolute position of the bone (world space) to the result param
  14623. * @param mesh The mesh that this bone is attached to
  14624. * @param result The vector3 to copy the absolute position to
  14625. */
  14626. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14627. /**
  14628. * Compute the absolute transforms of this bone and its children
  14629. */
  14630. computeAbsoluteTransforms(): void;
  14631. /**
  14632. * Get the world direction from an axis that is in the local space of the bone
  14633. * @param localAxis The local direction that is used to compute the world direction
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @returns The world direction
  14636. */
  14637. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14638. /**
  14639. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14640. * @param localAxis The local direction that is used to compute the world direction
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @param result The vector3 that the world direction will be copied to
  14643. */
  14644. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14645. /**
  14646. * Get the euler rotation of the bone in local or world space
  14647. * @param space The space that the rotation should be in
  14648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14649. * @returns The euler rotation
  14650. */
  14651. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14652. /**
  14653. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14654. * @param space The space that the rotation should be in
  14655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14656. * @param result The vector3 that the rotation should be copied to
  14657. */
  14658. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14659. /**
  14660. * Get the quaternion rotation of the bone in either local or world space
  14661. * @param space The space that the rotation should be in
  14662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14663. * @returns The quaternion rotation
  14664. */
  14665. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14666. /**
  14667. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14668. * @param space The space that the rotation should be in
  14669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14670. * @param result The quaternion that the rotation should be copied to
  14671. */
  14672. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14673. /**
  14674. * Get the rotation matrix of the bone in local or world space
  14675. * @param space The space that the rotation should be in
  14676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14677. * @returns The rotation matrix
  14678. */
  14679. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14680. /**
  14681. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14682. * @param space The space that the rotation should be in
  14683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14684. * @param result The quaternion that the rotation should be copied to
  14685. */
  14686. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14687. /**
  14688. * Get the world position of a point that is in the local space of the bone
  14689. * @param position The local position
  14690. * @param mesh The mesh that this bone is attached to
  14691. * @returns The world position
  14692. */
  14693. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14694. /**
  14695. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14696. * @param position The local position
  14697. * @param mesh The mesh that this bone is attached to
  14698. * @param result The vector3 that the world position should be copied to
  14699. */
  14700. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14701. /**
  14702. * Get the local position of a point that is in world space
  14703. * @param position The world position
  14704. * @param mesh The mesh that this bone is attached to
  14705. * @returns The local position
  14706. */
  14707. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14708. /**
  14709. * Get the local position of a point that is in world space and copy it to the result param
  14710. * @param position The world position
  14711. * @param mesh The mesh that this bone is attached to
  14712. * @param result The vector3 that the local position should be copied to
  14713. */
  14714. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14715. }
  14716. }
  14717. declare module "babylonjs/Animations/runtimeAnimation" {
  14718. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14719. import { Animatable } from "babylonjs/Animations/animatable";
  14720. import { Scene } from "babylonjs/scene";
  14721. /**
  14722. * Defines a runtime animation
  14723. */
  14724. export class RuntimeAnimation {
  14725. private _events;
  14726. /**
  14727. * The current frame of the runtime animation
  14728. */
  14729. private _currentFrame;
  14730. /**
  14731. * The animation used by the runtime animation
  14732. */
  14733. private _animation;
  14734. /**
  14735. * The target of the runtime animation
  14736. */
  14737. private _target;
  14738. /**
  14739. * The initiating animatable
  14740. */
  14741. private _host;
  14742. /**
  14743. * The original value of the runtime animation
  14744. */
  14745. private _originalValue;
  14746. /**
  14747. * The original blend value of the runtime animation
  14748. */
  14749. private _originalBlendValue;
  14750. /**
  14751. * The offsets cache of the runtime animation
  14752. */
  14753. private _offsetsCache;
  14754. /**
  14755. * The high limits cache of the runtime animation
  14756. */
  14757. private _highLimitsCache;
  14758. /**
  14759. * Specifies if the runtime animation has been stopped
  14760. */
  14761. private _stopped;
  14762. /**
  14763. * The blending factor of the runtime animation
  14764. */
  14765. private _blendingFactor;
  14766. /**
  14767. * The BabylonJS scene
  14768. */
  14769. private _scene;
  14770. /**
  14771. * The current value of the runtime animation
  14772. */
  14773. private _currentValue;
  14774. /** @hidden */
  14775. _animationState: _IAnimationState;
  14776. /**
  14777. * The active target of the runtime animation
  14778. */
  14779. private _activeTargets;
  14780. private _currentActiveTarget;
  14781. private _directTarget;
  14782. /**
  14783. * The target path of the runtime animation
  14784. */
  14785. private _targetPath;
  14786. /**
  14787. * The weight of the runtime animation
  14788. */
  14789. private _weight;
  14790. /**
  14791. * The ratio offset of the runtime animation
  14792. */
  14793. private _ratioOffset;
  14794. /**
  14795. * The previous delay of the runtime animation
  14796. */
  14797. private _previousDelay;
  14798. /**
  14799. * The previous ratio of the runtime animation
  14800. */
  14801. private _previousRatio;
  14802. private _enableBlending;
  14803. private _keys;
  14804. private _minFrame;
  14805. private _maxFrame;
  14806. private _minValue;
  14807. private _maxValue;
  14808. private _targetIsArray;
  14809. /**
  14810. * Gets the current frame of the runtime animation
  14811. */
  14812. get currentFrame(): number;
  14813. /**
  14814. * Gets the weight of the runtime animation
  14815. */
  14816. get weight(): number;
  14817. /**
  14818. * Gets the current value of the runtime animation
  14819. */
  14820. get currentValue(): any;
  14821. /**
  14822. * Gets the target path of the runtime animation
  14823. */
  14824. get targetPath(): string;
  14825. /**
  14826. * Gets the actual target of the runtime animation
  14827. */
  14828. get target(): any;
  14829. /** @hidden */
  14830. _onLoop: () => void;
  14831. /**
  14832. * Create a new RuntimeAnimation object
  14833. * @param target defines the target of the animation
  14834. * @param animation defines the source animation object
  14835. * @param scene defines the hosting scene
  14836. * @param host defines the initiating Animatable
  14837. */
  14838. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14839. private _preparePath;
  14840. /**
  14841. * Gets the animation from the runtime animation
  14842. */
  14843. get animation(): Animation;
  14844. /**
  14845. * Resets the runtime animation to the beginning
  14846. * @param restoreOriginal defines whether to restore the target property to the original value
  14847. */
  14848. reset(restoreOriginal?: boolean): void;
  14849. /**
  14850. * Specifies if the runtime animation is stopped
  14851. * @returns Boolean specifying if the runtime animation is stopped
  14852. */
  14853. isStopped(): boolean;
  14854. /**
  14855. * Disposes of the runtime animation
  14856. */
  14857. dispose(): void;
  14858. /**
  14859. * Apply the interpolated value to the target
  14860. * @param currentValue defines the value computed by the animation
  14861. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14862. */
  14863. setValue(currentValue: any, weight: number): void;
  14864. private _getOriginalValues;
  14865. private _setValue;
  14866. /**
  14867. * Gets the loop pmode of the runtime animation
  14868. * @returns Loop Mode
  14869. */
  14870. private _getCorrectLoopMode;
  14871. /**
  14872. * Move the current animation to a given frame
  14873. * @param frame defines the frame to move to
  14874. */
  14875. goToFrame(frame: number): void;
  14876. /**
  14877. * @hidden Internal use only
  14878. */
  14879. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14880. /**
  14881. * Execute the current animation
  14882. * @param delay defines the delay to add to the current frame
  14883. * @param from defines the lower bound of the animation range
  14884. * @param to defines the upper bound of the animation range
  14885. * @param loop defines if the current animation must loop
  14886. * @param speedRatio defines the current speed ratio
  14887. * @param weight defines the weight of the animation (default is -1 so no weight)
  14888. * @param onLoop optional callback called when animation loops
  14889. * @returns a boolean indicating if the animation is running
  14890. */
  14891. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14892. }
  14893. }
  14894. declare module "babylonjs/Animations/animatable" {
  14895. import { Animation } from "babylonjs/Animations/animation";
  14896. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14897. import { Nullable } from "babylonjs/types";
  14898. import { Observable } from "babylonjs/Misc/observable";
  14899. import { Scene } from "babylonjs/scene";
  14900. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14901. import { Node } from "babylonjs/node";
  14902. /**
  14903. * Class used to store an actual running animation
  14904. */
  14905. export class Animatable {
  14906. /** defines the target object */
  14907. target: any;
  14908. /** defines the starting frame number (default is 0) */
  14909. fromFrame: number;
  14910. /** defines the ending frame number (default is 100) */
  14911. toFrame: number;
  14912. /** defines if the animation must loop (default is false) */
  14913. loopAnimation: boolean;
  14914. /** defines a callback to call when animation ends if it is not looping */
  14915. onAnimationEnd?: (() => void) | null | undefined;
  14916. /** defines a callback to call when animation loops */
  14917. onAnimationLoop?: (() => void) | null | undefined;
  14918. private _localDelayOffset;
  14919. private _pausedDelay;
  14920. private _runtimeAnimations;
  14921. private _paused;
  14922. private _scene;
  14923. private _speedRatio;
  14924. private _weight;
  14925. private _syncRoot;
  14926. /**
  14927. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14928. * This will only apply for non looping animation (default is true)
  14929. */
  14930. disposeOnEnd: boolean;
  14931. /**
  14932. * Gets a boolean indicating if the animation has started
  14933. */
  14934. animationStarted: boolean;
  14935. /**
  14936. * Observer raised when the animation ends
  14937. */
  14938. onAnimationEndObservable: Observable<Animatable>;
  14939. /**
  14940. * Observer raised when the animation loops
  14941. */
  14942. onAnimationLoopObservable: Observable<Animatable>;
  14943. /**
  14944. * Gets the root Animatable used to synchronize and normalize animations
  14945. */
  14946. get syncRoot(): Nullable<Animatable>;
  14947. /**
  14948. * Gets the current frame of the first RuntimeAnimation
  14949. * Used to synchronize Animatables
  14950. */
  14951. get masterFrame(): number;
  14952. /**
  14953. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14954. */
  14955. get weight(): number;
  14956. set weight(value: number);
  14957. /**
  14958. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14959. */
  14960. get speedRatio(): number;
  14961. set speedRatio(value: number);
  14962. /**
  14963. * Creates a new Animatable
  14964. * @param scene defines the hosting scene
  14965. * @param target defines the target object
  14966. * @param fromFrame defines the starting frame number (default is 0)
  14967. * @param toFrame defines the ending frame number (default is 100)
  14968. * @param loopAnimation defines if the animation must loop (default is false)
  14969. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14970. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14971. * @param animations defines a group of animation to add to the new Animatable
  14972. * @param onAnimationLoop defines a callback to call when animation loops
  14973. */
  14974. constructor(scene: Scene,
  14975. /** defines the target object */
  14976. target: any,
  14977. /** defines the starting frame number (default is 0) */
  14978. fromFrame?: number,
  14979. /** defines the ending frame number (default is 100) */
  14980. toFrame?: number,
  14981. /** defines if the animation must loop (default is false) */
  14982. loopAnimation?: boolean, speedRatio?: number,
  14983. /** defines a callback to call when animation ends if it is not looping */
  14984. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14985. /** defines a callback to call when animation loops */
  14986. onAnimationLoop?: (() => void) | null | undefined);
  14987. /**
  14988. * Synchronize and normalize current Animatable with a source Animatable
  14989. * This is useful when using animation weights and when animations are not of the same length
  14990. * @param root defines the root Animatable to synchronize with
  14991. * @returns the current Animatable
  14992. */
  14993. syncWith(root: Animatable): Animatable;
  14994. /**
  14995. * Gets the list of runtime animations
  14996. * @returns an array of RuntimeAnimation
  14997. */
  14998. getAnimations(): RuntimeAnimation[];
  14999. /**
  15000. * Adds more animations to the current animatable
  15001. * @param target defines the target of the animations
  15002. * @param animations defines the new animations to add
  15003. */
  15004. appendAnimations(target: any, animations: Animation[]): void;
  15005. /**
  15006. * Gets the source animation for a specific property
  15007. * @param property defines the propertyu to look for
  15008. * @returns null or the source animation for the given property
  15009. */
  15010. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15011. /**
  15012. * Gets the runtime animation for a specific property
  15013. * @param property defines the propertyu to look for
  15014. * @returns null or the runtime animation for the given property
  15015. */
  15016. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15017. /**
  15018. * Resets the animatable to its original state
  15019. */
  15020. reset(): void;
  15021. /**
  15022. * Allows the animatable to blend with current running animations
  15023. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15024. * @param blendingSpeed defines the blending speed to use
  15025. */
  15026. enableBlending(blendingSpeed: number): void;
  15027. /**
  15028. * Disable animation blending
  15029. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15030. */
  15031. disableBlending(): void;
  15032. /**
  15033. * Jump directly to a given frame
  15034. * @param frame defines the frame to jump to
  15035. */
  15036. goToFrame(frame: number): void;
  15037. /**
  15038. * Pause the animation
  15039. */
  15040. pause(): void;
  15041. /**
  15042. * Restart the animation
  15043. */
  15044. restart(): void;
  15045. private _raiseOnAnimationEnd;
  15046. /**
  15047. * Stop and delete the current animation
  15048. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15049. * @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)
  15050. */
  15051. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15052. /**
  15053. * Wait asynchronously for the animation to end
  15054. * @returns a promise which will be fullfilled when the animation ends
  15055. */
  15056. waitAsync(): Promise<Animatable>;
  15057. /** @hidden */
  15058. _animate(delay: number): boolean;
  15059. }
  15060. module "babylonjs/scene" {
  15061. interface Scene {
  15062. /** @hidden */
  15063. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15064. /** @hidden */
  15065. _processLateAnimationBindingsForMatrices(holder: {
  15066. totalWeight: number;
  15067. animations: RuntimeAnimation[];
  15068. originalValue: Matrix;
  15069. }): any;
  15070. /** @hidden */
  15071. _processLateAnimationBindingsForQuaternions(holder: {
  15072. totalWeight: number;
  15073. animations: RuntimeAnimation[];
  15074. originalValue: Quaternion;
  15075. }, refQuaternion: Quaternion): Quaternion;
  15076. /** @hidden */
  15077. _processLateAnimationBindings(): void;
  15078. /**
  15079. * Will start the animation sequence of a given target
  15080. * @param target defines the target
  15081. * @param from defines from which frame should animation start
  15082. * @param to defines until which frame should animation run.
  15083. * @param weight defines the weight to apply to the animation (1.0 by default)
  15084. * @param loop defines if the animation loops
  15085. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15086. * @param onAnimationEnd defines the function to be executed when the animation ends
  15087. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15088. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15089. * @param onAnimationLoop defines the callback to call when an animation loops
  15090. * @returns the animatable object created for this animation
  15091. */
  15092. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15093. /**
  15094. * Will start the animation sequence of a given target
  15095. * @param target defines the target
  15096. * @param from defines from which frame should animation start
  15097. * @param to defines until which frame should animation run.
  15098. * @param loop defines if the animation loops
  15099. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15100. * @param onAnimationEnd defines the function to be executed when the animation ends
  15101. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15102. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15103. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15104. * @param onAnimationLoop defines the callback to call when an animation loops
  15105. * @returns the animatable object created for this animation
  15106. */
  15107. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15108. /**
  15109. * Will start the animation sequence of a given target and its hierarchy
  15110. * @param target defines the target
  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 from defines from which frame should animation start
  15113. * @param to defines until which frame should animation run.
  15114. * @param loop defines if the animation loops
  15115. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15116. * @param onAnimationEnd defines the function to be executed when the animation ends
  15117. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15118. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15119. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15120. * @param onAnimationLoop defines the callback to call when an animation loops
  15121. * @returns the list of created animatables
  15122. */
  15123. 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[];
  15124. /**
  15125. * Begin a new animation on a given node
  15126. * @param target defines the target where the animation will take place
  15127. * @param animations defines the list of animations to start
  15128. * @param from defines the initial value
  15129. * @param to defines the final value
  15130. * @param loop defines if you want animation to loop (off by default)
  15131. * @param speedRatio defines the speed ratio to apply to all animations
  15132. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15133. * @param onAnimationLoop defines the callback to call when an animation loops
  15134. * @returns the list of created animatables
  15135. */
  15136. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15137. /**
  15138. * Begin a new animation on a given node and its hierarchy
  15139. * @param target defines the root node where the animation will take place
  15140. * @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.
  15141. * @param animations defines the list of animations to start
  15142. * @param from defines the initial value
  15143. * @param to defines the final value
  15144. * @param loop defines if you want animation to loop (off by default)
  15145. * @param speedRatio defines the speed ratio to apply to all animations
  15146. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15147. * @param onAnimationLoop defines the callback to call when an animation loops
  15148. * @returns the list of animatables created for all nodes
  15149. */
  15150. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15151. /**
  15152. * Gets the animatable associated with a specific target
  15153. * @param target defines the target of the animatable
  15154. * @returns the required animatable if found
  15155. */
  15156. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15157. /**
  15158. * Gets all animatables associated with a given target
  15159. * @param target defines the target to look animatables for
  15160. * @returns an array of Animatables
  15161. */
  15162. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15163. /**
  15164. * Stops and removes all animations that have been applied to the scene
  15165. */
  15166. stopAllAnimations(): void;
  15167. /**
  15168. * Gets the current delta time used by animation engine
  15169. */
  15170. deltaTime: number;
  15171. }
  15172. }
  15173. module "babylonjs/Bones/bone" {
  15174. interface Bone {
  15175. /**
  15176. * Copy an animation range from another bone
  15177. * @param source defines the source bone
  15178. * @param rangeName defines the range name to copy
  15179. * @param frameOffset defines the frame offset
  15180. * @param rescaleAsRequired defines if rescaling must be applied if required
  15181. * @param skelDimensionsRatio defines the scaling ratio
  15182. * @returns true if operation was successful
  15183. */
  15184. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15185. }
  15186. }
  15187. }
  15188. declare module "babylonjs/Bones/skeleton" {
  15189. import { Bone } from "babylonjs/Bones/bone";
  15190. import { Observable } from "babylonjs/Misc/observable";
  15191. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15192. import { Scene } from "babylonjs/scene";
  15193. import { Nullable } from "babylonjs/types";
  15194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15195. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15196. import { Animatable } from "babylonjs/Animations/animatable";
  15197. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15198. import { Animation } from "babylonjs/Animations/animation";
  15199. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15200. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15201. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15202. /**
  15203. * Class used to handle skinning animations
  15204. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15205. */
  15206. export class Skeleton implements IAnimatable {
  15207. /** defines the skeleton name */
  15208. name: string;
  15209. /** defines the skeleton Id */
  15210. id: string;
  15211. /**
  15212. * Defines the list of child bones
  15213. */
  15214. bones: Bone[];
  15215. /**
  15216. * Defines an estimate of the dimension of the skeleton at rest
  15217. */
  15218. dimensionsAtRest: Vector3;
  15219. /**
  15220. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15221. */
  15222. needInitialSkinMatrix: boolean;
  15223. /**
  15224. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15225. */
  15226. overrideMesh: Nullable<AbstractMesh>;
  15227. /**
  15228. * Gets the list of animations attached to this skeleton
  15229. */
  15230. animations: Array<Animation>;
  15231. private _scene;
  15232. private _isDirty;
  15233. private _transformMatrices;
  15234. private _transformMatrixTexture;
  15235. private _meshesWithPoseMatrix;
  15236. private _animatables;
  15237. private _identity;
  15238. private _synchronizedWithMesh;
  15239. private _ranges;
  15240. private _lastAbsoluteTransformsUpdateId;
  15241. private _canUseTextureForBones;
  15242. private _uniqueId;
  15243. /** @hidden */
  15244. _numBonesWithLinkedTransformNode: number;
  15245. /** @hidden */
  15246. _hasWaitingData: Nullable<boolean>;
  15247. /**
  15248. * Specifies if the skeleton should be serialized
  15249. */
  15250. doNotSerialize: boolean;
  15251. private _useTextureToStoreBoneMatrices;
  15252. /**
  15253. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15254. * Please note that this option is not available if the hardware does not support it
  15255. */
  15256. get useTextureToStoreBoneMatrices(): boolean;
  15257. set useTextureToStoreBoneMatrices(value: boolean);
  15258. private _animationPropertiesOverride;
  15259. /**
  15260. * Gets or sets the animation properties override
  15261. */
  15262. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15263. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15264. /**
  15265. * List of inspectable custom properties (used by the Inspector)
  15266. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15267. */
  15268. inspectableCustomProperties: IInspectable[];
  15269. /**
  15270. * An observable triggered before computing the skeleton's matrices
  15271. */
  15272. onBeforeComputeObservable: Observable<Skeleton>;
  15273. /**
  15274. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15275. */
  15276. get isUsingTextureForMatrices(): boolean;
  15277. /**
  15278. * Gets the unique ID of this skeleton
  15279. */
  15280. get uniqueId(): number;
  15281. /**
  15282. * Creates a new skeleton
  15283. * @param name defines the skeleton name
  15284. * @param id defines the skeleton Id
  15285. * @param scene defines the hosting scene
  15286. */
  15287. constructor(
  15288. /** defines the skeleton name */
  15289. name: string,
  15290. /** defines the skeleton Id */
  15291. id: string, scene: Scene);
  15292. /**
  15293. * Gets the current object class name.
  15294. * @return the class name
  15295. */
  15296. getClassName(): string;
  15297. /**
  15298. * Returns an array containing the root bones
  15299. * @returns an array containing the root bones
  15300. */
  15301. getChildren(): Array<Bone>;
  15302. /**
  15303. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15304. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15305. * @returns a Float32Array containing matrices data
  15306. */
  15307. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15308. /**
  15309. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15310. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15311. * @returns a raw texture containing the data
  15312. */
  15313. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15314. /**
  15315. * Gets the current hosting scene
  15316. * @returns a scene object
  15317. */
  15318. getScene(): Scene;
  15319. /**
  15320. * Gets a string representing the current skeleton data
  15321. * @param fullDetails defines a boolean indicating if we want a verbose version
  15322. * @returns a string representing the current skeleton data
  15323. */
  15324. toString(fullDetails?: boolean): string;
  15325. /**
  15326. * Get bone's index searching by name
  15327. * @param name defines bone's name to search for
  15328. * @return the indice of the bone. Returns -1 if not found
  15329. */
  15330. getBoneIndexByName(name: string): number;
  15331. /**
  15332. * Creater a new animation range
  15333. * @param name defines the name of the range
  15334. * @param from defines the start key
  15335. * @param to defines the end key
  15336. */
  15337. createAnimationRange(name: string, from: number, to: number): void;
  15338. /**
  15339. * Delete a specific animation range
  15340. * @param name defines the name of the range
  15341. * @param deleteFrames defines if frames must be removed as well
  15342. */
  15343. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15344. /**
  15345. * Gets a specific animation range
  15346. * @param name defines the name of the range to look for
  15347. * @returns the requested animation range or null if not found
  15348. */
  15349. getAnimationRange(name: string): Nullable<AnimationRange>;
  15350. /**
  15351. * Gets the list of all animation ranges defined on this skeleton
  15352. * @returns an array
  15353. */
  15354. getAnimationRanges(): Nullable<AnimationRange>[];
  15355. /**
  15356. * Copy animation range from a source skeleton.
  15357. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15358. * @param source defines the source skeleton
  15359. * @param name defines the name of the range to copy
  15360. * @param rescaleAsRequired defines if rescaling must be applied if required
  15361. * @returns true if operation was successful
  15362. */
  15363. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15364. /**
  15365. * Forces the skeleton to go to rest pose
  15366. */
  15367. returnToRest(): void;
  15368. private _getHighestAnimationFrame;
  15369. /**
  15370. * Begin a specific animation range
  15371. * @param name defines the name of the range to start
  15372. * @param loop defines if looping must be turned on (false by default)
  15373. * @param speedRatio defines the speed ratio to apply (1 by default)
  15374. * @param onAnimationEnd defines a callback which will be called when animation will end
  15375. * @returns a new animatable
  15376. */
  15377. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15378. /** @hidden */
  15379. _markAsDirty(): void;
  15380. /** @hidden */
  15381. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15382. /** @hidden */
  15383. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15384. private _computeTransformMatrices;
  15385. /**
  15386. * Build all resources required to render a skeleton
  15387. */
  15388. prepare(): void;
  15389. /**
  15390. * Gets the list of animatables currently running for this skeleton
  15391. * @returns an array of animatables
  15392. */
  15393. getAnimatables(): IAnimatable[];
  15394. /**
  15395. * Clone the current skeleton
  15396. * @param name defines the name of the new skeleton
  15397. * @param id defines the id of the new skeleton
  15398. * @returns the new skeleton
  15399. */
  15400. clone(name: string, id?: string): Skeleton;
  15401. /**
  15402. * Enable animation blending for this skeleton
  15403. * @param blendingSpeed defines the blending speed to apply
  15404. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15405. */
  15406. enableBlending(blendingSpeed?: number): void;
  15407. /**
  15408. * Releases all resources associated with the current skeleton
  15409. */
  15410. dispose(): void;
  15411. /**
  15412. * Serialize the skeleton in a JSON object
  15413. * @returns a JSON object
  15414. */
  15415. serialize(): any;
  15416. /**
  15417. * Creates a new skeleton from serialized data
  15418. * @param parsedSkeleton defines the serialized data
  15419. * @param scene defines the hosting scene
  15420. * @returns a new skeleton
  15421. */
  15422. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15423. /**
  15424. * Compute all node absolute transforms
  15425. * @param forceUpdate defines if computation must be done even if cache is up to date
  15426. */
  15427. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15428. /**
  15429. * Gets the root pose matrix
  15430. * @returns a matrix
  15431. */
  15432. getPoseMatrix(): Nullable<Matrix>;
  15433. /**
  15434. * Sorts bones per internal index
  15435. */
  15436. sortBones(): void;
  15437. private _sortBones;
  15438. }
  15439. }
  15440. declare module "babylonjs/Meshes/instancedMesh" {
  15441. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15442. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15443. import { Camera } from "babylonjs/Cameras/camera";
  15444. import { Node } from "babylonjs/node";
  15445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15446. import { Mesh } from "babylonjs/Meshes/mesh";
  15447. import { Material } from "babylonjs/Materials/material";
  15448. import { Skeleton } from "babylonjs/Bones/skeleton";
  15449. import { Light } from "babylonjs/Lights/light";
  15450. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15451. /**
  15452. * Creates an instance based on a source mesh.
  15453. */
  15454. export class InstancedMesh extends AbstractMesh {
  15455. private _sourceMesh;
  15456. private _currentLOD;
  15457. /** @hidden */
  15458. _indexInSourceMeshInstanceArray: number;
  15459. constructor(name: string, source: Mesh);
  15460. /**
  15461. * Returns the string "InstancedMesh".
  15462. */
  15463. getClassName(): string;
  15464. /** Gets the list of lights affecting that mesh */
  15465. get lightSources(): Light[];
  15466. _resyncLightSources(): void;
  15467. _resyncLightSource(light: Light): void;
  15468. _removeLightSource(light: Light, dispose: boolean): void;
  15469. /**
  15470. * If the source mesh receives shadows
  15471. */
  15472. get receiveShadows(): boolean;
  15473. /**
  15474. * The material of the source mesh
  15475. */
  15476. get material(): Nullable<Material>;
  15477. /**
  15478. * Visibility of the source mesh
  15479. */
  15480. get visibility(): number;
  15481. /**
  15482. * Skeleton of the source mesh
  15483. */
  15484. get skeleton(): Nullable<Skeleton>;
  15485. /**
  15486. * Rendering ground id of the source mesh
  15487. */
  15488. get renderingGroupId(): number;
  15489. set renderingGroupId(value: number);
  15490. /**
  15491. * Returns the total number of vertices (integer).
  15492. */
  15493. getTotalVertices(): number;
  15494. /**
  15495. * Returns a positive integer : the total number of indices in this mesh geometry.
  15496. * @returns the numner of indices or zero if the mesh has no geometry.
  15497. */
  15498. getTotalIndices(): number;
  15499. /**
  15500. * The source mesh of the instance
  15501. */
  15502. get sourceMesh(): Mesh;
  15503. /**
  15504. * Is this node ready to be used/rendered
  15505. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15506. * @return {boolean} is it ready
  15507. */
  15508. isReady(completeCheck?: boolean): boolean;
  15509. /**
  15510. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15511. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15512. * @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.
  15513. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15514. */
  15515. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15516. /**
  15517. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15518. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15519. * The `data` are either a numeric array either a Float32Array.
  15520. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15521. * 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).
  15522. * Note that a new underlying VertexBuffer object is created each call.
  15523. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15524. *
  15525. * Possible `kind` values :
  15526. * - VertexBuffer.PositionKind
  15527. * - VertexBuffer.UVKind
  15528. * - VertexBuffer.UV2Kind
  15529. * - VertexBuffer.UV3Kind
  15530. * - VertexBuffer.UV4Kind
  15531. * - VertexBuffer.UV5Kind
  15532. * - VertexBuffer.UV6Kind
  15533. * - VertexBuffer.ColorKind
  15534. * - VertexBuffer.MatricesIndicesKind
  15535. * - VertexBuffer.MatricesIndicesExtraKind
  15536. * - VertexBuffer.MatricesWeightsKind
  15537. * - VertexBuffer.MatricesWeightsExtraKind
  15538. *
  15539. * Returns the Mesh.
  15540. */
  15541. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15542. /**
  15543. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15544. * If the mesh has no geometry, it is simply returned as it is.
  15545. * The `data` are either a numeric array either a Float32Array.
  15546. * No new underlying VertexBuffer object is created.
  15547. * 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.
  15548. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15549. *
  15550. * Possible `kind` values :
  15551. * - VertexBuffer.PositionKind
  15552. * - VertexBuffer.UVKind
  15553. * - VertexBuffer.UV2Kind
  15554. * - VertexBuffer.UV3Kind
  15555. * - VertexBuffer.UV4Kind
  15556. * - VertexBuffer.UV5Kind
  15557. * - VertexBuffer.UV6Kind
  15558. * - VertexBuffer.ColorKind
  15559. * - VertexBuffer.MatricesIndicesKind
  15560. * - VertexBuffer.MatricesIndicesExtraKind
  15561. * - VertexBuffer.MatricesWeightsKind
  15562. * - VertexBuffer.MatricesWeightsExtraKind
  15563. *
  15564. * Returns the Mesh.
  15565. */
  15566. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15567. /**
  15568. * Sets the mesh indices.
  15569. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15570. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15571. * This method creates a new index buffer each call.
  15572. * Returns the Mesh.
  15573. */
  15574. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15575. /**
  15576. * Boolean : True if the mesh owns the requested kind of data.
  15577. */
  15578. isVerticesDataPresent(kind: string): boolean;
  15579. /**
  15580. * Returns an array of indices (IndicesArray).
  15581. */
  15582. getIndices(): Nullable<IndicesArray>;
  15583. get _positions(): Nullable<Vector3[]>;
  15584. /**
  15585. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15586. * This means the mesh underlying bounding box and sphere are recomputed.
  15587. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15588. * @returns the current mesh
  15589. */
  15590. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15591. /** @hidden */
  15592. _preActivate(): InstancedMesh;
  15593. /** @hidden */
  15594. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15595. /** @hidden */
  15596. _postActivate(): void;
  15597. getWorldMatrix(): Matrix;
  15598. get isAnInstance(): boolean;
  15599. /**
  15600. * Returns the current associated LOD AbstractMesh.
  15601. */
  15602. getLOD(camera: Camera): AbstractMesh;
  15603. /** @hidden */
  15604. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15605. /** @hidden */
  15606. _syncSubMeshes(): InstancedMesh;
  15607. /** @hidden */
  15608. _generatePointsArray(): boolean;
  15609. /**
  15610. * Creates a new InstancedMesh from the current mesh.
  15611. * - name (string) : the cloned mesh name
  15612. * - newParent (optional Node) : the optional Node to parent the clone to.
  15613. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15614. *
  15615. * Returns the clone.
  15616. */
  15617. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15618. /**
  15619. * Disposes the InstancedMesh.
  15620. * Returns nothing.
  15621. */
  15622. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15623. }
  15624. module "babylonjs/Meshes/mesh" {
  15625. interface Mesh {
  15626. /**
  15627. * Register a custom buffer that will be instanced
  15628. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15629. * @param kind defines the buffer kind
  15630. * @param stride defines the stride in floats
  15631. */
  15632. registerInstancedBuffer(kind: string, stride: number): void;
  15633. /** @hidden */
  15634. _userInstancedBuffersStorage: {
  15635. data: {
  15636. [key: string]: Float32Array;
  15637. };
  15638. sizes: {
  15639. [key: string]: number;
  15640. };
  15641. vertexBuffers: {
  15642. [key: string]: Nullable<VertexBuffer>;
  15643. };
  15644. strides: {
  15645. [key: string]: number;
  15646. };
  15647. };
  15648. }
  15649. }
  15650. module "babylonjs/Meshes/abstractMesh" {
  15651. interface AbstractMesh {
  15652. /**
  15653. * Object used to store instanced buffers defined by user
  15654. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15655. */
  15656. instancedBuffers: {
  15657. [key: string]: any;
  15658. };
  15659. }
  15660. }
  15661. }
  15662. declare module "babylonjs/Materials/shaderMaterial" {
  15663. import { Scene } from "babylonjs/scene";
  15664. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15666. import { Mesh } from "babylonjs/Meshes/mesh";
  15667. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15669. import { Texture } from "babylonjs/Materials/Textures/texture";
  15670. import { Material } from "babylonjs/Materials/material";
  15671. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15672. /**
  15673. * Defines the options associated with the creation of a shader material.
  15674. */
  15675. export interface IShaderMaterialOptions {
  15676. /**
  15677. * Does the material work in alpha blend mode
  15678. */
  15679. needAlphaBlending: boolean;
  15680. /**
  15681. * Does the material work in alpha test mode
  15682. */
  15683. needAlphaTesting: boolean;
  15684. /**
  15685. * The list of attribute names used in the shader
  15686. */
  15687. attributes: string[];
  15688. /**
  15689. * The list of unifrom names used in the shader
  15690. */
  15691. uniforms: string[];
  15692. /**
  15693. * The list of UBO names used in the shader
  15694. */
  15695. uniformBuffers: string[];
  15696. /**
  15697. * The list of sampler names used in the shader
  15698. */
  15699. samplers: string[];
  15700. /**
  15701. * The list of defines used in the shader
  15702. */
  15703. defines: string[];
  15704. }
  15705. /**
  15706. * 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.
  15707. *
  15708. * This returned material effects how the mesh will look based on the code in the shaders.
  15709. *
  15710. * @see http://doc.babylonjs.com/how_to/shader_material
  15711. */
  15712. export class ShaderMaterial extends Material {
  15713. private _shaderPath;
  15714. private _options;
  15715. private _textures;
  15716. private _textureArrays;
  15717. private _floats;
  15718. private _ints;
  15719. private _floatsArrays;
  15720. private _colors3;
  15721. private _colors3Arrays;
  15722. private _colors4;
  15723. private _colors4Arrays;
  15724. private _vectors2;
  15725. private _vectors3;
  15726. private _vectors4;
  15727. private _matrices;
  15728. private _matrixArrays;
  15729. private _matrices3x3;
  15730. private _matrices2x2;
  15731. private _vectors2Arrays;
  15732. private _vectors3Arrays;
  15733. private _vectors4Arrays;
  15734. private _cachedWorldViewMatrix;
  15735. private _cachedWorldViewProjectionMatrix;
  15736. private _renderId;
  15737. private _multiview;
  15738. /**
  15739. * Instantiate a new shader material.
  15740. * 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.
  15741. * This returned material effects how the mesh will look based on the code in the shaders.
  15742. * @see http://doc.babylonjs.com/how_to/shader_material
  15743. * @param name Define the name of the material in the scene
  15744. * @param scene Define the scene the material belongs to
  15745. * @param shaderPath Defines the route to the shader code in one of three ways:
  15746. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15747. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15748. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15749. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15750. * @param options Define the options used to create the shader
  15751. */
  15752. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15753. /**
  15754. * Gets the shader path used to define the shader code
  15755. * It can be modified to trigger a new compilation
  15756. */
  15757. get shaderPath(): any;
  15758. /**
  15759. * Sets the shader path used to define the shader code
  15760. * It can be modified to trigger a new compilation
  15761. */
  15762. set shaderPath(shaderPath: any);
  15763. /**
  15764. * Gets the options used to compile the shader.
  15765. * They can be modified to trigger a new compilation
  15766. */
  15767. get options(): IShaderMaterialOptions;
  15768. /**
  15769. * Gets the current class name of the material e.g. "ShaderMaterial"
  15770. * Mainly use in serialization.
  15771. * @returns the class name
  15772. */
  15773. getClassName(): string;
  15774. /**
  15775. * Specifies if the material will require alpha blending
  15776. * @returns a boolean specifying if alpha blending is needed
  15777. */
  15778. needAlphaBlending(): boolean;
  15779. /**
  15780. * Specifies if this material should be rendered in alpha test mode
  15781. * @returns a boolean specifying if an alpha test is needed.
  15782. */
  15783. needAlphaTesting(): boolean;
  15784. private _checkUniform;
  15785. /**
  15786. * Set a texture in the shader.
  15787. * @param name Define the name of the uniform samplers as defined in the shader
  15788. * @param texture Define the texture to bind to this sampler
  15789. * @return the material itself allowing "fluent" like uniform updates
  15790. */
  15791. setTexture(name: string, texture: Texture): ShaderMaterial;
  15792. /**
  15793. * Set a texture array in the shader.
  15794. * @param name Define the name of the uniform sampler array as defined in the shader
  15795. * @param textures Define the list of textures to bind to this sampler
  15796. * @return the material itself allowing "fluent" like uniform updates
  15797. */
  15798. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15799. /**
  15800. * Set a float in the shader.
  15801. * @param name Define the name of the uniform as defined in the shader
  15802. * @param value Define the value to give to the uniform
  15803. * @return the material itself allowing "fluent" like uniform updates
  15804. */
  15805. setFloat(name: string, value: number): ShaderMaterial;
  15806. /**
  15807. * Set a int in the shader.
  15808. * @param name Define the name of the uniform as defined in the shader
  15809. * @param value Define the value to give to the uniform
  15810. * @return the material itself allowing "fluent" like uniform updates
  15811. */
  15812. setInt(name: string, value: number): ShaderMaterial;
  15813. /**
  15814. * Set an array of floats in the shader.
  15815. * @param name Define the name of the uniform as defined in the shader
  15816. * @param value Define the value to give to the uniform
  15817. * @return the material itself allowing "fluent" like uniform updates
  15818. */
  15819. setFloats(name: string, value: number[]): ShaderMaterial;
  15820. /**
  15821. * Set a vec3 in the shader from a Color3.
  15822. * @param name Define the name of the uniform as defined in the shader
  15823. * @param value Define the value to give to the uniform
  15824. * @return the material itself allowing "fluent" like uniform updates
  15825. */
  15826. setColor3(name: string, value: Color3): ShaderMaterial;
  15827. /**
  15828. * Set a vec3 array in the shader from a Color3 array.
  15829. * @param name Define the name of the uniform as defined in the shader
  15830. * @param value Define the value to give to the uniform
  15831. * @return the material itself allowing "fluent" like uniform updates
  15832. */
  15833. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15834. /**
  15835. * Set a vec4 in the shader from a Color4.
  15836. * @param name Define the name of the uniform as defined in the shader
  15837. * @param value Define the value to give to the uniform
  15838. * @return the material itself allowing "fluent" like uniform updates
  15839. */
  15840. setColor4(name: string, value: Color4): ShaderMaterial;
  15841. /**
  15842. * Set a vec4 array in the shader from a Color4 array.
  15843. * @param name Define the name of the uniform as defined in the shader
  15844. * @param value Define the value to give to the uniform
  15845. * @return the material itself allowing "fluent" like uniform updates
  15846. */
  15847. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15848. /**
  15849. * Set a vec2 in the shader from a Vector2.
  15850. * @param name Define the name of the uniform as defined in the shader
  15851. * @param value Define the value to give to the uniform
  15852. * @return the material itself allowing "fluent" like uniform updates
  15853. */
  15854. setVector2(name: string, value: Vector2): ShaderMaterial;
  15855. /**
  15856. * Set a vec3 in the shader from a Vector3.
  15857. * @param name Define the name of the uniform as defined in the shader
  15858. * @param value Define the value to give to the uniform
  15859. * @return the material itself allowing "fluent" like uniform updates
  15860. */
  15861. setVector3(name: string, value: Vector3): ShaderMaterial;
  15862. /**
  15863. * Set a vec4 in the shader from a Vector4.
  15864. * @param name Define the name of the uniform as defined in the shader
  15865. * @param value Define the value to give to the uniform
  15866. * @return the material itself allowing "fluent" like uniform updates
  15867. */
  15868. setVector4(name: string, value: Vector4): ShaderMaterial;
  15869. /**
  15870. * Set a mat4 in the shader from a Matrix.
  15871. * @param name Define the name of the uniform as defined in the shader
  15872. * @param value Define the value to give to the uniform
  15873. * @return the material itself allowing "fluent" like uniform updates
  15874. */
  15875. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15876. /**
  15877. * Set a float32Array in the shader from a matrix array.
  15878. * @param name Define the name of the uniform as defined in the shader
  15879. * @param value Define the value to give to the uniform
  15880. * @return the material itself allowing "fluent" like uniform updates
  15881. */
  15882. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15883. /**
  15884. * Set a mat3 in the shader from a Float32Array.
  15885. * @param name Define the name of the uniform as defined in the shader
  15886. * @param value Define the value to give to the uniform
  15887. * @return the material itself allowing "fluent" like uniform updates
  15888. */
  15889. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15890. /**
  15891. * Set a mat2 in the shader from a Float32Array.
  15892. * @param name Define the name of the uniform as defined in the shader
  15893. * @param value Define the value to give to the uniform
  15894. * @return the material itself allowing "fluent" like uniform updates
  15895. */
  15896. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15897. /**
  15898. * Set a vec2 array in the shader from a number array.
  15899. * @param name Define the name of the uniform as defined in the shader
  15900. * @param value Define the value to give to the uniform
  15901. * @return the material itself allowing "fluent" like uniform updates
  15902. */
  15903. setArray2(name: string, value: number[]): ShaderMaterial;
  15904. /**
  15905. * Set a vec3 array in the shader from a number array.
  15906. * @param name Define the name of the uniform as defined in the shader
  15907. * @param value Define the value to give to the uniform
  15908. * @return the material itself allowing "fluent" like uniform updates
  15909. */
  15910. setArray3(name: string, value: number[]): ShaderMaterial;
  15911. /**
  15912. * Set a vec4 array in the shader from a number array.
  15913. * @param name Define the name of the uniform as defined in the shader
  15914. * @param value Define the value to give to the uniform
  15915. * @return the material itself allowing "fluent" like uniform updates
  15916. */
  15917. setArray4(name: string, value: number[]): ShaderMaterial;
  15918. private _checkCache;
  15919. /**
  15920. * Specifies that the submesh is ready to be used
  15921. * @param mesh defines the mesh to check
  15922. * @param subMesh defines which submesh to check
  15923. * @param useInstances specifies that instances should be used
  15924. * @returns a boolean indicating that the submesh is ready or not
  15925. */
  15926. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15927. /**
  15928. * Checks if the material is ready to render the requested mesh
  15929. * @param mesh Define the mesh to render
  15930. * @param useInstances Define whether or not the material is used with instances
  15931. * @returns true if ready, otherwise false
  15932. */
  15933. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15934. /**
  15935. * Binds the world matrix to the material
  15936. * @param world defines the world transformation matrix
  15937. */
  15938. bindOnlyWorldMatrix(world: Matrix): void;
  15939. /**
  15940. * Binds the material to the mesh
  15941. * @param world defines the world transformation matrix
  15942. * @param mesh defines the mesh to bind the material to
  15943. */
  15944. bind(world: Matrix, mesh?: Mesh): void;
  15945. /**
  15946. * Gets the active textures from the material
  15947. * @returns an array of textures
  15948. */
  15949. getActiveTextures(): BaseTexture[];
  15950. /**
  15951. * Specifies if the material uses a texture
  15952. * @param texture defines the texture to check against the material
  15953. * @returns a boolean specifying if the material uses the texture
  15954. */
  15955. hasTexture(texture: BaseTexture): boolean;
  15956. /**
  15957. * Makes a duplicate of the material, and gives it a new name
  15958. * @param name defines the new name for the duplicated material
  15959. * @returns the cloned material
  15960. */
  15961. clone(name: string): ShaderMaterial;
  15962. /**
  15963. * Disposes the material
  15964. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15965. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15966. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15967. */
  15968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15969. /**
  15970. * Serializes this material in a JSON representation
  15971. * @returns the serialized material object
  15972. */
  15973. serialize(): any;
  15974. /**
  15975. * Creates a shader material from parsed shader material data
  15976. * @param source defines the JSON represnetation of the material
  15977. * @param scene defines the hosting scene
  15978. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15979. * @returns a new material
  15980. */
  15981. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15982. }
  15983. }
  15984. declare module "babylonjs/Shaders/color.fragment" {
  15985. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15986. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15987. /** @hidden */
  15988. export var colorPixelShader: {
  15989. name: string;
  15990. shader: string;
  15991. };
  15992. }
  15993. declare module "babylonjs/Shaders/color.vertex" {
  15994. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15995. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15996. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15997. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15998. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15999. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16000. /** @hidden */
  16001. export var colorVertexShader: {
  16002. name: string;
  16003. shader: string;
  16004. };
  16005. }
  16006. declare module "babylonjs/Meshes/linesMesh" {
  16007. import { Nullable } from "babylonjs/types";
  16008. import { Scene } from "babylonjs/scene";
  16009. import { Color3 } from "babylonjs/Maths/math.color";
  16010. import { Node } from "babylonjs/node";
  16011. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16012. import { Mesh } from "babylonjs/Meshes/mesh";
  16013. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16014. import { Effect } from "babylonjs/Materials/effect";
  16015. import { Material } from "babylonjs/Materials/material";
  16016. import "babylonjs/Shaders/color.fragment";
  16017. import "babylonjs/Shaders/color.vertex";
  16018. /**
  16019. * Line mesh
  16020. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16021. */
  16022. export class LinesMesh extends Mesh {
  16023. /**
  16024. * If vertex color should be applied to the mesh
  16025. */
  16026. readonly useVertexColor?: boolean | undefined;
  16027. /**
  16028. * If vertex alpha should be applied to the mesh
  16029. */
  16030. readonly useVertexAlpha?: boolean | undefined;
  16031. /**
  16032. * Color of the line (Default: White)
  16033. */
  16034. color: Color3;
  16035. /**
  16036. * Alpha of the line (Default: 1)
  16037. */
  16038. alpha: number;
  16039. /**
  16040. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16041. * This margin is expressed in world space coordinates, so its value may vary.
  16042. * Default value is 0.1
  16043. */
  16044. intersectionThreshold: number;
  16045. private _colorShader;
  16046. private color4;
  16047. /**
  16048. * Creates a new LinesMesh
  16049. * @param name defines the name
  16050. * @param scene defines the hosting scene
  16051. * @param parent defines the parent mesh if any
  16052. * @param source defines the optional source LinesMesh used to clone data from
  16053. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16054. * When false, achieved by calling a clone(), also passing False.
  16055. * This will make creation of children, recursive.
  16056. * @param useVertexColor defines if this LinesMesh supports vertex color
  16057. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16058. */
  16059. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16060. /**
  16061. * If vertex color should be applied to the mesh
  16062. */
  16063. useVertexColor?: boolean | undefined,
  16064. /**
  16065. * If vertex alpha should be applied to the mesh
  16066. */
  16067. useVertexAlpha?: boolean | undefined);
  16068. private _addClipPlaneDefine;
  16069. private _removeClipPlaneDefine;
  16070. isReady(): boolean;
  16071. /**
  16072. * Returns the string "LineMesh"
  16073. */
  16074. getClassName(): string;
  16075. /**
  16076. * @hidden
  16077. */
  16078. get material(): Material;
  16079. /**
  16080. * @hidden
  16081. */
  16082. set material(value: Material);
  16083. /**
  16084. * @hidden
  16085. */
  16086. get checkCollisions(): boolean;
  16087. /** @hidden */
  16088. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16089. /** @hidden */
  16090. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16091. /**
  16092. * Disposes of the line mesh
  16093. * @param doNotRecurse If children should be disposed
  16094. */
  16095. dispose(doNotRecurse?: boolean): void;
  16096. /**
  16097. * Returns a new LineMesh object cloned from the current one.
  16098. */
  16099. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16100. /**
  16101. * Creates a new InstancedLinesMesh object from the mesh model.
  16102. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16103. * @param name defines the name of the new instance
  16104. * @returns a new InstancedLinesMesh
  16105. */
  16106. createInstance(name: string): InstancedLinesMesh;
  16107. }
  16108. /**
  16109. * Creates an instance based on a source LinesMesh
  16110. */
  16111. export class InstancedLinesMesh extends InstancedMesh {
  16112. /**
  16113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16114. * This margin is expressed in world space coordinates, so its value may vary.
  16115. * Initilized with the intersectionThreshold value of the source LinesMesh
  16116. */
  16117. intersectionThreshold: number;
  16118. constructor(name: string, source: LinesMesh);
  16119. /**
  16120. * Returns the string "InstancedLinesMesh".
  16121. */
  16122. getClassName(): string;
  16123. }
  16124. }
  16125. declare module "babylonjs/Shaders/line.fragment" {
  16126. /** @hidden */
  16127. export var linePixelShader: {
  16128. name: string;
  16129. shader: string;
  16130. };
  16131. }
  16132. declare module "babylonjs/Shaders/line.vertex" {
  16133. /** @hidden */
  16134. export var lineVertexShader: {
  16135. name: string;
  16136. shader: string;
  16137. };
  16138. }
  16139. declare module "babylonjs/Rendering/edgesRenderer" {
  16140. import { Nullable } from "babylonjs/types";
  16141. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16143. import { Vector3 } from "babylonjs/Maths/math.vector";
  16144. import { IDisposable } from "babylonjs/scene";
  16145. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16146. import "babylonjs/Shaders/line.fragment";
  16147. import "babylonjs/Shaders/line.vertex";
  16148. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16149. module "babylonjs/Meshes/abstractMesh" {
  16150. interface AbstractMesh {
  16151. /**
  16152. * Gets the edgesRenderer associated with the mesh
  16153. */
  16154. edgesRenderer: Nullable<EdgesRenderer>;
  16155. }
  16156. }
  16157. module "babylonjs/Meshes/linesMesh" {
  16158. interface LinesMesh {
  16159. /**
  16160. * Enables the edge rendering mode on the mesh.
  16161. * This mode makes the mesh edges visible
  16162. * @param epsilon defines the maximal distance between two angles to detect a face
  16163. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16164. * @returns the currentAbstractMesh
  16165. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16166. */
  16167. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16168. }
  16169. }
  16170. module "babylonjs/Meshes/linesMesh" {
  16171. interface InstancedLinesMesh {
  16172. /**
  16173. * Enables the edge rendering mode on the mesh.
  16174. * This mode makes the mesh edges visible
  16175. * @param epsilon defines the maximal distance between two angles to detect a face
  16176. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16177. * @returns the current InstancedLinesMesh
  16178. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16179. */
  16180. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16181. }
  16182. }
  16183. /**
  16184. * Defines the minimum contract an Edges renderer should follow.
  16185. */
  16186. export interface IEdgesRenderer extends IDisposable {
  16187. /**
  16188. * Gets or sets a boolean indicating if the edgesRenderer is active
  16189. */
  16190. isEnabled: boolean;
  16191. /**
  16192. * Renders the edges of the attached mesh,
  16193. */
  16194. render(): void;
  16195. /**
  16196. * Checks wether or not the edges renderer is ready to render.
  16197. * @return true if ready, otherwise false.
  16198. */
  16199. isReady(): boolean;
  16200. }
  16201. /**
  16202. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16203. */
  16204. export class EdgesRenderer implements IEdgesRenderer {
  16205. /**
  16206. * Define the size of the edges with an orthographic camera
  16207. */
  16208. edgesWidthScalerForOrthographic: number;
  16209. /**
  16210. * Define the size of the edges with a perspective camera
  16211. */
  16212. edgesWidthScalerForPerspective: number;
  16213. protected _source: AbstractMesh;
  16214. protected _linesPositions: number[];
  16215. protected _linesNormals: number[];
  16216. protected _linesIndices: number[];
  16217. protected _epsilon: number;
  16218. protected _indicesCount: number;
  16219. protected _lineShader: ShaderMaterial;
  16220. protected _ib: DataBuffer;
  16221. protected _buffers: {
  16222. [key: string]: Nullable<VertexBuffer>;
  16223. };
  16224. protected _checkVerticesInsteadOfIndices: boolean;
  16225. private _meshRebuildObserver;
  16226. private _meshDisposeObserver;
  16227. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16228. isEnabled: boolean;
  16229. /**
  16230. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16231. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16232. * @param source Mesh used to create edges
  16233. * @param epsilon sum of angles in adjacency to check for edge
  16234. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16235. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16236. */
  16237. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16238. protected _prepareRessources(): void;
  16239. /** @hidden */
  16240. _rebuild(): void;
  16241. /**
  16242. * Releases the required resources for the edges renderer
  16243. */
  16244. dispose(): void;
  16245. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16246. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16247. /**
  16248. * Checks if the pair of p0 and p1 is en edge
  16249. * @param faceIndex
  16250. * @param edge
  16251. * @param faceNormals
  16252. * @param p0
  16253. * @param p1
  16254. * @private
  16255. */
  16256. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16257. /**
  16258. * push line into the position, normal and index buffer
  16259. * @protected
  16260. */
  16261. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16262. /**
  16263. * Generates lines edges from adjacencjes
  16264. * @private
  16265. */
  16266. _generateEdgesLines(): void;
  16267. /**
  16268. * Checks wether or not the edges renderer is ready to render.
  16269. * @return true if ready, otherwise false.
  16270. */
  16271. isReady(): boolean;
  16272. /**
  16273. * Renders the edges of the attached mesh,
  16274. */
  16275. render(): void;
  16276. }
  16277. /**
  16278. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16279. */
  16280. export class LineEdgesRenderer extends EdgesRenderer {
  16281. /**
  16282. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16283. * @param source LineMesh used to generate edges
  16284. * @param epsilon not important (specified angle for edge detection)
  16285. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16286. */
  16287. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16288. /**
  16289. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16290. */
  16291. _generateEdgesLines(): void;
  16292. }
  16293. }
  16294. declare module "babylonjs/Rendering/renderingGroup" {
  16295. import { SmartArray } from "babylonjs/Misc/smartArray";
  16296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16298. import { Nullable } from "babylonjs/types";
  16299. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16300. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16301. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16302. import { Material } from "babylonjs/Materials/material";
  16303. import { Scene } from "babylonjs/scene";
  16304. /**
  16305. * This represents the object necessary to create a rendering group.
  16306. * This is exclusively used and created by the rendering manager.
  16307. * To modify the behavior, you use the available helpers in your scene or meshes.
  16308. * @hidden
  16309. */
  16310. export class RenderingGroup {
  16311. index: number;
  16312. private static _zeroVector;
  16313. private _scene;
  16314. private _opaqueSubMeshes;
  16315. private _transparentSubMeshes;
  16316. private _alphaTestSubMeshes;
  16317. private _depthOnlySubMeshes;
  16318. private _particleSystems;
  16319. private _spriteManagers;
  16320. private _opaqueSortCompareFn;
  16321. private _alphaTestSortCompareFn;
  16322. private _transparentSortCompareFn;
  16323. private _renderOpaque;
  16324. private _renderAlphaTest;
  16325. private _renderTransparent;
  16326. /** @hidden */
  16327. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16328. onBeforeTransparentRendering: () => void;
  16329. /**
  16330. * Set the opaque sort comparison function.
  16331. * If null the sub meshes will be render in the order they were created
  16332. */
  16333. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16334. /**
  16335. * Set the alpha test sort comparison function.
  16336. * If null the sub meshes will be render in the order they were created
  16337. */
  16338. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16339. /**
  16340. * Set the transparent sort comparison function.
  16341. * If null the sub meshes will be render in the order they were created
  16342. */
  16343. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16344. /**
  16345. * Creates a new rendering group.
  16346. * @param index The rendering group index
  16347. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16348. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16349. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16350. */
  16351. 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>);
  16352. /**
  16353. * Render all the sub meshes contained in the group.
  16354. * @param customRenderFunction Used to override the default render behaviour of the group.
  16355. * @returns true if rendered some submeshes.
  16356. */
  16357. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16358. /**
  16359. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16360. * @param subMeshes The submeshes to render
  16361. */
  16362. private renderOpaqueSorted;
  16363. /**
  16364. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16365. * @param subMeshes The submeshes to render
  16366. */
  16367. private renderAlphaTestSorted;
  16368. /**
  16369. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16370. * @param subMeshes The submeshes to render
  16371. */
  16372. private renderTransparentSorted;
  16373. /**
  16374. * Renders the submeshes in a specified order.
  16375. * @param subMeshes The submeshes to sort before render
  16376. * @param sortCompareFn The comparison function use to sort
  16377. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16378. * @param transparent Specifies to activate blending if true
  16379. */
  16380. private static renderSorted;
  16381. /**
  16382. * Renders the submeshes in the order they were dispatched (no sort applied).
  16383. * @param subMeshes The submeshes to render
  16384. */
  16385. private static renderUnsorted;
  16386. /**
  16387. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16388. * are rendered back to front if in the same alpha index.
  16389. *
  16390. * @param a The first submesh
  16391. * @param b The second submesh
  16392. * @returns The result of the comparison
  16393. */
  16394. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16395. /**
  16396. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16397. * are rendered back to front.
  16398. *
  16399. * @param a The first submesh
  16400. * @param b The second submesh
  16401. * @returns The result of the comparison
  16402. */
  16403. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16404. /**
  16405. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16406. * are rendered front to back (prevent overdraw).
  16407. *
  16408. * @param a The first submesh
  16409. * @param b The second submesh
  16410. * @returns The result of the comparison
  16411. */
  16412. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16413. /**
  16414. * Resets the different lists of submeshes to prepare a new frame.
  16415. */
  16416. prepare(): void;
  16417. dispose(): void;
  16418. /**
  16419. * Inserts the submesh in its correct queue depending on its material.
  16420. * @param subMesh The submesh to dispatch
  16421. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16422. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16423. */
  16424. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16425. dispatchSprites(spriteManager: ISpriteManager): void;
  16426. dispatchParticles(particleSystem: IParticleSystem): void;
  16427. private _renderParticles;
  16428. private _renderSprites;
  16429. }
  16430. }
  16431. declare module "babylonjs/Rendering/renderingManager" {
  16432. import { Nullable } from "babylonjs/types";
  16433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16435. import { SmartArray } from "babylonjs/Misc/smartArray";
  16436. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16437. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16438. import { Material } from "babylonjs/Materials/material";
  16439. import { Scene } from "babylonjs/scene";
  16440. import { Camera } from "babylonjs/Cameras/camera";
  16441. /**
  16442. * Interface describing the different options available in the rendering manager
  16443. * regarding Auto Clear between groups.
  16444. */
  16445. export interface IRenderingManagerAutoClearSetup {
  16446. /**
  16447. * Defines whether or not autoclear is enable.
  16448. */
  16449. autoClear: boolean;
  16450. /**
  16451. * Defines whether or not to autoclear the depth buffer.
  16452. */
  16453. depth: boolean;
  16454. /**
  16455. * Defines whether or not to autoclear the stencil buffer.
  16456. */
  16457. stencil: boolean;
  16458. }
  16459. /**
  16460. * This class is used by the onRenderingGroupObservable
  16461. */
  16462. export class RenderingGroupInfo {
  16463. /**
  16464. * The Scene that being rendered
  16465. */
  16466. scene: Scene;
  16467. /**
  16468. * The camera currently used for the rendering pass
  16469. */
  16470. camera: Nullable<Camera>;
  16471. /**
  16472. * The ID of the renderingGroup being processed
  16473. */
  16474. renderingGroupId: number;
  16475. }
  16476. /**
  16477. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16478. * It is enable to manage the different groups as well as the different necessary sort functions.
  16479. * This should not be used directly aside of the few static configurations
  16480. */
  16481. export class RenderingManager {
  16482. /**
  16483. * The max id used for rendering groups (not included)
  16484. */
  16485. static MAX_RENDERINGGROUPS: number;
  16486. /**
  16487. * The min id used for rendering groups (included)
  16488. */
  16489. static MIN_RENDERINGGROUPS: number;
  16490. /**
  16491. * Used to globally prevent autoclearing scenes.
  16492. */
  16493. static AUTOCLEAR: boolean;
  16494. /**
  16495. * @hidden
  16496. */
  16497. _useSceneAutoClearSetup: boolean;
  16498. private _scene;
  16499. private _renderingGroups;
  16500. private _depthStencilBufferAlreadyCleaned;
  16501. private _autoClearDepthStencil;
  16502. private _customOpaqueSortCompareFn;
  16503. private _customAlphaTestSortCompareFn;
  16504. private _customTransparentSortCompareFn;
  16505. private _renderingGroupInfo;
  16506. /**
  16507. * Instantiates a new rendering group for a particular scene
  16508. * @param scene Defines the scene the groups belongs to
  16509. */
  16510. constructor(scene: Scene);
  16511. private _clearDepthStencilBuffer;
  16512. /**
  16513. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16514. * @hidden
  16515. */
  16516. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16517. /**
  16518. * Resets the different information of the group to prepare a new frame
  16519. * @hidden
  16520. */
  16521. reset(): void;
  16522. /**
  16523. * Dispose and release the group and its associated resources.
  16524. * @hidden
  16525. */
  16526. dispose(): void;
  16527. /**
  16528. * Clear the info related to rendering groups preventing retention points during dispose.
  16529. */
  16530. freeRenderingGroups(): void;
  16531. private _prepareRenderingGroup;
  16532. /**
  16533. * Add a sprite manager to the rendering manager in order to render it this frame.
  16534. * @param spriteManager Define the sprite manager to render
  16535. */
  16536. dispatchSprites(spriteManager: ISpriteManager): void;
  16537. /**
  16538. * Add a particle system to the rendering manager in order to render it this frame.
  16539. * @param particleSystem Define the particle system to render
  16540. */
  16541. dispatchParticles(particleSystem: IParticleSystem): void;
  16542. /**
  16543. * Add a submesh to the manager in order to render it this frame
  16544. * @param subMesh The submesh to dispatch
  16545. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16546. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16547. */
  16548. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16549. /**
  16550. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16551. * This allowed control for front to back rendering or reversly depending of the special needs.
  16552. *
  16553. * @param renderingGroupId The rendering group id corresponding to its index
  16554. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16555. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16556. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16557. */
  16558. 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;
  16559. /**
  16560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16561. *
  16562. * @param renderingGroupId The rendering group id corresponding to its index
  16563. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16564. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16565. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16566. */
  16567. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16568. /**
  16569. * Gets the current auto clear configuration for one rendering group of the rendering
  16570. * manager.
  16571. * @param index the rendering group index to get the information for
  16572. * @returns The auto clear setup for the requested rendering group
  16573. */
  16574. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16575. }
  16576. }
  16577. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16578. import { SmartArray } from "babylonjs/Misc/smartArray";
  16579. import { Nullable } from "babylonjs/types";
  16580. import { Scene } from "babylonjs/scene";
  16581. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16582. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16584. import { Mesh } from "babylonjs/Meshes/mesh";
  16585. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16586. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16587. import { Effect } from "babylonjs/Materials/effect";
  16588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16589. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16590. import "babylonjs/Shaders/shadowMap.fragment";
  16591. import "babylonjs/Shaders/shadowMap.vertex";
  16592. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16593. import { Observable } from "babylonjs/Misc/observable";
  16594. /**
  16595. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16596. */
  16597. export interface ICustomShaderOptions {
  16598. /**
  16599. * Gets or sets the custom shader name to use
  16600. */
  16601. shaderName: string;
  16602. /**
  16603. * The list of attribute names used in the shader
  16604. */
  16605. attributes?: string[];
  16606. /**
  16607. * The list of unifrom names used in the shader
  16608. */
  16609. uniforms?: string[];
  16610. /**
  16611. * The list of sampler names used in the shader
  16612. */
  16613. samplers?: string[];
  16614. /**
  16615. * The list of defines used in the shader
  16616. */
  16617. defines?: string[];
  16618. }
  16619. /**
  16620. * Interface to implement to create a shadow generator compatible with BJS.
  16621. */
  16622. export interface IShadowGenerator {
  16623. /**
  16624. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16625. * @returns The render target texture if present otherwise, null
  16626. */
  16627. getShadowMap(): Nullable<RenderTargetTexture>;
  16628. /**
  16629. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16630. * @param subMesh The submesh we want to render in the shadow map
  16631. * @param useInstances Defines wether will draw in the map using instances
  16632. * @returns true if ready otherwise, false
  16633. */
  16634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16635. /**
  16636. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16637. * @param defines Defines of the material we want to update
  16638. * @param lightIndex Index of the light in the enabled light list of the material
  16639. */
  16640. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16641. /**
  16642. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16643. * defined in the generator but impacting the effect).
  16644. * It implies the unifroms available on the materials are the standard BJS ones.
  16645. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16646. * @param effect The effect we are binfing the information for
  16647. */
  16648. bindShadowLight(lightIndex: string, effect: Effect): void;
  16649. /**
  16650. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16651. * (eq to shadow prjection matrix * light transform matrix)
  16652. * @returns The transform matrix used to create the shadow map
  16653. */
  16654. getTransformMatrix(): Matrix;
  16655. /**
  16656. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16657. * Cube and 2D textures for instance.
  16658. */
  16659. recreateShadowMap(): void;
  16660. /**
  16661. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16662. * @param onCompiled Callback triggered at the and of the effects compilation
  16663. * @param options Sets of optional options forcing the compilation with different modes
  16664. */
  16665. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16666. useInstances: boolean;
  16667. }>): void;
  16668. /**
  16669. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16670. * @param options Sets of optional options forcing the compilation with different modes
  16671. * @returns A promise that resolves when the compilation completes
  16672. */
  16673. forceCompilationAsync(options?: Partial<{
  16674. useInstances: boolean;
  16675. }>): Promise<void>;
  16676. /**
  16677. * Serializes the shadow generator setup to a json object.
  16678. * @returns The serialized JSON object
  16679. */
  16680. serialize(): any;
  16681. /**
  16682. * Disposes the Shadow map and related Textures and effects.
  16683. */
  16684. dispose(): void;
  16685. }
  16686. /**
  16687. * Default implementation IShadowGenerator.
  16688. * This is the main object responsible of generating shadows in the framework.
  16689. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16690. */
  16691. export class ShadowGenerator implements IShadowGenerator {
  16692. /**
  16693. * Name of the shadow generator class
  16694. */
  16695. static CLASSNAME: string;
  16696. /**
  16697. * Shadow generator mode None: no filtering applied.
  16698. */
  16699. static readonly FILTER_NONE: number;
  16700. /**
  16701. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16702. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16703. */
  16704. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16705. /**
  16706. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16707. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16708. */
  16709. static readonly FILTER_POISSONSAMPLING: number;
  16710. /**
  16711. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16712. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16713. */
  16714. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16715. /**
  16716. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16717. * edge artifacts on steep falloff.
  16718. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16719. */
  16720. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16721. /**
  16722. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16723. * edge artifacts on steep falloff.
  16724. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16725. */
  16726. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16727. /**
  16728. * Shadow generator mode PCF: Percentage Closer Filtering
  16729. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16730. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16731. */
  16732. static readonly FILTER_PCF: number;
  16733. /**
  16734. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16735. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16736. * Contact Hardening
  16737. */
  16738. static readonly FILTER_PCSS: number;
  16739. /**
  16740. * Reserved for PCF and PCSS
  16741. * Highest Quality.
  16742. *
  16743. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16744. *
  16745. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16746. */
  16747. static readonly QUALITY_HIGH: number;
  16748. /**
  16749. * Reserved for PCF and PCSS
  16750. * Good tradeoff for quality/perf cross devices
  16751. *
  16752. * Execute PCF on a 3*3 kernel.
  16753. *
  16754. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16755. */
  16756. static readonly QUALITY_MEDIUM: number;
  16757. /**
  16758. * Reserved for PCF and PCSS
  16759. * The lowest quality but the fastest.
  16760. *
  16761. * Execute PCF on a 1*1 kernel.
  16762. *
  16763. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16764. */
  16765. static readonly QUALITY_LOW: number;
  16766. /** Gets or sets the custom shader name to use */
  16767. customShaderOptions: ICustomShaderOptions;
  16768. /**
  16769. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16770. */
  16771. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16772. /**
  16773. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16774. */
  16775. onAfterShadowMapRenderObservable: Observable<Effect>;
  16776. /**
  16777. * Observable triggered before a mesh is rendered in the shadow map.
  16778. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16779. */
  16780. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16781. /**
  16782. * Observable triggered after a mesh is rendered in the shadow map.
  16783. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16784. */
  16785. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16786. protected _bias: number;
  16787. /**
  16788. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16789. */
  16790. get bias(): number;
  16791. /**
  16792. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16793. */
  16794. set bias(bias: number);
  16795. protected _normalBias: number;
  16796. /**
  16797. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16798. */
  16799. get normalBias(): number;
  16800. /**
  16801. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16802. */
  16803. set normalBias(normalBias: number);
  16804. protected _blurBoxOffset: number;
  16805. /**
  16806. * Gets the blur box offset: offset applied during the blur pass.
  16807. * Only useful if useKernelBlur = false
  16808. */
  16809. get blurBoxOffset(): number;
  16810. /**
  16811. * Sets the blur box offset: offset applied during the blur pass.
  16812. * Only useful if useKernelBlur = false
  16813. */
  16814. set blurBoxOffset(value: number);
  16815. protected _blurScale: number;
  16816. /**
  16817. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16818. * 2 means half of the size.
  16819. */
  16820. get blurScale(): number;
  16821. /**
  16822. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16823. * 2 means half of the size.
  16824. */
  16825. set blurScale(value: number);
  16826. protected _blurKernel: number;
  16827. /**
  16828. * Gets the blur kernel: kernel size of the blur pass.
  16829. * Only useful if useKernelBlur = true
  16830. */
  16831. get blurKernel(): number;
  16832. /**
  16833. * Sets the blur kernel: kernel size of the blur pass.
  16834. * Only useful if useKernelBlur = true
  16835. */
  16836. set blurKernel(value: number);
  16837. protected _useKernelBlur: boolean;
  16838. /**
  16839. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16840. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16841. */
  16842. get useKernelBlur(): boolean;
  16843. /**
  16844. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16845. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16846. */
  16847. set useKernelBlur(value: boolean);
  16848. protected _depthScale: number;
  16849. /**
  16850. * Gets the depth scale used in ESM mode.
  16851. */
  16852. get depthScale(): number;
  16853. /**
  16854. * Sets the depth scale used in ESM mode.
  16855. * This can override the scale stored on the light.
  16856. */
  16857. set depthScale(value: number);
  16858. protected _validateFilter(filter: number): number;
  16859. protected _filter: number;
  16860. /**
  16861. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16862. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16863. */
  16864. get filter(): number;
  16865. /**
  16866. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16867. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16868. */
  16869. set filter(value: number);
  16870. /**
  16871. * Gets if the current filter is set to Poisson Sampling.
  16872. */
  16873. get usePoissonSampling(): boolean;
  16874. /**
  16875. * Sets the current filter to Poisson Sampling.
  16876. */
  16877. set usePoissonSampling(value: boolean);
  16878. /**
  16879. * Gets if the current filter is set to ESM.
  16880. */
  16881. get useExponentialShadowMap(): boolean;
  16882. /**
  16883. * Sets the current filter is to ESM.
  16884. */
  16885. set useExponentialShadowMap(value: boolean);
  16886. /**
  16887. * Gets if the current filter is set to filtered ESM.
  16888. */
  16889. get useBlurExponentialShadowMap(): boolean;
  16890. /**
  16891. * Gets if the current filter is set to filtered ESM.
  16892. */
  16893. set useBlurExponentialShadowMap(value: boolean);
  16894. /**
  16895. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16896. * exponential to prevent steep falloff artifacts).
  16897. */
  16898. get useCloseExponentialShadowMap(): boolean;
  16899. /**
  16900. * Sets the current filter to "close ESM" (using the inverse of the
  16901. * exponential to prevent steep falloff artifacts).
  16902. */
  16903. set useCloseExponentialShadowMap(value: boolean);
  16904. /**
  16905. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16906. * exponential to prevent steep falloff artifacts).
  16907. */
  16908. get useBlurCloseExponentialShadowMap(): boolean;
  16909. /**
  16910. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16911. * exponential to prevent steep falloff artifacts).
  16912. */
  16913. set useBlurCloseExponentialShadowMap(value: boolean);
  16914. /**
  16915. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16916. */
  16917. get usePercentageCloserFiltering(): boolean;
  16918. /**
  16919. * Sets the current filter to "PCF" (percentage closer filtering).
  16920. */
  16921. set usePercentageCloserFiltering(value: boolean);
  16922. protected _filteringQuality: number;
  16923. /**
  16924. * Gets the PCF or PCSS Quality.
  16925. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16926. */
  16927. get filteringQuality(): number;
  16928. /**
  16929. * Sets the PCF or PCSS Quality.
  16930. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16931. */
  16932. set filteringQuality(filteringQuality: number);
  16933. /**
  16934. * Gets if the current filter is set to "PCSS" (contact hardening).
  16935. */
  16936. get useContactHardeningShadow(): boolean;
  16937. /**
  16938. * Sets the current filter to "PCSS" (contact hardening).
  16939. */
  16940. set useContactHardeningShadow(value: boolean);
  16941. protected _contactHardeningLightSizeUVRatio: number;
  16942. /**
  16943. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16944. * Using a ratio helps keeping shape stability independently of the map size.
  16945. *
  16946. * It does not account for the light projection as it was having too much
  16947. * instability during the light setup or during light position changes.
  16948. *
  16949. * Only valid if useContactHardeningShadow is true.
  16950. */
  16951. get contactHardeningLightSizeUVRatio(): number;
  16952. /**
  16953. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16954. * Using a ratio helps keeping shape stability independently of the map size.
  16955. *
  16956. * It does not account for the light projection as it was having too much
  16957. * instability during the light setup or during light position changes.
  16958. *
  16959. * Only valid if useContactHardeningShadow is true.
  16960. */
  16961. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16962. protected _darkness: number;
  16963. /** Gets or sets the actual darkness of a shadow */
  16964. get darkness(): number;
  16965. set darkness(value: number);
  16966. /**
  16967. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16968. * 0 means strongest and 1 would means no shadow.
  16969. * @returns the darkness.
  16970. */
  16971. getDarkness(): number;
  16972. /**
  16973. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16974. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16975. * @returns the shadow generator allowing fluent coding.
  16976. */
  16977. setDarkness(darkness: number): ShadowGenerator;
  16978. protected _transparencyShadow: boolean;
  16979. /** Gets or sets the ability to have transparent shadow */
  16980. get transparencyShadow(): boolean;
  16981. set transparencyShadow(value: boolean);
  16982. /**
  16983. * Sets the ability to have transparent shadow (boolean).
  16984. * @param transparent True if transparent else False
  16985. * @returns the shadow generator allowing fluent coding
  16986. */
  16987. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16988. protected _shadowMap: Nullable<RenderTargetTexture>;
  16989. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16990. /**
  16991. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16992. * @returns The render target texture if present otherwise, null
  16993. */
  16994. getShadowMap(): Nullable<RenderTargetTexture>;
  16995. /**
  16996. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16997. * @returns The render target texture if the shadow map is present otherwise, null
  16998. */
  16999. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17000. /**
  17001. * Gets the class name of that object
  17002. * @returns "ShadowGenerator"
  17003. */
  17004. getClassName(): string;
  17005. /**
  17006. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17007. * @param mesh Mesh to add
  17008. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17009. * @returns the Shadow Generator itself
  17010. */
  17011. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17012. /**
  17013. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17014. * @param mesh Mesh to remove
  17015. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17016. * @returns the Shadow Generator itself
  17017. */
  17018. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17019. /**
  17020. * Controls the extent to which the shadows fade out at the edge of the frustum
  17021. */
  17022. frustumEdgeFalloff: number;
  17023. protected _light: IShadowLight;
  17024. /**
  17025. * Returns the associated light object.
  17026. * @returns the light generating the shadow
  17027. */
  17028. getLight(): IShadowLight;
  17029. /**
  17030. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17031. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17032. * It might on the other hand introduce peter panning.
  17033. */
  17034. forceBackFacesOnly: boolean;
  17035. protected _scene: Scene;
  17036. protected _lightDirection: Vector3;
  17037. protected _effect: Effect;
  17038. protected _viewMatrix: Matrix;
  17039. protected _projectionMatrix: Matrix;
  17040. protected _transformMatrix: Matrix;
  17041. protected _cachedPosition: Vector3;
  17042. protected _cachedDirection: Vector3;
  17043. protected _cachedDefines: string;
  17044. protected _currentRenderID: number;
  17045. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17046. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17047. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17048. protected _blurPostProcesses: PostProcess[];
  17049. protected _mapSize: number;
  17050. protected _currentFaceIndex: number;
  17051. protected _currentFaceIndexCache: number;
  17052. protected _textureType: number;
  17053. protected _defaultTextureMatrix: Matrix;
  17054. protected _storedUniqueId: Nullable<number>;
  17055. /** @hidden */
  17056. static _SceneComponentInitialization: (scene: Scene) => void;
  17057. /**
  17058. * Creates a ShadowGenerator object.
  17059. * A ShadowGenerator is the required tool to use the shadows.
  17060. * Each light casting shadows needs to use its own ShadowGenerator.
  17061. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17062. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17063. * @param light The light object generating the shadows.
  17064. * @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.
  17065. */
  17066. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17067. protected _initializeGenerator(): void;
  17068. protected _createTargetRenderTexture(): void;
  17069. protected _initializeShadowMap(): void;
  17070. protected _initializeBlurRTTAndPostProcesses(): void;
  17071. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17072. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17073. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17074. protected _applyFilterValues(): void;
  17075. /**
  17076. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17077. * @param onCompiled Callback triggered at the and of the effects compilation
  17078. * @param options Sets of optional options forcing the compilation with different modes
  17079. */
  17080. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17081. useInstances: boolean;
  17082. }>): void;
  17083. /**
  17084. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17085. * @param options Sets of optional options forcing the compilation with different modes
  17086. * @returns A promise that resolves when the compilation completes
  17087. */
  17088. forceCompilationAsync(options?: Partial<{
  17089. useInstances: boolean;
  17090. }>): Promise<void>;
  17091. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17092. /**
  17093. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17094. * @param subMesh The submesh we want to render in the shadow map
  17095. * @param useInstances Defines wether will draw in the map using instances
  17096. * @returns true if ready otherwise, false
  17097. */
  17098. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17099. /**
  17100. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17101. * @param defines Defines of the material we want to update
  17102. * @param lightIndex Index of the light in the enabled light list of the material
  17103. */
  17104. prepareDefines(defines: any, lightIndex: number): void;
  17105. /**
  17106. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17107. * defined in the generator but impacting the effect).
  17108. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17109. * @param effect The effect we are binfing the information for
  17110. */
  17111. bindShadowLight(lightIndex: string, effect: Effect): void;
  17112. /**
  17113. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17114. * (eq to shadow prjection matrix * light transform matrix)
  17115. * @returns The transform matrix used to create the shadow map
  17116. */
  17117. getTransformMatrix(): Matrix;
  17118. /**
  17119. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17120. * Cube and 2D textures for instance.
  17121. */
  17122. recreateShadowMap(): void;
  17123. protected _disposeBlurPostProcesses(): void;
  17124. protected _disposeRTTandPostProcesses(): void;
  17125. /**
  17126. * Disposes the ShadowGenerator.
  17127. * Returns nothing.
  17128. */
  17129. dispose(): void;
  17130. /**
  17131. * Serializes the shadow generator setup to a json object.
  17132. * @returns The serialized JSON object
  17133. */
  17134. serialize(): any;
  17135. /**
  17136. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17137. * @param parsedShadowGenerator The JSON object to parse
  17138. * @param scene The scene to create the shadow map for
  17139. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17140. * @returns The parsed shadow generator
  17141. */
  17142. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17143. }
  17144. }
  17145. declare module "babylonjs/Lights/light" {
  17146. import { Nullable } from "babylonjs/types";
  17147. import { Scene } from "babylonjs/scene";
  17148. import { Vector3 } from "babylonjs/Maths/math.vector";
  17149. import { Color3 } from "babylonjs/Maths/math.color";
  17150. import { Node } from "babylonjs/node";
  17151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17152. import { Effect } from "babylonjs/Materials/effect";
  17153. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17154. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17155. /**
  17156. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17157. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17158. * 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.
  17159. */
  17160. export abstract class Light extends Node {
  17161. /**
  17162. * Falloff Default: light is falling off following the material specification:
  17163. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17164. */
  17165. static readonly FALLOFF_DEFAULT: number;
  17166. /**
  17167. * Falloff Physical: light is falling off following the inverse squared distance law.
  17168. */
  17169. static readonly FALLOFF_PHYSICAL: number;
  17170. /**
  17171. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17172. * to enhance interoperability with other engines.
  17173. */
  17174. static readonly FALLOFF_GLTF: number;
  17175. /**
  17176. * Falloff Standard: light is falling off like in the standard material
  17177. * to enhance interoperability with other materials.
  17178. */
  17179. static readonly FALLOFF_STANDARD: number;
  17180. /**
  17181. * If every light affecting the material is in this lightmapMode,
  17182. * material.lightmapTexture adds or multiplies
  17183. * (depends on material.useLightmapAsShadowmap)
  17184. * after every other light calculations.
  17185. */
  17186. static readonly LIGHTMAP_DEFAULT: number;
  17187. /**
  17188. * material.lightmapTexture as only diffuse lighting from this light
  17189. * adds only specular lighting from this light
  17190. * adds dynamic shadows
  17191. */
  17192. static readonly LIGHTMAP_SPECULAR: number;
  17193. /**
  17194. * material.lightmapTexture as only lighting
  17195. * no light calculation from this light
  17196. * only adds dynamic shadows from this light
  17197. */
  17198. static readonly LIGHTMAP_SHADOWSONLY: number;
  17199. /**
  17200. * Each light type uses the default quantity according to its type:
  17201. * point/spot lights use luminous intensity
  17202. * directional lights use illuminance
  17203. */
  17204. static readonly INTENSITYMODE_AUTOMATIC: number;
  17205. /**
  17206. * lumen (lm)
  17207. */
  17208. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17209. /**
  17210. * candela (lm/sr)
  17211. */
  17212. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17213. /**
  17214. * lux (lm/m^2)
  17215. */
  17216. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17217. /**
  17218. * nit (cd/m^2)
  17219. */
  17220. static readonly INTENSITYMODE_LUMINANCE: number;
  17221. /**
  17222. * Light type const id of the point light.
  17223. */
  17224. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17225. /**
  17226. * Light type const id of the directional light.
  17227. */
  17228. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17229. /**
  17230. * Light type const id of the spot light.
  17231. */
  17232. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17233. /**
  17234. * Light type const id of the hemispheric light.
  17235. */
  17236. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17237. /**
  17238. * Diffuse gives the basic color to an object.
  17239. */
  17240. diffuse: Color3;
  17241. /**
  17242. * Specular produces a highlight color on an object.
  17243. * Note: This is note affecting PBR materials.
  17244. */
  17245. specular: Color3;
  17246. /**
  17247. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17248. * falling off base on range or angle.
  17249. * This can be set to any values in Light.FALLOFF_x.
  17250. *
  17251. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17252. * other types of materials.
  17253. */
  17254. falloffType: number;
  17255. /**
  17256. * Strength of the light.
  17257. * Note: By default it is define in the framework own unit.
  17258. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17259. */
  17260. intensity: number;
  17261. private _range;
  17262. protected _inverseSquaredRange: number;
  17263. /**
  17264. * Defines how far from the source the light is impacting in scene units.
  17265. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17266. */
  17267. get range(): number;
  17268. /**
  17269. * Defines how far from the source the light is impacting in scene units.
  17270. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17271. */
  17272. set range(value: number);
  17273. /**
  17274. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17275. * of light.
  17276. */
  17277. private _photometricScale;
  17278. private _intensityMode;
  17279. /**
  17280. * Gets the photometric scale used to interpret the intensity.
  17281. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17282. */
  17283. get intensityMode(): number;
  17284. /**
  17285. * Sets the photometric scale used to interpret the intensity.
  17286. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17287. */
  17288. set intensityMode(value: number);
  17289. private _radius;
  17290. /**
  17291. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17292. */
  17293. get radius(): number;
  17294. /**
  17295. * sets the light radius used by PBR Materials to simulate soft area lights.
  17296. */
  17297. set radius(value: number);
  17298. private _renderPriority;
  17299. /**
  17300. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17301. * exceeding the number allowed of the materials.
  17302. */
  17303. renderPriority: number;
  17304. private _shadowEnabled;
  17305. /**
  17306. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17307. * the current shadow generator.
  17308. */
  17309. get shadowEnabled(): boolean;
  17310. /**
  17311. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17312. * the current shadow generator.
  17313. */
  17314. set shadowEnabled(value: boolean);
  17315. private _includedOnlyMeshes;
  17316. /**
  17317. * Gets the only meshes impacted by this light.
  17318. */
  17319. get includedOnlyMeshes(): AbstractMesh[];
  17320. /**
  17321. * Sets the only meshes impacted by this light.
  17322. */
  17323. set includedOnlyMeshes(value: AbstractMesh[]);
  17324. private _excludedMeshes;
  17325. /**
  17326. * Gets the meshes not impacted by this light.
  17327. */
  17328. get excludedMeshes(): AbstractMesh[];
  17329. /**
  17330. * Sets the meshes not impacted by this light.
  17331. */
  17332. set excludedMeshes(value: AbstractMesh[]);
  17333. private _excludeWithLayerMask;
  17334. /**
  17335. * Gets the layer id use to find what meshes are not impacted by the light.
  17336. * Inactive if 0
  17337. */
  17338. get excludeWithLayerMask(): number;
  17339. /**
  17340. * Sets the layer id use to find what meshes are not impacted by the light.
  17341. * Inactive if 0
  17342. */
  17343. set excludeWithLayerMask(value: number);
  17344. private _includeOnlyWithLayerMask;
  17345. /**
  17346. * Gets the layer id use to find what meshes are impacted by the light.
  17347. * Inactive if 0
  17348. */
  17349. get includeOnlyWithLayerMask(): number;
  17350. /**
  17351. * Sets the layer id use to find what meshes are impacted by the light.
  17352. * Inactive if 0
  17353. */
  17354. set includeOnlyWithLayerMask(value: number);
  17355. private _lightmapMode;
  17356. /**
  17357. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17358. */
  17359. get lightmapMode(): number;
  17360. /**
  17361. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17362. */
  17363. set lightmapMode(value: number);
  17364. /**
  17365. * Shadow generator associted to the light.
  17366. * @hidden Internal use only.
  17367. */
  17368. _shadowGenerator: Nullable<IShadowGenerator>;
  17369. /**
  17370. * @hidden Internal use only.
  17371. */
  17372. _excludedMeshesIds: string[];
  17373. /**
  17374. * @hidden Internal use only.
  17375. */
  17376. _includedOnlyMeshesIds: string[];
  17377. /**
  17378. * The current light unifom buffer.
  17379. * @hidden Internal use only.
  17380. */
  17381. _uniformBuffer: UniformBuffer;
  17382. /** @hidden */
  17383. _renderId: number;
  17384. /**
  17385. * Creates a Light object in the scene.
  17386. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17387. * @param name The firendly name of the light
  17388. * @param scene The scene the light belongs too
  17389. */
  17390. constructor(name: string, scene: Scene);
  17391. protected abstract _buildUniformLayout(): void;
  17392. /**
  17393. * Sets the passed Effect "effect" with the Light information.
  17394. * @param effect The effect to update
  17395. * @param lightIndex The index of the light in the effect to update
  17396. * @returns The light
  17397. */
  17398. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17399. /**
  17400. * Sets the passed Effect "effect" with the Light textures.
  17401. * @param effect The effect to update
  17402. * @param lightIndex The index of the light in the effect to update
  17403. * @returns The light
  17404. */
  17405. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17406. /**
  17407. * Binds the lights information from the scene to the effect for the given mesh.
  17408. * @param lightIndex Light index
  17409. * @param scene The scene where the light belongs to
  17410. * @param effect The effect we are binding the data to
  17411. * @param useSpecular Defines if specular is supported
  17412. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17413. */
  17414. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17415. /**
  17416. * Sets the passed Effect "effect" with the Light information.
  17417. * @param effect The effect to update
  17418. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17419. * @returns The light
  17420. */
  17421. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17422. /**
  17423. * Returns the string "Light".
  17424. * @returns the class name
  17425. */
  17426. getClassName(): string;
  17427. /** @hidden */
  17428. readonly _isLight: boolean;
  17429. /**
  17430. * Converts the light information to a readable string for debug purpose.
  17431. * @param fullDetails Supports for multiple levels of logging within scene loading
  17432. * @returns the human readable light info
  17433. */
  17434. toString(fullDetails?: boolean): string;
  17435. /** @hidden */
  17436. protected _syncParentEnabledState(): void;
  17437. /**
  17438. * Set the enabled state of this node.
  17439. * @param value - the new enabled state
  17440. */
  17441. setEnabled(value: boolean): void;
  17442. /**
  17443. * Returns the Light associated shadow generator if any.
  17444. * @return the associated shadow generator.
  17445. */
  17446. getShadowGenerator(): Nullable<IShadowGenerator>;
  17447. /**
  17448. * Returns a Vector3, the absolute light position in the World.
  17449. * @returns the world space position of the light
  17450. */
  17451. getAbsolutePosition(): Vector3;
  17452. /**
  17453. * Specifies if the light will affect the passed mesh.
  17454. * @param mesh The mesh to test against the light
  17455. * @return true the mesh is affected otherwise, false.
  17456. */
  17457. canAffectMesh(mesh: AbstractMesh): boolean;
  17458. /**
  17459. * Sort function to order lights for rendering.
  17460. * @param a First Light object to compare to second.
  17461. * @param b Second Light object to compare first.
  17462. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17463. */
  17464. static CompareLightsPriority(a: Light, b: Light): number;
  17465. /**
  17466. * Releases resources associated with this node.
  17467. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17468. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17469. */
  17470. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17471. /**
  17472. * Returns the light type ID (integer).
  17473. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17474. */
  17475. getTypeID(): number;
  17476. /**
  17477. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17478. * @returns the scaled intensity in intensity mode unit
  17479. */
  17480. getScaledIntensity(): number;
  17481. /**
  17482. * Returns a new Light object, named "name", from the current one.
  17483. * @param name The name of the cloned light
  17484. * @returns the new created light
  17485. */
  17486. clone(name: string): Nullable<Light>;
  17487. /**
  17488. * Serializes the current light into a Serialization object.
  17489. * @returns the serialized object.
  17490. */
  17491. serialize(): any;
  17492. /**
  17493. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17494. * This new light is named "name" and added to the passed scene.
  17495. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17496. * @param name The friendly name of the light
  17497. * @param scene The scene the new light will belong to
  17498. * @returns the constructor function
  17499. */
  17500. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17501. /**
  17502. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17503. * @param parsedLight The JSON representation of the light
  17504. * @param scene The scene to create the parsed light in
  17505. * @returns the created light after parsing
  17506. */
  17507. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17508. private _hookArrayForExcluded;
  17509. private _hookArrayForIncludedOnly;
  17510. private _resyncMeshes;
  17511. /**
  17512. * Forces the meshes to update their light related information in their rendering used effects
  17513. * @hidden Internal Use Only
  17514. */
  17515. _markMeshesAsLightDirty(): void;
  17516. /**
  17517. * Recomputes the cached photometric scale if needed.
  17518. */
  17519. private _computePhotometricScale;
  17520. /**
  17521. * Returns the Photometric Scale according to the light type and intensity mode.
  17522. */
  17523. private _getPhotometricScale;
  17524. /**
  17525. * Reorder the light in the scene according to their defined priority.
  17526. * @hidden Internal Use Only
  17527. */
  17528. _reorderLightsInScene(): void;
  17529. /**
  17530. * Prepares the list of defines specific to the light type.
  17531. * @param defines the list of defines
  17532. * @param lightIndex defines the index of the light for the effect
  17533. */
  17534. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17535. }
  17536. }
  17537. declare module "babylonjs/Actions/action" {
  17538. import { Observable } from "babylonjs/Misc/observable";
  17539. import { Condition } from "babylonjs/Actions/condition";
  17540. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17541. import { ActionManager } from "babylonjs/Actions/actionManager";
  17542. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17543. /**
  17544. * Interface used to define Action
  17545. */
  17546. export interface IAction {
  17547. /**
  17548. * Trigger for the action
  17549. */
  17550. trigger: number;
  17551. /** Options of the trigger */
  17552. triggerOptions: any;
  17553. /**
  17554. * Gets the trigger parameters
  17555. * @returns the trigger parameters
  17556. */
  17557. getTriggerParameter(): any;
  17558. /**
  17559. * Internal only - executes current action event
  17560. * @hidden
  17561. */
  17562. _executeCurrent(evt?: ActionEvent): void;
  17563. /**
  17564. * Serialize placeholder for child classes
  17565. * @param parent of child
  17566. * @returns the serialized object
  17567. */
  17568. serialize(parent: any): any;
  17569. /**
  17570. * Internal only
  17571. * @hidden
  17572. */
  17573. _prepare(): void;
  17574. /**
  17575. * Internal only - manager for action
  17576. * @hidden
  17577. */
  17578. _actionManager: AbstractActionManager;
  17579. /**
  17580. * Adds action to chain of actions, may be a DoNothingAction
  17581. * @param action defines the next action to execute
  17582. * @returns The action passed in
  17583. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17584. */
  17585. then(action: IAction): IAction;
  17586. }
  17587. /**
  17588. * The action to be carried out following a trigger
  17589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17590. */
  17591. export class Action implements IAction {
  17592. /** the trigger, with or without parameters, for the action */
  17593. triggerOptions: any;
  17594. /**
  17595. * Trigger for the action
  17596. */
  17597. trigger: number;
  17598. /**
  17599. * Internal only - manager for action
  17600. * @hidden
  17601. */
  17602. _actionManager: ActionManager;
  17603. private _nextActiveAction;
  17604. private _child;
  17605. private _condition?;
  17606. private _triggerParameter;
  17607. /**
  17608. * An event triggered prior to action being executed.
  17609. */
  17610. onBeforeExecuteObservable: Observable<Action>;
  17611. /**
  17612. * Creates a new Action
  17613. * @param triggerOptions the trigger, with or without parameters, for the action
  17614. * @param condition an optional determinant of action
  17615. */
  17616. constructor(
  17617. /** the trigger, with or without parameters, for the action */
  17618. triggerOptions: any, condition?: Condition);
  17619. /**
  17620. * Internal only
  17621. * @hidden
  17622. */
  17623. _prepare(): void;
  17624. /**
  17625. * Gets the trigger parameters
  17626. * @returns the trigger parameters
  17627. */
  17628. getTriggerParameter(): any;
  17629. /**
  17630. * Internal only - executes current action event
  17631. * @hidden
  17632. */
  17633. _executeCurrent(evt?: ActionEvent): void;
  17634. /**
  17635. * Execute placeholder for child classes
  17636. * @param evt optional action event
  17637. */
  17638. execute(evt?: ActionEvent): void;
  17639. /**
  17640. * Skips to next active action
  17641. */
  17642. skipToNextActiveAction(): void;
  17643. /**
  17644. * Adds action to chain of actions, may be a DoNothingAction
  17645. * @param action defines the next action to execute
  17646. * @returns The action passed in
  17647. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17648. */
  17649. then(action: Action): Action;
  17650. /**
  17651. * Internal only
  17652. * @hidden
  17653. */
  17654. _getProperty(propertyPath: string): string;
  17655. /**
  17656. * Internal only
  17657. * @hidden
  17658. */
  17659. _getEffectiveTarget(target: any, propertyPath: string): any;
  17660. /**
  17661. * Serialize placeholder for child classes
  17662. * @param parent of child
  17663. * @returns the serialized object
  17664. */
  17665. serialize(parent: any): any;
  17666. /**
  17667. * Internal only called by serialize
  17668. * @hidden
  17669. */
  17670. protected _serialize(serializedAction: any, parent?: any): any;
  17671. /**
  17672. * Internal only
  17673. * @hidden
  17674. */
  17675. static _SerializeValueAsString: (value: any) => string;
  17676. /**
  17677. * Internal only
  17678. * @hidden
  17679. */
  17680. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17681. name: string;
  17682. targetType: string;
  17683. value: string;
  17684. };
  17685. }
  17686. }
  17687. declare module "babylonjs/Actions/condition" {
  17688. import { ActionManager } from "babylonjs/Actions/actionManager";
  17689. /**
  17690. * A Condition applied to an Action
  17691. */
  17692. export class Condition {
  17693. /**
  17694. * Internal only - manager for action
  17695. * @hidden
  17696. */
  17697. _actionManager: ActionManager;
  17698. /**
  17699. * Internal only
  17700. * @hidden
  17701. */
  17702. _evaluationId: number;
  17703. /**
  17704. * Internal only
  17705. * @hidden
  17706. */
  17707. _currentResult: boolean;
  17708. /**
  17709. * Creates a new Condition
  17710. * @param actionManager the manager of the action the condition is applied to
  17711. */
  17712. constructor(actionManager: ActionManager);
  17713. /**
  17714. * Check if the current condition is valid
  17715. * @returns a boolean
  17716. */
  17717. isValid(): boolean;
  17718. /**
  17719. * Internal only
  17720. * @hidden
  17721. */
  17722. _getProperty(propertyPath: string): string;
  17723. /**
  17724. * Internal only
  17725. * @hidden
  17726. */
  17727. _getEffectiveTarget(target: any, propertyPath: string): any;
  17728. /**
  17729. * Serialize placeholder for child classes
  17730. * @returns the serialized object
  17731. */
  17732. serialize(): any;
  17733. /**
  17734. * Internal only
  17735. * @hidden
  17736. */
  17737. protected _serialize(serializedCondition: any): any;
  17738. }
  17739. /**
  17740. * Defines specific conditional operators as extensions of Condition
  17741. */
  17742. export class ValueCondition extends Condition {
  17743. /** path to specify the property of the target the conditional operator uses */
  17744. propertyPath: string;
  17745. /** the value compared by the conditional operator against the current value of the property */
  17746. value: any;
  17747. /** the conditional operator, default ValueCondition.IsEqual */
  17748. operator: number;
  17749. /**
  17750. * Internal only
  17751. * @hidden
  17752. */
  17753. private static _IsEqual;
  17754. /**
  17755. * Internal only
  17756. * @hidden
  17757. */
  17758. private static _IsDifferent;
  17759. /**
  17760. * Internal only
  17761. * @hidden
  17762. */
  17763. private static _IsGreater;
  17764. /**
  17765. * Internal only
  17766. * @hidden
  17767. */
  17768. private static _IsLesser;
  17769. /**
  17770. * returns the number for IsEqual
  17771. */
  17772. static get IsEqual(): number;
  17773. /**
  17774. * Returns the number for IsDifferent
  17775. */
  17776. static get IsDifferent(): number;
  17777. /**
  17778. * Returns the number for IsGreater
  17779. */
  17780. static get IsGreater(): number;
  17781. /**
  17782. * Returns the number for IsLesser
  17783. */
  17784. static get IsLesser(): number;
  17785. /**
  17786. * Internal only The action manager for the condition
  17787. * @hidden
  17788. */
  17789. _actionManager: ActionManager;
  17790. /**
  17791. * Internal only
  17792. * @hidden
  17793. */
  17794. private _target;
  17795. /**
  17796. * Internal only
  17797. * @hidden
  17798. */
  17799. private _effectiveTarget;
  17800. /**
  17801. * Internal only
  17802. * @hidden
  17803. */
  17804. private _property;
  17805. /**
  17806. * Creates a new ValueCondition
  17807. * @param actionManager manager for the action the condition applies to
  17808. * @param target for the action
  17809. * @param propertyPath path to specify the property of the target the conditional operator uses
  17810. * @param value the value compared by the conditional operator against the current value of the property
  17811. * @param operator the conditional operator, default ValueCondition.IsEqual
  17812. */
  17813. constructor(actionManager: ActionManager, target: any,
  17814. /** path to specify the property of the target the conditional operator uses */
  17815. propertyPath: string,
  17816. /** the value compared by the conditional operator against the current value of the property */
  17817. value: any,
  17818. /** the conditional operator, default ValueCondition.IsEqual */
  17819. operator?: number);
  17820. /**
  17821. * Compares the given value with the property value for the specified conditional operator
  17822. * @returns the result of the comparison
  17823. */
  17824. isValid(): boolean;
  17825. /**
  17826. * Serialize the ValueCondition into a JSON compatible object
  17827. * @returns serialization object
  17828. */
  17829. serialize(): any;
  17830. /**
  17831. * Gets the name of the conditional operator for the ValueCondition
  17832. * @param operator the conditional operator
  17833. * @returns the name
  17834. */
  17835. static GetOperatorName(operator: number): string;
  17836. }
  17837. /**
  17838. * Defines a predicate condition as an extension of Condition
  17839. */
  17840. export class PredicateCondition extends Condition {
  17841. /** defines the predicate function used to validate the condition */
  17842. predicate: () => boolean;
  17843. /**
  17844. * Internal only - manager for action
  17845. * @hidden
  17846. */
  17847. _actionManager: ActionManager;
  17848. /**
  17849. * Creates a new PredicateCondition
  17850. * @param actionManager manager for the action the condition applies to
  17851. * @param predicate defines the predicate function used to validate the condition
  17852. */
  17853. constructor(actionManager: ActionManager,
  17854. /** defines the predicate function used to validate the condition */
  17855. predicate: () => boolean);
  17856. /**
  17857. * @returns the validity of the predicate condition
  17858. */
  17859. isValid(): boolean;
  17860. }
  17861. /**
  17862. * Defines a state condition as an extension of Condition
  17863. */
  17864. export class StateCondition extends Condition {
  17865. /** Value to compare with target state */
  17866. value: string;
  17867. /**
  17868. * Internal only - manager for action
  17869. * @hidden
  17870. */
  17871. _actionManager: ActionManager;
  17872. /**
  17873. * Internal only
  17874. * @hidden
  17875. */
  17876. private _target;
  17877. /**
  17878. * Creates a new StateCondition
  17879. * @param actionManager manager for the action the condition applies to
  17880. * @param target of the condition
  17881. * @param value to compare with target state
  17882. */
  17883. constructor(actionManager: ActionManager, target: any,
  17884. /** Value to compare with target state */
  17885. value: string);
  17886. /**
  17887. * Gets a boolean indicating if the current condition is met
  17888. * @returns the validity of the state
  17889. */
  17890. isValid(): boolean;
  17891. /**
  17892. * Serialize the StateCondition into a JSON compatible object
  17893. * @returns serialization object
  17894. */
  17895. serialize(): any;
  17896. }
  17897. }
  17898. declare module "babylonjs/Actions/directActions" {
  17899. import { Action } from "babylonjs/Actions/action";
  17900. import { Condition } from "babylonjs/Actions/condition";
  17901. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17902. /**
  17903. * This defines an action responsible to toggle a boolean once triggered.
  17904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17905. */
  17906. export class SwitchBooleanAction extends Action {
  17907. /**
  17908. * The path to the boolean property in the target object
  17909. */
  17910. propertyPath: string;
  17911. private _target;
  17912. private _effectiveTarget;
  17913. private _property;
  17914. /**
  17915. * Instantiate the action
  17916. * @param triggerOptions defines the trigger options
  17917. * @param target defines the object containing the boolean
  17918. * @param propertyPath defines the path to the boolean property in the target object
  17919. * @param condition defines the trigger related conditions
  17920. */
  17921. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17922. /** @hidden */
  17923. _prepare(): void;
  17924. /**
  17925. * Execute the action toggle the boolean value.
  17926. */
  17927. execute(): void;
  17928. /**
  17929. * Serializes the actions and its related information.
  17930. * @param parent defines the object to serialize in
  17931. * @returns the serialized object
  17932. */
  17933. serialize(parent: any): any;
  17934. }
  17935. /**
  17936. * This defines an action responsible to set a the state field of the target
  17937. * to a desired value once triggered.
  17938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17939. */
  17940. export class SetStateAction extends Action {
  17941. /**
  17942. * The value to store in the state field.
  17943. */
  17944. value: string;
  17945. private _target;
  17946. /**
  17947. * Instantiate the action
  17948. * @param triggerOptions defines the trigger options
  17949. * @param target defines the object containing the state property
  17950. * @param value defines the value to store in the state field
  17951. * @param condition defines the trigger related conditions
  17952. */
  17953. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17954. /**
  17955. * Execute the action and store the value on the target state property.
  17956. */
  17957. execute(): void;
  17958. /**
  17959. * Serializes the actions and its related information.
  17960. * @param parent defines the object to serialize in
  17961. * @returns the serialized object
  17962. */
  17963. serialize(parent: any): any;
  17964. }
  17965. /**
  17966. * This defines an action responsible to set a property of the target
  17967. * to a desired value once triggered.
  17968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17969. */
  17970. export class SetValueAction extends Action {
  17971. /**
  17972. * The path of the property to set in the target.
  17973. */
  17974. propertyPath: string;
  17975. /**
  17976. * The value to set in the property
  17977. */
  17978. value: any;
  17979. private _target;
  17980. private _effectiveTarget;
  17981. private _property;
  17982. /**
  17983. * Instantiate the action
  17984. * @param triggerOptions defines the trigger options
  17985. * @param target defines the object containing the property
  17986. * @param propertyPath defines the path of the property to set in the target
  17987. * @param value defines the value to set in the property
  17988. * @param condition defines the trigger related conditions
  17989. */
  17990. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17991. /** @hidden */
  17992. _prepare(): void;
  17993. /**
  17994. * Execute the action and set the targetted property to the desired value.
  17995. */
  17996. execute(): void;
  17997. /**
  17998. * Serializes the actions and its related information.
  17999. * @param parent defines the object to serialize in
  18000. * @returns the serialized object
  18001. */
  18002. serialize(parent: any): any;
  18003. }
  18004. /**
  18005. * This defines an action responsible to increment the target value
  18006. * to a desired value once triggered.
  18007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18008. */
  18009. export class IncrementValueAction extends Action {
  18010. /**
  18011. * The path of the property to increment in the target.
  18012. */
  18013. propertyPath: string;
  18014. /**
  18015. * The value we should increment the property by.
  18016. */
  18017. value: any;
  18018. private _target;
  18019. private _effectiveTarget;
  18020. private _property;
  18021. /**
  18022. * Instantiate the action
  18023. * @param triggerOptions defines the trigger options
  18024. * @param target defines the object containing the property
  18025. * @param propertyPath defines the path of the property to increment in the target
  18026. * @param value defines the value value we should increment the property by
  18027. * @param condition defines the trigger related conditions
  18028. */
  18029. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18030. /** @hidden */
  18031. _prepare(): void;
  18032. /**
  18033. * Execute the action and increment the target of the value amount.
  18034. */
  18035. execute(): void;
  18036. /**
  18037. * Serializes the actions and its related information.
  18038. * @param parent defines the object to serialize in
  18039. * @returns the serialized object
  18040. */
  18041. serialize(parent: any): any;
  18042. }
  18043. /**
  18044. * This defines an action responsible to start an animation once triggered.
  18045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18046. */
  18047. export class PlayAnimationAction extends Action {
  18048. /**
  18049. * Where the animation should start (animation frame)
  18050. */
  18051. from: number;
  18052. /**
  18053. * Where the animation should stop (animation frame)
  18054. */
  18055. to: number;
  18056. /**
  18057. * Define if the animation should loop or stop after the first play.
  18058. */
  18059. loop?: boolean;
  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 from defines from where the animation should start (animation frame)
  18066. * @param end defines where the animation should stop (animation frame)
  18067. * @param loop defines if the animation should loop or stop after the first play
  18068. * @param condition defines the trigger related conditions
  18069. */
  18070. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18071. /** @hidden */
  18072. _prepare(): void;
  18073. /**
  18074. * Execute the action and play the animation.
  18075. */
  18076. execute(): void;
  18077. /**
  18078. * Serializes the actions and its related information.
  18079. * @param parent defines the object to serialize in
  18080. * @returns the serialized object
  18081. */
  18082. serialize(parent: any): any;
  18083. }
  18084. /**
  18085. * This defines an action responsible to stop an animation once triggered.
  18086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18087. */
  18088. export class StopAnimationAction extends Action {
  18089. private _target;
  18090. /**
  18091. * Instantiate the action
  18092. * @param triggerOptions defines the trigger options
  18093. * @param target defines the target animation or animation name
  18094. * @param condition defines the trigger related conditions
  18095. */
  18096. constructor(triggerOptions: any, target: any, condition?: Condition);
  18097. /** @hidden */
  18098. _prepare(): void;
  18099. /**
  18100. * Execute the action and stop the animation.
  18101. */
  18102. execute(): void;
  18103. /**
  18104. * Serializes the actions and its related information.
  18105. * @param parent defines the object to serialize in
  18106. * @returns the serialized object
  18107. */
  18108. serialize(parent: any): any;
  18109. }
  18110. /**
  18111. * This defines an action responsible that does nothing once triggered.
  18112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18113. */
  18114. export class DoNothingAction extends Action {
  18115. /**
  18116. * Instantiate the action
  18117. * @param triggerOptions defines the trigger options
  18118. * @param condition defines the trigger related conditions
  18119. */
  18120. constructor(triggerOptions?: any, condition?: Condition);
  18121. /**
  18122. * Execute the action and do nothing.
  18123. */
  18124. execute(): 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 trigger several actions once triggered.
  18134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18135. */
  18136. export class CombineAction extends Action {
  18137. /**
  18138. * The list of aggregated animations to run.
  18139. */
  18140. children: Action[];
  18141. /**
  18142. * Instantiate the action
  18143. * @param triggerOptions defines the trigger options
  18144. * @param children defines the list of aggregated animations to run
  18145. * @param condition defines the trigger related conditions
  18146. */
  18147. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18148. /** @hidden */
  18149. _prepare(): void;
  18150. /**
  18151. * Execute the action and executes all the aggregated actions.
  18152. */
  18153. execute(evt: ActionEvent): void;
  18154. /**
  18155. * Serializes the actions and its related information.
  18156. * @param parent defines the object to serialize in
  18157. * @returns the serialized object
  18158. */
  18159. serialize(parent: any): any;
  18160. }
  18161. /**
  18162. * This defines an action responsible to run code (external event) once triggered.
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18164. */
  18165. export class ExecuteCodeAction extends Action {
  18166. /**
  18167. * The callback function to run.
  18168. */
  18169. func: (evt: ActionEvent) => void;
  18170. /**
  18171. * Instantiate the action
  18172. * @param triggerOptions defines the trigger options
  18173. * @param func defines the callback function to run
  18174. * @param condition defines the trigger related conditions
  18175. */
  18176. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18177. /**
  18178. * Execute the action and run the attached code.
  18179. */
  18180. execute(evt: ActionEvent): void;
  18181. }
  18182. /**
  18183. * This defines an action responsible to set the parent property of the target once triggered.
  18184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18185. */
  18186. export class SetParentAction extends Action {
  18187. private _parent;
  18188. private _target;
  18189. /**
  18190. * Instantiate the action
  18191. * @param triggerOptions defines the trigger options
  18192. * @param target defines the target containing the parent property
  18193. * @param parent defines from where the animation should start (animation frame)
  18194. * @param condition defines the trigger related conditions
  18195. */
  18196. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18197. /** @hidden */
  18198. _prepare(): void;
  18199. /**
  18200. * Execute the action and set the parent property.
  18201. */
  18202. execute(): void;
  18203. /**
  18204. * Serializes the actions and its related information.
  18205. * @param parent defines the object to serialize in
  18206. * @returns the serialized object
  18207. */
  18208. serialize(parent: any): any;
  18209. }
  18210. }
  18211. declare module "babylonjs/Actions/actionManager" {
  18212. import { Nullable } from "babylonjs/types";
  18213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18214. import { Scene } from "babylonjs/scene";
  18215. import { IAction } from "babylonjs/Actions/action";
  18216. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18217. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18218. /**
  18219. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18220. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18222. */
  18223. export class ActionManager extends AbstractActionManager {
  18224. /**
  18225. * Nothing
  18226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18227. */
  18228. static readonly NothingTrigger: number;
  18229. /**
  18230. * On pick
  18231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18232. */
  18233. static readonly OnPickTrigger: number;
  18234. /**
  18235. * On left pick
  18236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18237. */
  18238. static readonly OnLeftPickTrigger: number;
  18239. /**
  18240. * On right pick
  18241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18242. */
  18243. static readonly OnRightPickTrigger: number;
  18244. /**
  18245. * On center pick
  18246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18247. */
  18248. static readonly OnCenterPickTrigger: number;
  18249. /**
  18250. * On pick down
  18251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18252. */
  18253. static readonly OnPickDownTrigger: number;
  18254. /**
  18255. * On double pick
  18256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18257. */
  18258. static readonly OnDoublePickTrigger: number;
  18259. /**
  18260. * On pick up
  18261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18262. */
  18263. static readonly OnPickUpTrigger: number;
  18264. /**
  18265. * On pick out.
  18266. * This trigger will only be raised if you also declared a OnPickDown
  18267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18268. */
  18269. static readonly OnPickOutTrigger: number;
  18270. /**
  18271. * On long press
  18272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18273. */
  18274. static readonly OnLongPressTrigger: number;
  18275. /**
  18276. * On pointer over
  18277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18278. */
  18279. static readonly OnPointerOverTrigger: number;
  18280. /**
  18281. * On pointer out
  18282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18283. */
  18284. static readonly OnPointerOutTrigger: number;
  18285. /**
  18286. * On every frame
  18287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18288. */
  18289. static readonly OnEveryFrameTrigger: number;
  18290. /**
  18291. * On intersection enter
  18292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18293. */
  18294. static readonly OnIntersectionEnterTrigger: number;
  18295. /**
  18296. * On intersection exit
  18297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18298. */
  18299. static readonly OnIntersectionExitTrigger: number;
  18300. /**
  18301. * On key down
  18302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18303. */
  18304. static readonly OnKeyDownTrigger: number;
  18305. /**
  18306. * On key up
  18307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18308. */
  18309. static readonly OnKeyUpTrigger: number;
  18310. private _scene;
  18311. /**
  18312. * Creates a new action manager
  18313. * @param scene defines the hosting scene
  18314. */
  18315. constructor(scene: Scene);
  18316. /**
  18317. * Releases all associated resources
  18318. */
  18319. dispose(): void;
  18320. /**
  18321. * Gets hosting scene
  18322. * @returns the hosting scene
  18323. */
  18324. getScene(): Scene;
  18325. /**
  18326. * Does this action manager handles actions of any of the given triggers
  18327. * @param triggers defines the triggers to be tested
  18328. * @return a boolean indicating whether one (or more) of the triggers is handled
  18329. */
  18330. hasSpecificTriggers(triggers: number[]): boolean;
  18331. /**
  18332. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18333. * speed.
  18334. * @param triggerA defines the trigger to be tested
  18335. * @param triggerB defines the trigger to be tested
  18336. * @return a boolean indicating whether one (or more) of the triggers is handled
  18337. */
  18338. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18339. /**
  18340. * Does this action manager handles actions of a given trigger
  18341. * @param trigger defines the trigger to be tested
  18342. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18343. * @return whether the trigger is handled
  18344. */
  18345. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18346. /**
  18347. * Does this action manager has pointer triggers
  18348. */
  18349. get hasPointerTriggers(): boolean;
  18350. /**
  18351. * Does this action manager has pick triggers
  18352. */
  18353. get hasPickTriggers(): boolean;
  18354. /**
  18355. * Registers an action to this action manager
  18356. * @param action defines the action to be registered
  18357. * @return the action amended (prepared) after registration
  18358. */
  18359. registerAction(action: IAction): Nullable<IAction>;
  18360. /**
  18361. * Unregisters an action to this action manager
  18362. * @param action defines the action to be unregistered
  18363. * @return a boolean indicating whether the action has been unregistered
  18364. */
  18365. unregisterAction(action: IAction): Boolean;
  18366. /**
  18367. * Process a specific trigger
  18368. * @param trigger defines the trigger to process
  18369. * @param evt defines the event details to be processed
  18370. */
  18371. processTrigger(trigger: number, evt?: IActionEvent): void;
  18372. /** @hidden */
  18373. _getEffectiveTarget(target: any, propertyPath: string): any;
  18374. /** @hidden */
  18375. _getProperty(propertyPath: string): string;
  18376. /**
  18377. * Serialize this manager to a JSON object
  18378. * @param name defines the property name to store this manager
  18379. * @returns a JSON representation of this manager
  18380. */
  18381. serialize(name: string): any;
  18382. /**
  18383. * Creates a new ActionManager from a JSON data
  18384. * @param parsedActions defines the JSON data to read from
  18385. * @param object defines the hosting mesh
  18386. * @param scene defines the hosting scene
  18387. */
  18388. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18389. /**
  18390. * Get a trigger name by index
  18391. * @param trigger defines the trigger index
  18392. * @returns a trigger name
  18393. */
  18394. static GetTriggerName(trigger: number): string;
  18395. }
  18396. }
  18397. declare module "babylonjs/Sprites/sprite" {
  18398. import { Vector3 } from "babylonjs/Maths/math.vector";
  18399. import { Nullable } from "babylonjs/types";
  18400. import { ActionManager } from "babylonjs/Actions/actionManager";
  18401. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18402. import { Color4 } from "babylonjs/Maths/math.color";
  18403. /**
  18404. * Class used to represent a sprite
  18405. * @see http://doc.babylonjs.com/babylon101/sprites
  18406. */
  18407. export class Sprite {
  18408. /** defines the name */
  18409. name: string;
  18410. /** Gets or sets the current world position */
  18411. position: Vector3;
  18412. /** Gets or sets the main color */
  18413. color: Color4;
  18414. /** Gets or sets the width */
  18415. width: number;
  18416. /** Gets or sets the height */
  18417. height: number;
  18418. /** Gets or sets rotation angle */
  18419. angle: number;
  18420. /** Gets or sets the cell index in the sprite sheet */
  18421. cellIndex: number;
  18422. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18423. cellRef: string;
  18424. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18425. invertU: number;
  18426. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18427. invertV: number;
  18428. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18429. disposeWhenFinishedAnimating: boolean;
  18430. /** Gets the list of attached animations */
  18431. animations: Animation[];
  18432. /** Gets or sets a boolean indicating if the sprite can be picked */
  18433. isPickable: boolean;
  18434. /**
  18435. * Gets or sets the associated action manager
  18436. */
  18437. actionManager: Nullable<ActionManager>;
  18438. private _animationStarted;
  18439. private _loopAnimation;
  18440. private _fromIndex;
  18441. private _toIndex;
  18442. private _delay;
  18443. private _direction;
  18444. private _manager;
  18445. private _time;
  18446. private _onAnimationEnd;
  18447. /**
  18448. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18449. */
  18450. isVisible: boolean;
  18451. /**
  18452. * Gets or sets the sprite size
  18453. */
  18454. get size(): number;
  18455. set size(value: number);
  18456. /**
  18457. * Creates a new Sprite
  18458. * @param name defines the name
  18459. * @param manager defines the manager
  18460. */
  18461. constructor(
  18462. /** defines the name */
  18463. name: string, manager: ISpriteManager);
  18464. /**
  18465. * Starts an animation
  18466. * @param from defines the initial key
  18467. * @param to defines the end key
  18468. * @param loop defines if the animation must loop
  18469. * @param delay defines the start delay (in ms)
  18470. * @param onAnimationEnd defines a callback to call when animation ends
  18471. */
  18472. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18473. /** Stops current animation (if any) */
  18474. stopAnimation(): void;
  18475. /** @hidden */
  18476. _animate(deltaTime: number): void;
  18477. /** Release associated resources */
  18478. dispose(): void;
  18479. }
  18480. }
  18481. declare module "babylonjs/Collisions/pickingInfo" {
  18482. import { Nullable } from "babylonjs/types";
  18483. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18485. import { Sprite } from "babylonjs/Sprites/sprite";
  18486. import { Ray } from "babylonjs/Culling/ray";
  18487. /**
  18488. * Information about the result of picking within a scene
  18489. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18490. */
  18491. export class PickingInfo {
  18492. /** @hidden */
  18493. _pickingUnavailable: boolean;
  18494. /**
  18495. * If the pick collided with an object
  18496. */
  18497. hit: boolean;
  18498. /**
  18499. * Distance away where the pick collided
  18500. */
  18501. distance: number;
  18502. /**
  18503. * The location of pick collision
  18504. */
  18505. pickedPoint: Nullable<Vector3>;
  18506. /**
  18507. * The mesh corresponding the the pick collision
  18508. */
  18509. pickedMesh: Nullable<AbstractMesh>;
  18510. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18511. bu: number;
  18512. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18513. bv: number;
  18514. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18515. faceId: number;
  18516. /** Id of the the submesh that was picked */
  18517. subMeshId: number;
  18518. /** If a sprite was picked, this will be the sprite the pick collided with */
  18519. pickedSprite: Nullable<Sprite>;
  18520. /**
  18521. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18522. */
  18523. originMesh: Nullable<AbstractMesh>;
  18524. /**
  18525. * The ray that was used to perform the picking.
  18526. */
  18527. ray: Nullable<Ray>;
  18528. /**
  18529. * Gets the normal correspodning to the face the pick collided with
  18530. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18531. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18532. * @returns The normal correspodning to the face the pick collided with
  18533. */
  18534. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18535. /**
  18536. * Gets the texture coordinates of where the pick occured
  18537. * @returns the vector containing the coordnates of the texture
  18538. */
  18539. getTextureCoordinates(): Nullable<Vector2>;
  18540. }
  18541. }
  18542. declare module "babylonjs/Events/pointerEvents" {
  18543. import { Nullable } from "babylonjs/types";
  18544. import { Vector2 } from "babylonjs/Maths/math.vector";
  18545. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18546. import { Ray } from "babylonjs/Culling/ray";
  18547. /**
  18548. * Gather the list of pointer event types as constants.
  18549. */
  18550. export class PointerEventTypes {
  18551. /**
  18552. * 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.
  18553. */
  18554. static readonly POINTERDOWN: number;
  18555. /**
  18556. * The pointerup event is fired when a pointer is no longer active.
  18557. */
  18558. static readonly POINTERUP: number;
  18559. /**
  18560. * The pointermove event is fired when a pointer changes coordinates.
  18561. */
  18562. static readonly POINTERMOVE: number;
  18563. /**
  18564. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18565. */
  18566. static readonly POINTERWHEEL: number;
  18567. /**
  18568. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18569. */
  18570. static readonly POINTERPICK: number;
  18571. /**
  18572. * The pointertap event is fired when a the object has been touched and released without drag.
  18573. */
  18574. static readonly POINTERTAP: number;
  18575. /**
  18576. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18577. */
  18578. static readonly POINTERDOUBLETAP: number;
  18579. }
  18580. /**
  18581. * Base class of pointer info types.
  18582. */
  18583. export class PointerInfoBase {
  18584. /**
  18585. * Defines the type of event (PointerEventTypes)
  18586. */
  18587. type: number;
  18588. /**
  18589. * Defines the related dom event
  18590. */
  18591. event: PointerEvent | MouseWheelEvent;
  18592. /**
  18593. * Instantiates the base class of pointers info.
  18594. * @param type Defines the type of event (PointerEventTypes)
  18595. * @param event Defines the related dom event
  18596. */
  18597. constructor(
  18598. /**
  18599. * Defines the type of event (PointerEventTypes)
  18600. */
  18601. type: number,
  18602. /**
  18603. * Defines the related dom event
  18604. */
  18605. event: PointerEvent | MouseWheelEvent);
  18606. }
  18607. /**
  18608. * This class is used to store pointer related info for the onPrePointerObservable event.
  18609. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18610. */
  18611. export class PointerInfoPre extends PointerInfoBase {
  18612. /**
  18613. * Ray from a pointer if availible (eg. 6dof controller)
  18614. */
  18615. ray: Nullable<Ray>;
  18616. /**
  18617. * Defines the local position of the pointer on the canvas.
  18618. */
  18619. localPosition: Vector2;
  18620. /**
  18621. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18622. */
  18623. skipOnPointerObservable: boolean;
  18624. /**
  18625. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18626. * @param type Defines the type of event (PointerEventTypes)
  18627. * @param event Defines the related dom event
  18628. * @param localX Defines the local x coordinates of the pointer when the event occured
  18629. * @param localY Defines the local y coordinates of the pointer when the event occured
  18630. */
  18631. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18632. }
  18633. /**
  18634. * This type contains all the data related to a pointer event in Babylon.js.
  18635. * 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.
  18636. */
  18637. export class PointerInfo extends PointerInfoBase {
  18638. /**
  18639. * Defines the picking info associated to the info (if any)\
  18640. */
  18641. pickInfo: Nullable<PickingInfo>;
  18642. /**
  18643. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18644. * @param type Defines the type of event (PointerEventTypes)
  18645. * @param event Defines the related dom event
  18646. * @param pickInfo Defines the picking info associated to the info (if any)\
  18647. */
  18648. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18649. /**
  18650. * Defines the picking info associated to the info (if any)\
  18651. */
  18652. pickInfo: Nullable<PickingInfo>);
  18653. }
  18654. /**
  18655. * Data relating to a touch event on the screen.
  18656. */
  18657. export interface PointerTouch {
  18658. /**
  18659. * X coordinate of touch.
  18660. */
  18661. x: number;
  18662. /**
  18663. * Y coordinate of touch.
  18664. */
  18665. y: number;
  18666. /**
  18667. * Id of touch. Unique for each finger.
  18668. */
  18669. pointerId: number;
  18670. /**
  18671. * Event type passed from DOM.
  18672. */
  18673. type: any;
  18674. }
  18675. }
  18676. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18677. import { Observable } from "babylonjs/Misc/observable";
  18678. import { Nullable } from "babylonjs/types";
  18679. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18680. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18681. /**
  18682. * Manage the mouse inputs to control the movement of a free camera.
  18683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18684. */
  18685. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18686. /**
  18687. * Define if touch is enabled in the mouse input
  18688. */
  18689. touchEnabled: boolean;
  18690. /**
  18691. * Defines the camera the input is attached to.
  18692. */
  18693. camera: FreeCamera;
  18694. /**
  18695. * Defines the buttons associated with the input to handle camera move.
  18696. */
  18697. buttons: number[];
  18698. /**
  18699. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18700. */
  18701. angularSensibility: number;
  18702. private _pointerInput;
  18703. private _onMouseMove;
  18704. private _observer;
  18705. private previousPosition;
  18706. /**
  18707. * Observable for when a pointer move event occurs containing the move offset
  18708. */
  18709. onPointerMovedObservable: Observable<{
  18710. offsetX: number;
  18711. offsetY: number;
  18712. }>;
  18713. /**
  18714. * @hidden
  18715. * If the camera should be rotated automatically based on pointer movement
  18716. */
  18717. _allowCameraRotation: boolean;
  18718. /**
  18719. * Manage the mouse inputs to control the movement of a free camera.
  18720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18721. * @param touchEnabled Defines if touch is enabled or not
  18722. */
  18723. constructor(
  18724. /**
  18725. * Define if touch is enabled in the mouse input
  18726. */
  18727. touchEnabled?: boolean);
  18728. /**
  18729. * Attach the input controls to a specific dom element to get the input from.
  18730. * @param element Defines the element the controls should be listened from
  18731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18732. */
  18733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18734. /**
  18735. * Called on JS contextmenu event.
  18736. * Override this method to provide functionality.
  18737. */
  18738. protected onContextMenu(evt: PointerEvent): void;
  18739. /**
  18740. * Detach the current controls from the specified dom element.
  18741. * @param element Defines the element to stop listening the inputs from
  18742. */
  18743. detachControl(element: Nullable<HTMLElement>): void;
  18744. /**
  18745. * Gets the class name of the current intput.
  18746. * @returns the class name
  18747. */
  18748. getClassName(): string;
  18749. /**
  18750. * Get the friendly name associated with the input class.
  18751. * @returns the input friendly name
  18752. */
  18753. getSimpleName(): string;
  18754. }
  18755. }
  18756. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18757. import { Nullable } from "babylonjs/types";
  18758. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18759. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18760. /**
  18761. * Manage the touch inputs to control the movement of a free camera.
  18762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18763. */
  18764. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18765. /**
  18766. * Defines the camera the input is attached to.
  18767. */
  18768. camera: FreeCamera;
  18769. /**
  18770. * Defines the touch sensibility for rotation.
  18771. * The higher the faster.
  18772. */
  18773. touchAngularSensibility: number;
  18774. /**
  18775. * Defines the touch sensibility for move.
  18776. * The higher the faster.
  18777. */
  18778. touchMoveSensibility: number;
  18779. private _offsetX;
  18780. private _offsetY;
  18781. private _pointerPressed;
  18782. private _pointerInput;
  18783. private _observer;
  18784. private _onLostFocus;
  18785. /**
  18786. * Attach the input controls to a specific dom element to get the input from.
  18787. * @param element Defines the element the controls should be listened from
  18788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18789. */
  18790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18791. /**
  18792. * Detach the current controls from the specified dom element.
  18793. * @param element Defines the element to stop listening the inputs from
  18794. */
  18795. detachControl(element: Nullable<HTMLElement>): void;
  18796. /**
  18797. * Update the current camera state depending on the inputs that have been used this frame.
  18798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18799. */
  18800. checkInputs(): void;
  18801. /**
  18802. * Gets the class name of the current intput.
  18803. * @returns the class name
  18804. */
  18805. getClassName(): string;
  18806. /**
  18807. * Get the friendly name associated with the input class.
  18808. * @returns the input friendly name
  18809. */
  18810. getSimpleName(): string;
  18811. }
  18812. }
  18813. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18814. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18815. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18816. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18817. import { Nullable } from "babylonjs/types";
  18818. /**
  18819. * Default Inputs manager for the FreeCamera.
  18820. * It groups all the default supported inputs for ease of use.
  18821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18822. */
  18823. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18824. /**
  18825. * @hidden
  18826. */
  18827. _mouseInput: Nullable<FreeCameraMouseInput>;
  18828. /**
  18829. * Instantiates a new FreeCameraInputsManager.
  18830. * @param camera Defines the camera the inputs belong to
  18831. */
  18832. constructor(camera: FreeCamera);
  18833. /**
  18834. * Add keyboard input support to the input manager.
  18835. * @returns the current input manager
  18836. */
  18837. addKeyboard(): FreeCameraInputsManager;
  18838. /**
  18839. * Add mouse input support to the input manager.
  18840. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18841. * @returns the current input manager
  18842. */
  18843. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18844. /**
  18845. * Removes the mouse input support from the manager
  18846. * @returns the current input manager
  18847. */
  18848. removeMouse(): FreeCameraInputsManager;
  18849. /**
  18850. * Add touch input support to the input manager.
  18851. * @returns the current input manager
  18852. */
  18853. addTouch(): FreeCameraInputsManager;
  18854. /**
  18855. * Remove all attached input methods from a camera
  18856. */
  18857. clear(): void;
  18858. }
  18859. }
  18860. declare module "babylonjs/Cameras/freeCamera" {
  18861. import { Vector3 } from "babylonjs/Maths/math.vector";
  18862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18863. import { Scene } from "babylonjs/scene";
  18864. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18865. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18866. /**
  18867. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18868. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18870. */
  18871. export class FreeCamera extends TargetCamera {
  18872. /**
  18873. * Define the collision ellipsoid of the camera.
  18874. * This is helpful to simulate a camera body like the player body around the camera
  18875. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18876. */
  18877. ellipsoid: Vector3;
  18878. /**
  18879. * Define an offset for the position of the ellipsoid around the camera.
  18880. * This can be helpful to determine the center of the body near the gravity center of the body
  18881. * instead of its head.
  18882. */
  18883. ellipsoidOffset: Vector3;
  18884. /**
  18885. * Enable or disable collisions of the camera with the rest of the scene objects.
  18886. */
  18887. checkCollisions: boolean;
  18888. /**
  18889. * Enable or disable gravity on the camera.
  18890. */
  18891. applyGravity: boolean;
  18892. /**
  18893. * Define the input manager associated to the camera.
  18894. */
  18895. inputs: FreeCameraInputsManager;
  18896. /**
  18897. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18898. * Higher values reduce sensitivity.
  18899. */
  18900. get angularSensibility(): number;
  18901. /**
  18902. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18903. * Higher values reduce sensitivity.
  18904. */
  18905. set angularSensibility(value: number);
  18906. /**
  18907. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18908. */
  18909. get keysUp(): number[];
  18910. set keysUp(value: number[]);
  18911. /**
  18912. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18913. */
  18914. get keysDown(): number[];
  18915. set keysDown(value: number[]);
  18916. /**
  18917. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18918. */
  18919. get keysLeft(): number[];
  18920. set keysLeft(value: number[]);
  18921. /**
  18922. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18923. */
  18924. get keysRight(): number[];
  18925. set keysRight(value: number[]);
  18926. /**
  18927. * Event raised when the camera collide with a mesh in the scene.
  18928. */
  18929. onCollide: (collidedMesh: AbstractMesh) => void;
  18930. private _collider;
  18931. private _needMoveForGravity;
  18932. private _oldPosition;
  18933. private _diffPosition;
  18934. private _newPosition;
  18935. /** @hidden */
  18936. _localDirection: Vector3;
  18937. /** @hidden */
  18938. _transformedDirection: Vector3;
  18939. /**
  18940. * Instantiates a Free Camera.
  18941. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18942. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18943. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18944. * @param name Define the name of the camera in the scene
  18945. * @param position Define the start position of the camera in the scene
  18946. * @param scene Define the scene the camera belongs to
  18947. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18948. */
  18949. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18950. /**
  18951. * Attached controls to the current camera.
  18952. * @param element Defines the element the controls should be listened from
  18953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18954. */
  18955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18956. /**
  18957. * Detach the current controls from the camera.
  18958. * The camera will stop reacting to inputs.
  18959. * @param element Defines the element to stop listening the inputs from
  18960. */
  18961. detachControl(element: HTMLElement): void;
  18962. private _collisionMask;
  18963. /**
  18964. * Define a collision mask to limit the list of object the camera can collide with
  18965. */
  18966. get collisionMask(): number;
  18967. set collisionMask(mask: number);
  18968. /** @hidden */
  18969. _collideWithWorld(displacement: Vector3): void;
  18970. private _onCollisionPositionChange;
  18971. /** @hidden */
  18972. _checkInputs(): void;
  18973. /** @hidden */
  18974. _decideIfNeedsToMove(): boolean;
  18975. /** @hidden */
  18976. _updatePosition(): void;
  18977. /**
  18978. * Destroy the camera and release the current resources hold by it.
  18979. */
  18980. dispose(): void;
  18981. /**
  18982. * Gets the current object class name.
  18983. * @return the class name
  18984. */
  18985. getClassName(): string;
  18986. }
  18987. }
  18988. declare module "babylonjs/Gamepads/gamepad" {
  18989. import { Observable } from "babylonjs/Misc/observable";
  18990. /**
  18991. * Represents a gamepad control stick position
  18992. */
  18993. export class StickValues {
  18994. /**
  18995. * The x component of the control stick
  18996. */
  18997. x: number;
  18998. /**
  18999. * The y component of the control stick
  19000. */
  19001. y: number;
  19002. /**
  19003. * Initializes the gamepad x and y control stick values
  19004. * @param x The x component of the gamepad control stick value
  19005. * @param y The y component of the gamepad control stick value
  19006. */
  19007. constructor(
  19008. /**
  19009. * The x component of the control stick
  19010. */
  19011. x: number,
  19012. /**
  19013. * The y component of the control stick
  19014. */
  19015. y: number);
  19016. }
  19017. /**
  19018. * An interface which manages callbacks for gamepad button changes
  19019. */
  19020. export interface GamepadButtonChanges {
  19021. /**
  19022. * Called when a gamepad has been changed
  19023. */
  19024. changed: boolean;
  19025. /**
  19026. * Called when a gamepad press event has been triggered
  19027. */
  19028. pressChanged: boolean;
  19029. /**
  19030. * Called when a touch event has been triggered
  19031. */
  19032. touchChanged: boolean;
  19033. /**
  19034. * Called when a value has changed
  19035. */
  19036. valueChanged: boolean;
  19037. }
  19038. /**
  19039. * Represents a gamepad
  19040. */
  19041. export class Gamepad {
  19042. /**
  19043. * The id of the gamepad
  19044. */
  19045. id: string;
  19046. /**
  19047. * The index of the gamepad
  19048. */
  19049. index: number;
  19050. /**
  19051. * The browser gamepad
  19052. */
  19053. browserGamepad: any;
  19054. /**
  19055. * Specifies what type of gamepad this represents
  19056. */
  19057. type: number;
  19058. private _leftStick;
  19059. private _rightStick;
  19060. /** @hidden */
  19061. _isConnected: boolean;
  19062. private _leftStickAxisX;
  19063. private _leftStickAxisY;
  19064. private _rightStickAxisX;
  19065. private _rightStickAxisY;
  19066. /**
  19067. * Triggered when the left control stick has been changed
  19068. */
  19069. private _onleftstickchanged;
  19070. /**
  19071. * Triggered when the right control stick has been changed
  19072. */
  19073. private _onrightstickchanged;
  19074. /**
  19075. * Represents a gamepad controller
  19076. */
  19077. static GAMEPAD: number;
  19078. /**
  19079. * Represents a generic controller
  19080. */
  19081. static GENERIC: number;
  19082. /**
  19083. * Represents an XBox controller
  19084. */
  19085. static XBOX: number;
  19086. /**
  19087. * Represents a pose-enabled controller
  19088. */
  19089. static POSE_ENABLED: number;
  19090. /**
  19091. * Represents an Dual Shock controller
  19092. */
  19093. static DUALSHOCK: number;
  19094. /**
  19095. * Specifies whether the left control stick should be Y-inverted
  19096. */
  19097. protected _invertLeftStickY: boolean;
  19098. /**
  19099. * Specifies if the gamepad has been connected
  19100. */
  19101. get isConnected(): boolean;
  19102. /**
  19103. * Initializes the gamepad
  19104. * @param id The id of the gamepad
  19105. * @param index The index of the gamepad
  19106. * @param browserGamepad The browser gamepad
  19107. * @param leftStickX The x component of the left joystick
  19108. * @param leftStickY The y component of the left joystick
  19109. * @param rightStickX The x component of the right joystick
  19110. * @param rightStickY The y component of the right joystick
  19111. */
  19112. constructor(
  19113. /**
  19114. * The id of the gamepad
  19115. */
  19116. id: string,
  19117. /**
  19118. * The index of the gamepad
  19119. */
  19120. index: number,
  19121. /**
  19122. * The browser gamepad
  19123. */
  19124. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19125. /**
  19126. * Callback triggered when the left joystick has changed
  19127. * @param callback
  19128. */
  19129. onleftstickchanged(callback: (values: StickValues) => void): void;
  19130. /**
  19131. * Callback triggered when the right joystick has changed
  19132. * @param callback
  19133. */
  19134. onrightstickchanged(callback: (values: StickValues) => void): void;
  19135. /**
  19136. * Gets the left joystick
  19137. */
  19138. get leftStick(): StickValues;
  19139. /**
  19140. * Sets the left joystick values
  19141. */
  19142. set leftStick(newValues: StickValues);
  19143. /**
  19144. * Gets the right joystick
  19145. */
  19146. get rightStick(): StickValues;
  19147. /**
  19148. * Sets the right joystick value
  19149. */
  19150. set rightStick(newValues: StickValues);
  19151. /**
  19152. * Updates the gamepad joystick positions
  19153. */
  19154. update(): void;
  19155. /**
  19156. * Disposes the gamepad
  19157. */
  19158. dispose(): void;
  19159. }
  19160. /**
  19161. * Represents a generic gamepad
  19162. */
  19163. export class GenericPad extends Gamepad {
  19164. private _buttons;
  19165. private _onbuttondown;
  19166. private _onbuttonup;
  19167. /**
  19168. * Observable triggered when a button has been pressed
  19169. */
  19170. onButtonDownObservable: Observable<number>;
  19171. /**
  19172. * Observable triggered when a button has been released
  19173. */
  19174. onButtonUpObservable: Observable<number>;
  19175. /**
  19176. * Callback triggered when a button has been pressed
  19177. * @param callback Called when a button has been pressed
  19178. */
  19179. onbuttondown(callback: (buttonPressed: number) => void): void;
  19180. /**
  19181. * Callback triggered when a button has been released
  19182. * @param callback Called when a button has been released
  19183. */
  19184. onbuttonup(callback: (buttonReleased: number) => void): void;
  19185. /**
  19186. * Initializes the generic gamepad
  19187. * @param id The id of the generic gamepad
  19188. * @param index The index of the generic gamepad
  19189. * @param browserGamepad The browser gamepad
  19190. */
  19191. constructor(id: string, index: number, browserGamepad: any);
  19192. private _setButtonValue;
  19193. /**
  19194. * Updates the generic gamepad
  19195. */
  19196. update(): void;
  19197. /**
  19198. * Disposes the generic gamepad
  19199. */
  19200. dispose(): void;
  19201. }
  19202. }
  19203. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19204. import { Observable } from "babylonjs/Misc/observable";
  19205. import { Nullable } from "babylonjs/types";
  19206. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19209. import { Ray } from "babylonjs/Culling/ray";
  19210. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19211. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19212. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19213. /**
  19214. * Defines the types of pose enabled controllers that are supported
  19215. */
  19216. export enum PoseEnabledControllerType {
  19217. /**
  19218. * HTC Vive
  19219. */
  19220. VIVE = 0,
  19221. /**
  19222. * Oculus Rift
  19223. */
  19224. OCULUS = 1,
  19225. /**
  19226. * Windows mixed reality
  19227. */
  19228. WINDOWS = 2,
  19229. /**
  19230. * Samsung gear VR
  19231. */
  19232. GEAR_VR = 3,
  19233. /**
  19234. * Google Daydream
  19235. */
  19236. DAYDREAM = 4,
  19237. /**
  19238. * Generic
  19239. */
  19240. GENERIC = 5
  19241. }
  19242. /**
  19243. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19244. */
  19245. export interface MutableGamepadButton {
  19246. /**
  19247. * Value of the button/trigger
  19248. */
  19249. value: number;
  19250. /**
  19251. * If the button/trigger is currently touched
  19252. */
  19253. touched: boolean;
  19254. /**
  19255. * If the button/trigger is currently pressed
  19256. */
  19257. pressed: boolean;
  19258. }
  19259. /**
  19260. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19261. * @hidden
  19262. */
  19263. export interface ExtendedGamepadButton extends GamepadButton {
  19264. /**
  19265. * If the button/trigger is currently pressed
  19266. */
  19267. readonly pressed: boolean;
  19268. /**
  19269. * If the button/trigger is currently touched
  19270. */
  19271. readonly touched: boolean;
  19272. /**
  19273. * Value of the button/trigger
  19274. */
  19275. readonly value: number;
  19276. }
  19277. /** @hidden */
  19278. export interface _GamePadFactory {
  19279. /**
  19280. * Returns whether or not the current gamepad can be created for this type of controller.
  19281. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19282. * @returns true if it can be created, otherwise false
  19283. */
  19284. canCreate(gamepadInfo: any): boolean;
  19285. /**
  19286. * Creates a new instance of the Gamepad.
  19287. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19288. * @returns the new gamepad instance
  19289. */
  19290. create(gamepadInfo: any): Gamepad;
  19291. }
  19292. /**
  19293. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19294. */
  19295. export class PoseEnabledControllerHelper {
  19296. /** @hidden */
  19297. static _ControllerFactories: _GamePadFactory[];
  19298. /** @hidden */
  19299. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19300. /**
  19301. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19302. * @param vrGamepad the gamepad to initialized
  19303. * @returns a vr controller of the type the gamepad identified as
  19304. */
  19305. static InitiateController(vrGamepad: any): Gamepad;
  19306. }
  19307. /**
  19308. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19309. */
  19310. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19311. /**
  19312. * If the controller is used in a webXR session
  19313. */
  19314. isXR: boolean;
  19315. private _deviceRoomPosition;
  19316. private _deviceRoomRotationQuaternion;
  19317. /**
  19318. * The device position in babylon space
  19319. */
  19320. devicePosition: Vector3;
  19321. /**
  19322. * The device rotation in babylon space
  19323. */
  19324. deviceRotationQuaternion: Quaternion;
  19325. /**
  19326. * The scale factor of the device in babylon space
  19327. */
  19328. deviceScaleFactor: number;
  19329. /**
  19330. * (Likely devicePosition should be used instead) The device position in its room space
  19331. */
  19332. position: Vector3;
  19333. /**
  19334. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19335. */
  19336. rotationQuaternion: Quaternion;
  19337. /**
  19338. * The type of controller (Eg. Windows mixed reality)
  19339. */
  19340. controllerType: PoseEnabledControllerType;
  19341. protected _calculatedPosition: Vector3;
  19342. private _calculatedRotation;
  19343. /**
  19344. * The raw pose from the device
  19345. */
  19346. rawPose: DevicePose;
  19347. private _trackPosition;
  19348. private _maxRotationDistFromHeadset;
  19349. private _draggedRoomRotation;
  19350. /**
  19351. * @hidden
  19352. */
  19353. _disableTrackPosition(fixedPosition: Vector3): void;
  19354. /**
  19355. * Internal, the mesh attached to the controller
  19356. * @hidden
  19357. */
  19358. _mesh: Nullable<AbstractMesh>;
  19359. private _poseControlledCamera;
  19360. private _leftHandSystemQuaternion;
  19361. /**
  19362. * Internal, matrix used to convert room space to babylon space
  19363. * @hidden
  19364. */
  19365. _deviceToWorld: Matrix;
  19366. /**
  19367. * Node to be used when casting a ray from the controller
  19368. * @hidden
  19369. */
  19370. _pointingPoseNode: Nullable<TransformNode>;
  19371. /**
  19372. * Name of the child mesh that can be used to cast a ray from the controller
  19373. */
  19374. static readonly POINTING_POSE: string;
  19375. /**
  19376. * Creates a new PoseEnabledController from a gamepad
  19377. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19378. */
  19379. constructor(browserGamepad: any);
  19380. private _workingMatrix;
  19381. /**
  19382. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19383. */
  19384. update(): void;
  19385. /**
  19386. * Updates only the pose device and mesh without doing any button event checking
  19387. */
  19388. protected _updatePoseAndMesh(): void;
  19389. /**
  19390. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19391. * @param poseData raw pose fromthe device
  19392. */
  19393. updateFromDevice(poseData: DevicePose): void;
  19394. /**
  19395. * @hidden
  19396. */
  19397. _meshAttachedObservable: Observable<AbstractMesh>;
  19398. /**
  19399. * Attaches a mesh to the controller
  19400. * @param mesh the mesh to be attached
  19401. */
  19402. attachToMesh(mesh: AbstractMesh): void;
  19403. /**
  19404. * Attaches the controllers mesh to a camera
  19405. * @param camera the camera the mesh should be attached to
  19406. */
  19407. attachToPoseControlledCamera(camera: TargetCamera): void;
  19408. /**
  19409. * Disposes of the controller
  19410. */
  19411. dispose(): void;
  19412. /**
  19413. * The mesh that is attached to the controller
  19414. */
  19415. get mesh(): Nullable<AbstractMesh>;
  19416. /**
  19417. * Gets the ray of the controller in the direction the controller is pointing
  19418. * @param length the length the resulting ray should be
  19419. * @returns a ray in the direction the controller is pointing
  19420. */
  19421. getForwardRay(length?: number): Ray;
  19422. }
  19423. }
  19424. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19425. import { Observable } from "babylonjs/Misc/observable";
  19426. import { Scene } from "babylonjs/scene";
  19427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19428. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19429. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19430. import { Nullable } from "babylonjs/types";
  19431. /**
  19432. * Defines the WebVRController object that represents controllers tracked in 3D space
  19433. */
  19434. export abstract class WebVRController extends PoseEnabledController {
  19435. /**
  19436. * Internal, the default controller model for the controller
  19437. */
  19438. protected _defaultModel: Nullable<AbstractMesh>;
  19439. /**
  19440. * Fired when the trigger state has changed
  19441. */
  19442. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19443. /**
  19444. * Fired when the main button state has changed
  19445. */
  19446. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19447. /**
  19448. * Fired when the secondary button state has changed
  19449. */
  19450. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19451. /**
  19452. * Fired when the pad state has changed
  19453. */
  19454. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19455. /**
  19456. * Fired when controllers stick values have changed
  19457. */
  19458. onPadValuesChangedObservable: Observable<StickValues>;
  19459. /**
  19460. * Array of button availible on the controller
  19461. */
  19462. protected _buttons: Array<MutableGamepadButton>;
  19463. private _onButtonStateChange;
  19464. /**
  19465. * Fired when a controller button's state has changed
  19466. * @param callback the callback containing the button that was modified
  19467. */
  19468. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19469. /**
  19470. * X and Y axis corresponding to the controllers joystick
  19471. */
  19472. pad: StickValues;
  19473. /**
  19474. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19475. */
  19476. hand: string;
  19477. /**
  19478. * The default controller model for the controller
  19479. */
  19480. get defaultModel(): Nullable<AbstractMesh>;
  19481. /**
  19482. * Creates a new WebVRController from a gamepad
  19483. * @param vrGamepad the gamepad that the WebVRController should be created from
  19484. */
  19485. constructor(vrGamepad: any);
  19486. /**
  19487. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19488. */
  19489. update(): void;
  19490. /**
  19491. * Function to be called when a button is modified
  19492. */
  19493. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19494. /**
  19495. * Loads a mesh and attaches it to the controller
  19496. * @param scene the scene the mesh should be added to
  19497. * @param meshLoaded callback for when the mesh has been loaded
  19498. */
  19499. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19500. private _setButtonValue;
  19501. private _changes;
  19502. private _checkChanges;
  19503. /**
  19504. * Disposes of th webVRCOntroller
  19505. */
  19506. dispose(): void;
  19507. }
  19508. }
  19509. declare module "babylonjs/Lights/hemisphericLight" {
  19510. import { Nullable } from "babylonjs/types";
  19511. import { Scene } from "babylonjs/scene";
  19512. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19513. import { Color3 } from "babylonjs/Maths/math.color";
  19514. import { Effect } from "babylonjs/Materials/effect";
  19515. import { Light } from "babylonjs/Lights/light";
  19516. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19517. /**
  19518. * The HemisphericLight simulates the ambient environment light,
  19519. * so the passed direction is the light reflection direction, not the incoming direction.
  19520. */
  19521. export class HemisphericLight extends Light {
  19522. /**
  19523. * The groundColor is the light in the opposite direction to the one specified during creation.
  19524. * 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.
  19525. */
  19526. groundColor: Color3;
  19527. /**
  19528. * The light reflection direction, not the incoming direction.
  19529. */
  19530. direction: Vector3;
  19531. /**
  19532. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19533. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19534. * The HemisphericLight can't cast shadows.
  19535. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19536. * @param name The friendly name of the light
  19537. * @param direction The direction of the light reflection
  19538. * @param scene The scene the light belongs to
  19539. */
  19540. constructor(name: string, direction: Vector3, scene: Scene);
  19541. protected _buildUniformLayout(): void;
  19542. /**
  19543. * Returns the string "HemisphericLight".
  19544. * @return The class name
  19545. */
  19546. getClassName(): string;
  19547. /**
  19548. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19549. * Returns the updated direction.
  19550. * @param target The target the direction should point to
  19551. * @return The computed direction
  19552. */
  19553. setDirectionToTarget(target: Vector3): Vector3;
  19554. /**
  19555. * Returns the shadow generator associated to the light.
  19556. * @returns Always null for hemispheric lights because it does not support shadows.
  19557. */
  19558. getShadowGenerator(): Nullable<IShadowGenerator>;
  19559. /**
  19560. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19561. * @param effect The effect to update
  19562. * @param lightIndex The index of the light in the effect to update
  19563. * @returns The hemispheric light
  19564. */
  19565. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19566. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19567. /**
  19568. * Computes the world matrix of the node
  19569. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19570. * @param useWasUpdatedFlag defines a reserved property
  19571. * @returns the world matrix
  19572. */
  19573. computeWorldMatrix(): Matrix;
  19574. /**
  19575. * Returns the integer 3.
  19576. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19577. */
  19578. getTypeID(): number;
  19579. /**
  19580. * Prepares the list of defines specific to the light type.
  19581. * @param defines the list of defines
  19582. * @param lightIndex defines the index of the light for the effect
  19583. */
  19584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19585. }
  19586. }
  19587. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19588. /** @hidden */
  19589. export var vrMultiviewToSingleviewPixelShader: {
  19590. name: string;
  19591. shader: string;
  19592. };
  19593. }
  19594. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19595. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19596. import { Scene } from "babylonjs/scene";
  19597. /**
  19598. * Renders to multiple views with a single draw call
  19599. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19600. */
  19601. export class MultiviewRenderTarget extends RenderTargetTexture {
  19602. /**
  19603. * Creates a multiview render target
  19604. * @param scene scene used with the render target
  19605. * @param size the size of the render target (used for each view)
  19606. */
  19607. constructor(scene: Scene, size?: number | {
  19608. width: number;
  19609. height: number;
  19610. } | {
  19611. ratio: number;
  19612. });
  19613. /**
  19614. * @hidden
  19615. * @param faceIndex the face index, if its a cube texture
  19616. */
  19617. _bindFrameBuffer(faceIndex?: number): void;
  19618. /**
  19619. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19620. * @returns the view count
  19621. */
  19622. getViewCount(): number;
  19623. }
  19624. }
  19625. declare module "babylonjs/Maths/math.frustum" {
  19626. import { Matrix } from "babylonjs/Maths/math.vector";
  19627. import { DeepImmutable } from "babylonjs/types";
  19628. import { Plane } from "babylonjs/Maths/math.plane";
  19629. /**
  19630. * Represents a camera frustum
  19631. */
  19632. export class Frustum {
  19633. /**
  19634. * Gets the planes representing the frustum
  19635. * @param transform matrix to be applied to the returned planes
  19636. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19637. */
  19638. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19639. /**
  19640. * Gets the near frustum plane transformed by the transform matrix
  19641. * @param transform transformation matrix to be applied to the resulting frustum plane
  19642. * @param frustumPlane the resuling frustum plane
  19643. */
  19644. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19645. /**
  19646. * Gets the far frustum plane transformed by the transform matrix
  19647. * @param transform transformation matrix to be applied to the resulting frustum plane
  19648. * @param frustumPlane the resuling frustum plane
  19649. */
  19650. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19651. /**
  19652. * Gets the left frustum plane transformed by the transform matrix
  19653. * @param transform transformation matrix to be applied to the resulting frustum plane
  19654. * @param frustumPlane the resuling frustum plane
  19655. */
  19656. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19657. /**
  19658. * Gets the right frustum plane transformed by the transform matrix
  19659. * @param transform transformation matrix to be applied to the resulting frustum plane
  19660. * @param frustumPlane the resuling frustum plane
  19661. */
  19662. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19663. /**
  19664. * Gets the top frustum plane transformed by the transform matrix
  19665. * @param transform transformation matrix to be applied to the resulting frustum plane
  19666. * @param frustumPlane the resuling frustum plane
  19667. */
  19668. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19669. /**
  19670. * Gets the bottom frustum plane transformed by the transform matrix
  19671. * @param transform transformation matrix to be applied to the resulting frustum plane
  19672. * @param frustumPlane the resuling frustum plane
  19673. */
  19674. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19675. /**
  19676. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19677. * @param transform transformation matrix to be applied to the resulting frustum planes
  19678. * @param frustumPlanes the resuling frustum planes
  19679. */
  19680. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19681. }
  19682. }
  19683. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19684. import { Camera } from "babylonjs/Cameras/camera";
  19685. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19686. import { Nullable } from "babylonjs/types";
  19687. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19688. import { Matrix } from "babylonjs/Maths/math.vector";
  19689. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19690. module "babylonjs/Engines/engine" {
  19691. interface Engine {
  19692. /**
  19693. * Creates a new multiview render target
  19694. * @param width defines the width of the texture
  19695. * @param height defines the height of the texture
  19696. * @returns the created multiview texture
  19697. */
  19698. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19699. /**
  19700. * Binds a multiview framebuffer to be drawn to
  19701. * @param multiviewTexture texture to bind
  19702. */
  19703. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19704. }
  19705. }
  19706. module "babylonjs/Cameras/camera" {
  19707. interface Camera {
  19708. /**
  19709. * @hidden
  19710. * 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)
  19711. */
  19712. _useMultiviewToSingleView: boolean;
  19713. /**
  19714. * @hidden
  19715. * 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)
  19716. */
  19717. _multiviewTexture: Nullable<RenderTargetTexture>;
  19718. /**
  19719. * @hidden
  19720. * ensures the multiview texture of the camera exists and has the specified width/height
  19721. * @param width height to set on the multiview texture
  19722. * @param height width to set on the multiview texture
  19723. */
  19724. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19725. }
  19726. }
  19727. module "babylonjs/scene" {
  19728. interface Scene {
  19729. /** @hidden */
  19730. _transformMatrixR: Matrix;
  19731. /** @hidden */
  19732. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19733. /** @hidden */
  19734. _createMultiviewUbo(): void;
  19735. /** @hidden */
  19736. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19737. /** @hidden */
  19738. _renderMultiviewToSingleView(camera: Camera): void;
  19739. }
  19740. }
  19741. }
  19742. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19743. import { Camera } from "babylonjs/Cameras/camera";
  19744. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19745. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19746. import "babylonjs/Engines/Extensions/engine.multiview";
  19747. /**
  19748. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19749. * This will not be used for webXR as it supports displaying texture arrays directly
  19750. */
  19751. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19752. /**
  19753. * Initializes a VRMultiviewToSingleview
  19754. * @param name name of the post process
  19755. * @param camera camera to be applied to
  19756. * @param scaleFactor scaling factor to the size of the output texture
  19757. */
  19758. constructor(name: string, camera: Camera, scaleFactor: number);
  19759. }
  19760. }
  19761. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19762. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19763. import { Nullable } from "babylonjs/types";
  19764. import { Size } from "babylonjs/Maths/math.size";
  19765. import { Observable } from "babylonjs/Misc/observable";
  19766. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19767. /**
  19768. * Interface used to define additional presentation attributes
  19769. */
  19770. export interface IVRPresentationAttributes {
  19771. /**
  19772. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19773. */
  19774. highRefreshRate: boolean;
  19775. /**
  19776. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19777. */
  19778. foveationLevel: number;
  19779. }
  19780. module "babylonjs/Engines/engine" {
  19781. interface Engine {
  19782. /** @hidden */
  19783. _vrDisplay: any;
  19784. /** @hidden */
  19785. _vrSupported: boolean;
  19786. /** @hidden */
  19787. _oldSize: Size;
  19788. /** @hidden */
  19789. _oldHardwareScaleFactor: number;
  19790. /** @hidden */
  19791. _vrExclusivePointerMode: boolean;
  19792. /** @hidden */
  19793. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19794. /** @hidden */
  19795. _onVRDisplayPointerRestricted: () => void;
  19796. /** @hidden */
  19797. _onVRDisplayPointerUnrestricted: () => void;
  19798. /** @hidden */
  19799. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19800. /** @hidden */
  19801. _onVrDisplayDisconnect: Nullable<() => void>;
  19802. /** @hidden */
  19803. _onVrDisplayPresentChange: Nullable<() => void>;
  19804. /**
  19805. * Observable signaled when VR display mode changes
  19806. */
  19807. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19808. /**
  19809. * Observable signaled when VR request present is complete
  19810. */
  19811. onVRRequestPresentComplete: Observable<boolean>;
  19812. /**
  19813. * Observable signaled when VR request present starts
  19814. */
  19815. onVRRequestPresentStart: Observable<Engine>;
  19816. /**
  19817. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19818. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19819. */
  19820. isInVRExclusivePointerMode: boolean;
  19821. /**
  19822. * Gets a boolean indicating if a webVR device was detected
  19823. * @returns true if a webVR device was detected
  19824. */
  19825. isVRDevicePresent(): boolean;
  19826. /**
  19827. * Gets the current webVR device
  19828. * @returns the current webVR device (or null)
  19829. */
  19830. getVRDevice(): any;
  19831. /**
  19832. * Initializes a webVR display and starts listening to display change events
  19833. * The onVRDisplayChangedObservable will be notified upon these changes
  19834. * @returns A promise containing a VRDisplay and if vr is supported
  19835. */
  19836. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19837. /** @hidden */
  19838. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19839. /**
  19840. * Gets or sets the presentation attributes used to configure VR rendering
  19841. */
  19842. vrPresentationAttributes?: IVRPresentationAttributes;
  19843. /**
  19844. * Call this function to switch to webVR mode
  19845. * Will do nothing if webVR is not supported or if there is no webVR device
  19846. * @param options the webvr options provided to the camera. mainly used for multiview
  19847. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19848. */
  19849. enableVR(options: WebVROptions): void;
  19850. /** @hidden */
  19851. _onVRFullScreenTriggered(): void;
  19852. }
  19853. }
  19854. }
  19855. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19856. import { Nullable } from "babylonjs/types";
  19857. import { Observable } from "babylonjs/Misc/observable";
  19858. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19859. import { Scene } from "babylonjs/scene";
  19860. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19861. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19862. import { Node } from "babylonjs/node";
  19863. import { Ray } from "babylonjs/Culling/ray";
  19864. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19865. import "babylonjs/Engines/Extensions/engine.webVR";
  19866. /**
  19867. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19868. * IMPORTANT!! The data is right-hand data.
  19869. * @export
  19870. * @interface DevicePose
  19871. */
  19872. export interface DevicePose {
  19873. /**
  19874. * The position of the device, values in array are [x,y,z].
  19875. */
  19876. readonly position: Nullable<Float32Array>;
  19877. /**
  19878. * The linearVelocity of the device, values in array are [x,y,z].
  19879. */
  19880. readonly linearVelocity: Nullable<Float32Array>;
  19881. /**
  19882. * The linearAcceleration of the device, values in array are [x,y,z].
  19883. */
  19884. readonly linearAcceleration: Nullable<Float32Array>;
  19885. /**
  19886. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19887. */
  19888. readonly orientation: Nullable<Float32Array>;
  19889. /**
  19890. * The angularVelocity of the device, values in array are [x,y,z].
  19891. */
  19892. readonly angularVelocity: Nullable<Float32Array>;
  19893. /**
  19894. * The angularAcceleration of the device, values in array are [x,y,z].
  19895. */
  19896. readonly angularAcceleration: Nullable<Float32Array>;
  19897. }
  19898. /**
  19899. * Interface representing a pose controlled object in Babylon.
  19900. * A pose controlled object has both regular pose values as well as pose values
  19901. * from an external device such as a VR head mounted display
  19902. */
  19903. export interface PoseControlled {
  19904. /**
  19905. * The position of the object in babylon space.
  19906. */
  19907. position: Vector3;
  19908. /**
  19909. * The rotation quaternion of the object in babylon space.
  19910. */
  19911. rotationQuaternion: Quaternion;
  19912. /**
  19913. * The position of the device in babylon space.
  19914. */
  19915. devicePosition?: Vector3;
  19916. /**
  19917. * The rotation quaternion of the device in babylon space.
  19918. */
  19919. deviceRotationQuaternion: Quaternion;
  19920. /**
  19921. * The raw pose coming from the device.
  19922. */
  19923. rawPose: Nullable<DevicePose>;
  19924. /**
  19925. * The scale of the device to be used when translating from device space to babylon space.
  19926. */
  19927. deviceScaleFactor: number;
  19928. /**
  19929. * Updates the poseControlled values based on the input device pose.
  19930. * @param poseData the pose data to update the object with
  19931. */
  19932. updateFromDevice(poseData: DevicePose): void;
  19933. }
  19934. /**
  19935. * Set of options to customize the webVRCamera
  19936. */
  19937. export interface WebVROptions {
  19938. /**
  19939. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19940. */
  19941. trackPosition?: boolean;
  19942. /**
  19943. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19944. */
  19945. positionScale?: number;
  19946. /**
  19947. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19948. */
  19949. displayName?: string;
  19950. /**
  19951. * Should the native controller meshes be initialized. (default: true)
  19952. */
  19953. controllerMeshes?: boolean;
  19954. /**
  19955. * Creating a default HemiLight only on controllers. (default: true)
  19956. */
  19957. defaultLightingOnControllers?: boolean;
  19958. /**
  19959. * If you don't want to use the default VR button of the helper. (default: false)
  19960. */
  19961. useCustomVRButton?: boolean;
  19962. /**
  19963. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19964. */
  19965. customVRButton?: HTMLButtonElement;
  19966. /**
  19967. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19968. */
  19969. rayLength?: number;
  19970. /**
  19971. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19972. */
  19973. defaultHeight?: number;
  19974. /**
  19975. * If multiview should be used if availible (default: false)
  19976. */
  19977. useMultiview?: boolean;
  19978. }
  19979. /**
  19980. * This represents a WebVR camera.
  19981. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19982. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19983. */
  19984. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19985. private webVROptions;
  19986. /**
  19987. * @hidden
  19988. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19989. */
  19990. _vrDevice: any;
  19991. /**
  19992. * The rawPose of the vrDevice.
  19993. */
  19994. rawPose: Nullable<DevicePose>;
  19995. private _onVREnabled;
  19996. private _specsVersion;
  19997. private _attached;
  19998. private _frameData;
  19999. protected _descendants: Array<Node>;
  20000. private _deviceRoomPosition;
  20001. /** @hidden */
  20002. _deviceRoomRotationQuaternion: Quaternion;
  20003. private _standingMatrix;
  20004. /**
  20005. * Represents device position in babylon space.
  20006. */
  20007. devicePosition: Vector3;
  20008. /**
  20009. * Represents device rotation in babylon space.
  20010. */
  20011. deviceRotationQuaternion: Quaternion;
  20012. /**
  20013. * The scale of the device to be used when translating from device space to babylon space.
  20014. */
  20015. deviceScaleFactor: number;
  20016. private _deviceToWorld;
  20017. private _worldToDevice;
  20018. /**
  20019. * References to the webVR controllers for the vrDevice.
  20020. */
  20021. controllers: Array<WebVRController>;
  20022. /**
  20023. * Emits an event when a controller is attached.
  20024. */
  20025. onControllersAttachedObservable: Observable<WebVRController[]>;
  20026. /**
  20027. * Emits an event when a controller's mesh has been loaded;
  20028. */
  20029. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20030. /**
  20031. * Emits an event when the HMD's pose has been updated.
  20032. */
  20033. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20034. private _poseSet;
  20035. /**
  20036. * If the rig cameras be used as parent instead of this camera.
  20037. */
  20038. rigParenting: boolean;
  20039. private _lightOnControllers;
  20040. private _defaultHeight?;
  20041. /**
  20042. * Instantiates a WebVRFreeCamera.
  20043. * @param name The name of the WebVRFreeCamera
  20044. * @param position The starting anchor position for the camera
  20045. * @param scene The scene the camera belongs to
  20046. * @param webVROptions a set of customizable options for the webVRCamera
  20047. */
  20048. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20049. /**
  20050. * Gets the device distance from the ground in meters.
  20051. * @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.
  20052. */
  20053. deviceDistanceToRoomGround(): number;
  20054. /**
  20055. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20056. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20057. */
  20058. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20059. /**
  20060. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20061. * @returns A promise with a boolean set to if the standing matrix is supported.
  20062. */
  20063. useStandingMatrixAsync(): Promise<boolean>;
  20064. /**
  20065. * Disposes the camera
  20066. */
  20067. dispose(): void;
  20068. /**
  20069. * Gets a vrController by name.
  20070. * @param name The name of the controller to retreive
  20071. * @returns the controller matching the name specified or null if not found
  20072. */
  20073. getControllerByName(name: string): Nullable<WebVRController>;
  20074. private _leftController;
  20075. /**
  20076. * The controller corresponding to the users left hand.
  20077. */
  20078. get leftController(): Nullable<WebVRController>;
  20079. private _rightController;
  20080. /**
  20081. * The controller corresponding to the users right hand.
  20082. */
  20083. get rightController(): Nullable<WebVRController>;
  20084. /**
  20085. * Casts a ray forward from the vrCamera's gaze.
  20086. * @param length Length of the ray (default: 100)
  20087. * @returns the ray corresponding to the gaze
  20088. */
  20089. getForwardRay(length?: number): Ray;
  20090. /**
  20091. * @hidden
  20092. * Updates the camera based on device's frame data
  20093. */
  20094. _checkInputs(): void;
  20095. /**
  20096. * Updates the poseControlled values based on the input device pose.
  20097. * @param poseData Pose coming from the device
  20098. */
  20099. updateFromDevice(poseData: DevicePose): void;
  20100. private _htmlElementAttached;
  20101. private _detachIfAttached;
  20102. /**
  20103. * WebVR's attach control will start broadcasting frames to the device.
  20104. * Note that in certain browsers (chrome for example) this function must be called
  20105. * within a user-interaction callback. Example:
  20106. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20107. *
  20108. * @param element html element to attach the vrDevice to
  20109. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20110. */
  20111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20112. /**
  20113. * Detaches the camera from the html element and disables VR
  20114. *
  20115. * @param element html element to detach from
  20116. */
  20117. detachControl(element: HTMLElement): void;
  20118. /**
  20119. * @returns the name of this class
  20120. */
  20121. getClassName(): string;
  20122. /**
  20123. * Calls resetPose on the vrDisplay
  20124. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20125. */
  20126. resetToCurrentRotation(): void;
  20127. /**
  20128. * @hidden
  20129. * Updates the rig cameras (left and right eye)
  20130. */
  20131. _updateRigCameras(): void;
  20132. private _workingVector;
  20133. private _oneVector;
  20134. private _workingMatrix;
  20135. private updateCacheCalled;
  20136. private _correctPositionIfNotTrackPosition;
  20137. /**
  20138. * @hidden
  20139. * Updates the cached values of the camera
  20140. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20141. */
  20142. _updateCache(ignoreParentClass?: boolean): void;
  20143. /**
  20144. * @hidden
  20145. * Get current device position in babylon world
  20146. */
  20147. _computeDevicePosition(): void;
  20148. /**
  20149. * Updates the current device position and rotation in the babylon world
  20150. */
  20151. update(): void;
  20152. /**
  20153. * @hidden
  20154. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20155. * @returns an identity matrix
  20156. */
  20157. _getViewMatrix(): Matrix;
  20158. private _tmpMatrix;
  20159. /**
  20160. * This function is called by the two RIG cameras.
  20161. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20162. * @hidden
  20163. */
  20164. _getWebVRViewMatrix(): Matrix;
  20165. /** @hidden */
  20166. _getWebVRProjectionMatrix(): Matrix;
  20167. private _onGamepadConnectedObserver;
  20168. private _onGamepadDisconnectedObserver;
  20169. private _updateCacheWhenTrackingDisabledObserver;
  20170. /**
  20171. * Initializes the controllers and their meshes
  20172. */
  20173. initControllers(): void;
  20174. }
  20175. }
  20176. declare module "babylonjs/PostProcesses/postProcess" {
  20177. import { Nullable } from "babylonjs/types";
  20178. import { SmartArray } from "babylonjs/Misc/smartArray";
  20179. import { Observable } from "babylonjs/Misc/observable";
  20180. import { Vector2 } from "babylonjs/Maths/math.vector";
  20181. import { Camera } from "babylonjs/Cameras/camera";
  20182. import { Effect } from "babylonjs/Materials/effect";
  20183. import "babylonjs/Shaders/postprocess.vertex";
  20184. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20185. import { Engine } from "babylonjs/Engines/engine";
  20186. import { Color4 } from "babylonjs/Maths/math.color";
  20187. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20188. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20189. /**
  20190. * Size options for a post process
  20191. */
  20192. export type PostProcessOptions = {
  20193. width: number;
  20194. height: number;
  20195. };
  20196. /**
  20197. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20198. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20199. */
  20200. export class PostProcess {
  20201. /** Name of the PostProcess. */
  20202. name: string;
  20203. /**
  20204. * Gets or sets the unique id of the post process
  20205. */
  20206. uniqueId: number;
  20207. /**
  20208. * Width of the texture to apply the post process on
  20209. */
  20210. width: number;
  20211. /**
  20212. * Height of the texture to apply the post process on
  20213. */
  20214. height: number;
  20215. /**
  20216. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20217. * @hidden
  20218. */
  20219. _outputTexture: Nullable<InternalTexture>;
  20220. /**
  20221. * Sampling mode used by the shader
  20222. * See https://doc.babylonjs.com/classes/3.1/texture
  20223. */
  20224. renderTargetSamplingMode: number;
  20225. /**
  20226. * Clear color to use when screen clearing
  20227. */
  20228. clearColor: Color4;
  20229. /**
  20230. * If the buffer needs to be cleared before applying the post process. (default: true)
  20231. * Should be set to false if shader will overwrite all previous pixels.
  20232. */
  20233. autoClear: boolean;
  20234. /**
  20235. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20236. */
  20237. alphaMode: number;
  20238. /**
  20239. * Sets the setAlphaBlendConstants of the babylon engine
  20240. */
  20241. alphaConstants: Color4;
  20242. /**
  20243. * Animations to be used for the post processing
  20244. */
  20245. animations: import("babylonjs/Animations/animation").Animation[];
  20246. /**
  20247. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20248. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20249. */
  20250. enablePixelPerfectMode: boolean;
  20251. /**
  20252. * Force the postprocess to be applied without taking in account viewport
  20253. */
  20254. forceFullscreenViewport: boolean;
  20255. /**
  20256. * List of inspectable custom properties (used by the Inspector)
  20257. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20258. */
  20259. inspectableCustomProperties: IInspectable[];
  20260. /**
  20261. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20262. *
  20263. * | Value | Type | Description |
  20264. * | ----- | ----------------------------------- | ----------- |
  20265. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20266. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20267. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20268. *
  20269. */
  20270. scaleMode: number;
  20271. /**
  20272. * Force textures to be a power of two (default: false)
  20273. */
  20274. alwaysForcePOT: boolean;
  20275. private _samples;
  20276. /**
  20277. * Number of sample textures (default: 1)
  20278. */
  20279. get samples(): number;
  20280. set samples(n: number);
  20281. /**
  20282. * Modify the scale of the post process to be the same as the viewport (default: false)
  20283. */
  20284. adaptScaleToCurrentViewport: boolean;
  20285. private _camera;
  20286. private _scene;
  20287. private _engine;
  20288. private _options;
  20289. private _reusable;
  20290. private _textureType;
  20291. private _textureFormat;
  20292. /**
  20293. * Smart array of input and output textures for the post process.
  20294. * @hidden
  20295. */
  20296. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20297. /**
  20298. * The index in _textures that corresponds to the output texture.
  20299. * @hidden
  20300. */
  20301. _currentRenderTextureInd: number;
  20302. private _effect;
  20303. private _samplers;
  20304. private _fragmentUrl;
  20305. private _vertexUrl;
  20306. private _parameters;
  20307. private _scaleRatio;
  20308. protected _indexParameters: any;
  20309. private _shareOutputWithPostProcess;
  20310. private _texelSize;
  20311. private _forcedOutputTexture;
  20312. /**
  20313. * Returns the fragment url or shader name used in the post process.
  20314. * @returns the fragment url or name in the shader store.
  20315. */
  20316. getEffectName(): string;
  20317. /**
  20318. * An event triggered when the postprocess is activated.
  20319. */
  20320. onActivateObservable: Observable<Camera>;
  20321. private _onActivateObserver;
  20322. /**
  20323. * A function that is added to the onActivateObservable
  20324. */
  20325. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20326. /**
  20327. * An event triggered when the postprocess changes its size.
  20328. */
  20329. onSizeChangedObservable: Observable<PostProcess>;
  20330. private _onSizeChangedObserver;
  20331. /**
  20332. * A function that is added to the onSizeChangedObservable
  20333. */
  20334. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20335. /**
  20336. * An event triggered when the postprocess applies its effect.
  20337. */
  20338. onApplyObservable: Observable<Effect>;
  20339. private _onApplyObserver;
  20340. /**
  20341. * A function that is added to the onApplyObservable
  20342. */
  20343. set onApply(callback: (effect: Effect) => void);
  20344. /**
  20345. * An event triggered before rendering the postprocess
  20346. */
  20347. onBeforeRenderObservable: Observable<Effect>;
  20348. private _onBeforeRenderObserver;
  20349. /**
  20350. * A function that is added to the onBeforeRenderObservable
  20351. */
  20352. set onBeforeRender(callback: (effect: Effect) => void);
  20353. /**
  20354. * An event triggered after rendering the postprocess
  20355. */
  20356. onAfterRenderObservable: Observable<Effect>;
  20357. private _onAfterRenderObserver;
  20358. /**
  20359. * A function that is added to the onAfterRenderObservable
  20360. */
  20361. set onAfterRender(callback: (efect: Effect) => void);
  20362. /**
  20363. * 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
  20364. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20365. */
  20366. get inputTexture(): InternalTexture;
  20367. set inputTexture(value: InternalTexture);
  20368. /**
  20369. * Gets the camera which post process is applied to.
  20370. * @returns The camera the post process is applied to.
  20371. */
  20372. getCamera(): Camera;
  20373. /**
  20374. * Gets the texel size of the postprocess.
  20375. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20376. */
  20377. get texelSize(): Vector2;
  20378. /**
  20379. * Creates a new instance PostProcess
  20380. * @param name The name of the PostProcess.
  20381. * @param fragmentUrl The url of the fragment shader to be used.
  20382. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20383. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20384. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20385. * @param camera The camera to apply the render pass to.
  20386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20387. * @param engine The engine which the post process will be applied. (default: current engine)
  20388. * @param reusable If the post process can be reused on the same frame. (default: false)
  20389. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20390. * @param textureType Type of textures used when performing the post process. (default: 0)
  20391. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20392. * @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
  20393. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20394. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20395. */
  20396. constructor(
  20397. /** Name of the PostProcess. */
  20398. 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);
  20399. /**
  20400. * Gets a string idenfifying the name of the class
  20401. * @returns "PostProcess" string
  20402. */
  20403. getClassName(): string;
  20404. /**
  20405. * Gets the engine which this post process belongs to.
  20406. * @returns The engine the post process was enabled with.
  20407. */
  20408. getEngine(): Engine;
  20409. /**
  20410. * The effect that is created when initializing the post process.
  20411. * @returns The created effect corresponding the the postprocess.
  20412. */
  20413. getEffect(): Effect;
  20414. /**
  20415. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20416. * @param postProcess The post process to share the output with.
  20417. * @returns This post process.
  20418. */
  20419. shareOutputWith(postProcess: PostProcess): PostProcess;
  20420. /**
  20421. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20422. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20423. */
  20424. useOwnOutput(): void;
  20425. /**
  20426. * Updates the effect with the current post process compile time values and recompiles the shader.
  20427. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20428. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20429. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20430. * @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
  20431. * @param onCompiled Called when the shader has been compiled.
  20432. * @param onError Called if there is an error when compiling a shader.
  20433. */
  20434. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20435. /**
  20436. * The post process is reusable if it can be used multiple times within one frame.
  20437. * @returns If the post process is reusable
  20438. */
  20439. isReusable(): boolean;
  20440. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20441. markTextureDirty(): void;
  20442. /**
  20443. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20444. * 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.
  20445. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20446. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20447. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20448. * @returns The target texture that was bound to be written to.
  20449. */
  20450. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20451. /**
  20452. * If the post process is supported.
  20453. */
  20454. get isSupported(): boolean;
  20455. /**
  20456. * The aspect ratio of the output texture.
  20457. */
  20458. get aspectRatio(): number;
  20459. /**
  20460. * Get a value indicating if the post-process is ready to be used
  20461. * @returns true if the post-process is ready (shader is compiled)
  20462. */
  20463. isReady(): boolean;
  20464. /**
  20465. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20466. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20467. */
  20468. apply(): Nullable<Effect>;
  20469. private _disposeTextures;
  20470. /**
  20471. * Disposes the post process.
  20472. * @param camera The camera to dispose the post process on.
  20473. */
  20474. dispose(camera?: Camera): void;
  20475. }
  20476. }
  20477. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20478. /** @hidden */
  20479. export var kernelBlurVaryingDeclaration: {
  20480. name: string;
  20481. shader: string;
  20482. };
  20483. }
  20484. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20485. /** @hidden */
  20486. export var kernelBlurFragment: {
  20487. name: string;
  20488. shader: string;
  20489. };
  20490. }
  20491. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20492. /** @hidden */
  20493. export var kernelBlurFragment2: {
  20494. name: string;
  20495. shader: string;
  20496. };
  20497. }
  20498. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20499. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20500. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20501. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20502. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20503. /** @hidden */
  20504. export var kernelBlurPixelShader: {
  20505. name: string;
  20506. shader: string;
  20507. };
  20508. }
  20509. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20510. /** @hidden */
  20511. export var kernelBlurVertex: {
  20512. name: string;
  20513. shader: string;
  20514. };
  20515. }
  20516. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20517. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20518. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20519. /** @hidden */
  20520. export var kernelBlurVertexShader: {
  20521. name: string;
  20522. shader: string;
  20523. };
  20524. }
  20525. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20526. import { Vector2 } from "babylonjs/Maths/math.vector";
  20527. import { Nullable } from "babylonjs/types";
  20528. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20529. import { Camera } from "babylonjs/Cameras/camera";
  20530. import { Effect } from "babylonjs/Materials/effect";
  20531. import { Engine } from "babylonjs/Engines/engine";
  20532. import "babylonjs/Shaders/kernelBlur.fragment";
  20533. import "babylonjs/Shaders/kernelBlur.vertex";
  20534. /**
  20535. * The Blur Post Process which blurs an image based on a kernel and direction.
  20536. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20537. */
  20538. export class BlurPostProcess extends PostProcess {
  20539. /** The direction in which to blur the image. */
  20540. direction: Vector2;
  20541. private blockCompilation;
  20542. protected _kernel: number;
  20543. protected _idealKernel: number;
  20544. protected _packedFloat: boolean;
  20545. private _staticDefines;
  20546. /**
  20547. * Sets the length in pixels of the blur sample region
  20548. */
  20549. set kernel(v: number);
  20550. /**
  20551. * Gets the length in pixels of the blur sample region
  20552. */
  20553. get kernel(): number;
  20554. /**
  20555. * Sets wether or not the blur needs to unpack/repack floats
  20556. */
  20557. set packedFloat(v: boolean);
  20558. /**
  20559. * Gets wether or not the blur is unpacking/repacking floats
  20560. */
  20561. get packedFloat(): boolean;
  20562. /**
  20563. * Creates a new instance BlurPostProcess
  20564. * @param name The name of the effect.
  20565. * @param direction The direction in which to blur the image.
  20566. * @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.
  20567. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20568. * @param camera The camera to apply the render pass to.
  20569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20570. * @param engine The engine which the post process will be applied. (default: current engine)
  20571. * @param reusable If the post process can be reused on the same frame. (default: false)
  20572. * @param textureType Type of textures used when performing the post process. (default: 0)
  20573. * @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)
  20574. */
  20575. constructor(name: string,
  20576. /** The direction in which to blur the image. */
  20577. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20578. /**
  20579. * Updates the effect with the current post process compile time values and recompiles the shader.
  20580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20583. * @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
  20584. * @param onCompiled Called when the shader has been compiled.
  20585. * @param onError Called if there is an error when compiling a shader.
  20586. */
  20587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20588. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20589. /**
  20590. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20591. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20592. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20593. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20594. * The gaps between physical kernels are compensated for in the weighting of the samples
  20595. * @param idealKernel Ideal blur kernel.
  20596. * @return Nearest best kernel.
  20597. */
  20598. protected _nearestBestKernel(idealKernel: number): number;
  20599. /**
  20600. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20601. * @param x The point on the Gaussian distribution to sample.
  20602. * @return the value of the Gaussian function at x.
  20603. */
  20604. protected _gaussianWeight(x: number): number;
  20605. /**
  20606. * Generates a string that can be used as a floating point number in GLSL.
  20607. * @param x Value to print.
  20608. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20609. * @return GLSL float string.
  20610. */
  20611. protected _glslFloat(x: number, decimalFigures?: number): string;
  20612. }
  20613. }
  20614. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20615. import { Scene } from "babylonjs/scene";
  20616. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20617. import { Plane } from "babylonjs/Maths/math.plane";
  20618. /**
  20619. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20620. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20621. * You can then easily use it as a reflectionTexture on a flat surface.
  20622. * In case the surface is not a plane, please consider relying on reflection probes.
  20623. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20624. */
  20625. export class MirrorTexture extends RenderTargetTexture {
  20626. private scene;
  20627. /**
  20628. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20629. * 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.
  20630. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20631. */
  20632. mirrorPlane: Plane;
  20633. /**
  20634. * Define the blur ratio used to blur the reflection if needed.
  20635. */
  20636. set blurRatio(value: number);
  20637. get blurRatio(): number;
  20638. /**
  20639. * Define the adaptive blur kernel used to blur the reflection if needed.
  20640. * This will autocompute the closest best match for the `blurKernel`
  20641. */
  20642. set adaptiveBlurKernel(value: number);
  20643. /**
  20644. * Define the blur kernel used to blur the reflection if needed.
  20645. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20646. */
  20647. set blurKernel(value: number);
  20648. /**
  20649. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20650. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20651. */
  20652. set blurKernelX(value: number);
  20653. get blurKernelX(): number;
  20654. /**
  20655. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20656. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20657. */
  20658. set blurKernelY(value: number);
  20659. get blurKernelY(): number;
  20660. private _autoComputeBlurKernel;
  20661. protected _onRatioRescale(): void;
  20662. private _updateGammaSpace;
  20663. private _imageProcessingConfigChangeObserver;
  20664. private _transformMatrix;
  20665. private _mirrorMatrix;
  20666. private _savedViewMatrix;
  20667. private _blurX;
  20668. private _blurY;
  20669. private _adaptiveBlurKernel;
  20670. private _blurKernelX;
  20671. private _blurKernelY;
  20672. private _blurRatio;
  20673. /**
  20674. * Instantiates a Mirror Texture.
  20675. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20676. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20677. * You can then easily use it as a reflectionTexture on a flat surface.
  20678. * In case the surface is not a plane, please consider relying on reflection probes.
  20679. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20680. * @param name
  20681. * @param size
  20682. * @param scene
  20683. * @param generateMipMaps
  20684. * @param type
  20685. * @param samplingMode
  20686. * @param generateDepthBuffer
  20687. */
  20688. constructor(name: string, size: number | {
  20689. width: number;
  20690. height: number;
  20691. } | {
  20692. ratio: number;
  20693. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20694. private _preparePostProcesses;
  20695. /**
  20696. * Clone the mirror texture.
  20697. * @returns the cloned texture
  20698. */
  20699. clone(): MirrorTexture;
  20700. /**
  20701. * Serialize the texture to a JSON representation you could use in Parse later on
  20702. * @returns the serialized JSON representation
  20703. */
  20704. serialize(): any;
  20705. /**
  20706. * Dispose the texture and release its associated resources.
  20707. */
  20708. dispose(): void;
  20709. }
  20710. }
  20711. declare module "babylonjs/Materials/Textures/texture" {
  20712. import { Observable } from "babylonjs/Misc/observable";
  20713. import { Nullable } from "babylonjs/types";
  20714. import { Matrix } from "babylonjs/Maths/math.vector";
  20715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20716. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20718. import { Scene } from "babylonjs/scene";
  20719. /**
  20720. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20721. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20722. */
  20723. export class Texture extends BaseTexture {
  20724. /**
  20725. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20726. */
  20727. static SerializeBuffers: boolean;
  20728. /** @hidden */
  20729. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20730. /** @hidden */
  20731. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20732. /** @hidden */
  20733. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20734. /** nearest is mag = nearest and min = nearest and mip = linear */
  20735. static readonly NEAREST_SAMPLINGMODE: number;
  20736. /** nearest is mag = nearest and min = nearest and mip = linear */
  20737. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20738. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20739. static readonly BILINEAR_SAMPLINGMODE: number;
  20740. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20741. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20742. /** Trilinear is mag = linear and min = linear and mip = linear */
  20743. static readonly TRILINEAR_SAMPLINGMODE: number;
  20744. /** Trilinear is mag = linear and min = linear and mip = linear */
  20745. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20746. /** mag = nearest and min = nearest and mip = nearest */
  20747. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20748. /** mag = nearest and min = linear and mip = nearest */
  20749. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20750. /** mag = nearest and min = linear and mip = linear */
  20751. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20752. /** mag = nearest and min = linear and mip = none */
  20753. static readonly NEAREST_LINEAR: number;
  20754. /** mag = nearest and min = nearest and mip = none */
  20755. static readonly NEAREST_NEAREST: number;
  20756. /** mag = linear and min = nearest and mip = nearest */
  20757. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20758. /** mag = linear and min = nearest and mip = linear */
  20759. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20760. /** mag = linear and min = linear and mip = none */
  20761. static readonly LINEAR_LINEAR: number;
  20762. /** mag = linear and min = nearest and mip = none */
  20763. static readonly LINEAR_NEAREST: number;
  20764. /** Explicit coordinates mode */
  20765. static readonly EXPLICIT_MODE: number;
  20766. /** Spherical coordinates mode */
  20767. static readonly SPHERICAL_MODE: number;
  20768. /** Planar coordinates mode */
  20769. static readonly PLANAR_MODE: number;
  20770. /** Cubic coordinates mode */
  20771. static readonly CUBIC_MODE: number;
  20772. /** Projection coordinates mode */
  20773. static readonly PROJECTION_MODE: number;
  20774. /** Inverse Cubic coordinates mode */
  20775. static readonly SKYBOX_MODE: number;
  20776. /** Inverse Cubic coordinates mode */
  20777. static readonly INVCUBIC_MODE: number;
  20778. /** Equirectangular coordinates mode */
  20779. static readonly EQUIRECTANGULAR_MODE: number;
  20780. /** Equirectangular Fixed coordinates mode */
  20781. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20782. /** Equirectangular Fixed Mirrored coordinates mode */
  20783. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20784. /** Texture is not repeating outside of 0..1 UVs */
  20785. static readonly CLAMP_ADDRESSMODE: number;
  20786. /** Texture is repeating outside of 0..1 UVs */
  20787. static readonly WRAP_ADDRESSMODE: number;
  20788. /** Texture is repeating and mirrored */
  20789. static readonly MIRROR_ADDRESSMODE: number;
  20790. /**
  20791. * 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
  20792. */
  20793. static UseSerializedUrlIfAny: boolean;
  20794. /**
  20795. * Define the url of the texture.
  20796. */
  20797. url: Nullable<string>;
  20798. /**
  20799. * Define an offset on the texture to offset the u coordinates of the UVs
  20800. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20801. */
  20802. uOffset: number;
  20803. /**
  20804. * Define an offset on the texture to offset the v coordinates of the UVs
  20805. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20806. */
  20807. vOffset: number;
  20808. /**
  20809. * Define an offset on the texture to scale the u coordinates of the UVs
  20810. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20811. */
  20812. uScale: number;
  20813. /**
  20814. * Define an offset on the texture to scale the v coordinates of the UVs
  20815. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20816. */
  20817. vScale: number;
  20818. /**
  20819. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20820. * @see http://doc.babylonjs.com/how_to/more_materials
  20821. */
  20822. uAng: number;
  20823. /**
  20824. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20825. * @see http://doc.babylonjs.com/how_to/more_materials
  20826. */
  20827. vAng: number;
  20828. /**
  20829. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20830. * @see http://doc.babylonjs.com/how_to/more_materials
  20831. */
  20832. wAng: number;
  20833. /**
  20834. * Defines the center of rotation (U)
  20835. */
  20836. uRotationCenter: number;
  20837. /**
  20838. * Defines the center of rotation (V)
  20839. */
  20840. vRotationCenter: number;
  20841. /**
  20842. * Defines the center of rotation (W)
  20843. */
  20844. wRotationCenter: number;
  20845. /**
  20846. * Are mip maps generated for this texture or not.
  20847. */
  20848. get noMipmap(): boolean;
  20849. /**
  20850. * List of inspectable custom properties (used by the Inspector)
  20851. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20852. */
  20853. inspectableCustomProperties: Nullable<IInspectable[]>;
  20854. private _noMipmap;
  20855. /** @hidden */
  20856. _invertY: boolean;
  20857. private _rowGenerationMatrix;
  20858. private _cachedTextureMatrix;
  20859. private _projectionModeMatrix;
  20860. private _t0;
  20861. private _t1;
  20862. private _t2;
  20863. private _cachedUOffset;
  20864. private _cachedVOffset;
  20865. private _cachedUScale;
  20866. private _cachedVScale;
  20867. private _cachedUAng;
  20868. private _cachedVAng;
  20869. private _cachedWAng;
  20870. private _cachedProjectionMatrixId;
  20871. private _cachedCoordinatesMode;
  20872. /** @hidden */
  20873. protected _initialSamplingMode: number;
  20874. /** @hidden */
  20875. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20876. private _deleteBuffer;
  20877. protected _format: Nullable<number>;
  20878. private _delayedOnLoad;
  20879. private _delayedOnError;
  20880. private _mimeType?;
  20881. /**
  20882. * Observable triggered once the texture has been loaded.
  20883. */
  20884. onLoadObservable: Observable<Texture>;
  20885. protected _isBlocking: boolean;
  20886. /**
  20887. * Is the texture preventing material to render while loading.
  20888. * If false, a default texture will be used instead of the loading one during the preparation step.
  20889. */
  20890. set isBlocking(value: boolean);
  20891. get isBlocking(): boolean;
  20892. /**
  20893. * Get the current sampling mode associated with the texture.
  20894. */
  20895. get samplingMode(): number;
  20896. /**
  20897. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20898. */
  20899. get invertY(): boolean;
  20900. /**
  20901. * Instantiates a new texture.
  20902. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20903. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20904. * @param url defines the url of the picture to load as a texture
  20905. * @param scene defines the scene or engine the texture will belong to
  20906. * @param noMipmap defines if the texture will require mip maps or not
  20907. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20908. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20909. * @param onLoad defines a callback triggered when the texture has been loaded
  20910. * @param onError defines a callback triggered when an error occurred during the loading session
  20911. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20912. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20913. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20914. * @param mimeType defines an optional mime type information
  20915. */
  20916. 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);
  20917. /**
  20918. * Update the url (and optional buffer) of this texture if url was null during construction.
  20919. * @param url the url of the texture
  20920. * @param buffer the buffer of the texture (defaults to null)
  20921. * @param onLoad callback called when the texture is loaded (defaults to null)
  20922. */
  20923. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20924. /**
  20925. * Finish the loading sequence of a texture flagged as delayed load.
  20926. * @hidden
  20927. */
  20928. delayLoad(): void;
  20929. private _prepareRowForTextureGeneration;
  20930. /**
  20931. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20932. * @returns the transform matrix of the texture.
  20933. */
  20934. getTextureMatrix(uBase?: number): Matrix;
  20935. /**
  20936. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20937. * @returns The reflection texture transform
  20938. */
  20939. getReflectionTextureMatrix(): Matrix;
  20940. /**
  20941. * Clones the texture.
  20942. * @returns the cloned texture
  20943. */
  20944. clone(): Texture;
  20945. /**
  20946. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20947. * @returns The JSON representation of the texture
  20948. */
  20949. serialize(): any;
  20950. /**
  20951. * Get the current class name of the texture useful for serialization or dynamic coding.
  20952. * @returns "Texture"
  20953. */
  20954. getClassName(): string;
  20955. /**
  20956. * Dispose the texture and release its associated resources.
  20957. */
  20958. dispose(): void;
  20959. /**
  20960. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20961. * @param parsedTexture Define the JSON representation of the texture
  20962. * @param scene Define the scene the parsed texture should be instantiated in
  20963. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20964. * @returns The parsed texture if successful
  20965. */
  20966. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20967. /**
  20968. * Creates a texture from its base 64 representation.
  20969. * @param data Define the base64 payload without the data: prefix
  20970. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20971. * @param scene Define the scene the texture should belong to
  20972. * @param noMipmap Forces the texture to not create mip map information if true
  20973. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20974. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20975. * @param onLoad define a callback triggered when the texture has been loaded
  20976. * @param onError define a callback triggered when an error occurred during the loading session
  20977. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20978. * @returns the created texture
  20979. */
  20980. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20981. /**
  20982. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20983. * @param data Define the base64 payload without the data: prefix
  20984. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20985. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20986. * @param scene Define the scene the texture should belong to
  20987. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20988. * @param noMipmap Forces the texture to not create mip map information if true
  20989. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20990. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20991. * @param onLoad define a callback triggered when the texture has been loaded
  20992. * @param onError define a callback triggered when an error occurred during the loading session
  20993. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20994. * @returns the created texture
  20995. */
  20996. 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;
  20997. }
  20998. }
  20999. declare module "babylonjs/PostProcesses/postProcessManager" {
  21000. import { Nullable } from "babylonjs/types";
  21001. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21002. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21003. import { Scene } from "babylonjs/scene";
  21004. /**
  21005. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21006. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21007. */
  21008. export class PostProcessManager {
  21009. private _scene;
  21010. private _indexBuffer;
  21011. private _vertexBuffers;
  21012. /**
  21013. * Creates a new instance PostProcess
  21014. * @param scene The scene that the post process is associated with.
  21015. */
  21016. constructor(scene: Scene);
  21017. private _prepareBuffers;
  21018. private _buildIndexBuffer;
  21019. /**
  21020. * Rebuilds the vertex buffers of the manager.
  21021. * @hidden
  21022. */
  21023. _rebuild(): void;
  21024. /**
  21025. * Prepares a frame to be run through a post process.
  21026. * @param sourceTexture The input texture to the post procesess. (default: null)
  21027. * @param postProcesses An array of post processes to be run. (default: null)
  21028. * @returns True if the post processes were able to be run.
  21029. * @hidden
  21030. */
  21031. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21032. /**
  21033. * Manually render a set of post processes to a texture.
  21034. * @param postProcesses An array of post processes to be run.
  21035. * @param targetTexture The target texture to render to.
  21036. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21037. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21038. * @param lodLevel defines which lod of the texture to render to
  21039. */
  21040. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21041. /**
  21042. * Finalize the result of the output of the postprocesses.
  21043. * @param doNotPresent If true the result will not be displayed to the screen.
  21044. * @param targetTexture The target texture to render to.
  21045. * @param faceIndex The index of the face to bind the target texture to.
  21046. * @param postProcesses The array of post processes to render.
  21047. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21048. * @hidden
  21049. */
  21050. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21051. /**
  21052. * Disposes of the post process manager.
  21053. */
  21054. dispose(): void;
  21055. }
  21056. }
  21057. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21058. import { Observable } from "babylonjs/Misc/observable";
  21059. import { SmartArray } from "babylonjs/Misc/smartArray";
  21060. import { Nullable, Immutable } from "babylonjs/types";
  21061. import { Camera } from "babylonjs/Cameras/camera";
  21062. import { Scene } from "babylonjs/scene";
  21063. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21064. import { Color4 } from "babylonjs/Maths/math.color";
  21065. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21067. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21068. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21069. import { Texture } from "babylonjs/Materials/Textures/texture";
  21070. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21071. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21072. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21073. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21074. import { Engine } from "babylonjs/Engines/engine";
  21075. /**
  21076. * This Helps creating a texture that will be created from a camera in your scene.
  21077. * It is basically a dynamic texture that could be used to create special effects for instance.
  21078. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21079. */
  21080. export class RenderTargetTexture extends Texture {
  21081. isCube: boolean;
  21082. /**
  21083. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21084. */
  21085. static readonly REFRESHRATE_RENDER_ONCE: number;
  21086. /**
  21087. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21088. */
  21089. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21090. /**
  21091. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21092. * the central point of your effect and can save a lot of performances.
  21093. */
  21094. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21095. /**
  21096. * Use this predicate to dynamically define the list of mesh you want to render.
  21097. * If set, the renderList property will be overwritten.
  21098. */
  21099. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21100. private _renderList;
  21101. /**
  21102. * Use this list to define the list of mesh you want to render.
  21103. */
  21104. get renderList(): Nullable<Array<AbstractMesh>>;
  21105. set renderList(value: Nullable<Array<AbstractMesh>>);
  21106. /**
  21107. * Use this function to overload the renderList array at rendering time.
  21108. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21109. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21110. * the cube (if the RTT is a cube, else layerOrFace=0).
  21111. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21112. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21113. * hold dummy elements!
  21114. */
  21115. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21116. private _hookArray;
  21117. /**
  21118. * Define if particles should be rendered in your texture.
  21119. */
  21120. renderParticles: boolean;
  21121. /**
  21122. * Define if sprites should be rendered in your texture.
  21123. */
  21124. renderSprites: boolean;
  21125. /**
  21126. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21127. */
  21128. coordinatesMode: number;
  21129. /**
  21130. * Define the camera used to render the texture.
  21131. */
  21132. activeCamera: Nullable<Camera>;
  21133. /**
  21134. * Override the render function of the texture with your own one.
  21135. */
  21136. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21137. /**
  21138. * Define if camera post processes should be use while rendering the texture.
  21139. */
  21140. useCameraPostProcesses: boolean;
  21141. /**
  21142. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21143. */
  21144. ignoreCameraViewport: boolean;
  21145. private _postProcessManager;
  21146. private _postProcesses;
  21147. private _resizeObserver;
  21148. /**
  21149. * An event triggered when the texture is unbind.
  21150. */
  21151. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21152. /**
  21153. * An event triggered when the texture is unbind.
  21154. */
  21155. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21156. private _onAfterUnbindObserver;
  21157. /**
  21158. * Set a after unbind callback in the texture.
  21159. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21160. */
  21161. set onAfterUnbind(callback: () => void);
  21162. /**
  21163. * An event triggered before rendering the texture
  21164. */
  21165. onBeforeRenderObservable: Observable<number>;
  21166. private _onBeforeRenderObserver;
  21167. /**
  21168. * Set a before render callback in the texture.
  21169. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21170. */
  21171. set onBeforeRender(callback: (faceIndex: number) => void);
  21172. /**
  21173. * An event triggered after rendering the texture
  21174. */
  21175. onAfterRenderObservable: Observable<number>;
  21176. private _onAfterRenderObserver;
  21177. /**
  21178. * Set a after render callback in the texture.
  21179. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21180. */
  21181. set onAfterRender(callback: (faceIndex: number) => void);
  21182. /**
  21183. * An event triggered after the texture clear
  21184. */
  21185. onClearObservable: Observable<Engine>;
  21186. private _onClearObserver;
  21187. /**
  21188. * Set a clear callback in the texture.
  21189. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21190. */
  21191. set onClear(callback: (Engine: Engine) => void);
  21192. /**
  21193. * An event triggered when the texture is resized.
  21194. */
  21195. onResizeObservable: Observable<RenderTargetTexture>;
  21196. /**
  21197. * Define the clear color of the Render Target if it should be different from the scene.
  21198. */
  21199. clearColor: Color4;
  21200. protected _size: number | {
  21201. width: number;
  21202. height: number;
  21203. layers?: number;
  21204. };
  21205. protected _initialSizeParameter: number | {
  21206. width: number;
  21207. height: number;
  21208. } | {
  21209. ratio: number;
  21210. };
  21211. protected _sizeRatio: Nullable<number>;
  21212. /** @hidden */
  21213. _generateMipMaps: boolean;
  21214. protected _renderingManager: RenderingManager;
  21215. /** @hidden */
  21216. _waitingRenderList: string[];
  21217. protected _doNotChangeAspectRatio: boolean;
  21218. protected _currentRefreshId: number;
  21219. protected _refreshRate: number;
  21220. protected _textureMatrix: Matrix;
  21221. protected _samples: number;
  21222. protected _renderTargetOptions: RenderTargetCreationOptions;
  21223. /**
  21224. * Gets render target creation options that were used.
  21225. */
  21226. get renderTargetOptions(): RenderTargetCreationOptions;
  21227. protected _engine: Engine;
  21228. protected _onRatioRescale(): void;
  21229. /**
  21230. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21231. * It must define where the camera used to render the texture is set
  21232. */
  21233. boundingBoxPosition: Vector3;
  21234. private _boundingBoxSize;
  21235. /**
  21236. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21237. * When defined, the cubemap will switch to local mode
  21238. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21239. * @example https://www.babylonjs-playground.com/#RNASML
  21240. */
  21241. set boundingBoxSize(value: Vector3);
  21242. get boundingBoxSize(): Vector3;
  21243. /**
  21244. * In case the RTT has been created with a depth texture, get the associated
  21245. * depth texture.
  21246. * Otherwise, return null.
  21247. */
  21248. get depthStencilTexture(): Nullable<InternalTexture>;
  21249. /**
  21250. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21251. * or used a shadow, depth texture...
  21252. * @param name The friendly name of the texture
  21253. * @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)
  21254. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21255. * @param generateMipMaps True if mip maps need to be generated after render.
  21256. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21257. * @param type The type of the buffer in the RTT (int, half float, float...)
  21258. * @param isCube True if a cube texture needs to be created
  21259. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21260. * @param generateDepthBuffer True to generate a depth buffer
  21261. * @param generateStencilBuffer True to generate a stencil buffer
  21262. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21263. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21264. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21265. */
  21266. constructor(name: string, size: number | {
  21267. width: number;
  21268. height: number;
  21269. layers?: number;
  21270. } | {
  21271. ratio: number;
  21272. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21273. /**
  21274. * Creates a depth stencil texture.
  21275. * This is only available in WebGL 2 or with the depth texture extension available.
  21276. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21277. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21278. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21279. */
  21280. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21281. private _processSizeParameter;
  21282. /**
  21283. * Define the number of samples to use in case of MSAA.
  21284. * It defaults to one meaning no MSAA has been enabled.
  21285. */
  21286. get samples(): number;
  21287. set samples(value: number);
  21288. /**
  21289. * Resets the refresh counter of the texture and start bak from scratch.
  21290. * Could be useful to regenerate the texture if it is setup to render only once.
  21291. */
  21292. resetRefreshCounter(): void;
  21293. /**
  21294. * Define the refresh rate of the texture or the rendering frequency.
  21295. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21296. */
  21297. get refreshRate(): number;
  21298. set refreshRate(value: number);
  21299. /**
  21300. * Adds a post process to the render target rendering passes.
  21301. * @param postProcess define the post process to add
  21302. */
  21303. addPostProcess(postProcess: PostProcess): void;
  21304. /**
  21305. * Clear all the post processes attached to the render target
  21306. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21307. */
  21308. clearPostProcesses(dispose?: boolean): void;
  21309. /**
  21310. * Remove one of the post process from the list of attached post processes to the texture
  21311. * @param postProcess define the post process to remove from the list
  21312. */
  21313. removePostProcess(postProcess: PostProcess): void;
  21314. /** @hidden */
  21315. _shouldRender(): boolean;
  21316. /**
  21317. * Gets the actual render size of the texture.
  21318. * @returns the width of the render size
  21319. */
  21320. getRenderSize(): number;
  21321. /**
  21322. * Gets the actual render width of the texture.
  21323. * @returns the width of the render size
  21324. */
  21325. getRenderWidth(): number;
  21326. /**
  21327. * Gets the actual render height of the texture.
  21328. * @returns the height of the render size
  21329. */
  21330. getRenderHeight(): number;
  21331. /**
  21332. * Gets the actual number of layers of the texture.
  21333. * @returns the number of layers
  21334. */
  21335. getRenderLayers(): number;
  21336. /**
  21337. * Get if the texture can be rescaled or not.
  21338. */
  21339. get canRescale(): boolean;
  21340. /**
  21341. * Resize the texture using a ratio.
  21342. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21343. */
  21344. scale(ratio: number): void;
  21345. /**
  21346. * Get the texture reflection matrix used to rotate/transform the reflection.
  21347. * @returns the reflection matrix
  21348. */
  21349. getReflectionTextureMatrix(): Matrix;
  21350. /**
  21351. * Resize the texture to a new desired size.
  21352. * Be carrefull as it will recreate all the data in the new texture.
  21353. * @param size Define the new size. It can be:
  21354. * - a number for squared texture,
  21355. * - an object containing { width: number, height: number }
  21356. * - or an object containing a ratio { ratio: number }
  21357. */
  21358. resize(size: number | {
  21359. width: number;
  21360. height: number;
  21361. } | {
  21362. ratio: number;
  21363. }): void;
  21364. private _defaultRenderListPrepared;
  21365. /**
  21366. * Renders all the objects from the render list into the texture.
  21367. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21368. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21369. */
  21370. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21371. private _bestReflectionRenderTargetDimension;
  21372. private _prepareRenderingManager;
  21373. /**
  21374. * @hidden
  21375. * @param faceIndex face index to bind to if this is a cubetexture
  21376. * @param layer defines the index of the texture to bind in the array
  21377. */
  21378. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21379. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21380. private renderToTarget;
  21381. /**
  21382. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21383. * This allowed control for front to back rendering or reversly depending of the special needs.
  21384. *
  21385. * @param renderingGroupId The rendering group id corresponding to its index
  21386. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21387. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21388. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21389. */
  21390. 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;
  21391. /**
  21392. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21393. *
  21394. * @param renderingGroupId The rendering group id corresponding to its index
  21395. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21396. */
  21397. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21398. /**
  21399. * Clones the texture.
  21400. * @returns the cloned texture
  21401. */
  21402. clone(): RenderTargetTexture;
  21403. /**
  21404. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21405. * @returns The JSON representation of the texture
  21406. */
  21407. serialize(): any;
  21408. /**
  21409. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21410. */
  21411. disposeFramebufferObjects(): void;
  21412. /**
  21413. * Dispose the texture and release its associated resources.
  21414. */
  21415. dispose(): void;
  21416. /** @hidden */
  21417. _rebuild(): void;
  21418. /**
  21419. * Clear the info related to rendering groups preventing retention point in material dispose.
  21420. */
  21421. freeRenderingGroups(): void;
  21422. /**
  21423. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21424. * @returns the view count
  21425. */
  21426. getViewCount(): number;
  21427. }
  21428. }
  21429. declare module "babylonjs/Materials/material" {
  21430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21431. import { SmartArray } from "babylonjs/Misc/smartArray";
  21432. import { Observable } from "babylonjs/Misc/observable";
  21433. import { Nullable } from "babylonjs/types";
  21434. import { Scene } from "babylonjs/scene";
  21435. import { Matrix } from "babylonjs/Maths/math.vector";
  21436. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21438. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21439. import { Effect } from "babylonjs/Materials/effect";
  21440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21441. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21442. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21443. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21444. import { Mesh } from "babylonjs/Meshes/mesh";
  21445. import { Animation } from "babylonjs/Animations/animation";
  21446. /**
  21447. * Options for compiling materials.
  21448. */
  21449. export interface IMaterialCompilationOptions {
  21450. /**
  21451. * Defines whether clip planes are enabled.
  21452. */
  21453. clipPlane: boolean;
  21454. /**
  21455. * Defines whether instances are enabled.
  21456. */
  21457. useInstances: boolean;
  21458. }
  21459. /**
  21460. * Base class for the main features of a material in Babylon.js
  21461. */
  21462. export class Material implements IAnimatable {
  21463. /**
  21464. * Returns the triangle fill mode
  21465. */
  21466. static readonly TriangleFillMode: number;
  21467. /**
  21468. * Returns the wireframe mode
  21469. */
  21470. static readonly WireFrameFillMode: number;
  21471. /**
  21472. * Returns the point fill mode
  21473. */
  21474. static readonly PointFillMode: number;
  21475. /**
  21476. * Returns the point list draw mode
  21477. */
  21478. static readonly PointListDrawMode: number;
  21479. /**
  21480. * Returns the line list draw mode
  21481. */
  21482. static readonly LineListDrawMode: number;
  21483. /**
  21484. * Returns the line loop draw mode
  21485. */
  21486. static readonly LineLoopDrawMode: number;
  21487. /**
  21488. * Returns the line strip draw mode
  21489. */
  21490. static readonly LineStripDrawMode: number;
  21491. /**
  21492. * Returns the triangle strip draw mode
  21493. */
  21494. static readonly TriangleStripDrawMode: number;
  21495. /**
  21496. * Returns the triangle fan draw mode
  21497. */
  21498. static readonly TriangleFanDrawMode: number;
  21499. /**
  21500. * Stores the clock-wise side orientation
  21501. */
  21502. static readonly ClockWiseSideOrientation: number;
  21503. /**
  21504. * Stores the counter clock-wise side orientation
  21505. */
  21506. static readonly CounterClockWiseSideOrientation: number;
  21507. /**
  21508. * The dirty texture flag value
  21509. */
  21510. static readonly TextureDirtyFlag: number;
  21511. /**
  21512. * The dirty light flag value
  21513. */
  21514. static readonly LightDirtyFlag: number;
  21515. /**
  21516. * The dirty fresnel flag value
  21517. */
  21518. static readonly FresnelDirtyFlag: number;
  21519. /**
  21520. * The dirty attribute flag value
  21521. */
  21522. static readonly AttributesDirtyFlag: number;
  21523. /**
  21524. * The dirty misc flag value
  21525. */
  21526. static readonly MiscDirtyFlag: number;
  21527. /**
  21528. * The all dirty flag value
  21529. */
  21530. static readonly AllDirtyFlag: number;
  21531. /**
  21532. * The ID of the material
  21533. */
  21534. id: string;
  21535. /**
  21536. * Gets or sets the unique id of the material
  21537. */
  21538. uniqueId: number;
  21539. /**
  21540. * The name of the material
  21541. */
  21542. name: string;
  21543. /**
  21544. * Gets or sets user defined metadata
  21545. */
  21546. metadata: any;
  21547. /**
  21548. * For internal use only. Please do not use.
  21549. */
  21550. reservedDataStore: any;
  21551. /**
  21552. * Specifies if the ready state should be checked on each call
  21553. */
  21554. checkReadyOnEveryCall: boolean;
  21555. /**
  21556. * Specifies if the ready state should be checked once
  21557. */
  21558. checkReadyOnlyOnce: boolean;
  21559. /**
  21560. * The state of the material
  21561. */
  21562. state: string;
  21563. /**
  21564. * The alpha value of the material
  21565. */
  21566. protected _alpha: number;
  21567. /**
  21568. * List of inspectable custom properties (used by the Inspector)
  21569. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21570. */
  21571. inspectableCustomProperties: IInspectable[];
  21572. /**
  21573. * Sets the alpha value of the material
  21574. */
  21575. set alpha(value: number);
  21576. /**
  21577. * Gets the alpha value of the material
  21578. */
  21579. get alpha(): number;
  21580. /**
  21581. * Specifies if back face culling is enabled
  21582. */
  21583. protected _backFaceCulling: boolean;
  21584. /**
  21585. * Sets the back-face culling state
  21586. */
  21587. set backFaceCulling(value: boolean);
  21588. /**
  21589. * Gets the back-face culling state
  21590. */
  21591. get backFaceCulling(): boolean;
  21592. /**
  21593. * Stores the value for side orientation
  21594. */
  21595. sideOrientation: number;
  21596. /**
  21597. * Callback triggered when the material is compiled
  21598. */
  21599. onCompiled: Nullable<(effect: Effect) => void>;
  21600. /**
  21601. * Callback triggered when an error occurs
  21602. */
  21603. onError: Nullable<(effect: Effect, errors: string) => void>;
  21604. /**
  21605. * Callback triggered to get the render target textures
  21606. */
  21607. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21608. /**
  21609. * Gets a boolean indicating that current material needs to register RTT
  21610. */
  21611. get hasRenderTargetTextures(): boolean;
  21612. /**
  21613. * Specifies if the material should be serialized
  21614. */
  21615. doNotSerialize: boolean;
  21616. /**
  21617. * @hidden
  21618. */
  21619. _storeEffectOnSubMeshes: boolean;
  21620. /**
  21621. * Stores the animations for the material
  21622. */
  21623. animations: Nullable<Array<Animation>>;
  21624. /**
  21625. * An event triggered when the material is disposed
  21626. */
  21627. onDisposeObservable: Observable<Material>;
  21628. /**
  21629. * An observer which watches for dispose events
  21630. */
  21631. private _onDisposeObserver;
  21632. private _onUnBindObservable;
  21633. /**
  21634. * Called during a dispose event
  21635. */
  21636. set onDispose(callback: () => void);
  21637. private _onBindObservable;
  21638. /**
  21639. * An event triggered when the material is bound
  21640. */
  21641. get onBindObservable(): Observable<AbstractMesh>;
  21642. /**
  21643. * An observer which watches for bind events
  21644. */
  21645. private _onBindObserver;
  21646. /**
  21647. * Called during a bind event
  21648. */
  21649. set onBind(callback: (Mesh: AbstractMesh) => void);
  21650. /**
  21651. * An event triggered when the material is unbound
  21652. */
  21653. get onUnBindObservable(): Observable<Material>;
  21654. /**
  21655. * Stores the value of the alpha mode
  21656. */
  21657. private _alphaMode;
  21658. /**
  21659. * Sets the value of the alpha mode.
  21660. *
  21661. * | Value | Type | Description |
  21662. * | --- | --- | --- |
  21663. * | 0 | ALPHA_DISABLE | |
  21664. * | 1 | ALPHA_ADD | |
  21665. * | 2 | ALPHA_COMBINE | |
  21666. * | 3 | ALPHA_SUBTRACT | |
  21667. * | 4 | ALPHA_MULTIPLY | |
  21668. * | 5 | ALPHA_MAXIMIZED | |
  21669. * | 6 | ALPHA_ONEONE | |
  21670. * | 7 | ALPHA_PREMULTIPLIED | |
  21671. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21672. * | 9 | ALPHA_INTERPOLATE | |
  21673. * | 10 | ALPHA_SCREENMODE | |
  21674. *
  21675. */
  21676. set alphaMode(value: number);
  21677. /**
  21678. * Gets the value of the alpha mode
  21679. */
  21680. get alphaMode(): number;
  21681. /**
  21682. * Stores the state of the need depth pre-pass value
  21683. */
  21684. private _needDepthPrePass;
  21685. /**
  21686. * Sets the need depth pre-pass value
  21687. */
  21688. set needDepthPrePass(value: boolean);
  21689. /**
  21690. * Gets the depth pre-pass value
  21691. */
  21692. get needDepthPrePass(): boolean;
  21693. /**
  21694. * Specifies if depth writing should be disabled
  21695. */
  21696. disableDepthWrite: boolean;
  21697. /**
  21698. * Specifies if depth writing should be forced
  21699. */
  21700. forceDepthWrite: boolean;
  21701. /**
  21702. * Specifies the depth function that should be used. 0 means the default engine function
  21703. */
  21704. depthFunction: number;
  21705. /**
  21706. * Specifies if there should be a separate pass for culling
  21707. */
  21708. separateCullingPass: boolean;
  21709. /**
  21710. * Stores the state specifing if fog should be enabled
  21711. */
  21712. private _fogEnabled;
  21713. /**
  21714. * Sets the state for enabling fog
  21715. */
  21716. set fogEnabled(value: boolean);
  21717. /**
  21718. * Gets the value of the fog enabled state
  21719. */
  21720. get fogEnabled(): boolean;
  21721. /**
  21722. * Stores the size of points
  21723. */
  21724. pointSize: number;
  21725. /**
  21726. * Stores the z offset value
  21727. */
  21728. zOffset: number;
  21729. /**
  21730. * Gets a value specifying if wireframe mode is enabled
  21731. */
  21732. get wireframe(): boolean;
  21733. /**
  21734. * Sets the state of wireframe mode
  21735. */
  21736. set wireframe(value: boolean);
  21737. /**
  21738. * Gets the value specifying if point clouds are enabled
  21739. */
  21740. get pointsCloud(): boolean;
  21741. /**
  21742. * Sets the state of point cloud mode
  21743. */
  21744. set pointsCloud(value: boolean);
  21745. /**
  21746. * Gets the material fill mode
  21747. */
  21748. get fillMode(): number;
  21749. /**
  21750. * Sets the material fill mode
  21751. */
  21752. set fillMode(value: number);
  21753. /**
  21754. * @hidden
  21755. * Stores the effects for the material
  21756. */
  21757. _effect: Nullable<Effect>;
  21758. /**
  21759. * Specifies if uniform buffers should be used
  21760. */
  21761. private _useUBO;
  21762. /**
  21763. * Stores a reference to the scene
  21764. */
  21765. private _scene;
  21766. /**
  21767. * Stores the fill mode state
  21768. */
  21769. private _fillMode;
  21770. /**
  21771. * Specifies if the depth write state should be cached
  21772. */
  21773. private _cachedDepthWriteState;
  21774. /**
  21775. * Specifies if the depth function state should be cached
  21776. */
  21777. private _cachedDepthFunctionState;
  21778. /**
  21779. * Stores the uniform buffer
  21780. */
  21781. protected _uniformBuffer: UniformBuffer;
  21782. /** @hidden */
  21783. _indexInSceneMaterialArray: number;
  21784. /** @hidden */
  21785. meshMap: Nullable<{
  21786. [id: string]: AbstractMesh | undefined;
  21787. }>;
  21788. /**
  21789. * Creates a material instance
  21790. * @param name defines the name of the material
  21791. * @param scene defines the scene to reference
  21792. * @param doNotAdd specifies if the material should be added to the scene
  21793. */
  21794. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21795. /**
  21796. * Returns a string representation of the current material
  21797. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21798. * @returns a string with material information
  21799. */
  21800. toString(fullDetails?: boolean): string;
  21801. /**
  21802. * Gets the class name of the material
  21803. * @returns a string with the class name of the material
  21804. */
  21805. getClassName(): string;
  21806. /**
  21807. * Specifies if updates for the material been locked
  21808. */
  21809. get isFrozen(): boolean;
  21810. /**
  21811. * Locks updates for the material
  21812. */
  21813. freeze(): void;
  21814. /**
  21815. * Unlocks updates for the material
  21816. */
  21817. unfreeze(): void;
  21818. /**
  21819. * Specifies if the material is ready to be used
  21820. * @param mesh defines the mesh to check
  21821. * @param useInstances specifies if instances should be used
  21822. * @returns a boolean indicating if the material is ready to be used
  21823. */
  21824. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21825. /**
  21826. * Specifies that the submesh is ready to be used
  21827. * @param mesh defines the mesh to check
  21828. * @param subMesh defines which submesh to check
  21829. * @param useInstances specifies that instances should be used
  21830. * @returns a boolean indicating that the submesh is ready or not
  21831. */
  21832. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21833. /**
  21834. * Returns the material effect
  21835. * @returns the effect associated with the material
  21836. */
  21837. getEffect(): Nullable<Effect>;
  21838. /**
  21839. * Returns the current scene
  21840. * @returns a Scene
  21841. */
  21842. getScene(): Scene;
  21843. /**
  21844. * Specifies if the material will require alpha blending
  21845. * @returns a boolean specifying if alpha blending is needed
  21846. */
  21847. needAlphaBlending(): boolean;
  21848. /**
  21849. * Specifies if the mesh will require alpha blending
  21850. * @param mesh defines the mesh to check
  21851. * @returns a boolean specifying if alpha blending is needed for the mesh
  21852. */
  21853. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21854. /**
  21855. * Specifies if this material should be rendered in alpha test mode
  21856. * @returns a boolean specifying if an alpha test is needed.
  21857. */
  21858. needAlphaTesting(): boolean;
  21859. /**
  21860. * Gets the texture used for the alpha test
  21861. * @returns the texture to use for alpha testing
  21862. */
  21863. getAlphaTestTexture(): Nullable<BaseTexture>;
  21864. /**
  21865. * Marks the material to indicate that it needs to be re-calculated
  21866. */
  21867. markDirty(): void;
  21868. /** @hidden */
  21869. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21870. /**
  21871. * Binds the material to the mesh
  21872. * @param world defines the world transformation matrix
  21873. * @param mesh defines the mesh to bind the material to
  21874. */
  21875. bind(world: Matrix, mesh?: Mesh): void;
  21876. /**
  21877. * Binds the submesh to the material
  21878. * @param world defines the world transformation matrix
  21879. * @param mesh defines the mesh containing the submesh
  21880. * @param subMesh defines the submesh to bind the material to
  21881. */
  21882. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21883. /**
  21884. * Binds the world matrix to the material
  21885. * @param world defines the world transformation matrix
  21886. */
  21887. bindOnlyWorldMatrix(world: Matrix): void;
  21888. /**
  21889. * Binds the scene's uniform buffer to the effect.
  21890. * @param effect defines the effect to bind to the scene uniform buffer
  21891. * @param sceneUbo defines the uniform buffer storing scene data
  21892. */
  21893. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21894. /**
  21895. * Binds the view matrix to the effect
  21896. * @param effect defines the effect to bind the view matrix to
  21897. */
  21898. bindView(effect: Effect): void;
  21899. /**
  21900. * Binds the view projection matrix to the effect
  21901. * @param effect defines the effect to bind the view projection matrix to
  21902. */
  21903. bindViewProjection(effect: Effect): void;
  21904. /**
  21905. * Specifies if material alpha testing should be turned on for the mesh
  21906. * @param mesh defines the mesh to check
  21907. */
  21908. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21909. /**
  21910. * Processes to execute after binding the material to a mesh
  21911. * @param mesh defines the rendered mesh
  21912. */
  21913. protected _afterBind(mesh?: Mesh): void;
  21914. /**
  21915. * Unbinds the material from the mesh
  21916. */
  21917. unbind(): void;
  21918. /**
  21919. * Gets the active textures from the material
  21920. * @returns an array of textures
  21921. */
  21922. getActiveTextures(): BaseTexture[];
  21923. /**
  21924. * Specifies if the material uses a texture
  21925. * @param texture defines the texture to check against the material
  21926. * @returns a boolean specifying if the material uses the texture
  21927. */
  21928. hasTexture(texture: BaseTexture): boolean;
  21929. /**
  21930. * Makes a duplicate of the material, and gives it a new name
  21931. * @param name defines the new name for the duplicated material
  21932. * @returns the cloned material
  21933. */
  21934. clone(name: string): Nullable<Material>;
  21935. /**
  21936. * Gets the meshes bound to the material
  21937. * @returns an array of meshes bound to the material
  21938. */
  21939. getBindedMeshes(): AbstractMesh[];
  21940. /**
  21941. * Force shader compilation
  21942. * @param mesh defines the mesh associated with this material
  21943. * @param onCompiled defines a function to execute once the material is compiled
  21944. * @param options defines the options to configure the compilation
  21945. * @param onError defines a function to execute if the material fails compiling
  21946. */
  21947. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21948. /**
  21949. * Force shader compilation
  21950. * @param mesh defines the mesh that will use this material
  21951. * @param options defines additional options for compiling the shaders
  21952. * @returns a promise that resolves when the compilation completes
  21953. */
  21954. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21955. private static readonly _AllDirtyCallBack;
  21956. private static readonly _ImageProcessingDirtyCallBack;
  21957. private static readonly _TextureDirtyCallBack;
  21958. private static readonly _FresnelDirtyCallBack;
  21959. private static readonly _MiscDirtyCallBack;
  21960. private static readonly _LightsDirtyCallBack;
  21961. private static readonly _AttributeDirtyCallBack;
  21962. private static _FresnelAndMiscDirtyCallBack;
  21963. private static _TextureAndMiscDirtyCallBack;
  21964. private static readonly _DirtyCallbackArray;
  21965. private static readonly _RunDirtyCallBacks;
  21966. /**
  21967. * Marks a define in the material to indicate that it needs to be re-computed
  21968. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21969. */
  21970. markAsDirty(flag: number): void;
  21971. /**
  21972. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21973. * @param func defines a function which checks material defines against the submeshes
  21974. */
  21975. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21976. /**
  21977. * Indicates that we need to re-calculated for all submeshes
  21978. */
  21979. protected _markAllSubMeshesAsAllDirty(): void;
  21980. /**
  21981. * Indicates that image processing needs to be re-calculated for all submeshes
  21982. */
  21983. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21984. /**
  21985. * Indicates that textures need to be re-calculated for all submeshes
  21986. */
  21987. protected _markAllSubMeshesAsTexturesDirty(): void;
  21988. /**
  21989. * Indicates that fresnel needs to be re-calculated for all submeshes
  21990. */
  21991. protected _markAllSubMeshesAsFresnelDirty(): void;
  21992. /**
  21993. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21994. */
  21995. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21996. /**
  21997. * Indicates that lights need to be re-calculated for all submeshes
  21998. */
  21999. protected _markAllSubMeshesAsLightsDirty(): void;
  22000. /**
  22001. * Indicates that attributes need to be re-calculated for all submeshes
  22002. */
  22003. protected _markAllSubMeshesAsAttributesDirty(): void;
  22004. /**
  22005. * Indicates that misc needs to be re-calculated for all submeshes
  22006. */
  22007. protected _markAllSubMeshesAsMiscDirty(): void;
  22008. /**
  22009. * Indicates that textures and misc need to be re-calculated for all submeshes
  22010. */
  22011. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22012. /**
  22013. * Disposes the material
  22014. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22015. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22016. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22017. */
  22018. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22019. /** @hidden */
  22020. private releaseVertexArrayObject;
  22021. /**
  22022. * Serializes this material
  22023. * @returns the serialized material object
  22024. */
  22025. serialize(): any;
  22026. /**
  22027. * Creates a material from parsed material data
  22028. * @param parsedMaterial defines parsed material data
  22029. * @param scene defines the hosting scene
  22030. * @param rootUrl defines the root URL to use to load textures
  22031. * @returns a new material
  22032. */
  22033. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22034. }
  22035. }
  22036. declare module "babylonjs/Materials/multiMaterial" {
  22037. import { Nullable } from "babylonjs/types";
  22038. import { Scene } from "babylonjs/scene";
  22039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22040. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22042. import { Material } from "babylonjs/Materials/material";
  22043. /**
  22044. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22045. * separate meshes. This can be use to improve performances.
  22046. * @see http://doc.babylonjs.com/how_to/multi_materials
  22047. */
  22048. export class MultiMaterial extends Material {
  22049. private _subMaterials;
  22050. /**
  22051. * Gets or Sets the list of Materials used within the multi material.
  22052. * They need to be ordered according to the submeshes order in the associated mesh
  22053. */
  22054. get subMaterials(): Nullable<Material>[];
  22055. set subMaterials(value: Nullable<Material>[]);
  22056. /**
  22057. * Function used to align with Node.getChildren()
  22058. * @returns the list of Materials used within the multi material
  22059. */
  22060. getChildren(): Nullable<Material>[];
  22061. /**
  22062. * Instantiates a new Multi Material
  22063. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22064. * separate meshes. This can be use to improve performances.
  22065. * @see http://doc.babylonjs.com/how_to/multi_materials
  22066. * @param name Define the name in the scene
  22067. * @param scene Define the scene the material belongs to
  22068. */
  22069. constructor(name: string, scene: Scene);
  22070. private _hookArray;
  22071. /**
  22072. * Get one of the submaterial by its index in the submaterials array
  22073. * @param index The index to look the sub material at
  22074. * @returns The Material if the index has been defined
  22075. */
  22076. getSubMaterial(index: number): Nullable<Material>;
  22077. /**
  22078. * Get the list of active textures for the whole sub materials list.
  22079. * @returns All the textures that will be used during the rendering
  22080. */
  22081. getActiveTextures(): BaseTexture[];
  22082. /**
  22083. * Gets the current class name of the material e.g. "MultiMaterial"
  22084. * Mainly use in serialization.
  22085. * @returns the class name
  22086. */
  22087. getClassName(): string;
  22088. /**
  22089. * Checks if the material is ready to render the requested sub mesh
  22090. * @param mesh Define the mesh the submesh belongs to
  22091. * @param subMesh Define the sub mesh to look readyness for
  22092. * @param useInstances Define whether or not the material is used with instances
  22093. * @returns true if ready, otherwise false
  22094. */
  22095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22096. /**
  22097. * Clones the current material and its related sub materials
  22098. * @param name Define the name of the newly cloned material
  22099. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22100. * @returns the cloned material
  22101. */
  22102. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22103. /**
  22104. * Serializes the materials into a JSON representation.
  22105. * @returns the JSON representation
  22106. */
  22107. serialize(): any;
  22108. /**
  22109. * Dispose the material and release its associated resources
  22110. * @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)
  22111. * @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)
  22112. * @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)
  22113. */
  22114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22115. /**
  22116. * Creates a MultiMaterial from parsed MultiMaterial data.
  22117. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22118. * @param scene defines the hosting scene
  22119. * @returns a new MultiMaterial
  22120. */
  22121. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22122. }
  22123. }
  22124. declare module "babylonjs/Meshes/subMesh" {
  22125. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22126. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22127. import { Engine } from "babylonjs/Engines/engine";
  22128. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22129. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22130. import { Effect } from "babylonjs/Materials/effect";
  22131. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22132. import { Plane } from "babylonjs/Maths/math.plane";
  22133. import { Collider } from "babylonjs/Collisions/collider";
  22134. import { Material } from "babylonjs/Materials/material";
  22135. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22137. import { Mesh } from "babylonjs/Meshes/mesh";
  22138. import { Ray } from "babylonjs/Culling/ray";
  22139. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22140. /**
  22141. * Base class for submeshes
  22142. */
  22143. export class BaseSubMesh {
  22144. /** @hidden */
  22145. _materialDefines: Nullable<MaterialDefines>;
  22146. /** @hidden */
  22147. _materialEffect: Nullable<Effect>;
  22148. /**
  22149. * Gets material defines used by the effect associated to the sub mesh
  22150. */
  22151. get materialDefines(): Nullable<MaterialDefines>;
  22152. /**
  22153. * Sets material defines used by the effect associated to the sub mesh
  22154. */
  22155. set materialDefines(defines: Nullable<MaterialDefines>);
  22156. /**
  22157. * Gets associated effect
  22158. */
  22159. get effect(): Nullable<Effect>;
  22160. /**
  22161. * Sets associated effect (effect used to render this submesh)
  22162. * @param effect defines the effect to associate with
  22163. * @param defines defines the set of defines used to compile this effect
  22164. */
  22165. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22166. }
  22167. /**
  22168. * Defines a subdivision inside a mesh
  22169. */
  22170. export class SubMesh extends BaseSubMesh implements ICullable {
  22171. /** the material index to use */
  22172. materialIndex: number;
  22173. /** vertex index start */
  22174. verticesStart: number;
  22175. /** vertices count */
  22176. verticesCount: number;
  22177. /** index start */
  22178. indexStart: number;
  22179. /** indices count */
  22180. indexCount: number;
  22181. /** @hidden */
  22182. _linesIndexCount: number;
  22183. private _mesh;
  22184. private _renderingMesh;
  22185. private _boundingInfo;
  22186. private _linesIndexBuffer;
  22187. /** @hidden */
  22188. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22189. /** @hidden */
  22190. _trianglePlanes: Plane[];
  22191. /** @hidden */
  22192. _lastColliderTransformMatrix: Nullable<Matrix>;
  22193. /** @hidden */
  22194. _renderId: number;
  22195. /** @hidden */
  22196. _alphaIndex: number;
  22197. /** @hidden */
  22198. _distanceToCamera: number;
  22199. /** @hidden */
  22200. _id: number;
  22201. private _currentMaterial;
  22202. /**
  22203. * Add a new submesh to a mesh
  22204. * @param materialIndex defines the material index to use
  22205. * @param verticesStart defines vertex index start
  22206. * @param verticesCount defines vertices count
  22207. * @param indexStart defines index start
  22208. * @param indexCount defines indices count
  22209. * @param mesh defines the parent mesh
  22210. * @param renderingMesh defines an optional rendering mesh
  22211. * @param createBoundingBox defines if bounding box should be created for this submesh
  22212. * @returns the new submesh
  22213. */
  22214. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22215. /**
  22216. * Creates a new submesh
  22217. * @param materialIndex defines the material index to use
  22218. * @param verticesStart defines vertex index start
  22219. * @param verticesCount defines vertices count
  22220. * @param indexStart defines index start
  22221. * @param indexCount defines indices count
  22222. * @param mesh defines the parent mesh
  22223. * @param renderingMesh defines an optional rendering mesh
  22224. * @param createBoundingBox defines if bounding box should be created for this submesh
  22225. */
  22226. constructor(
  22227. /** the material index to use */
  22228. materialIndex: number,
  22229. /** vertex index start */
  22230. verticesStart: number,
  22231. /** vertices count */
  22232. verticesCount: number,
  22233. /** index start */
  22234. indexStart: number,
  22235. /** indices count */
  22236. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22237. /**
  22238. * Returns true if this submesh covers the entire parent mesh
  22239. * @ignorenaming
  22240. */
  22241. get IsGlobal(): boolean;
  22242. /**
  22243. * Returns the submesh BoudingInfo object
  22244. * @returns current bounding info (or mesh's one if the submesh is global)
  22245. */
  22246. getBoundingInfo(): BoundingInfo;
  22247. /**
  22248. * Sets the submesh BoundingInfo
  22249. * @param boundingInfo defines the new bounding info to use
  22250. * @returns the SubMesh
  22251. */
  22252. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22253. /**
  22254. * Returns the mesh of the current submesh
  22255. * @return the parent mesh
  22256. */
  22257. getMesh(): AbstractMesh;
  22258. /**
  22259. * Returns the rendering mesh of the submesh
  22260. * @returns the rendering mesh (could be different from parent mesh)
  22261. */
  22262. getRenderingMesh(): Mesh;
  22263. /**
  22264. * Returns the submesh material
  22265. * @returns null or the current material
  22266. */
  22267. getMaterial(): Nullable<Material>;
  22268. /**
  22269. * Sets a new updated BoundingInfo object to the submesh
  22270. * @param data defines an optional position array to use to determine the bounding info
  22271. * @returns the SubMesh
  22272. */
  22273. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22274. /** @hidden */
  22275. _checkCollision(collider: Collider): boolean;
  22276. /**
  22277. * Updates the submesh BoundingInfo
  22278. * @param world defines the world matrix to use to update the bounding info
  22279. * @returns the submesh
  22280. */
  22281. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22282. /**
  22283. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22284. * @param frustumPlanes defines the frustum planes
  22285. * @returns true if the submesh is intersecting with the frustum
  22286. */
  22287. isInFrustum(frustumPlanes: Plane[]): boolean;
  22288. /**
  22289. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22290. * @param frustumPlanes defines the frustum planes
  22291. * @returns true if the submesh is inside the frustum
  22292. */
  22293. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22294. /**
  22295. * Renders the submesh
  22296. * @param enableAlphaMode defines if alpha needs to be used
  22297. * @returns the submesh
  22298. */
  22299. render(enableAlphaMode: boolean): SubMesh;
  22300. /**
  22301. * @hidden
  22302. */
  22303. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22304. /**
  22305. * Checks if the submesh intersects with a ray
  22306. * @param ray defines the ray to test
  22307. * @returns true is the passed ray intersects the submesh bounding box
  22308. */
  22309. canIntersects(ray: Ray): boolean;
  22310. /**
  22311. * Intersects current submesh with a ray
  22312. * @param ray defines the ray to test
  22313. * @param positions defines mesh's positions array
  22314. * @param indices defines mesh's indices array
  22315. * @param fastCheck defines if only bounding info should be used
  22316. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22317. * @returns intersection info or null if no intersection
  22318. */
  22319. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22320. /** @hidden */
  22321. private _intersectLines;
  22322. /** @hidden */
  22323. private _intersectUnIndexedLines;
  22324. /** @hidden */
  22325. private _intersectTriangles;
  22326. /** @hidden */
  22327. private _intersectUnIndexedTriangles;
  22328. /** @hidden */
  22329. _rebuild(): void;
  22330. /**
  22331. * Creates a new submesh from the passed mesh
  22332. * @param newMesh defines the new hosting mesh
  22333. * @param newRenderingMesh defines an optional rendering mesh
  22334. * @returns the new submesh
  22335. */
  22336. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22337. /**
  22338. * Release associated resources
  22339. */
  22340. dispose(): void;
  22341. /**
  22342. * Gets the class name
  22343. * @returns the string "SubMesh".
  22344. */
  22345. getClassName(): string;
  22346. /**
  22347. * Creates a new submesh from indices data
  22348. * @param materialIndex the index of the main mesh material
  22349. * @param startIndex the index where to start the copy in the mesh indices array
  22350. * @param indexCount the number of indices to copy then from the startIndex
  22351. * @param mesh the main mesh to create the submesh from
  22352. * @param renderingMesh the optional rendering mesh
  22353. * @returns a new submesh
  22354. */
  22355. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22356. }
  22357. }
  22358. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22359. /**
  22360. * Class used to represent data loading progression
  22361. */
  22362. export class SceneLoaderFlags {
  22363. private static _ForceFullSceneLoadingForIncremental;
  22364. private static _ShowLoadingScreen;
  22365. private static _CleanBoneMatrixWeights;
  22366. private static _loggingLevel;
  22367. /**
  22368. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22369. */
  22370. static get ForceFullSceneLoadingForIncremental(): boolean;
  22371. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22372. /**
  22373. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22374. */
  22375. static get ShowLoadingScreen(): boolean;
  22376. static set ShowLoadingScreen(value: boolean);
  22377. /**
  22378. * Defines the current logging level (while loading the scene)
  22379. * @ignorenaming
  22380. */
  22381. static get loggingLevel(): number;
  22382. static set loggingLevel(value: number);
  22383. /**
  22384. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22385. */
  22386. static get CleanBoneMatrixWeights(): boolean;
  22387. static set CleanBoneMatrixWeights(value: boolean);
  22388. }
  22389. }
  22390. declare module "babylonjs/Meshes/geometry" {
  22391. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22392. import { Scene } from "babylonjs/scene";
  22393. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22394. import { Engine } from "babylonjs/Engines/engine";
  22395. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22396. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22397. import { Effect } from "babylonjs/Materials/effect";
  22398. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22399. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22400. import { Mesh } from "babylonjs/Meshes/mesh";
  22401. /**
  22402. * Class used to store geometry data (vertex buffers + index buffer)
  22403. */
  22404. export class Geometry implements IGetSetVerticesData {
  22405. /**
  22406. * Gets or sets the ID of the geometry
  22407. */
  22408. id: string;
  22409. /**
  22410. * Gets or sets the unique ID of the geometry
  22411. */
  22412. uniqueId: number;
  22413. /**
  22414. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22415. */
  22416. delayLoadState: number;
  22417. /**
  22418. * Gets the file containing the data to load when running in delay load state
  22419. */
  22420. delayLoadingFile: Nullable<string>;
  22421. /**
  22422. * Callback called when the geometry is updated
  22423. */
  22424. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22425. private _scene;
  22426. private _engine;
  22427. private _meshes;
  22428. private _totalVertices;
  22429. /** @hidden */
  22430. _indices: IndicesArray;
  22431. /** @hidden */
  22432. _vertexBuffers: {
  22433. [key: string]: VertexBuffer;
  22434. };
  22435. private _isDisposed;
  22436. private _extend;
  22437. private _boundingBias;
  22438. /** @hidden */
  22439. _delayInfo: Array<string>;
  22440. private _indexBuffer;
  22441. private _indexBufferIsUpdatable;
  22442. /** @hidden */
  22443. _boundingInfo: Nullable<BoundingInfo>;
  22444. /** @hidden */
  22445. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22446. /** @hidden */
  22447. _softwareSkinningFrameId: number;
  22448. private _vertexArrayObjects;
  22449. private _updatable;
  22450. /** @hidden */
  22451. _positions: Nullable<Vector3[]>;
  22452. /**
  22453. * 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
  22454. */
  22455. get boundingBias(): Vector2;
  22456. /**
  22457. * 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
  22458. */
  22459. set boundingBias(value: Vector2);
  22460. /**
  22461. * Static function used to attach a new empty geometry to a mesh
  22462. * @param mesh defines the mesh to attach the geometry to
  22463. * @returns the new Geometry
  22464. */
  22465. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22466. /**
  22467. * Creates a new geometry
  22468. * @param id defines the unique ID
  22469. * @param scene defines the hosting scene
  22470. * @param vertexData defines the VertexData used to get geometry data
  22471. * @param updatable defines if geometry must be updatable (false by default)
  22472. * @param mesh defines the mesh that will be associated with the geometry
  22473. */
  22474. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22475. /**
  22476. * Gets the current extend of the geometry
  22477. */
  22478. get extend(): {
  22479. minimum: Vector3;
  22480. maximum: Vector3;
  22481. };
  22482. /**
  22483. * Gets the hosting scene
  22484. * @returns the hosting Scene
  22485. */
  22486. getScene(): Scene;
  22487. /**
  22488. * Gets the hosting engine
  22489. * @returns the hosting Engine
  22490. */
  22491. getEngine(): Engine;
  22492. /**
  22493. * Defines if the geometry is ready to use
  22494. * @returns true if the geometry is ready to be used
  22495. */
  22496. isReady(): boolean;
  22497. /**
  22498. * Gets a value indicating that the geometry should not be serialized
  22499. */
  22500. get doNotSerialize(): boolean;
  22501. /** @hidden */
  22502. _rebuild(): void;
  22503. /**
  22504. * Affects all geometry data in one call
  22505. * @param vertexData defines the geometry data
  22506. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22507. */
  22508. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22509. /**
  22510. * Set specific vertex data
  22511. * @param kind defines the data kind (Position, normal, etc...)
  22512. * @param data defines the vertex data to use
  22513. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22514. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22515. */
  22516. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22517. /**
  22518. * Removes a specific vertex data
  22519. * @param kind defines the data kind (Position, normal, etc...)
  22520. */
  22521. removeVerticesData(kind: string): void;
  22522. /**
  22523. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22524. * @param buffer defines the vertex buffer to use
  22525. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22526. */
  22527. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22528. /**
  22529. * Update a specific vertex buffer
  22530. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22531. * It will do nothing if the buffer is not updatable
  22532. * @param kind defines the data kind (Position, normal, etc...)
  22533. * @param data defines the data to use
  22534. * @param offset defines the offset in the target buffer where to store the data
  22535. * @param useBytes set to true if the offset is in bytes
  22536. */
  22537. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22538. /**
  22539. * Update a specific vertex buffer
  22540. * This function will create a new buffer if the current one is not updatable
  22541. * @param kind defines the data kind (Position, normal, etc...)
  22542. * @param data defines the data to use
  22543. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22544. */
  22545. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22546. private _updateBoundingInfo;
  22547. /** @hidden */
  22548. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22549. /**
  22550. * Gets total number of vertices
  22551. * @returns the total number of vertices
  22552. */
  22553. getTotalVertices(): number;
  22554. /**
  22555. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22556. * @param kind defines the data kind (Position, normal, etc...)
  22557. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22558. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22559. * @returns a float array containing vertex data
  22560. */
  22561. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22562. /**
  22563. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22564. * @param kind defines the data kind (Position, normal, etc...)
  22565. * @returns true if the vertex buffer with the specified kind is updatable
  22566. */
  22567. isVertexBufferUpdatable(kind: string): boolean;
  22568. /**
  22569. * Gets a specific vertex buffer
  22570. * @param kind defines the data kind (Position, normal, etc...)
  22571. * @returns a VertexBuffer
  22572. */
  22573. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22574. /**
  22575. * Returns all vertex buffers
  22576. * @return an object holding all vertex buffers indexed by kind
  22577. */
  22578. getVertexBuffers(): Nullable<{
  22579. [key: string]: VertexBuffer;
  22580. }>;
  22581. /**
  22582. * Gets a boolean indicating if specific vertex buffer is present
  22583. * @param kind defines the data kind (Position, normal, etc...)
  22584. * @returns true if data is present
  22585. */
  22586. isVerticesDataPresent(kind: string): boolean;
  22587. /**
  22588. * Gets a list of all attached data kinds (Position, normal, etc...)
  22589. * @returns a list of string containing all kinds
  22590. */
  22591. getVerticesDataKinds(): string[];
  22592. /**
  22593. * Update index buffer
  22594. * @param indices defines the indices to store in the index buffer
  22595. * @param offset defines the offset in the target buffer where to store the data
  22596. * @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)
  22597. */
  22598. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22599. /**
  22600. * Creates a new index buffer
  22601. * @param indices defines the indices to store in the index buffer
  22602. * @param totalVertices defines the total number of vertices (could be null)
  22603. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22604. */
  22605. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22606. /**
  22607. * Return the total number of indices
  22608. * @returns the total number of indices
  22609. */
  22610. getTotalIndices(): number;
  22611. /**
  22612. * Gets the index buffer array
  22613. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22614. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22615. * @returns the index buffer array
  22616. */
  22617. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22618. /**
  22619. * Gets the index buffer
  22620. * @return the index buffer
  22621. */
  22622. getIndexBuffer(): Nullable<DataBuffer>;
  22623. /** @hidden */
  22624. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22625. /**
  22626. * Release the associated resources for a specific mesh
  22627. * @param mesh defines the source mesh
  22628. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22629. */
  22630. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22631. /**
  22632. * Apply current geometry to a given mesh
  22633. * @param mesh defines the mesh to apply geometry to
  22634. */
  22635. applyToMesh(mesh: Mesh): void;
  22636. private _updateExtend;
  22637. private _applyToMesh;
  22638. private notifyUpdate;
  22639. /**
  22640. * Load the geometry if it was flagged as delay loaded
  22641. * @param scene defines the hosting scene
  22642. * @param onLoaded defines a callback called when the geometry is loaded
  22643. */
  22644. load(scene: Scene, onLoaded?: () => void): void;
  22645. private _queueLoad;
  22646. /**
  22647. * Invert the geometry to move from a right handed system to a left handed one.
  22648. */
  22649. toLeftHanded(): void;
  22650. /** @hidden */
  22651. _resetPointsArrayCache(): void;
  22652. /** @hidden */
  22653. _generatePointsArray(): boolean;
  22654. /**
  22655. * Gets a value indicating if the geometry is disposed
  22656. * @returns true if the geometry was disposed
  22657. */
  22658. isDisposed(): boolean;
  22659. private _disposeVertexArrayObjects;
  22660. /**
  22661. * Free all associated resources
  22662. */
  22663. dispose(): void;
  22664. /**
  22665. * Clone the current geometry into a new geometry
  22666. * @param id defines the unique ID of the new geometry
  22667. * @returns a new geometry object
  22668. */
  22669. copy(id: string): Geometry;
  22670. /**
  22671. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22672. * @return a JSON representation of the current geometry data (without the vertices data)
  22673. */
  22674. serialize(): any;
  22675. private toNumberArray;
  22676. /**
  22677. * Serialize all vertices data into a JSON oject
  22678. * @returns a JSON representation of the current geometry data
  22679. */
  22680. serializeVerticeData(): any;
  22681. /**
  22682. * Extracts a clone of a mesh geometry
  22683. * @param mesh defines the source mesh
  22684. * @param id defines the unique ID of the new geometry object
  22685. * @returns the new geometry object
  22686. */
  22687. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22688. /**
  22689. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22690. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22691. * Be aware Math.random() could cause collisions, but:
  22692. * "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"
  22693. * @returns a string containing a new GUID
  22694. */
  22695. static RandomId(): string;
  22696. /** @hidden */
  22697. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22698. private static _CleanMatricesWeights;
  22699. /**
  22700. * Create a new geometry from persisted data (Using .babylon file format)
  22701. * @param parsedVertexData defines the persisted data
  22702. * @param scene defines the hosting scene
  22703. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22704. * @returns the new geometry object
  22705. */
  22706. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22707. }
  22708. }
  22709. declare module "babylonjs/Meshes/mesh.vertexData" {
  22710. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22711. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22712. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22713. import { Geometry } from "babylonjs/Meshes/geometry";
  22714. import { Mesh } from "babylonjs/Meshes/mesh";
  22715. /**
  22716. * Define an interface for all classes that will get and set the data on vertices
  22717. */
  22718. export interface IGetSetVerticesData {
  22719. /**
  22720. * Gets a boolean indicating if specific vertex data is present
  22721. * @param kind defines the vertex data kind to use
  22722. * @returns true is data kind is present
  22723. */
  22724. isVerticesDataPresent(kind: string): boolean;
  22725. /**
  22726. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22727. * @param kind defines the data kind (Position, normal, etc...)
  22728. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22729. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22730. * @returns a float array containing vertex data
  22731. */
  22732. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22733. /**
  22734. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22735. * @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.
  22736. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22737. * @returns the indices array or an empty array if the mesh has no geometry
  22738. */
  22739. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22740. /**
  22741. * Set specific vertex data
  22742. * @param kind defines the data kind (Position, normal, etc...)
  22743. * @param data defines the vertex data to use
  22744. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22745. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22746. */
  22747. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22748. /**
  22749. * Update a specific associated vertex buffer
  22750. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22751. * - VertexBuffer.PositionKind
  22752. * - VertexBuffer.UVKind
  22753. * - VertexBuffer.UV2Kind
  22754. * - VertexBuffer.UV3Kind
  22755. * - VertexBuffer.UV4Kind
  22756. * - VertexBuffer.UV5Kind
  22757. * - VertexBuffer.UV6Kind
  22758. * - VertexBuffer.ColorKind
  22759. * - VertexBuffer.MatricesIndicesKind
  22760. * - VertexBuffer.MatricesIndicesExtraKind
  22761. * - VertexBuffer.MatricesWeightsKind
  22762. * - VertexBuffer.MatricesWeightsExtraKind
  22763. * @param data defines the data source
  22764. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22765. * @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)
  22766. */
  22767. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22768. /**
  22769. * Creates a new index buffer
  22770. * @param indices defines the indices to store in the index buffer
  22771. * @param totalVertices defines the total number of vertices (could be null)
  22772. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22773. */
  22774. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22775. }
  22776. /**
  22777. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22778. */
  22779. export class VertexData {
  22780. /**
  22781. * Mesh side orientation : usually the external or front surface
  22782. */
  22783. static readonly FRONTSIDE: number;
  22784. /**
  22785. * Mesh side orientation : usually the internal or back surface
  22786. */
  22787. static readonly BACKSIDE: number;
  22788. /**
  22789. * Mesh side orientation : both internal and external or front and back surfaces
  22790. */
  22791. static readonly DOUBLESIDE: number;
  22792. /**
  22793. * Mesh side orientation : by default, `FRONTSIDE`
  22794. */
  22795. static readonly DEFAULTSIDE: number;
  22796. /**
  22797. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22798. */
  22799. positions: Nullable<FloatArray>;
  22800. /**
  22801. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22802. */
  22803. normals: Nullable<FloatArray>;
  22804. /**
  22805. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22806. */
  22807. tangents: Nullable<FloatArray>;
  22808. /**
  22809. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22810. */
  22811. uvs: Nullable<FloatArray>;
  22812. /**
  22813. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22814. */
  22815. uvs2: Nullable<FloatArray>;
  22816. /**
  22817. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22818. */
  22819. uvs3: Nullable<FloatArray>;
  22820. /**
  22821. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22822. */
  22823. uvs4: Nullable<FloatArray>;
  22824. /**
  22825. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22826. */
  22827. uvs5: Nullable<FloatArray>;
  22828. /**
  22829. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22830. */
  22831. uvs6: Nullable<FloatArray>;
  22832. /**
  22833. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22834. */
  22835. colors: Nullable<FloatArray>;
  22836. /**
  22837. * 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).
  22838. */
  22839. matricesIndices: Nullable<FloatArray>;
  22840. /**
  22841. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22842. */
  22843. matricesWeights: Nullable<FloatArray>;
  22844. /**
  22845. * An array extending the number of possible indices
  22846. */
  22847. matricesIndicesExtra: Nullable<FloatArray>;
  22848. /**
  22849. * An array extending the number of possible weights when the number of indices is extended
  22850. */
  22851. matricesWeightsExtra: Nullable<FloatArray>;
  22852. /**
  22853. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22854. */
  22855. indices: Nullable<IndicesArray>;
  22856. /**
  22857. * Uses the passed data array to set the set the values for the specified kind of data
  22858. * @param data a linear array of floating numbers
  22859. * @param kind the type of data that is being set, eg positions, colors etc
  22860. */
  22861. set(data: FloatArray, kind: string): void;
  22862. /**
  22863. * Associates the vertexData to the passed Mesh.
  22864. * Sets it as updatable or not (default `false`)
  22865. * @param mesh the mesh the vertexData is applied to
  22866. * @param updatable when used and having the value true allows new data to update the vertexData
  22867. * @returns the VertexData
  22868. */
  22869. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22870. /**
  22871. * Associates the vertexData to the passed Geometry.
  22872. * Sets it as updatable or not (default `false`)
  22873. * @param geometry the geometry the vertexData is applied to
  22874. * @param updatable when used and having the value true allows new data to update the vertexData
  22875. * @returns VertexData
  22876. */
  22877. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22878. /**
  22879. * Updates the associated mesh
  22880. * @param mesh the mesh to be updated
  22881. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22882. * @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
  22883. * @returns VertexData
  22884. */
  22885. updateMesh(mesh: Mesh): VertexData;
  22886. /**
  22887. * Updates the associated geometry
  22888. * @param geometry the geometry to be updated
  22889. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22890. * @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
  22891. * @returns VertexData.
  22892. */
  22893. updateGeometry(geometry: Geometry): VertexData;
  22894. private _applyTo;
  22895. private _update;
  22896. /**
  22897. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22898. * @param matrix the transforming matrix
  22899. * @returns the VertexData
  22900. */
  22901. transform(matrix: Matrix): VertexData;
  22902. /**
  22903. * Merges the passed VertexData into the current one
  22904. * @param other the VertexData to be merged into the current one
  22905. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22906. * @returns the modified VertexData
  22907. */
  22908. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22909. private _mergeElement;
  22910. private _validate;
  22911. /**
  22912. * Serializes the VertexData
  22913. * @returns a serialized object
  22914. */
  22915. serialize(): any;
  22916. /**
  22917. * Extracts the vertexData from a mesh
  22918. * @param mesh the mesh from which to extract the VertexData
  22919. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22920. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22921. * @returns the object VertexData associated to the passed mesh
  22922. */
  22923. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22924. /**
  22925. * Extracts the vertexData from the geometry
  22926. * @param geometry the geometry from which to extract the VertexData
  22927. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22928. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22929. * @returns the object VertexData associated to the passed mesh
  22930. */
  22931. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22932. private static _ExtractFrom;
  22933. /**
  22934. * Creates the VertexData for a Ribbon
  22935. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22936. * * pathArray array of paths, each of which an array of successive Vector3
  22937. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22938. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22939. * * 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
  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. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22944. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22945. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22946. * @returns the VertexData of the ribbon
  22947. */
  22948. static CreateRibbon(options: {
  22949. pathArray: Vector3[][];
  22950. closeArray?: boolean;
  22951. closePath?: boolean;
  22952. offset?: number;
  22953. sideOrientation?: number;
  22954. frontUVs?: Vector4;
  22955. backUVs?: Vector4;
  22956. invertUV?: boolean;
  22957. uvs?: Vector2[];
  22958. colors?: Color4[];
  22959. }): VertexData;
  22960. /**
  22961. * Creates the VertexData for a box
  22962. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22963. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22964. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22965. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22966. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22967. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22968. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22969. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22970. * * 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)
  22971. * * 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)
  22972. * @returns the VertexData of the box
  22973. */
  22974. static CreateBox(options: {
  22975. size?: number;
  22976. width?: number;
  22977. height?: number;
  22978. depth?: number;
  22979. faceUV?: Vector4[];
  22980. faceColors?: Color4[];
  22981. sideOrientation?: number;
  22982. frontUVs?: Vector4;
  22983. backUVs?: Vector4;
  22984. }): VertexData;
  22985. /**
  22986. * Creates the VertexData for a tiled box
  22987. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22988. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22989. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22990. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22992. * @returns the VertexData of the box
  22993. */
  22994. static CreateTiledBox(options: {
  22995. pattern?: number;
  22996. width?: number;
  22997. height?: number;
  22998. depth?: number;
  22999. tileSize?: number;
  23000. tileWidth?: number;
  23001. tileHeight?: number;
  23002. alignHorizontal?: number;
  23003. alignVertical?: number;
  23004. faceUV?: Vector4[];
  23005. faceColors?: Color4[];
  23006. sideOrientation?: number;
  23007. }): VertexData;
  23008. /**
  23009. * Creates the VertexData for a tiled plane
  23010. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23011. * * pattern a limited pattern arrangement depending on the number
  23012. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23013. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23014. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  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 tiled plane
  23019. */
  23020. static CreateTiledPlane(options: {
  23021. pattern?: number;
  23022. tileSize?: number;
  23023. tileWidth?: number;
  23024. tileHeight?: number;
  23025. size?: number;
  23026. width?: number;
  23027. height?: number;
  23028. alignHorizontal?: number;
  23029. alignVertical?: number;
  23030. sideOrientation?: number;
  23031. frontUVs?: Vector4;
  23032. backUVs?: Vector4;
  23033. }): VertexData;
  23034. /**
  23035. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23037. * * segments sets the number of horizontal strips optional, default 32
  23038. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23039. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23040. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23041. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23042. * * 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
  23043. * * 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
  23044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23045. * * 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)
  23046. * * 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)
  23047. * @returns the VertexData of the ellipsoid
  23048. */
  23049. static CreateSphere(options: {
  23050. segments?: number;
  23051. diameter?: number;
  23052. diameterX?: number;
  23053. diameterY?: number;
  23054. diameterZ?: number;
  23055. arc?: number;
  23056. slice?: number;
  23057. sideOrientation?: number;
  23058. frontUVs?: Vector4;
  23059. backUVs?: Vector4;
  23060. }): VertexData;
  23061. /**
  23062. * Creates the VertexData for a cylinder, cone or prism
  23063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23064. * * height sets the height (y direction) of the cylinder, optional, default 2
  23065. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23066. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23067. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23068. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23069. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23070. * * 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
  23071. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23072. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23073. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23074. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23076. * * 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)
  23077. * * 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)
  23078. * @returns the VertexData of the cylinder, cone or prism
  23079. */
  23080. static CreateCylinder(options: {
  23081. height?: number;
  23082. diameterTop?: number;
  23083. diameterBottom?: number;
  23084. diameter?: number;
  23085. tessellation?: number;
  23086. subdivisions?: number;
  23087. arc?: number;
  23088. faceColors?: Color4[];
  23089. faceUV?: Vector4[];
  23090. hasRings?: boolean;
  23091. enclose?: boolean;
  23092. sideOrientation?: number;
  23093. frontUVs?: Vector4;
  23094. backUVs?: Vector4;
  23095. }): VertexData;
  23096. /**
  23097. * Creates the VertexData for a torus
  23098. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23099. * * diameter the diameter of the torus, optional default 1
  23100. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23101. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23102. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23103. * * 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)
  23104. * * 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)
  23105. * @returns the VertexData of the torus
  23106. */
  23107. static CreateTorus(options: {
  23108. diameter?: number;
  23109. thickness?: number;
  23110. tessellation?: number;
  23111. sideOrientation?: number;
  23112. frontUVs?: Vector4;
  23113. backUVs?: Vector4;
  23114. }): VertexData;
  23115. /**
  23116. * Creates the VertexData of the LineSystem
  23117. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23118. * - lines an array of lines, each line being an array of successive Vector3
  23119. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23120. * @returns the VertexData of the LineSystem
  23121. */
  23122. static CreateLineSystem(options: {
  23123. lines: Vector3[][];
  23124. colors?: Nullable<Color4[][]>;
  23125. }): VertexData;
  23126. /**
  23127. * Create the VertexData for a DashedLines
  23128. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23129. * - points an array successive Vector3
  23130. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23131. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23132. * - dashNb the intended total number of dashes, optional, default 200
  23133. * @returns the VertexData for the DashedLines
  23134. */
  23135. static CreateDashedLines(options: {
  23136. points: Vector3[];
  23137. dashSize?: number;
  23138. gapSize?: number;
  23139. dashNb?: number;
  23140. }): VertexData;
  23141. /**
  23142. * Creates the VertexData for a Ground
  23143. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23144. * - width the width (x direction) of the ground, optional, default 1
  23145. * - height the height (z direction) of the ground, optional, default 1
  23146. * - subdivisions the number of subdivisions per side, optional, default 1
  23147. * @returns the VertexData of the Ground
  23148. */
  23149. static CreateGround(options: {
  23150. width?: number;
  23151. height?: number;
  23152. subdivisions?: number;
  23153. subdivisionsX?: number;
  23154. subdivisionsY?: number;
  23155. }): VertexData;
  23156. /**
  23157. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23158. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23159. * * xmin the ground minimum X coordinate, optional, default -1
  23160. * * zmin the ground minimum Z coordinate, optional, default -1
  23161. * * xmax the ground maximum X coordinate, optional, default 1
  23162. * * zmax the ground maximum Z coordinate, optional, default 1
  23163. * * 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}
  23164. * * 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}
  23165. * @returns the VertexData of the TiledGround
  23166. */
  23167. static CreateTiledGround(options: {
  23168. xmin: number;
  23169. zmin: number;
  23170. xmax: number;
  23171. zmax: number;
  23172. subdivisions?: {
  23173. w: number;
  23174. h: number;
  23175. };
  23176. precision?: {
  23177. w: number;
  23178. h: number;
  23179. };
  23180. }): VertexData;
  23181. /**
  23182. * Creates the VertexData of the Ground designed from a heightmap
  23183. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23184. * * width the width (x direction) of the ground
  23185. * * height the height (z direction) of the ground
  23186. * * subdivisions the number of subdivisions per side
  23187. * * minHeight the minimum altitude on the ground, optional, default 0
  23188. * * maxHeight the maximum altitude on the ground, optional default 1
  23189. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23190. * * buffer the array holding the image color data
  23191. * * bufferWidth the width of image
  23192. * * bufferHeight the height of image
  23193. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23194. * @returns the VertexData of the Ground designed from a heightmap
  23195. */
  23196. static CreateGroundFromHeightMap(options: {
  23197. width: number;
  23198. height: number;
  23199. subdivisions: number;
  23200. minHeight: number;
  23201. maxHeight: number;
  23202. colorFilter: Color3;
  23203. buffer: Uint8Array;
  23204. bufferWidth: number;
  23205. bufferHeight: number;
  23206. alphaFilter: number;
  23207. }): VertexData;
  23208. /**
  23209. * Creates the VertexData for a Plane
  23210. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23211. * * size sets the width and height of the plane to the value of size, optional default 1
  23212. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23213. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23215. * * 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)
  23216. * * 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)
  23217. * @returns the VertexData of the box
  23218. */
  23219. static CreatePlane(options: {
  23220. size?: number;
  23221. width?: number;
  23222. height?: number;
  23223. sideOrientation?: number;
  23224. frontUVs?: Vector4;
  23225. backUVs?: Vector4;
  23226. }): VertexData;
  23227. /**
  23228. * Creates the VertexData of the Disc or regular Polygon
  23229. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23230. * * radius the radius of the disc, optional default 0.5
  23231. * * tessellation the number of polygon sides, optional, default 64
  23232. * * 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
  23233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23234. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23235. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23236. * @returns the VertexData of the box
  23237. */
  23238. static CreateDisc(options: {
  23239. radius?: number;
  23240. tessellation?: number;
  23241. arc?: number;
  23242. sideOrientation?: number;
  23243. frontUVs?: Vector4;
  23244. backUVs?: Vector4;
  23245. }): VertexData;
  23246. /**
  23247. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23248. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23249. * @param polygon a mesh built from polygonTriangulation.build()
  23250. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23251. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23252. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23253. * @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)
  23254. * @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)
  23255. * @returns the VertexData of the Polygon
  23256. */
  23257. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23258. /**
  23259. * Creates the VertexData of the IcoSphere
  23260. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23261. * * radius the radius of the IcoSphere, optional default 1
  23262. * * radiusX allows stretching in the x direction, optional, default radius
  23263. * * radiusY allows stretching in the y direction, optional, default radius
  23264. * * radiusZ allows stretching in the z direction, optional, default radius
  23265. * * flat when true creates a flat shaded mesh, optional, default true
  23266. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23268. * * 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)
  23269. * * 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)
  23270. * @returns the VertexData of the IcoSphere
  23271. */
  23272. static CreateIcoSphere(options: {
  23273. radius?: number;
  23274. radiusX?: number;
  23275. radiusY?: number;
  23276. radiusZ?: number;
  23277. flat?: boolean;
  23278. subdivisions?: number;
  23279. sideOrientation?: number;
  23280. frontUVs?: Vector4;
  23281. backUVs?: Vector4;
  23282. }): VertexData;
  23283. /**
  23284. * Creates the VertexData for a Polyhedron
  23285. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23286. * * type provided types are:
  23287. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23288. * * 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)
  23289. * * size the size of the IcoSphere, optional default 1
  23290. * * sizeX allows stretching in the x direction, optional, default size
  23291. * * sizeY allows stretching in the y direction, optional, default size
  23292. * * sizeZ allows stretching in the z direction, optional, default size
  23293. * * 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
  23294. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23295. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23296. * * flat when true creates a flat shaded mesh, optional, default true
  23297. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23298. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23299. * * 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)
  23300. * * 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)
  23301. * @returns the VertexData of the Polyhedron
  23302. */
  23303. static CreatePolyhedron(options: {
  23304. type?: number;
  23305. size?: number;
  23306. sizeX?: number;
  23307. sizeY?: number;
  23308. sizeZ?: number;
  23309. custom?: any;
  23310. faceUV?: Vector4[];
  23311. faceColors?: Color4[];
  23312. flat?: boolean;
  23313. sideOrientation?: number;
  23314. frontUVs?: Vector4;
  23315. backUVs?: Vector4;
  23316. }): VertexData;
  23317. /**
  23318. * Creates the VertexData for a TorusKnot
  23319. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23320. * * radius the radius of the torus knot, optional, default 2
  23321. * * tube the thickness of the tube, optional, default 0.5
  23322. * * radialSegments the number of sides on each tube segments, optional, default 32
  23323. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23324. * * p the number of windings around the z axis, optional, default 2
  23325. * * q the number of windings around the x axis, optional, default 3
  23326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23327. * * 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)
  23328. * * 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)
  23329. * @returns the VertexData of the Torus Knot
  23330. */
  23331. static CreateTorusKnot(options: {
  23332. radius?: number;
  23333. tube?: number;
  23334. radialSegments?: number;
  23335. tubularSegments?: number;
  23336. p?: number;
  23337. q?: number;
  23338. sideOrientation?: number;
  23339. frontUVs?: Vector4;
  23340. backUVs?: Vector4;
  23341. }): VertexData;
  23342. /**
  23343. * Compute normals for given positions and indices
  23344. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23345. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23346. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23347. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23348. * * facetNormals : optional array of facet normals (vector3)
  23349. * * facetPositions : optional array of facet positions (vector3)
  23350. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23351. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23352. * * bInfo : optional bounding info, required for facetPartitioning computation
  23353. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23354. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23355. * * useRightHandedSystem: optional boolean to for right handed system computation
  23356. * * depthSort : optional boolean to enable the facet depth sort computation
  23357. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23358. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23359. */
  23360. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23361. facetNormals?: any;
  23362. facetPositions?: any;
  23363. facetPartitioning?: any;
  23364. ratio?: number;
  23365. bInfo?: any;
  23366. bbSize?: Vector3;
  23367. subDiv?: any;
  23368. useRightHandedSystem?: boolean;
  23369. depthSort?: boolean;
  23370. distanceTo?: Vector3;
  23371. depthSortedFacets?: any;
  23372. }): void;
  23373. /** @hidden */
  23374. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23375. /**
  23376. * Applies VertexData created from the imported parameters to the geometry
  23377. * @param parsedVertexData the parsed data from an imported file
  23378. * @param geometry the geometry to apply the VertexData to
  23379. */
  23380. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23381. }
  23382. }
  23383. declare module "babylonjs/Morph/morphTarget" {
  23384. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23385. import { Observable } from "babylonjs/Misc/observable";
  23386. import { Nullable, FloatArray } from "babylonjs/types";
  23387. import { Scene } from "babylonjs/scene";
  23388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23389. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23390. /**
  23391. * Defines a target to use with MorphTargetManager
  23392. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23393. */
  23394. export class MorphTarget implements IAnimatable {
  23395. /** defines the name of the target */
  23396. name: string;
  23397. /**
  23398. * Gets or sets the list of animations
  23399. */
  23400. animations: import("babylonjs/Animations/animation").Animation[];
  23401. private _scene;
  23402. private _positions;
  23403. private _normals;
  23404. private _tangents;
  23405. private _uvs;
  23406. private _influence;
  23407. private _uniqueId;
  23408. /**
  23409. * Observable raised when the influence changes
  23410. */
  23411. onInfluenceChanged: Observable<boolean>;
  23412. /** @hidden */
  23413. _onDataLayoutChanged: Observable<void>;
  23414. /**
  23415. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23416. */
  23417. get influence(): number;
  23418. set influence(influence: number);
  23419. /**
  23420. * Gets or sets the id of the morph Target
  23421. */
  23422. id: string;
  23423. private _animationPropertiesOverride;
  23424. /**
  23425. * Gets or sets the animation properties override
  23426. */
  23427. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23428. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23429. /**
  23430. * Creates a new MorphTarget
  23431. * @param name defines the name of the target
  23432. * @param influence defines the influence to use
  23433. * @param scene defines the scene the morphtarget belongs to
  23434. */
  23435. constructor(
  23436. /** defines the name of the target */
  23437. name: string, influence?: number, scene?: Nullable<Scene>);
  23438. /**
  23439. * Gets the unique ID of this manager
  23440. */
  23441. get uniqueId(): number;
  23442. /**
  23443. * Gets a boolean defining if the target contains position data
  23444. */
  23445. get hasPositions(): boolean;
  23446. /**
  23447. * Gets a boolean defining if the target contains normal data
  23448. */
  23449. get hasNormals(): boolean;
  23450. /**
  23451. * Gets a boolean defining if the target contains tangent data
  23452. */
  23453. get hasTangents(): boolean;
  23454. /**
  23455. * Gets a boolean defining if the target contains texture coordinates data
  23456. */
  23457. get hasUVs(): boolean;
  23458. /**
  23459. * Affects position data to this target
  23460. * @param data defines the position data to use
  23461. */
  23462. setPositions(data: Nullable<FloatArray>): void;
  23463. /**
  23464. * Gets the position data stored in this target
  23465. * @returns a FloatArray containing the position data (or null if not present)
  23466. */
  23467. getPositions(): Nullable<FloatArray>;
  23468. /**
  23469. * Affects normal data to this target
  23470. * @param data defines the normal data to use
  23471. */
  23472. setNormals(data: Nullable<FloatArray>): void;
  23473. /**
  23474. * Gets the normal data stored in this target
  23475. * @returns a FloatArray containing the normal data (or null if not present)
  23476. */
  23477. getNormals(): Nullable<FloatArray>;
  23478. /**
  23479. * Affects tangent data to this target
  23480. * @param data defines the tangent data to use
  23481. */
  23482. setTangents(data: Nullable<FloatArray>): void;
  23483. /**
  23484. * Gets the tangent data stored in this target
  23485. * @returns a FloatArray containing the tangent data (or null if not present)
  23486. */
  23487. getTangents(): Nullable<FloatArray>;
  23488. /**
  23489. * Affects texture coordinates data to this target
  23490. * @param data defines the texture coordinates data to use
  23491. */
  23492. setUVs(data: Nullable<FloatArray>): void;
  23493. /**
  23494. * Gets the texture coordinates data stored in this target
  23495. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23496. */
  23497. getUVs(): Nullable<FloatArray>;
  23498. /**
  23499. * Clone the current target
  23500. * @returns a new MorphTarget
  23501. */
  23502. clone(): MorphTarget;
  23503. /**
  23504. * Serializes the current target into a Serialization object
  23505. * @returns the serialized object
  23506. */
  23507. serialize(): any;
  23508. /**
  23509. * Returns the string "MorphTarget"
  23510. * @returns "MorphTarget"
  23511. */
  23512. getClassName(): string;
  23513. /**
  23514. * Creates a new target from serialized data
  23515. * @param serializationObject defines the serialized data to use
  23516. * @returns a new MorphTarget
  23517. */
  23518. static Parse(serializationObject: any): MorphTarget;
  23519. /**
  23520. * Creates a MorphTarget from mesh data
  23521. * @param mesh defines the source mesh
  23522. * @param name defines the name to use for the new target
  23523. * @param influence defines the influence to attach to the target
  23524. * @returns a new MorphTarget
  23525. */
  23526. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23527. }
  23528. }
  23529. declare module "babylonjs/Morph/morphTargetManager" {
  23530. import { Nullable } from "babylonjs/types";
  23531. import { Scene } from "babylonjs/scene";
  23532. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23533. /**
  23534. * This class is used to deform meshes using morphing between different targets
  23535. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23536. */
  23537. export class MorphTargetManager {
  23538. private _targets;
  23539. private _targetInfluenceChangedObservers;
  23540. private _targetDataLayoutChangedObservers;
  23541. private _activeTargets;
  23542. private _scene;
  23543. private _influences;
  23544. private _supportsNormals;
  23545. private _supportsTangents;
  23546. private _supportsUVs;
  23547. private _vertexCount;
  23548. private _uniqueId;
  23549. private _tempInfluences;
  23550. /**
  23551. * Gets or sets a boolean indicating if normals must be morphed
  23552. */
  23553. enableNormalMorphing: boolean;
  23554. /**
  23555. * Gets or sets a boolean indicating if tangents must be morphed
  23556. */
  23557. enableTangentMorphing: boolean;
  23558. /**
  23559. * Gets or sets a boolean indicating if UV must be morphed
  23560. */
  23561. enableUVMorphing: boolean;
  23562. /**
  23563. * Creates a new MorphTargetManager
  23564. * @param scene defines the current scene
  23565. */
  23566. constructor(scene?: Nullable<Scene>);
  23567. /**
  23568. * Gets the unique ID of this manager
  23569. */
  23570. get uniqueId(): number;
  23571. /**
  23572. * Gets the number of vertices handled by this manager
  23573. */
  23574. get vertexCount(): number;
  23575. /**
  23576. * Gets a boolean indicating if this manager supports morphing of normals
  23577. */
  23578. get supportsNormals(): boolean;
  23579. /**
  23580. * Gets a boolean indicating if this manager supports morphing of tangents
  23581. */
  23582. get supportsTangents(): boolean;
  23583. /**
  23584. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23585. */
  23586. get supportsUVs(): boolean;
  23587. /**
  23588. * Gets the number of targets stored in this manager
  23589. */
  23590. get numTargets(): number;
  23591. /**
  23592. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23593. */
  23594. get numInfluencers(): number;
  23595. /**
  23596. * Gets the list of influences (one per target)
  23597. */
  23598. get influences(): Float32Array;
  23599. /**
  23600. * Gets the active target at specified index. An active target is a target with an influence > 0
  23601. * @param index defines the index to check
  23602. * @returns the requested target
  23603. */
  23604. getActiveTarget(index: number): MorphTarget;
  23605. /**
  23606. * Gets the target at specified index
  23607. * @param index defines the index to check
  23608. * @returns the requested target
  23609. */
  23610. getTarget(index: number): MorphTarget;
  23611. /**
  23612. * Add a new target to this manager
  23613. * @param target defines the target to add
  23614. */
  23615. addTarget(target: MorphTarget): void;
  23616. /**
  23617. * Removes a target from the manager
  23618. * @param target defines the target to remove
  23619. */
  23620. removeTarget(target: MorphTarget): void;
  23621. /**
  23622. * Clone the current manager
  23623. * @returns a new MorphTargetManager
  23624. */
  23625. clone(): MorphTargetManager;
  23626. /**
  23627. * Serializes the current manager into a Serialization object
  23628. * @returns the serialized object
  23629. */
  23630. serialize(): any;
  23631. private _syncActiveTargets;
  23632. /**
  23633. * Syncrhonize the targets with all the meshes using this morph target manager
  23634. */
  23635. synchronize(): void;
  23636. /**
  23637. * Creates a new MorphTargetManager from serialized data
  23638. * @param serializationObject defines the serialized data
  23639. * @param scene defines the hosting scene
  23640. * @returns the new MorphTargetManager
  23641. */
  23642. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23643. }
  23644. }
  23645. declare module "babylonjs/Meshes/meshLODLevel" {
  23646. import { Mesh } from "babylonjs/Meshes/mesh";
  23647. import { Nullable } from "babylonjs/types";
  23648. /**
  23649. * Class used to represent a specific level of detail of a mesh
  23650. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23651. */
  23652. export class MeshLODLevel {
  23653. /** Defines the distance where this level should start being displayed */
  23654. distance: number;
  23655. /** Defines the mesh to use to render this level */
  23656. mesh: Nullable<Mesh>;
  23657. /**
  23658. * Creates a new LOD level
  23659. * @param distance defines the distance where this level should star being displayed
  23660. * @param mesh defines the mesh to use to render this level
  23661. */
  23662. constructor(
  23663. /** Defines the distance where this level should start being displayed */
  23664. distance: number,
  23665. /** Defines the mesh to use to render this level */
  23666. mesh: Nullable<Mesh>);
  23667. }
  23668. }
  23669. declare module "babylonjs/Meshes/groundMesh" {
  23670. import { Scene } from "babylonjs/scene";
  23671. import { Vector3 } from "babylonjs/Maths/math.vector";
  23672. import { Mesh } from "babylonjs/Meshes/mesh";
  23673. /**
  23674. * Mesh representing the gorund
  23675. */
  23676. export class GroundMesh extends Mesh {
  23677. /** If octree should be generated */
  23678. generateOctree: boolean;
  23679. private _heightQuads;
  23680. /** @hidden */
  23681. _subdivisionsX: number;
  23682. /** @hidden */
  23683. _subdivisionsY: number;
  23684. /** @hidden */
  23685. _width: number;
  23686. /** @hidden */
  23687. _height: number;
  23688. /** @hidden */
  23689. _minX: number;
  23690. /** @hidden */
  23691. _maxX: number;
  23692. /** @hidden */
  23693. _minZ: number;
  23694. /** @hidden */
  23695. _maxZ: number;
  23696. constructor(name: string, scene: Scene);
  23697. /**
  23698. * "GroundMesh"
  23699. * @returns "GroundMesh"
  23700. */
  23701. getClassName(): string;
  23702. /**
  23703. * The minimum of x and y subdivisions
  23704. */
  23705. get subdivisions(): number;
  23706. /**
  23707. * X subdivisions
  23708. */
  23709. get subdivisionsX(): number;
  23710. /**
  23711. * Y subdivisions
  23712. */
  23713. get subdivisionsY(): number;
  23714. /**
  23715. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23716. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23717. * @param chunksCount the number of subdivisions for x and y
  23718. * @param octreeBlocksSize (Default: 32)
  23719. */
  23720. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23721. /**
  23722. * Returns a height (y) value in the Worl system :
  23723. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23724. * @param x x coordinate
  23725. * @param z z coordinate
  23726. * @returns the ground y position if (x, z) are outside the ground surface.
  23727. */
  23728. getHeightAtCoordinates(x: number, z: number): number;
  23729. /**
  23730. * Returns a normalized vector (Vector3) orthogonal to the ground
  23731. * at the ground coordinates (x, z) expressed in the World system.
  23732. * @param x x coordinate
  23733. * @param z z coordinate
  23734. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23735. */
  23736. getNormalAtCoordinates(x: number, z: number): Vector3;
  23737. /**
  23738. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23739. * at the ground coordinates (x, z) expressed in the World system.
  23740. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23741. * @param x x coordinate
  23742. * @param z z coordinate
  23743. * @param ref vector to store the result
  23744. * @returns the GroundMesh.
  23745. */
  23746. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23747. /**
  23748. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23749. * if the ground has been updated.
  23750. * This can be used in the render loop.
  23751. * @returns the GroundMesh.
  23752. */
  23753. updateCoordinateHeights(): GroundMesh;
  23754. private _getFacetAt;
  23755. private _initHeightQuads;
  23756. private _computeHeightQuads;
  23757. /**
  23758. * Serializes this ground mesh
  23759. * @param serializationObject object to write serialization to
  23760. */
  23761. serialize(serializationObject: any): void;
  23762. /**
  23763. * Parses a serialized ground mesh
  23764. * @param parsedMesh the serialized mesh
  23765. * @param scene the scene to create the ground mesh in
  23766. * @returns the created ground mesh
  23767. */
  23768. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23769. }
  23770. }
  23771. declare module "babylonjs/Physics/physicsJoint" {
  23772. import { Vector3 } from "babylonjs/Maths/math.vector";
  23773. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23774. /**
  23775. * Interface for Physics-Joint data
  23776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23777. */
  23778. export interface PhysicsJointData {
  23779. /**
  23780. * The main pivot of the joint
  23781. */
  23782. mainPivot?: Vector3;
  23783. /**
  23784. * The connected pivot of the joint
  23785. */
  23786. connectedPivot?: Vector3;
  23787. /**
  23788. * The main axis of the joint
  23789. */
  23790. mainAxis?: Vector3;
  23791. /**
  23792. * The connected axis of the joint
  23793. */
  23794. connectedAxis?: Vector3;
  23795. /**
  23796. * The collision of the joint
  23797. */
  23798. collision?: boolean;
  23799. /**
  23800. * Native Oimo/Cannon/Energy data
  23801. */
  23802. nativeParams?: any;
  23803. }
  23804. /**
  23805. * This is a holder class for the physics joint created by the physics plugin
  23806. * It holds a set of functions to control the underlying joint
  23807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23808. */
  23809. export class PhysicsJoint {
  23810. /**
  23811. * The type of the physics joint
  23812. */
  23813. type: number;
  23814. /**
  23815. * The data for the physics joint
  23816. */
  23817. jointData: PhysicsJointData;
  23818. private _physicsJoint;
  23819. protected _physicsPlugin: IPhysicsEnginePlugin;
  23820. /**
  23821. * Initializes the physics joint
  23822. * @param type The type of the physics joint
  23823. * @param jointData The data for the physics joint
  23824. */
  23825. constructor(
  23826. /**
  23827. * The type of the physics joint
  23828. */
  23829. type: number,
  23830. /**
  23831. * The data for the physics joint
  23832. */
  23833. jointData: PhysicsJointData);
  23834. /**
  23835. * Gets the physics joint
  23836. */
  23837. get physicsJoint(): any;
  23838. /**
  23839. * Sets the physics joint
  23840. */
  23841. set physicsJoint(newJoint: any);
  23842. /**
  23843. * Sets the physics plugin
  23844. */
  23845. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23846. /**
  23847. * Execute a function that is physics-plugin specific.
  23848. * @param {Function} func the function that will be executed.
  23849. * It accepts two parameters: the physics world and the physics joint
  23850. */
  23851. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23852. /**
  23853. * Distance-Joint type
  23854. */
  23855. static DistanceJoint: number;
  23856. /**
  23857. * Hinge-Joint type
  23858. */
  23859. static HingeJoint: number;
  23860. /**
  23861. * Ball-and-Socket joint type
  23862. */
  23863. static BallAndSocketJoint: number;
  23864. /**
  23865. * Wheel-Joint type
  23866. */
  23867. static WheelJoint: number;
  23868. /**
  23869. * Slider-Joint type
  23870. */
  23871. static SliderJoint: number;
  23872. /**
  23873. * Prismatic-Joint type
  23874. */
  23875. static PrismaticJoint: number;
  23876. /**
  23877. * Universal-Joint type
  23878. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23879. */
  23880. static UniversalJoint: number;
  23881. /**
  23882. * Hinge-Joint 2 type
  23883. */
  23884. static Hinge2Joint: number;
  23885. /**
  23886. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23887. */
  23888. static PointToPointJoint: number;
  23889. /**
  23890. * Spring-Joint type
  23891. */
  23892. static SpringJoint: number;
  23893. /**
  23894. * Lock-Joint type
  23895. */
  23896. static LockJoint: number;
  23897. }
  23898. /**
  23899. * A class representing a physics distance joint
  23900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23901. */
  23902. export class DistanceJoint extends PhysicsJoint {
  23903. /**
  23904. *
  23905. * @param jointData The data for the Distance-Joint
  23906. */
  23907. constructor(jointData: DistanceJointData);
  23908. /**
  23909. * Update the predefined distance.
  23910. * @param maxDistance The maximum preferred distance
  23911. * @param minDistance The minimum preferred distance
  23912. */
  23913. updateDistance(maxDistance: number, minDistance?: number): void;
  23914. }
  23915. /**
  23916. * Represents a Motor-Enabled Joint
  23917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23918. */
  23919. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23920. /**
  23921. * Initializes the Motor-Enabled Joint
  23922. * @param type The type of the joint
  23923. * @param jointData The physica joint data for the joint
  23924. */
  23925. constructor(type: number, jointData: PhysicsJointData);
  23926. /**
  23927. * Set the motor values.
  23928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23929. * @param force the force to apply
  23930. * @param maxForce max force for this motor.
  23931. */
  23932. setMotor(force?: number, maxForce?: number): void;
  23933. /**
  23934. * Set the motor's limits.
  23935. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23936. * @param upperLimit The upper limit of the motor
  23937. * @param lowerLimit The lower limit of the motor
  23938. */
  23939. setLimit(upperLimit: number, lowerLimit?: number): void;
  23940. }
  23941. /**
  23942. * This class represents a single physics Hinge-Joint
  23943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23944. */
  23945. export class HingeJoint extends MotorEnabledJoint {
  23946. /**
  23947. * Initializes the Hinge-Joint
  23948. * @param jointData The joint data for the Hinge-Joint
  23949. */
  23950. constructor(jointData: PhysicsJointData);
  23951. /**
  23952. * Set the motor values.
  23953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23954. * @param {number} force the force to apply
  23955. * @param {number} maxForce max force for this motor.
  23956. */
  23957. setMotor(force?: number, maxForce?: number): void;
  23958. /**
  23959. * Set the motor's limits.
  23960. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23961. * @param upperLimit The upper limit of the motor
  23962. * @param lowerLimit The lower limit of the motor
  23963. */
  23964. setLimit(upperLimit: number, lowerLimit?: number): void;
  23965. }
  23966. /**
  23967. * This class represents a dual hinge physics joint (same as wheel joint)
  23968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23969. */
  23970. export class Hinge2Joint extends MotorEnabledJoint {
  23971. /**
  23972. * Initializes the Hinge2-Joint
  23973. * @param jointData The joint data for the Hinge2-Joint
  23974. */
  23975. constructor(jointData: PhysicsJointData);
  23976. /**
  23977. * Set the motor values.
  23978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23979. * @param {number} targetSpeed the speed the motor is to reach
  23980. * @param {number} maxForce max force for this motor.
  23981. * @param {motorIndex} the motor's index, 0 or 1.
  23982. */
  23983. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23984. /**
  23985. * Set the motor limits.
  23986. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23987. * @param {number} upperLimit the upper limit
  23988. * @param {number} lowerLimit lower limit
  23989. * @param {motorIndex} the motor's index, 0 or 1.
  23990. */
  23991. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23992. }
  23993. /**
  23994. * Interface for a motor enabled joint
  23995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23996. */
  23997. export interface IMotorEnabledJoint {
  23998. /**
  23999. * Physics joint
  24000. */
  24001. physicsJoint: any;
  24002. /**
  24003. * Sets the motor of the motor-enabled joint
  24004. * @param force The force of the motor
  24005. * @param maxForce The maximum force of the motor
  24006. * @param motorIndex The index of the motor
  24007. */
  24008. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24009. /**
  24010. * Sets the limit of the motor
  24011. * @param upperLimit The upper limit of the motor
  24012. * @param lowerLimit The lower limit of the motor
  24013. * @param motorIndex The index of the motor
  24014. */
  24015. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24016. }
  24017. /**
  24018. * Joint data for a Distance-Joint
  24019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24020. */
  24021. export interface DistanceJointData extends PhysicsJointData {
  24022. /**
  24023. * Max distance the 2 joint objects can be apart
  24024. */
  24025. maxDistance: number;
  24026. }
  24027. /**
  24028. * Joint data from a spring joint
  24029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24030. */
  24031. export interface SpringJointData extends PhysicsJointData {
  24032. /**
  24033. * Length of the spring
  24034. */
  24035. length: number;
  24036. /**
  24037. * Stiffness of the spring
  24038. */
  24039. stiffness: number;
  24040. /**
  24041. * Damping of the spring
  24042. */
  24043. damping: number;
  24044. /** this callback will be called when applying the force to the impostors. */
  24045. forceApplicationCallback: () => void;
  24046. }
  24047. }
  24048. declare module "babylonjs/Physics/physicsRaycastResult" {
  24049. import { Vector3 } from "babylonjs/Maths/math.vector";
  24050. /**
  24051. * Holds the data for the raycast result
  24052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24053. */
  24054. export class PhysicsRaycastResult {
  24055. private _hasHit;
  24056. private _hitDistance;
  24057. private _hitNormalWorld;
  24058. private _hitPointWorld;
  24059. private _rayFromWorld;
  24060. private _rayToWorld;
  24061. /**
  24062. * Gets if there was a hit
  24063. */
  24064. get hasHit(): boolean;
  24065. /**
  24066. * Gets the distance from the hit
  24067. */
  24068. get hitDistance(): number;
  24069. /**
  24070. * Gets the hit normal/direction in the world
  24071. */
  24072. get hitNormalWorld(): Vector3;
  24073. /**
  24074. * Gets the hit point in the world
  24075. */
  24076. get hitPointWorld(): Vector3;
  24077. /**
  24078. * Gets the ray "start point" of the ray in the world
  24079. */
  24080. get rayFromWorld(): Vector3;
  24081. /**
  24082. * Gets the ray "end point" of the ray in the world
  24083. */
  24084. get rayToWorld(): Vector3;
  24085. /**
  24086. * Sets the hit data (normal & point in world space)
  24087. * @param hitNormalWorld defines the normal in world space
  24088. * @param hitPointWorld defines the point in world space
  24089. */
  24090. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24091. /**
  24092. * Sets the distance from the start point to the hit point
  24093. * @param distance
  24094. */
  24095. setHitDistance(distance: number): void;
  24096. /**
  24097. * Calculates the distance manually
  24098. */
  24099. calculateHitDistance(): void;
  24100. /**
  24101. * Resets all the values to default
  24102. * @param from The from point on world space
  24103. * @param to The to point on world space
  24104. */
  24105. reset(from?: Vector3, to?: Vector3): void;
  24106. }
  24107. /**
  24108. * Interface for the size containing width and height
  24109. */
  24110. interface IXYZ {
  24111. /**
  24112. * X
  24113. */
  24114. x: number;
  24115. /**
  24116. * Y
  24117. */
  24118. y: number;
  24119. /**
  24120. * Z
  24121. */
  24122. z: number;
  24123. }
  24124. }
  24125. declare module "babylonjs/Physics/IPhysicsEngine" {
  24126. import { Nullable } from "babylonjs/types";
  24127. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24129. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24130. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24131. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24132. /**
  24133. * Interface used to describe a physics joint
  24134. */
  24135. export interface PhysicsImpostorJoint {
  24136. /** Defines the main impostor to which the joint is linked */
  24137. mainImpostor: PhysicsImpostor;
  24138. /** Defines the impostor that is connected to the main impostor using this joint */
  24139. connectedImpostor: PhysicsImpostor;
  24140. /** Defines the joint itself */
  24141. joint: PhysicsJoint;
  24142. }
  24143. /** @hidden */
  24144. export interface IPhysicsEnginePlugin {
  24145. world: any;
  24146. name: string;
  24147. setGravity(gravity: Vector3): void;
  24148. setTimeStep(timeStep: number): void;
  24149. getTimeStep(): number;
  24150. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24151. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24152. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24154. removePhysicsBody(impostor: PhysicsImpostor): void;
  24155. generateJoint(joint: PhysicsImpostorJoint): void;
  24156. removeJoint(joint: PhysicsImpostorJoint): void;
  24157. isSupported(): boolean;
  24158. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24159. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24160. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24161. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24162. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24163. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24165. getBodyMass(impostor: PhysicsImpostor): number;
  24166. getBodyFriction(impostor: PhysicsImpostor): number;
  24167. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24168. getBodyRestitution(impostor: PhysicsImpostor): number;
  24169. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24170. getBodyPressure?(impostor: PhysicsImpostor): number;
  24171. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24172. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24173. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24174. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24175. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24176. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24177. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24178. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24179. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24180. sleepBody(impostor: PhysicsImpostor): void;
  24181. wakeUpBody(impostor: PhysicsImpostor): void;
  24182. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24183. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24184. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24185. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24186. getRadius(impostor: PhysicsImpostor): number;
  24187. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24188. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24189. dispose(): void;
  24190. }
  24191. /**
  24192. * Interface used to define a physics engine
  24193. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24194. */
  24195. export interface IPhysicsEngine {
  24196. /**
  24197. * Gets the gravity vector used by the simulation
  24198. */
  24199. gravity: Vector3;
  24200. /**
  24201. * Sets the gravity vector used by the simulation
  24202. * @param gravity defines the gravity vector to use
  24203. */
  24204. setGravity(gravity: Vector3): void;
  24205. /**
  24206. * Set the time step of the physics engine.
  24207. * Default is 1/60.
  24208. * To slow it down, enter 1/600 for example.
  24209. * To speed it up, 1/30
  24210. * @param newTimeStep the new timestep to apply to this world.
  24211. */
  24212. setTimeStep(newTimeStep: number): void;
  24213. /**
  24214. * Get the time step of the physics engine.
  24215. * @returns the current time step
  24216. */
  24217. getTimeStep(): number;
  24218. /**
  24219. * Set the sub time step of the physics engine.
  24220. * Default is 0 meaning there is no sub steps
  24221. * To increase physics resolution precision, set a small value (like 1 ms)
  24222. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24223. */
  24224. setSubTimeStep(subTimeStep: number): void;
  24225. /**
  24226. * Get the sub time step of the physics engine.
  24227. * @returns the current sub time step
  24228. */
  24229. getSubTimeStep(): number;
  24230. /**
  24231. * Release all resources
  24232. */
  24233. dispose(): void;
  24234. /**
  24235. * Gets the name of the current physics plugin
  24236. * @returns the name of the plugin
  24237. */
  24238. getPhysicsPluginName(): string;
  24239. /**
  24240. * Adding a new impostor for the impostor tracking.
  24241. * This will be done by the impostor itself.
  24242. * @param impostor the impostor to add
  24243. */
  24244. addImpostor(impostor: PhysicsImpostor): void;
  24245. /**
  24246. * Remove an impostor from the engine.
  24247. * This impostor and its mesh will not longer be updated by the physics engine.
  24248. * @param impostor the impostor to remove
  24249. */
  24250. removeImpostor(impostor: PhysicsImpostor): void;
  24251. /**
  24252. * Add a joint to the physics engine
  24253. * @param mainImpostor defines the main impostor to which the joint is added.
  24254. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24255. * @param joint defines the joint that will connect both impostors.
  24256. */
  24257. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24258. /**
  24259. * Removes a joint from the simulation
  24260. * @param mainImpostor defines the impostor used with the joint
  24261. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24262. * @param joint defines the joint to remove
  24263. */
  24264. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24265. /**
  24266. * Gets the current plugin used to run the simulation
  24267. * @returns current plugin
  24268. */
  24269. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24270. /**
  24271. * Gets the list of physic impostors
  24272. * @returns an array of PhysicsImpostor
  24273. */
  24274. getImpostors(): Array<PhysicsImpostor>;
  24275. /**
  24276. * Gets the impostor for a physics enabled object
  24277. * @param object defines the object impersonated by the impostor
  24278. * @returns the PhysicsImpostor or null if not found
  24279. */
  24280. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24281. /**
  24282. * Gets the impostor for a physics body object
  24283. * @param body defines physics body used by the impostor
  24284. * @returns the PhysicsImpostor or null if not found
  24285. */
  24286. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24287. /**
  24288. * Does a raycast in the physics world
  24289. * @param from when should the ray start?
  24290. * @param to when should the ray end?
  24291. * @returns PhysicsRaycastResult
  24292. */
  24293. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24294. /**
  24295. * Called by the scene. No need to call it.
  24296. * @param delta defines the timespam between frames
  24297. */
  24298. _step(delta: number): void;
  24299. }
  24300. }
  24301. declare module "babylonjs/Physics/physicsImpostor" {
  24302. import { Nullable, IndicesArray } from "babylonjs/types";
  24303. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24306. import { Scene } from "babylonjs/scene";
  24307. import { Bone } from "babylonjs/Bones/bone";
  24308. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24309. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24310. import { Space } from "babylonjs/Maths/math.axis";
  24311. /**
  24312. * The interface for the physics imposter parameters
  24313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24314. */
  24315. export interface PhysicsImpostorParameters {
  24316. /**
  24317. * The mass of the physics imposter
  24318. */
  24319. mass: number;
  24320. /**
  24321. * The friction of the physics imposter
  24322. */
  24323. friction?: number;
  24324. /**
  24325. * The coefficient of restitution of the physics imposter
  24326. */
  24327. restitution?: number;
  24328. /**
  24329. * The native options of the physics imposter
  24330. */
  24331. nativeOptions?: any;
  24332. /**
  24333. * Specifies if the parent should be ignored
  24334. */
  24335. ignoreParent?: boolean;
  24336. /**
  24337. * Specifies if bi-directional transformations should be disabled
  24338. */
  24339. disableBidirectionalTransformation?: boolean;
  24340. /**
  24341. * The pressure inside the physics imposter, soft object only
  24342. */
  24343. pressure?: number;
  24344. /**
  24345. * The stiffness the physics imposter, soft object only
  24346. */
  24347. stiffness?: number;
  24348. /**
  24349. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24350. */
  24351. velocityIterations?: number;
  24352. /**
  24353. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24354. */
  24355. positionIterations?: number;
  24356. /**
  24357. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24358. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24359. * Add to fix multiple points
  24360. */
  24361. fixedPoints?: number;
  24362. /**
  24363. * The collision margin around a soft object
  24364. */
  24365. margin?: number;
  24366. /**
  24367. * The collision margin around a soft object
  24368. */
  24369. damping?: number;
  24370. /**
  24371. * The path for a rope based on an extrusion
  24372. */
  24373. path?: any;
  24374. /**
  24375. * The shape of an extrusion used for a rope based on an extrusion
  24376. */
  24377. shape?: any;
  24378. }
  24379. /**
  24380. * Interface for a physics-enabled object
  24381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24382. */
  24383. export interface IPhysicsEnabledObject {
  24384. /**
  24385. * The position of the physics-enabled object
  24386. */
  24387. position: Vector3;
  24388. /**
  24389. * The rotation of the physics-enabled object
  24390. */
  24391. rotationQuaternion: Nullable<Quaternion>;
  24392. /**
  24393. * The scale of the physics-enabled object
  24394. */
  24395. scaling: Vector3;
  24396. /**
  24397. * The rotation of the physics-enabled object
  24398. */
  24399. rotation?: Vector3;
  24400. /**
  24401. * The parent of the physics-enabled object
  24402. */
  24403. parent?: any;
  24404. /**
  24405. * The bounding info of the physics-enabled object
  24406. * @returns The bounding info of the physics-enabled object
  24407. */
  24408. getBoundingInfo(): BoundingInfo;
  24409. /**
  24410. * Computes the world matrix
  24411. * @param force Specifies if the world matrix should be computed by force
  24412. * @returns A world matrix
  24413. */
  24414. computeWorldMatrix(force: boolean): Matrix;
  24415. /**
  24416. * Gets the world matrix
  24417. * @returns A world matrix
  24418. */
  24419. getWorldMatrix?(): Matrix;
  24420. /**
  24421. * Gets the child meshes
  24422. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24423. * @returns An array of abstract meshes
  24424. */
  24425. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24426. /**
  24427. * Gets the vertex data
  24428. * @param kind The type of vertex data
  24429. * @returns A nullable array of numbers, or a float32 array
  24430. */
  24431. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24432. /**
  24433. * Gets the indices from the mesh
  24434. * @returns A nullable array of index arrays
  24435. */
  24436. getIndices?(): Nullable<IndicesArray>;
  24437. /**
  24438. * Gets the scene from the mesh
  24439. * @returns the indices array or null
  24440. */
  24441. getScene?(): Scene;
  24442. /**
  24443. * Gets the absolute position from the mesh
  24444. * @returns the absolute position
  24445. */
  24446. getAbsolutePosition(): Vector3;
  24447. /**
  24448. * Gets the absolute pivot point from the mesh
  24449. * @returns the absolute pivot point
  24450. */
  24451. getAbsolutePivotPoint(): Vector3;
  24452. /**
  24453. * Rotates the mesh
  24454. * @param axis The axis of rotation
  24455. * @param amount The amount of rotation
  24456. * @param space The space of the rotation
  24457. * @returns The rotation transform node
  24458. */
  24459. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24460. /**
  24461. * Translates the mesh
  24462. * @param axis The axis of translation
  24463. * @param distance The distance of translation
  24464. * @param space The space of the translation
  24465. * @returns The transform node
  24466. */
  24467. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24468. /**
  24469. * Sets the absolute position of the mesh
  24470. * @param absolutePosition The absolute position of the mesh
  24471. * @returns The transform node
  24472. */
  24473. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24474. /**
  24475. * Gets the class name of the mesh
  24476. * @returns The class name
  24477. */
  24478. getClassName(): string;
  24479. }
  24480. /**
  24481. * Represents a physics imposter
  24482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24483. */
  24484. export class PhysicsImpostor {
  24485. /**
  24486. * The physics-enabled object used as the physics imposter
  24487. */
  24488. object: IPhysicsEnabledObject;
  24489. /**
  24490. * The type of the physics imposter
  24491. */
  24492. type: number;
  24493. private _options;
  24494. private _scene?;
  24495. /**
  24496. * The default object size of the imposter
  24497. */
  24498. static DEFAULT_OBJECT_SIZE: Vector3;
  24499. /**
  24500. * The identity quaternion of the imposter
  24501. */
  24502. static IDENTITY_QUATERNION: Quaternion;
  24503. /** @hidden */
  24504. _pluginData: any;
  24505. private _physicsEngine;
  24506. private _physicsBody;
  24507. private _bodyUpdateRequired;
  24508. private _onBeforePhysicsStepCallbacks;
  24509. private _onAfterPhysicsStepCallbacks;
  24510. /** @hidden */
  24511. _onPhysicsCollideCallbacks: Array<{
  24512. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24513. otherImpostors: Array<PhysicsImpostor>;
  24514. }>;
  24515. private _deltaPosition;
  24516. private _deltaRotation;
  24517. private _deltaRotationConjugated;
  24518. /** @hidden */
  24519. _isFromLine: boolean;
  24520. private _parent;
  24521. private _isDisposed;
  24522. private static _tmpVecs;
  24523. private static _tmpQuat;
  24524. /**
  24525. * Specifies if the physics imposter is disposed
  24526. */
  24527. get isDisposed(): boolean;
  24528. /**
  24529. * Gets the mass of the physics imposter
  24530. */
  24531. get mass(): number;
  24532. set mass(value: number);
  24533. /**
  24534. * Gets the coefficient of friction
  24535. */
  24536. get friction(): number;
  24537. /**
  24538. * Sets the coefficient of friction
  24539. */
  24540. set friction(value: number);
  24541. /**
  24542. * Gets the coefficient of restitution
  24543. */
  24544. get restitution(): number;
  24545. /**
  24546. * Sets the coefficient of restitution
  24547. */
  24548. set restitution(value: number);
  24549. /**
  24550. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24551. */
  24552. get pressure(): number;
  24553. /**
  24554. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24555. */
  24556. set pressure(value: number);
  24557. /**
  24558. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24559. */
  24560. get stiffness(): number;
  24561. /**
  24562. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24563. */
  24564. set stiffness(value: number);
  24565. /**
  24566. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24567. */
  24568. get velocityIterations(): number;
  24569. /**
  24570. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24571. */
  24572. set velocityIterations(value: number);
  24573. /**
  24574. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24575. */
  24576. get positionIterations(): number;
  24577. /**
  24578. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24579. */
  24580. set positionIterations(value: number);
  24581. /**
  24582. * The unique id of the physics imposter
  24583. * set by the physics engine when adding this impostor to the array
  24584. */
  24585. uniqueId: number;
  24586. /**
  24587. * @hidden
  24588. */
  24589. soft: boolean;
  24590. /**
  24591. * @hidden
  24592. */
  24593. segments: number;
  24594. private _joints;
  24595. /**
  24596. * Initializes the physics imposter
  24597. * @param object The physics-enabled object used as the physics imposter
  24598. * @param type The type of the physics imposter
  24599. * @param _options The options for the physics imposter
  24600. * @param _scene The Babylon scene
  24601. */
  24602. constructor(
  24603. /**
  24604. * The physics-enabled object used as the physics imposter
  24605. */
  24606. object: IPhysicsEnabledObject,
  24607. /**
  24608. * The type of the physics imposter
  24609. */
  24610. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24611. /**
  24612. * This function will completly initialize this impostor.
  24613. * It will create a new body - but only if this mesh has no parent.
  24614. * If it has, this impostor will not be used other than to define the impostor
  24615. * of the child mesh.
  24616. * @hidden
  24617. */
  24618. _init(): void;
  24619. private _getPhysicsParent;
  24620. /**
  24621. * Should a new body be generated.
  24622. * @returns boolean specifying if body initialization is required
  24623. */
  24624. isBodyInitRequired(): boolean;
  24625. /**
  24626. * Sets the updated scaling
  24627. * @param updated Specifies if the scaling is updated
  24628. */
  24629. setScalingUpdated(): void;
  24630. /**
  24631. * Force a regeneration of this or the parent's impostor's body.
  24632. * Use under cautious - This will remove all joints already implemented.
  24633. */
  24634. forceUpdate(): void;
  24635. /**
  24636. * Gets the body that holds this impostor. Either its own, or its parent.
  24637. */
  24638. get physicsBody(): any;
  24639. /**
  24640. * Get the parent of the physics imposter
  24641. * @returns Physics imposter or null
  24642. */
  24643. get parent(): Nullable<PhysicsImpostor>;
  24644. /**
  24645. * Sets the parent of the physics imposter
  24646. */
  24647. set parent(value: Nullable<PhysicsImpostor>);
  24648. /**
  24649. * Set the physics body. Used mainly by the physics engine/plugin
  24650. */
  24651. set physicsBody(physicsBody: any);
  24652. /**
  24653. * Resets the update flags
  24654. */
  24655. resetUpdateFlags(): void;
  24656. /**
  24657. * Gets the object extend size
  24658. * @returns the object extend size
  24659. */
  24660. getObjectExtendSize(): Vector3;
  24661. /**
  24662. * Gets the object center
  24663. * @returns The object center
  24664. */
  24665. getObjectCenter(): Vector3;
  24666. /**
  24667. * Get a specific parameter from the options parameters
  24668. * @param paramName The object parameter name
  24669. * @returns The object parameter
  24670. */
  24671. getParam(paramName: string): any;
  24672. /**
  24673. * Sets a specific parameter in the options given to the physics plugin
  24674. * @param paramName The parameter name
  24675. * @param value The value of the parameter
  24676. */
  24677. setParam(paramName: string, value: number): void;
  24678. /**
  24679. * Specifically change the body's mass option. Won't recreate the physics body object
  24680. * @param mass The mass of the physics imposter
  24681. */
  24682. setMass(mass: number): void;
  24683. /**
  24684. * Gets the linear velocity
  24685. * @returns linear velocity or null
  24686. */
  24687. getLinearVelocity(): Nullable<Vector3>;
  24688. /**
  24689. * Sets the linear velocity
  24690. * @param velocity linear velocity or null
  24691. */
  24692. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24693. /**
  24694. * Gets the angular velocity
  24695. * @returns angular velocity or null
  24696. */
  24697. getAngularVelocity(): Nullable<Vector3>;
  24698. /**
  24699. * Sets the angular velocity
  24700. * @param velocity The velocity or null
  24701. */
  24702. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24703. /**
  24704. * Execute a function with the physics plugin native code
  24705. * Provide a function the will have two variables - the world object and the physics body object
  24706. * @param func The function to execute with the physics plugin native code
  24707. */
  24708. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24709. /**
  24710. * Register a function that will be executed before the physics world is stepping forward
  24711. * @param func The function to execute before the physics world is stepped forward
  24712. */
  24713. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24714. /**
  24715. * Unregister a function that will be executed before the physics world is stepping forward
  24716. * @param func The function to execute before the physics world is stepped forward
  24717. */
  24718. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24719. /**
  24720. * Register a function that will be executed after the physics step
  24721. * @param func The function to execute after physics step
  24722. */
  24723. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24724. /**
  24725. * Unregisters a function that will be executed after the physics step
  24726. * @param func The function to execute after physics step
  24727. */
  24728. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24729. /**
  24730. * register a function that will be executed when this impostor collides against a different body
  24731. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24732. * @param func Callback that is executed on collision
  24733. */
  24734. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24735. /**
  24736. * Unregisters the physics imposter on contact
  24737. * @param collideAgainst The physics object to collide against
  24738. * @param func Callback to execute on collision
  24739. */
  24740. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24741. private _tmpQuat;
  24742. private _tmpQuat2;
  24743. /**
  24744. * Get the parent rotation
  24745. * @returns The parent rotation
  24746. */
  24747. getParentsRotation(): Quaternion;
  24748. /**
  24749. * this function is executed by the physics engine.
  24750. */
  24751. beforeStep: () => void;
  24752. /**
  24753. * this function is executed by the physics engine
  24754. */
  24755. afterStep: () => void;
  24756. /**
  24757. * Legacy collision detection event support
  24758. */
  24759. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24760. /**
  24761. * event and body object due to cannon's event-based architecture.
  24762. */
  24763. onCollide: (e: {
  24764. body: any;
  24765. }) => void;
  24766. /**
  24767. * Apply a force
  24768. * @param force The force to apply
  24769. * @param contactPoint The contact point for the force
  24770. * @returns The physics imposter
  24771. */
  24772. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24773. /**
  24774. * Apply an impulse
  24775. * @param force The impulse force
  24776. * @param contactPoint The contact point for the impulse force
  24777. * @returns The physics imposter
  24778. */
  24779. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24780. /**
  24781. * A help function to create a joint
  24782. * @param otherImpostor A physics imposter used to create a joint
  24783. * @param jointType The type of joint
  24784. * @param jointData The data for the joint
  24785. * @returns The physics imposter
  24786. */
  24787. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24788. /**
  24789. * Add a joint to this impostor with a different impostor
  24790. * @param otherImpostor A physics imposter used to add a joint
  24791. * @param joint The joint to add
  24792. * @returns The physics imposter
  24793. */
  24794. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24795. /**
  24796. * Add an anchor to a cloth impostor
  24797. * @param otherImpostor rigid impostor to anchor to
  24798. * @param width ratio across width from 0 to 1
  24799. * @param height ratio up height from 0 to 1
  24800. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24801. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24802. * @returns impostor the soft imposter
  24803. */
  24804. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24805. /**
  24806. * Add a hook to a rope impostor
  24807. * @param otherImpostor rigid impostor to anchor to
  24808. * @param length ratio across rope from 0 to 1
  24809. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24810. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24811. * @returns impostor the rope imposter
  24812. */
  24813. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24814. /**
  24815. * Will keep this body still, in a sleep mode.
  24816. * @returns the physics imposter
  24817. */
  24818. sleep(): PhysicsImpostor;
  24819. /**
  24820. * Wake the body up.
  24821. * @returns The physics imposter
  24822. */
  24823. wakeUp(): PhysicsImpostor;
  24824. /**
  24825. * Clones the physics imposter
  24826. * @param newObject The physics imposter clones to this physics-enabled object
  24827. * @returns A nullable physics imposter
  24828. */
  24829. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24830. /**
  24831. * Disposes the physics imposter
  24832. */
  24833. dispose(): void;
  24834. /**
  24835. * Sets the delta position
  24836. * @param position The delta position amount
  24837. */
  24838. setDeltaPosition(position: Vector3): void;
  24839. /**
  24840. * Sets the delta rotation
  24841. * @param rotation The delta rotation amount
  24842. */
  24843. setDeltaRotation(rotation: Quaternion): void;
  24844. /**
  24845. * Gets the box size of the physics imposter and stores the result in the input parameter
  24846. * @param result Stores the box size
  24847. * @returns The physics imposter
  24848. */
  24849. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24850. /**
  24851. * Gets the radius of the physics imposter
  24852. * @returns Radius of the physics imposter
  24853. */
  24854. getRadius(): number;
  24855. /**
  24856. * Sync a bone with this impostor
  24857. * @param bone The bone to sync to the impostor.
  24858. * @param boneMesh The mesh that the bone is influencing.
  24859. * @param jointPivot The pivot of the joint / bone in local space.
  24860. * @param distToJoint Optional distance from the impostor to the joint.
  24861. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24862. */
  24863. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24864. /**
  24865. * Sync impostor to a bone
  24866. * @param bone The bone that the impostor will be synced to.
  24867. * @param boneMesh The mesh that the bone is influencing.
  24868. * @param jointPivot The pivot of the joint / bone in local space.
  24869. * @param distToJoint Optional distance from the impostor to the joint.
  24870. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24871. * @param boneAxis Optional vector3 axis the bone is aligned with
  24872. */
  24873. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24874. /**
  24875. * No-Imposter type
  24876. */
  24877. static NoImpostor: number;
  24878. /**
  24879. * Sphere-Imposter type
  24880. */
  24881. static SphereImpostor: number;
  24882. /**
  24883. * Box-Imposter type
  24884. */
  24885. static BoxImpostor: number;
  24886. /**
  24887. * Plane-Imposter type
  24888. */
  24889. static PlaneImpostor: number;
  24890. /**
  24891. * Mesh-imposter type
  24892. */
  24893. static MeshImpostor: number;
  24894. /**
  24895. * Capsule-Impostor type (Ammo.js plugin only)
  24896. */
  24897. static CapsuleImpostor: number;
  24898. /**
  24899. * Cylinder-Imposter type
  24900. */
  24901. static CylinderImpostor: number;
  24902. /**
  24903. * Particle-Imposter type
  24904. */
  24905. static ParticleImpostor: number;
  24906. /**
  24907. * Heightmap-Imposter type
  24908. */
  24909. static HeightmapImpostor: number;
  24910. /**
  24911. * ConvexHull-Impostor type (Ammo.js plugin only)
  24912. */
  24913. static ConvexHullImpostor: number;
  24914. /**
  24915. * Custom-Imposter type (Ammo.js plugin only)
  24916. */
  24917. static CustomImpostor: number;
  24918. /**
  24919. * Rope-Imposter type
  24920. */
  24921. static RopeImpostor: number;
  24922. /**
  24923. * Cloth-Imposter type
  24924. */
  24925. static ClothImpostor: number;
  24926. /**
  24927. * Softbody-Imposter type
  24928. */
  24929. static SoftbodyImpostor: number;
  24930. }
  24931. }
  24932. declare module "babylonjs/Meshes/mesh" {
  24933. import { Observable } from "babylonjs/Misc/observable";
  24934. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24935. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24936. import { Camera } from "babylonjs/Cameras/camera";
  24937. import { Scene } from "babylonjs/scene";
  24938. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24939. import { Color4 } from "babylonjs/Maths/math.color";
  24940. import { Engine } from "babylonjs/Engines/engine";
  24941. import { Node } from "babylonjs/node";
  24942. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24943. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24944. import { Buffer } from "babylonjs/Meshes/buffer";
  24945. import { Geometry } from "babylonjs/Meshes/geometry";
  24946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24947. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24948. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24949. import { Effect } from "babylonjs/Materials/effect";
  24950. import { Material } from "babylonjs/Materials/material";
  24951. import { Skeleton } from "babylonjs/Bones/skeleton";
  24952. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24953. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24954. import { Path3D } from "babylonjs/Maths/math.path";
  24955. import { Plane } from "babylonjs/Maths/math.plane";
  24956. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24957. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24958. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24959. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24960. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24961. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24962. /**
  24963. * @hidden
  24964. **/
  24965. export class _CreationDataStorage {
  24966. closePath?: boolean;
  24967. closeArray?: boolean;
  24968. idx: number[];
  24969. dashSize: number;
  24970. gapSize: number;
  24971. path3D: Path3D;
  24972. pathArray: Vector3[][];
  24973. arc: number;
  24974. radius: number;
  24975. cap: number;
  24976. tessellation: number;
  24977. }
  24978. /**
  24979. * @hidden
  24980. **/
  24981. class _InstanceDataStorage {
  24982. visibleInstances: any;
  24983. batchCache: _InstancesBatch;
  24984. instancesBufferSize: number;
  24985. instancesBuffer: Nullable<Buffer>;
  24986. instancesData: Float32Array;
  24987. overridenInstanceCount: number;
  24988. isFrozen: boolean;
  24989. previousBatch: Nullable<_InstancesBatch>;
  24990. hardwareInstancedRendering: boolean;
  24991. sideOrientation: number;
  24992. manualUpdate: boolean;
  24993. }
  24994. /**
  24995. * @hidden
  24996. **/
  24997. export class _InstancesBatch {
  24998. mustReturn: boolean;
  24999. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25000. renderSelf: boolean[];
  25001. hardwareInstancedRendering: boolean[];
  25002. }
  25003. /**
  25004. * Class used to represent renderable models
  25005. */
  25006. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25007. /**
  25008. * Mesh side orientation : usually the external or front surface
  25009. */
  25010. static readonly FRONTSIDE: number;
  25011. /**
  25012. * Mesh side orientation : usually the internal or back surface
  25013. */
  25014. static readonly BACKSIDE: number;
  25015. /**
  25016. * Mesh side orientation : both internal and external or front and back surfaces
  25017. */
  25018. static readonly DOUBLESIDE: number;
  25019. /**
  25020. * Mesh side orientation : by default, `FRONTSIDE`
  25021. */
  25022. static readonly DEFAULTSIDE: number;
  25023. /**
  25024. * Mesh cap setting : no cap
  25025. */
  25026. static readonly NO_CAP: number;
  25027. /**
  25028. * Mesh cap setting : one cap at the beginning of the mesh
  25029. */
  25030. static readonly CAP_START: number;
  25031. /**
  25032. * Mesh cap setting : one cap at the end of the mesh
  25033. */
  25034. static readonly CAP_END: number;
  25035. /**
  25036. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25037. */
  25038. static readonly CAP_ALL: number;
  25039. /**
  25040. * Mesh pattern setting : no flip or rotate
  25041. */
  25042. static readonly NO_FLIP: number;
  25043. /**
  25044. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25045. */
  25046. static readonly FLIP_TILE: number;
  25047. /**
  25048. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25049. */
  25050. static readonly ROTATE_TILE: number;
  25051. /**
  25052. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25053. */
  25054. static readonly FLIP_ROW: number;
  25055. /**
  25056. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25057. */
  25058. static readonly ROTATE_ROW: number;
  25059. /**
  25060. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25061. */
  25062. static readonly FLIP_N_ROTATE_TILE: number;
  25063. /**
  25064. * Mesh pattern setting : rotate pattern and rotate
  25065. */
  25066. static readonly FLIP_N_ROTATE_ROW: number;
  25067. /**
  25068. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25069. */
  25070. static readonly CENTER: number;
  25071. /**
  25072. * Mesh tile positioning : part tiles on left
  25073. */
  25074. static readonly LEFT: number;
  25075. /**
  25076. * Mesh tile positioning : part tiles on right
  25077. */
  25078. static readonly RIGHT: number;
  25079. /**
  25080. * Mesh tile positioning : part tiles on top
  25081. */
  25082. static readonly TOP: number;
  25083. /**
  25084. * Mesh tile positioning : part tiles on bottom
  25085. */
  25086. static readonly BOTTOM: number;
  25087. /**
  25088. * Gets the default side orientation.
  25089. * @param orientation the orientation to value to attempt to get
  25090. * @returns the default orientation
  25091. * @hidden
  25092. */
  25093. static _GetDefaultSideOrientation(orientation?: number): number;
  25094. private _internalMeshDataInfo;
  25095. /**
  25096. * An event triggered before rendering the mesh
  25097. */
  25098. get onBeforeRenderObservable(): Observable<Mesh>;
  25099. /**
  25100. * An event triggered before binding the mesh
  25101. */
  25102. get onBeforeBindObservable(): Observable<Mesh>;
  25103. /**
  25104. * An event triggered after rendering the mesh
  25105. */
  25106. get onAfterRenderObservable(): Observable<Mesh>;
  25107. /**
  25108. * An event triggered before drawing the mesh
  25109. */
  25110. get onBeforeDrawObservable(): Observable<Mesh>;
  25111. private _onBeforeDrawObserver;
  25112. /**
  25113. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25114. */
  25115. set onBeforeDraw(callback: () => void);
  25116. get hasInstances(): boolean;
  25117. /**
  25118. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25119. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25120. */
  25121. delayLoadState: number;
  25122. /**
  25123. * Gets the list of instances created from this mesh
  25124. * it is not supposed to be modified manually.
  25125. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25126. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25127. */
  25128. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25129. /**
  25130. * Gets the file containing delay loading data for this mesh
  25131. */
  25132. delayLoadingFile: string;
  25133. /** @hidden */
  25134. _binaryInfo: any;
  25135. /**
  25136. * User defined function used to change how LOD level selection is done
  25137. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25138. */
  25139. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25140. /**
  25141. * Gets or sets the morph target manager
  25142. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25143. */
  25144. get morphTargetManager(): Nullable<MorphTargetManager>;
  25145. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25146. /** @hidden */
  25147. _creationDataStorage: Nullable<_CreationDataStorage>;
  25148. /** @hidden */
  25149. _geometry: Nullable<Geometry>;
  25150. /** @hidden */
  25151. _delayInfo: Array<string>;
  25152. /** @hidden */
  25153. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25154. /** @hidden */
  25155. _instanceDataStorage: _InstanceDataStorage;
  25156. private _effectiveMaterial;
  25157. /** @hidden */
  25158. _shouldGenerateFlatShading: boolean;
  25159. /** @hidden */
  25160. _originalBuilderSideOrientation: number;
  25161. /**
  25162. * Use this property to change the original side orientation defined at construction time
  25163. */
  25164. overrideMaterialSideOrientation: Nullable<number>;
  25165. /**
  25166. * Gets the source mesh (the one used to clone this one from)
  25167. */
  25168. get source(): Nullable<Mesh>;
  25169. /**
  25170. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25171. */
  25172. get isUnIndexed(): boolean;
  25173. set isUnIndexed(value: boolean);
  25174. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25175. get worldMatrixInstancedBuffer(): Float32Array;
  25176. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25177. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25178. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25179. /**
  25180. * @constructor
  25181. * @param name The value used by scene.getMeshByName() to do a lookup.
  25182. * @param scene The scene to add this mesh to.
  25183. * @param parent The parent of this mesh, if it has one
  25184. * @param source An optional Mesh from which geometry is shared, cloned.
  25185. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25186. * When false, achieved by calling a clone(), also passing False.
  25187. * This will make creation of children, recursive.
  25188. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25189. */
  25190. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25191. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25192. doNotInstantiate: boolean;
  25193. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25194. /**
  25195. * Gets the class name
  25196. * @returns the string "Mesh".
  25197. */
  25198. getClassName(): string;
  25199. /** @hidden */
  25200. get _isMesh(): boolean;
  25201. /**
  25202. * Returns a description of this mesh
  25203. * @param fullDetails define if full details about this mesh must be used
  25204. * @returns a descriptive string representing this mesh
  25205. */
  25206. toString(fullDetails?: boolean): string;
  25207. /** @hidden */
  25208. _unBindEffect(): void;
  25209. /**
  25210. * Gets a boolean indicating if this mesh has LOD
  25211. */
  25212. get hasLODLevels(): boolean;
  25213. /**
  25214. * Gets the list of MeshLODLevel associated with the current mesh
  25215. * @returns an array of MeshLODLevel
  25216. */
  25217. getLODLevels(): MeshLODLevel[];
  25218. private _sortLODLevels;
  25219. /**
  25220. * Add a mesh as LOD level triggered at the given distance.
  25221. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25222. * @param distance The distance from the center of the object to show this level
  25223. * @param mesh The mesh to be added as LOD level (can be null)
  25224. * @return This mesh (for chaining)
  25225. */
  25226. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25227. /**
  25228. * Returns the LOD level mesh at the passed distance or null if not found.
  25229. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25230. * @param distance The distance from the center of the object to show this level
  25231. * @returns a Mesh or `null`
  25232. */
  25233. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25234. /**
  25235. * Remove a mesh from the LOD array
  25236. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25237. * @param mesh defines the mesh to be removed
  25238. * @return This mesh (for chaining)
  25239. */
  25240. removeLODLevel(mesh: Mesh): Mesh;
  25241. /**
  25242. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25243. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25244. * @param camera defines the camera to use to compute distance
  25245. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25246. * @return This mesh (for chaining)
  25247. */
  25248. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25249. /**
  25250. * Gets the mesh internal Geometry object
  25251. */
  25252. get geometry(): Nullable<Geometry>;
  25253. /**
  25254. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25255. * @returns the total number of vertices
  25256. */
  25257. getTotalVertices(): number;
  25258. /**
  25259. * Returns the content of an associated vertex buffer
  25260. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25261. * - VertexBuffer.PositionKind
  25262. * - VertexBuffer.UVKind
  25263. * - VertexBuffer.UV2Kind
  25264. * - VertexBuffer.UV3Kind
  25265. * - VertexBuffer.UV4Kind
  25266. * - VertexBuffer.UV5Kind
  25267. * - VertexBuffer.UV6Kind
  25268. * - VertexBuffer.ColorKind
  25269. * - VertexBuffer.MatricesIndicesKind
  25270. * - VertexBuffer.MatricesIndicesExtraKind
  25271. * - VertexBuffer.MatricesWeightsKind
  25272. * - VertexBuffer.MatricesWeightsExtraKind
  25273. * @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
  25274. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25275. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25276. */
  25277. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25278. /**
  25279. * Returns the mesh VertexBuffer object from the requested `kind`
  25280. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25281. * - VertexBuffer.PositionKind
  25282. * - VertexBuffer.NormalKind
  25283. * - VertexBuffer.UVKind
  25284. * - VertexBuffer.UV2Kind
  25285. * - VertexBuffer.UV3Kind
  25286. * - VertexBuffer.UV4Kind
  25287. * - VertexBuffer.UV5Kind
  25288. * - VertexBuffer.UV6Kind
  25289. * - VertexBuffer.ColorKind
  25290. * - VertexBuffer.MatricesIndicesKind
  25291. * - VertexBuffer.MatricesIndicesExtraKind
  25292. * - VertexBuffer.MatricesWeightsKind
  25293. * - VertexBuffer.MatricesWeightsExtraKind
  25294. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25295. */
  25296. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25297. /**
  25298. * Tests if a specific vertex buffer is associated with this mesh
  25299. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25300. * - VertexBuffer.PositionKind
  25301. * - VertexBuffer.NormalKind
  25302. * - VertexBuffer.UVKind
  25303. * - VertexBuffer.UV2Kind
  25304. * - VertexBuffer.UV3Kind
  25305. * - VertexBuffer.UV4Kind
  25306. * - VertexBuffer.UV5Kind
  25307. * - VertexBuffer.UV6Kind
  25308. * - VertexBuffer.ColorKind
  25309. * - VertexBuffer.MatricesIndicesKind
  25310. * - VertexBuffer.MatricesIndicesExtraKind
  25311. * - VertexBuffer.MatricesWeightsKind
  25312. * - VertexBuffer.MatricesWeightsExtraKind
  25313. * @returns a boolean
  25314. */
  25315. isVerticesDataPresent(kind: string): boolean;
  25316. /**
  25317. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25318. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25319. * - VertexBuffer.PositionKind
  25320. * - VertexBuffer.UVKind
  25321. * - VertexBuffer.UV2Kind
  25322. * - VertexBuffer.UV3Kind
  25323. * - VertexBuffer.UV4Kind
  25324. * - VertexBuffer.UV5Kind
  25325. * - VertexBuffer.UV6Kind
  25326. * - VertexBuffer.ColorKind
  25327. * - VertexBuffer.MatricesIndicesKind
  25328. * - VertexBuffer.MatricesIndicesExtraKind
  25329. * - VertexBuffer.MatricesWeightsKind
  25330. * - VertexBuffer.MatricesWeightsExtraKind
  25331. * @returns a boolean
  25332. */
  25333. isVertexBufferUpdatable(kind: string): boolean;
  25334. /**
  25335. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25336. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25337. * - VertexBuffer.PositionKind
  25338. * - VertexBuffer.NormalKind
  25339. * - VertexBuffer.UVKind
  25340. * - VertexBuffer.UV2Kind
  25341. * - VertexBuffer.UV3Kind
  25342. * - VertexBuffer.UV4Kind
  25343. * - VertexBuffer.UV5Kind
  25344. * - VertexBuffer.UV6Kind
  25345. * - VertexBuffer.ColorKind
  25346. * - VertexBuffer.MatricesIndicesKind
  25347. * - VertexBuffer.MatricesIndicesExtraKind
  25348. * - VertexBuffer.MatricesWeightsKind
  25349. * - VertexBuffer.MatricesWeightsExtraKind
  25350. * @returns an array of strings
  25351. */
  25352. getVerticesDataKinds(): string[];
  25353. /**
  25354. * Returns a positive integer : the total number of indices in this mesh geometry.
  25355. * @returns the numner of indices or zero if the mesh has no geometry.
  25356. */
  25357. getTotalIndices(): number;
  25358. /**
  25359. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25360. * @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.
  25361. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25362. * @returns the indices array or an empty array if the mesh has no geometry
  25363. */
  25364. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25365. get isBlocked(): boolean;
  25366. /**
  25367. * Determine if the current mesh is ready to be rendered
  25368. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25369. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25370. * @returns true if all associated assets are ready (material, textures, shaders)
  25371. */
  25372. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25373. /**
  25374. * 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.
  25375. */
  25376. get areNormalsFrozen(): boolean;
  25377. /**
  25378. * 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.
  25379. * @returns the current mesh
  25380. */
  25381. freezeNormals(): Mesh;
  25382. /**
  25383. * 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
  25384. * @returns the current mesh
  25385. */
  25386. unfreezeNormals(): Mesh;
  25387. /**
  25388. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25389. */
  25390. set overridenInstanceCount(count: number);
  25391. /** @hidden */
  25392. _preActivate(): Mesh;
  25393. /** @hidden */
  25394. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25395. /** @hidden */
  25396. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25397. /**
  25398. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25399. * This means the mesh underlying bounding box and sphere are recomputed.
  25400. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25401. * @returns the current mesh
  25402. */
  25403. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25404. /** @hidden */
  25405. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25406. /**
  25407. * This function will subdivide the mesh into multiple submeshes
  25408. * @param count defines the expected number of submeshes
  25409. */
  25410. subdivide(count: number): void;
  25411. /**
  25412. * Copy a FloatArray into a specific associated vertex buffer
  25413. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25414. * - VertexBuffer.PositionKind
  25415. * - VertexBuffer.UVKind
  25416. * - VertexBuffer.UV2Kind
  25417. * - VertexBuffer.UV3Kind
  25418. * - VertexBuffer.UV4Kind
  25419. * - VertexBuffer.UV5Kind
  25420. * - VertexBuffer.UV6Kind
  25421. * - VertexBuffer.ColorKind
  25422. * - VertexBuffer.MatricesIndicesKind
  25423. * - VertexBuffer.MatricesIndicesExtraKind
  25424. * - VertexBuffer.MatricesWeightsKind
  25425. * - VertexBuffer.MatricesWeightsExtraKind
  25426. * @param data defines the data source
  25427. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25428. * @param stride defines the data stride size (can be null)
  25429. * @returns the current mesh
  25430. */
  25431. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25432. /**
  25433. * Delete a vertex buffer associated with this mesh
  25434. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25435. * - VertexBuffer.PositionKind
  25436. * - VertexBuffer.UVKind
  25437. * - VertexBuffer.UV2Kind
  25438. * - VertexBuffer.UV3Kind
  25439. * - VertexBuffer.UV4Kind
  25440. * - VertexBuffer.UV5Kind
  25441. * - VertexBuffer.UV6Kind
  25442. * - VertexBuffer.ColorKind
  25443. * - VertexBuffer.MatricesIndicesKind
  25444. * - VertexBuffer.MatricesIndicesExtraKind
  25445. * - VertexBuffer.MatricesWeightsKind
  25446. * - VertexBuffer.MatricesWeightsExtraKind
  25447. */
  25448. removeVerticesData(kind: string): void;
  25449. /**
  25450. * Flags an associated vertex buffer as updatable
  25451. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25452. * - VertexBuffer.PositionKind
  25453. * - VertexBuffer.UVKind
  25454. * - VertexBuffer.UV2Kind
  25455. * - VertexBuffer.UV3Kind
  25456. * - VertexBuffer.UV4Kind
  25457. * - VertexBuffer.UV5Kind
  25458. * - VertexBuffer.UV6Kind
  25459. * - VertexBuffer.ColorKind
  25460. * - VertexBuffer.MatricesIndicesKind
  25461. * - VertexBuffer.MatricesIndicesExtraKind
  25462. * - VertexBuffer.MatricesWeightsKind
  25463. * - VertexBuffer.MatricesWeightsExtraKind
  25464. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25465. */
  25466. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25467. /**
  25468. * Sets the mesh global Vertex Buffer
  25469. * @param buffer defines the buffer to use
  25470. * @returns the current mesh
  25471. */
  25472. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25473. /**
  25474. * Update a specific associated vertex buffer
  25475. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25476. * - VertexBuffer.PositionKind
  25477. * - VertexBuffer.UVKind
  25478. * - VertexBuffer.UV2Kind
  25479. * - VertexBuffer.UV3Kind
  25480. * - VertexBuffer.UV4Kind
  25481. * - VertexBuffer.UV5Kind
  25482. * - VertexBuffer.UV6Kind
  25483. * - VertexBuffer.ColorKind
  25484. * - VertexBuffer.MatricesIndicesKind
  25485. * - VertexBuffer.MatricesIndicesExtraKind
  25486. * - VertexBuffer.MatricesWeightsKind
  25487. * - VertexBuffer.MatricesWeightsExtraKind
  25488. * @param data defines the data source
  25489. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25490. * @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)
  25491. * @returns the current mesh
  25492. */
  25493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25494. /**
  25495. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25496. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25497. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25498. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25499. * @returns the current mesh
  25500. */
  25501. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25502. /**
  25503. * Creates a un-shared specific occurence of the geometry for the mesh.
  25504. * @returns the current mesh
  25505. */
  25506. makeGeometryUnique(): Mesh;
  25507. /**
  25508. * Set the index buffer of this mesh
  25509. * @param indices defines the source data
  25510. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25511. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25512. * @returns the current mesh
  25513. */
  25514. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25515. /**
  25516. * Update the current index buffer
  25517. * @param indices defines the source data
  25518. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25519. * @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)
  25520. * @returns the current mesh
  25521. */
  25522. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25523. /**
  25524. * Invert the geometry to move from a right handed system to a left handed one.
  25525. * @returns the current mesh
  25526. */
  25527. toLeftHanded(): Mesh;
  25528. /** @hidden */
  25529. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25530. /** @hidden */
  25531. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25532. /**
  25533. * Registers for this mesh a javascript function called just before the rendering process
  25534. * @param func defines the function to call before rendering this mesh
  25535. * @returns the current mesh
  25536. */
  25537. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25538. /**
  25539. * Disposes a previously registered javascript function called before the rendering
  25540. * @param func defines the function to remove
  25541. * @returns the current mesh
  25542. */
  25543. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25544. /**
  25545. * Registers for this mesh a javascript function called just after the rendering is complete
  25546. * @param func defines the function to call after rendering this mesh
  25547. * @returns the current mesh
  25548. */
  25549. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25550. /**
  25551. * Disposes a previously registered javascript function called after the rendering.
  25552. * @param func defines the function to remove
  25553. * @returns the current mesh
  25554. */
  25555. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25556. /** @hidden */
  25557. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25558. /** @hidden */
  25559. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25560. /** @hidden */
  25561. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25562. /** @hidden */
  25563. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25564. /** @hidden */
  25565. _rebuild(): void;
  25566. /** @hidden */
  25567. _freeze(): void;
  25568. /** @hidden */
  25569. _unFreeze(): void;
  25570. /**
  25571. * 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
  25572. * @param subMesh defines the subMesh to render
  25573. * @param enableAlphaMode defines if alpha mode can be changed
  25574. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25575. * @returns the current mesh
  25576. */
  25577. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25578. private _onBeforeDraw;
  25579. /**
  25580. * Renormalize the mesh and patch it up if there are no weights
  25581. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25582. * However in the case of zero weights then we set just a single influence to 1.
  25583. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25584. */
  25585. cleanMatrixWeights(): void;
  25586. private normalizeSkinFourWeights;
  25587. private normalizeSkinWeightsAndExtra;
  25588. /**
  25589. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25590. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25591. * the user know there was an issue with importing the mesh
  25592. * @returns a validation object with skinned, valid and report string
  25593. */
  25594. validateSkinning(): {
  25595. skinned: boolean;
  25596. valid: boolean;
  25597. report: string;
  25598. };
  25599. /** @hidden */
  25600. _checkDelayState(): Mesh;
  25601. private _queueLoad;
  25602. /**
  25603. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25604. * A mesh is in the frustum if its bounding box intersects the frustum
  25605. * @param frustumPlanes defines the frustum to test
  25606. * @returns true if the mesh is in the frustum planes
  25607. */
  25608. isInFrustum(frustumPlanes: Plane[]): boolean;
  25609. /**
  25610. * Sets the mesh material by the material or multiMaterial `id` property
  25611. * @param id is a string identifying the material or the multiMaterial
  25612. * @returns the current mesh
  25613. */
  25614. setMaterialByID(id: string): Mesh;
  25615. /**
  25616. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25617. * @returns an array of IAnimatable
  25618. */
  25619. getAnimatables(): IAnimatable[];
  25620. /**
  25621. * Modifies the mesh geometry according to the passed transformation matrix.
  25622. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25623. * The mesh normals are modified using the same transformation.
  25624. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25625. * @param transform defines the transform matrix to use
  25626. * @see http://doc.babylonjs.com/resources/baking_transformations
  25627. * @returns the current mesh
  25628. */
  25629. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25630. /**
  25631. * Modifies the mesh geometry according to its own current World Matrix.
  25632. * The mesh World Matrix is then reset.
  25633. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25634. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25635. * @see http://doc.babylonjs.com/resources/baking_transformations
  25636. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25637. * @returns the current mesh
  25638. */
  25639. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25640. /** @hidden */
  25641. get _positions(): Nullable<Vector3[]>;
  25642. /** @hidden */
  25643. _resetPointsArrayCache(): Mesh;
  25644. /** @hidden */
  25645. _generatePointsArray(): boolean;
  25646. /**
  25647. * Returns a new Mesh object generated from the current mesh properties.
  25648. * This method must not get confused with createInstance()
  25649. * @param name is a string, the name given to the new mesh
  25650. * @param newParent can be any Node object (default `null`)
  25651. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25652. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25653. * @returns a new mesh
  25654. */
  25655. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25656. /**
  25657. * Releases resources associated with this mesh.
  25658. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25659. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25660. */
  25661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25662. /** @hidden */
  25663. _disposeInstanceSpecificData(): void;
  25664. /**
  25665. * Modifies the mesh geometry according to a displacement map.
  25666. * 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.
  25667. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25668. * @param url is a string, the URL from the image file is to be downloaded.
  25669. * @param minHeight is the lower limit of the displacement.
  25670. * @param maxHeight is the upper limit of the displacement.
  25671. * @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.
  25672. * @param uvOffset is an optional vector2 used to offset UV.
  25673. * @param uvScale is an optional vector2 used to scale UV.
  25674. * @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.
  25675. * @returns the Mesh.
  25676. */
  25677. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25678. /**
  25679. * Modifies the mesh geometry according to a displacementMap buffer.
  25680. * 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.
  25681. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25682. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25683. * @param heightMapWidth is the width of the buffer image.
  25684. * @param heightMapHeight is the height of the buffer image.
  25685. * @param minHeight is the lower limit of the displacement.
  25686. * @param maxHeight is the upper limit of the displacement.
  25687. * @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.
  25688. * @param uvOffset is an optional vector2 used to offset UV.
  25689. * @param uvScale is an optional vector2 used to scale UV.
  25690. * @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.
  25691. * @returns the Mesh.
  25692. */
  25693. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25694. /**
  25695. * Modify the mesh to get a flat shading rendering.
  25696. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25697. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25698. * @returns current mesh
  25699. */
  25700. convertToFlatShadedMesh(): Mesh;
  25701. /**
  25702. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25703. * In other words, more vertices, no more indices and a single bigger VBO.
  25704. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25705. * @returns current mesh
  25706. */
  25707. convertToUnIndexedMesh(): Mesh;
  25708. /**
  25709. * Inverses facet orientations.
  25710. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25711. * @param flipNormals will also inverts the normals
  25712. * @returns current mesh
  25713. */
  25714. flipFaces(flipNormals?: boolean): Mesh;
  25715. /**
  25716. * Increase the number of facets and hence vertices in a mesh
  25717. * Vertex normals are interpolated from existing vertex normals
  25718. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25719. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25720. */
  25721. increaseVertices(numberPerEdge: number): void;
  25722. /**
  25723. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25724. * This will undo any application of covertToFlatShadedMesh
  25725. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25726. */
  25727. forceSharedVertices(): void;
  25728. /** @hidden */
  25729. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25730. /** @hidden */
  25731. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25732. /**
  25733. * Creates a new InstancedMesh object from the mesh model.
  25734. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25735. * @param name defines the name of the new instance
  25736. * @returns a new InstancedMesh
  25737. */
  25738. createInstance(name: string): InstancedMesh;
  25739. /**
  25740. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25741. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25742. * @returns the current mesh
  25743. */
  25744. synchronizeInstances(): Mesh;
  25745. /**
  25746. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25747. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25748. * This should be used together with the simplification to avoid disappearing triangles.
  25749. * @param successCallback an optional success callback to be called after the optimization finished.
  25750. * @returns the current mesh
  25751. */
  25752. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25753. /**
  25754. * Serialize current mesh
  25755. * @param serializationObject defines the object which will receive the serialization data
  25756. */
  25757. serialize(serializationObject: any): void;
  25758. /** @hidden */
  25759. _syncGeometryWithMorphTargetManager(): void;
  25760. /** @hidden */
  25761. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25762. /**
  25763. * Returns a new Mesh object parsed from the source provided.
  25764. * @param parsedMesh is the source
  25765. * @param scene defines the hosting scene
  25766. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25767. * @returns a new Mesh
  25768. */
  25769. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25770. /**
  25771. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25772. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25773. * @param name defines the name of the mesh to create
  25774. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25775. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25776. * @param closePath creates a seam between the first and the last points of each path of the path array
  25777. * @param offset is taken in account only if the `pathArray` is containing a single path
  25778. * @param scene defines the hosting scene
  25779. * @param updatable defines if the mesh must be flagged as updatable
  25780. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25781. * @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)
  25782. * @returns a new Mesh
  25783. */
  25784. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25785. /**
  25786. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25787. * @param name defines the name of the mesh to create
  25788. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25789. * @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
  25790. * @param scene defines the hosting scene
  25791. * @param updatable defines if the mesh must be flagged as updatable
  25792. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25793. * @returns a new Mesh
  25794. */
  25795. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25796. /**
  25797. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25798. * @param name defines the name of the mesh to create
  25799. * @param size sets the size (float) of each box side (default 1)
  25800. * @param scene defines the hosting scene
  25801. * @param updatable defines if the mesh must be flagged as updatable
  25802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25803. * @returns a new Mesh
  25804. */
  25805. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25806. /**
  25807. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25808. * @param name defines the name of the mesh to create
  25809. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25810. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25817. /**
  25818. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25821. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25822. * @param scene defines the hosting scene
  25823. * @returns a new Mesh
  25824. */
  25825. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25826. /**
  25827. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25828. * @param name defines the name of the mesh to create
  25829. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25830. * @param diameterTop set the top cap diameter (floats, default 1)
  25831. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25832. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25833. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25834. * @param scene defines the hosting scene
  25835. * @param updatable defines if the mesh must be flagged as updatable
  25836. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25837. * @returns a new Mesh
  25838. */
  25839. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25840. /**
  25841. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25842. * @param name defines the name of the mesh to create
  25843. * @param diameter sets the diameter size (float) of the torus (default 1)
  25844. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25845. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25846. * @param scene defines the hosting scene
  25847. * @param updatable defines if the mesh must be flagged as updatable
  25848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25849. * @returns a new Mesh
  25850. */
  25851. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25852. /**
  25853. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25854. * @param name defines the name of the mesh to create
  25855. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25856. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25857. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25858. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25859. * @param p the number of windings on X axis (positive integers, default 2)
  25860. * @param q the number of windings on Y axis (positive integers, default 3)
  25861. * @param scene defines the hosting scene
  25862. * @param updatable defines if the mesh must be flagged as updatable
  25863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25864. * @returns a new Mesh
  25865. */
  25866. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25867. /**
  25868. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25869. * @param name defines the name of the mesh to create
  25870. * @param points is an array successive Vector3
  25871. * @param scene defines the hosting scene
  25872. * @param updatable defines if the mesh must be flagged as updatable
  25873. * @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).
  25874. * @returns a new Mesh
  25875. */
  25876. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25877. /**
  25878. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25879. * @param name defines the name of the mesh to create
  25880. * @param points is an array successive Vector3
  25881. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25882. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25883. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25884. * @param scene defines the hosting scene
  25885. * @param updatable defines if the mesh must be flagged as updatable
  25886. * @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)
  25887. * @returns a new Mesh
  25888. */
  25889. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25890. /**
  25891. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25892. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25893. * 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.
  25894. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25895. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25896. * Remember you can only change the shape positions, not their number when updating a polygon.
  25897. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25898. * @param name defines the name of the mesh to create
  25899. * @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
  25900. * @param scene defines the hosting scene
  25901. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25902. * @param updatable defines if the mesh must be flagged as updatable
  25903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25904. * @param earcutInjection can be used to inject your own earcut reference
  25905. * @returns a new Mesh
  25906. */
  25907. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25908. /**
  25909. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25910. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25911. * @param name defines the name of the mesh to create
  25912. * @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
  25913. * @param depth defines the height of extrusion
  25914. * @param scene defines the hosting scene
  25915. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25916. * @param updatable defines if the mesh must be flagged as updatable
  25917. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25918. * @param earcutInjection can be used to inject your own earcut reference
  25919. * @returns a new Mesh
  25920. */
  25921. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25922. /**
  25923. * Creates an extruded shape mesh.
  25924. * 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
  25925. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25926. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25927. * @param name defines the name of the mesh to create
  25928. * @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
  25929. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25930. * @param scale is the value to scale the shape
  25931. * @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
  25932. * @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
  25933. * @param scene defines the hosting scene
  25934. * @param updatable defines if the mesh must be flagged as updatable
  25935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25936. * @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)
  25937. * @returns a new Mesh
  25938. */
  25939. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25940. /**
  25941. * Creates an custom extruded shape mesh.
  25942. * The custom extrusion is a parametric shape.
  25943. * It has no predefined shape. Its final shape will depend on the input parameters.
  25944. * Please consider using the same method from the MeshBuilder class instead
  25945. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25946. * @param name defines the name of the mesh to create
  25947. * @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
  25948. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25949. * @param scaleFunction is a custom Javascript function called on each path point
  25950. * @param rotationFunction is a custom Javascript function called on each path point
  25951. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25952. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25953. * @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
  25954. * @param scene defines the hosting scene
  25955. * @param updatable defines if the mesh must be flagged as updatable
  25956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25957. * @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)
  25958. * @returns a new Mesh
  25959. */
  25960. 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;
  25961. /**
  25962. * Creates lathe mesh.
  25963. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25964. * Please consider using the same method from the MeshBuilder class instead
  25965. * @param name defines the name of the mesh to create
  25966. * @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
  25967. * @param radius is the radius value of the lathe
  25968. * @param tessellation is the side number of the lathe.
  25969. * @param scene defines the hosting scene
  25970. * @param updatable defines if the mesh must be flagged as updatable
  25971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25972. * @returns a new Mesh
  25973. */
  25974. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25975. /**
  25976. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25977. * @param name defines the name of the mesh to create
  25978. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25979. * @param scene defines the hosting scene
  25980. * @param updatable defines if the mesh must be flagged as updatable
  25981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25982. * @returns a new Mesh
  25983. */
  25984. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25985. /**
  25986. * Creates a ground mesh.
  25987. * Please consider using the same method from the MeshBuilder class instead
  25988. * @param name defines the name of the mesh to create
  25989. * @param width set the width of the ground
  25990. * @param height set the height of the ground
  25991. * @param subdivisions sets the number of subdivisions per side
  25992. * @param scene defines the hosting scene
  25993. * @param updatable defines if the mesh must be flagged as updatable
  25994. * @returns a new Mesh
  25995. */
  25996. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25997. /**
  25998. * Creates a tiled ground mesh.
  25999. * Please consider using the same method from the MeshBuilder class instead
  26000. * @param name defines the name of the mesh to create
  26001. * @param xmin set the ground minimum X coordinate
  26002. * @param zmin set the ground minimum Y coordinate
  26003. * @param xmax set the ground maximum X coordinate
  26004. * @param zmax set the ground maximum Z coordinate
  26005. * @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
  26006. * @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
  26007. * @param scene defines the hosting scene
  26008. * @param updatable defines if the mesh must be flagged as updatable
  26009. * @returns a new Mesh
  26010. */
  26011. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26012. w: number;
  26013. h: number;
  26014. }, precision: {
  26015. w: number;
  26016. h: number;
  26017. }, scene: Scene, updatable?: boolean): Mesh;
  26018. /**
  26019. * Creates a ground mesh from a height map.
  26020. * Please consider using the same method from the MeshBuilder class instead
  26021. * @see http://doc.babylonjs.com/babylon101/height_map
  26022. * @param name defines the name of the mesh to create
  26023. * @param url sets the URL of the height map image resource
  26024. * @param width set the ground width size
  26025. * @param height set the ground height size
  26026. * @param subdivisions sets the number of subdivision per side
  26027. * @param minHeight is the minimum altitude on the ground
  26028. * @param maxHeight is the maximum altitude on the ground
  26029. * @param scene defines the hosting scene
  26030. * @param updatable defines if the mesh must be flagged as updatable
  26031. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26032. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26033. * @returns a new Mesh
  26034. */
  26035. 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;
  26036. /**
  26037. * Creates a tube mesh.
  26038. * The tube is a parametric shape.
  26039. * It has no predefined shape. Its final shape will depend on the input parameters.
  26040. * Please consider using the same method from the MeshBuilder class instead
  26041. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26042. * @param name defines the name of the mesh to create
  26043. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26044. * @param radius sets the tube radius size
  26045. * @param tessellation is the number of sides on the tubular surface
  26046. * @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
  26047. * @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
  26048. * @param scene defines the hosting scene
  26049. * @param updatable defines if the mesh must be flagged as updatable
  26050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26051. * @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)
  26052. * @returns a new Mesh
  26053. */
  26054. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26055. (i: number, distance: number): number;
  26056. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26057. /**
  26058. * Creates a polyhedron mesh.
  26059. * Please consider using the same method from the MeshBuilder class instead.
  26060. * * 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
  26061. * * The parameter `size` (positive float, default 1) sets the polygon size
  26062. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26063. * * 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`
  26064. * * 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
  26065. * * 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)`)
  26066. * * 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
  26067. * * 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
  26068. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26069. * * If you create a double-sided mesh, you can choose what parts of 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
  26070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26071. * @param name defines the name of the mesh to create
  26072. * @param options defines the options used to create the mesh
  26073. * @param scene defines the hosting scene
  26074. * @returns a new Mesh
  26075. */
  26076. static CreatePolyhedron(name: string, options: {
  26077. type?: number;
  26078. size?: number;
  26079. sizeX?: number;
  26080. sizeY?: number;
  26081. sizeZ?: number;
  26082. custom?: any;
  26083. faceUV?: Vector4[];
  26084. faceColors?: Color4[];
  26085. updatable?: boolean;
  26086. sideOrientation?: number;
  26087. }, scene: Scene): Mesh;
  26088. /**
  26089. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26090. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26091. * * 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`)
  26092. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26093. * * 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
  26094. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26095. * * If you create a double-sided mesh, you can choose what parts of 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
  26096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26097. * @param name defines the name of the mesh
  26098. * @param options defines the options used to create the mesh
  26099. * @param scene defines the hosting scene
  26100. * @returns a new Mesh
  26101. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26102. */
  26103. static CreateIcoSphere(name: string, options: {
  26104. radius?: number;
  26105. flat?: boolean;
  26106. subdivisions?: number;
  26107. sideOrientation?: number;
  26108. updatable?: boolean;
  26109. }, scene: Scene): Mesh;
  26110. /**
  26111. * Creates a decal mesh.
  26112. * Please consider using the same method from the MeshBuilder class instead.
  26113. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26114. * @param name defines the name of the mesh
  26115. * @param sourceMesh defines the mesh receiving the decal
  26116. * @param position sets the position of the decal in world coordinates
  26117. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26118. * @param size sets the decal scaling
  26119. * @param angle sets the angle to rotate the decal
  26120. * @returns a new Mesh
  26121. */
  26122. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26123. /**
  26124. * Prepare internal position array for software CPU skinning
  26125. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26126. */
  26127. setPositionsForCPUSkinning(): Float32Array;
  26128. /**
  26129. * Prepare internal normal array for software CPU skinning
  26130. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26131. */
  26132. setNormalsForCPUSkinning(): Float32Array;
  26133. /**
  26134. * Updates the vertex buffer by applying transformation from the bones
  26135. * @param skeleton defines the skeleton to apply to current mesh
  26136. * @returns the current mesh
  26137. */
  26138. applySkeleton(skeleton: Skeleton): Mesh;
  26139. /**
  26140. * 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
  26141. * @param meshes defines the list of meshes to scan
  26142. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26143. */
  26144. static MinMax(meshes: AbstractMesh[]): {
  26145. min: Vector3;
  26146. max: Vector3;
  26147. };
  26148. /**
  26149. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26150. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26151. * @returns a vector3
  26152. */
  26153. static Center(meshesOrMinMaxVector: {
  26154. min: Vector3;
  26155. max: Vector3;
  26156. } | AbstractMesh[]): Vector3;
  26157. /**
  26158. * Merge the array of meshes into a single mesh for performance reasons.
  26159. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26160. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26161. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26162. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26163. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26164. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26165. * @returns a new mesh
  26166. */
  26167. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26168. /** @hidden */
  26169. addInstance(instance: InstancedMesh): void;
  26170. /** @hidden */
  26171. removeInstance(instance: InstancedMesh): void;
  26172. }
  26173. }
  26174. declare module "babylonjs/Cameras/camera" {
  26175. import { SmartArray } from "babylonjs/Misc/smartArray";
  26176. import { Observable } from "babylonjs/Misc/observable";
  26177. import { Nullable } from "babylonjs/types";
  26178. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26179. import { Scene } from "babylonjs/scene";
  26180. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26181. import { Node } from "babylonjs/node";
  26182. import { Mesh } from "babylonjs/Meshes/mesh";
  26183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26184. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26185. import { Viewport } from "babylonjs/Maths/math.viewport";
  26186. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26187. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26188. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26189. import { Ray } from "babylonjs/Culling/ray";
  26190. /**
  26191. * This is the base class of all the camera used in the application.
  26192. * @see http://doc.babylonjs.com/features/cameras
  26193. */
  26194. export class Camera extends Node {
  26195. /** @hidden */
  26196. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26197. /**
  26198. * This is the default projection mode used by the cameras.
  26199. * It helps recreating a feeling of perspective and better appreciate depth.
  26200. * This is the best way to simulate real life cameras.
  26201. */
  26202. static readonly PERSPECTIVE_CAMERA: number;
  26203. /**
  26204. * This helps creating camera with an orthographic mode.
  26205. * 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.
  26206. */
  26207. static readonly ORTHOGRAPHIC_CAMERA: number;
  26208. /**
  26209. * This is the default FOV mode for perspective cameras.
  26210. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26211. */
  26212. static readonly FOVMODE_VERTICAL_FIXED: number;
  26213. /**
  26214. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26215. */
  26216. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26217. /**
  26218. * This specifies ther is no need for a camera rig.
  26219. * Basically only one eye is rendered corresponding to the camera.
  26220. */
  26221. static readonly RIG_MODE_NONE: number;
  26222. /**
  26223. * Simulates a camera Rig with one blue eye and one red eye.
  26224. * This can be use with 3d blue and red glasses.
  26225. */
  26226. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26227. /**
  26228. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26229. */
  26230. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26231. /**
  26232. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26233. */
  26234. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26235. /**
  26236. * Defines that both eyes of the camera will be rendered over under each other.
  26237. */
  26238. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26239. /**
  26240. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26241. */
  26242. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26243. /**
  26244. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26245. */
  26246. static readonly RIG_MODE_VR: number;
  26247. /**
  26248. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26249. */
  26250. static readonly RIG_MODE_WEBVR: number;
  26251. /**
  26252. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26253. */
  26254. static readonly RIG_MODE_CUSTOM: number;
  26255. /**
  26256. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26257. */
  26258. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26259. /**
  26260. * Define the input manager associated with the camera.
  26261. */
  26262. inputs: CameraInputsManager<Camera>;
  26263. /** @hidden */
  26264. _position: Vector3;
  26265. /**
  26266. * Define the current local position of the camera in the scene
  26267. */
  26268. get position(): Vector3;
  26269. set position(newPosition: Vector3);
  26270. /**
  26271. * The vector the camera should consider as up.
  26272. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26273. */
  26274. upVector: Vector3;
  26275. /**
  26276. * Define the current limit on the left side for an orthographic camera
  26277. * In scene unit
  26278. */
  26279. orthoLeft: Nullable<number>;
  26280. /**
  26281. * Define the current limit on the right side for an orthographic camera
  26282. * In scene unit
  26283. */
  26284. orthoRight: Nullable<number>;
  26285. /**
  26286. * Define the current limit on the bottom side for an orthographic camera
  26287. * In scene unit
  26288. */
  26289. orthoBottom: Nullable<number>;
  26290. /**
  26291. * Define the current limit on the top side for an orthographic camera
  26292. * In scene unit
  26293. */
  26294. orthoTop: Nullable<number>;
  26295. /**
  26296. * Field Of View is set in Radians. (default is 0.8)
  26297. */
  26298. fov: number;
  26299. /**
  26300. * Define the minimum distance the camera can see from.
  26301. * This is important to note that the depth buffer are not infinite and the closer it starts
  26302. * the more your scene might encounter depth fighting issue.
  26303. */
  26304. minZ: number;
  26305. /**
  26306. * Define the maximum distance the camera can see to.
  26307. * This is important to note that the depth buffer are not infinite and the further it end
  26308. * the more your scene might encounter depth fighting issue.
  26309. */
  26310. maxZ: number;
  26311. /**
  26312. * Define the default inertia of the camera.
  26313. * This helps giving a smooth feeling to the camera movement.
  26314. */
  26315. inertia: number;
  26316. /**
  26317. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26318. */
  26319. mode: number;
  26320. /**
  26321. * Define whether the camera is intermediate.
  26322. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26323. */
  26324. isIntermediate: boolean;
  26325. /**
  26326. * Define the viewport of the camera.
  26327. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26328. */
  26329. viewport: Viewport;
  26330. /**
  26331. * Restricts the camera to viewing objects with the same layerMask.
  26332. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26333. */
  26334. layerMask: number;
  26335. /**
  26336. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26337. */
  26338. fovMode: number;
  26339. /**
  26340. * Rig mode of the camera.
  26341. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26342. * This is normally controlled byt the camera themselves as internal use.
  26343. */
  26344. cameraRigMode: number;
  26345. /**
  26346. * Defines the distance between both "eyes" in case of a RIG
  26347. */
  26348. interaxialDistance: number;
  26349. /**
  26350. * Defines if stereoscopic rendering is done side by side or over under.
  26351. */
  26352. isStereoscopicSideBySide: boolean;
  26353. /**
  26354. * 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
  26355. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26356. * else in the scene. (Eg. security camera)
  26357. *
  26358. * 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)
  26359. */
  26360. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26361. /**
  26362. * When set, the camera will render to this render target instead of the default canvas
  26363. *
  26364. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26365. */
  26366. outputRenderTarget: Nullable<RenderTargetTexture>;
  26367. /**
  26368. * Observable triggered when the camera view matrix has changed.
  26369. */
  26370. onViewMatrixChangedObservable: Observable<Camera>;
  26371. /**
  26372. * Observable triggered when the camera Projection matrix has changed.
  26373. */
  26374. onProjectionMatrixChangedObservable: Observable<Camera>;
  26375. /**
  26376. * Observable triggered when the inputs have been processed.
  26377. */
  26378. onAfterCheckInputsObservable: Observable<Camera>;
  26379. /**
  26380. * Observable triggered when reset has been called and applied to the camera.
  26381. */
  26382. onRestoreStateObservable: Observable<Camera>;
  26383. /**
  26384. * Is this camera a part of a rig system?
  26385. */
  26386. isRigCamera: boolean;
  26387. /**
  26388. * If isRigCamera set to true this will be set with the parent camera.
  26389. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26390. */
  26391. rigParent?: Camera;
  26392. /** @hidden */
  26393. _cameraRigParams: any;
  26394. /** @hidden */
  26395. _rigCameras: Camera[];
  26396. /** @hidden */
  26397. _rigPostProcess: Nullable<PostProcess>;
  26398. protected _webvrViewMatrix: Matrix;
  26399. /** @hidden */
  26400. _skipRendering: boolean;
  26401. /** @hidden */
  26402. _projectionMatrix: Matrix;
  26403. /** @hidden */
  26404. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26405. /** @hidden */
  26406. _activeMeshes: SmartArray<AbstractMesh>;
  26407. protected _globalPosition: Vector3;
  26408. /** @hidden */
  26409. _computedViewMatrix: Matrix;
  26410. private _doNotComputeProjectionMatrix;
  26411. private _transformMatrix;
  26412. private _frustumPlanes;
  26413. private _refreshFrustumPlanes;
  26414. private _storedFov;
  26415. private _stateStored;
  26416. /**
  26417. * Instantiates a new camera object.
  26418. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26419. * @see http://doc.babylonjs.com/features/cameras
  26420. * @param name Defines the name of the camera in the scene
  26421. * @param position Defines the position of the camera
  26422. * @param scene Defines the scene the camera belongs too
  26423. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26424. */
  26425. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26426. /**
  26427. * Store current camera state (fov, position, etc..)
  26428. * @returns the camera
  26429. */
  26430. storeState(): Camera;
  26431. /**
  26432. * Restores the camera state values if it has been stored. You must call storeState() first
  26433. */
  26434. protected _restoreStateValues(): boolean;
  26435. /**
  26436. * Restored camera state. You must call storeState() first.
  26437. * @returns true if restored and false otherwise
  26438. */
  26439. restoreState(): boolean;
  26440. /**
  26441. * Gets the class name of the camera.
  26442. * @returns the class name
  26443. */
  26444. getClassName(): string;
  26445. /** @hidden */
  26446. readonly _isCamera: boolean;
  26447. /**
  26448. * Gets a string representation of the camera useful for debug purpose.
  26449. * @param fullDetails Defines that a more verboe level of logging is required
  26450. * @returns the string representation
  26451. */
  26452. toString(fullDetails?: boolean): string;
  26453. /**
  26454. * Gets the current world space position of the camera.
  26455. */
  26456. get globalPosition(): Vector3;
  26457. /**
  26458. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26459. * @returns the active meshe list
  26460. */
  26461. getActiveMeshes(): SmartArray<AbstractMesh>;
  26462. /**
  26463. * Check whether a mesh is part of the current active mesh list of the camera
  26464. * @param mesh Defines the mesh to check
  26465. * @returns true if active, false otherwise
  26466. */
  26467. isActiveMesh(mesh: Mesh): boolean;
  26468. /**
  26469. * Is this camera ready to be used/rendered
  26470. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26471. * @return true if the camera is ready
  26472. */
  26473. isReady(completeCheck?: boolean): boolean;
  26474. /** @hidden */
  26475. _initCache(): void;
  26476. /** @hidden */
  26477. _updateCache(ignoreParentClass?: boolean): void;
  26478. /** @hidden */
  26479. _isSynchronized(): boolean;
  26480. /** @hidden */
  26481. _isSynchronizedViewMatrix(): boolean;
  26482. /** @hidden */
  26483. _isSynchronizedProjectionMatrix(): boolean;
  26484. /**
  26485. * Attach the input controls to a specific dom element to get the input from.
  26486. * @param element Defines the element the controls should be listened from
  26487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26488. */
  26489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26490. /**
  26491. * Detach the current controls from the specified dom element.
  26492. * @param element Defines the element to stop listening the inputs from
  26493. */
  26494. detachControl(element: HTMLElement): void;
  26495. /**
  26496. * Update the camera state according to the different inputs gathered during the frame.
  26497. */
  26498. update(): void;
  26499. /** @hidden */
  26500. _checkInputs(): void;
  26501. /** @hidden */
  26502. get rigCameras(): Camera[];
  26503. /**
  26504. * Gets the post process used by the rig cameras
  26505. */
  26506. get rigPostProcess(): Nullable<PostProcess>;
  26507. /**
  26508. * Internal, gets the first post proces.
  26509. * @returns the first post process to be run on this camera.
  26510. */
  26511. _getFirstPostProcess(): Nullable<PostProcess>;
  26512. private _cascadePostProcessesToRigCams;
  26513. /**
  26514. * Attach a post process to the camera.
  26515. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26516. * @param postProcess The post process to attach to the camera
  26517. * @param insertAt The position of the post process in case several of them are in use in the scene
  26518. * @returns the position the post process has been inserted at
  26519. */
  26520. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26521. /**
  26522. * Detach a post process to the camera.
  26523. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26524. * @param postProcess The post process to detach from the camera
  26525. */
  26526. detachPostProcess(postProcess: PostProcess): void;
  26527. /**
  26528. * Gets the current world matrix of the camera
  26529. */
  26530. getWorldMatrix(): Matrix;
  26531. /** @hidden */
  26532. _getViewMatrix(): Matrix;
  26533. /**
  26534. * Gets the current view matrix of the camera.
  26535. * @param force forces the camera to recompute the matrix without looking at the cached state
  26536. * @returns the view matrix
  26537. */
  26538. getViewMatrix(force?: boolean): Matrix;
  26539. /**
  26540. * Freeze the projection matrix.
  26541. * It will prevent the cache check of the camera projection compute and can speed up perf
  26542. * if no parameter of the camera are meant to change
  26543. * @param projection Defines manually a projection if necessary
  26544. */
  26545. freezeProjectionMatrix(projection?: Matrix): void;
  26546. /**
  26547. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26548. */
  26549. unfreezeProjectionMatrix(): void;
  26550. /**
  26551. * Gets the current projection matrix of the camera.
  26552. * @param force forces the camera to recompute the matrix without looking at the cached state
  26553. * @returns the projection matrix
  26554. */
  26555. getProjectionMatrix(force?: boolean): Matrix;
  26556. /**
  26557. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26558. * @returns a Matrix
  26559. */
  26560. getTransformationMatrix(): Matrix;
  26561. private _updateFrustumPlanes;
  26562. /**
  26563. * Checks if a cullable object (mesh...) is in the camera frustum
  26564. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26565. * @param target The object to check
  26566. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26567. * @returns true if the object is in frustum otherwise false
  26568. */
  26569. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26570. /**
  26571. * Checks if a cullable object (mesh...) is in the camera frustum
  26572. * Unlike isInFrustum this cheks the full bounding box
  26573. * @param target The object to check
  26574. * @returns true if the object is in frustum otherwise false
  26575. */
  26576. isCompletelyInFrustum(target: ICullable): boolean;
  26577. /**
  26578. * Gets a ray in the forward direction from the camera.
  26579. * @param length Defines the length of the ray to create
  26580. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26581. * @param origin Defines the start point of the ray which defaults to the camera position
  26582. * @returns the forward ray
  26583. */
  26584. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26585. /**
  26586. * Releases resources associated with this node.
  26587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26589. */
  26590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26591. /** @hidden */
  26592. _isLeftCamera: boolean;
  26593. /**
  26594. * Gets the left camera of a rig setup in case of Rigged Camera
  26595. */
  26596. get isLeftCamera(): boolean;
  26597. /** @hidden */
  26598. _isRightCamera: boolean;
  26599. /**
  26600. * Gets the right camera of a rig setup in case of Rigged Camera
  26601. */
  26602. get isRightCamera(): boolean;
  26603. /**
  26604. * Gets the left camera of a rig setup in case of Rigged Camera
  26605. */
  26606. get leftCamera(): Nullable<FreeCamera>;
  26607. /**
  26608. * Gets the right camera of a rig setup in case of Rigged Camera
  26609. */
  26610. get rightCamera(): Nullable<FreeCamera>;
  26611. /**
  26612. * Gets the left camera target of a rig setup in case of Rigged Camera
  26613. * @returns the target position
  26614. */
  26615. getLeftTarget(): Nullable<Vector3>;
  26616. /**
  26617. * Gets the right camera target of a rig setup in case of Rigged Camera
  26618. * @returns the target position
  26619. */
  26620. getRightTarget(): Nullable<Vector3>;
  26621. /**
  26622. * @hidden
  26623. */
  26624. setCameraRigMode(mode: number, rigParams: any): void;
  26625. /** @hidden */
  26626. static _setStereoscopicRigMode(camera: Camera): void;
  26627. /** @hidden */
  26628. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26629. /** @hidden */
  26630. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26631. /** @hidden */
  26632. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26633. /** @hidden */
  26634. _getVRProjectionMatrix(): Matrix;
  26635. protected _updateCameraRotationMatrix(): void;
  26636. protected _updateWebVRCameraRotationMatrix(): void;
  26637. /**
  26638. * This function MUST be overwritten by the different WebVR cameras available.
  26639. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26640. * @hidden
  26641. */
  26642. _getWebVRProjectionMatrix(): Matrix;
  26643. /**
  26644. * This function MUST be overwritten by the different WebVR cameras available.
  26645. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26646. * @hidden
  26647. */
  26648. _getWebVRViewMatrix(): Matrix;
  26649. /** @hidden */
  26650. setCameraRigParameter(name: string, value: any): void;
  26651. /**
  26652. * needs to be overridden by children so sub has required properties to be copied
  26653. * @hidden
  26654. */
  26655. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26656. /**
  26657. * May need to be overridden by children
  26658. * @hidden
  26659. */
  26660. _updateRigCameras(): void;
  26661. /** @hidden */
  26662. _setupInputs(): void;
  26663. /**
  26664. * Serialiaze the camera setup to a json represention
  26665. * @returns the JSON representation
  26666. */
  26667. serialize(): any;
  26668. /**
  26669. * Clones the current camera.
  26670. * @param name The cloned camera name
  26671. * @returns the cloned camera
  26672. */
  26673. clone(name: string): Camera;
  26674. /**
  26675. * Gets the direction of the camera relative to a given local axis.
  26676. * @param localAxis Defines the reference axis to provide a relative direction.
  26677. * @return the direction
  26678. */
  26679. getDirection(localAxis: Vector3): Vector3;
  26680. /**
  26681. * Returns the current camera absolute rotation
  26682. */
  26683. get absoluteRotation(): Quaternion;
  26684. /**
  26685. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26686. * @param localAxis Defines the reference axis to provide a relative direction.
  26687. * @param result Defines the vector to store the result in
  26688. */
  26689. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26690. /**
  26691. * Gets a camera constructor for a given camera type
  26692. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26693. * @param name The name of the camera the result will be able to instantiate
  26694. * @param scene The scene the result will construct the camera in
  26695. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26696. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26697. * @returns a factory method to construc the camera
  26698. */
  26699. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26700. /**
  26701. * Compute the world matrix of the camera.
  26702. * @returns the camera world matrix
  26703. */
  26704. computeWorldMatrix(): Matrix;
  26705. /**
  26706. * Parse a JSON and creates the camera from the parsed information
  26707. * @param parsedCamera The JSON to parse
  26708. * @param scene The scene to instantiate the camera in
  26709. * @returns the newly constructed camera
  26710. */
  26711. static Parse(parsedCamera: any, scene: Scene): Camera;
  26712. }
  26713. }
  26714. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26715. import { Nullable } from "babylonjs/types";
  26716. import { Scene } from "babylonjs/scene";
  26717. import { Vector4 } from "babylonjs/Maths/math.vector";
  26718. import { Mesh } from "babylonjs/Meshes/mesh";
  26719. /**
  26720. * Class containing static functions to help procedurally build meshes
  26721. */
  26722. export class DiscBuilder {
  26723. /**
  26724. * Creates a plane polygonal mesh. By default, this is a disc
  26725. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26726. * * 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
  26727. * * 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
  26728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26731. * @param name defines the name of the mesh
  26732. * @param options defines the options used to create the mesh
  26733. * @param scene defines the hosting scene
  26734. * @returns the plane polygonal mesh
  26735. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26736. */
  26737. static CreateDisc(name: string, options: {
  26738. radius?: number;
  26739. tessellation?: number;
  26740. arc?: number;
  26741. updatable?: boolean;
  26742. sideOrientation?: number;
  26743. frontUVs?: Vector4;
  26744. backUVs?: Vector4;
  26745. }, scene?: Nullable<Scene>): Mesh;
  26746. }
  26747. }
  26748. declare module "babylonjs/Materials/fresnelParameters" {
  26749. import { Color3 } from "babylonjs/Maths/math.color";
  26750. /**
  26751. * This represents all the required information to add a fresnel effect on a material:
  26752. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26753. */
  26754. export class FresnelParameters {
  26755. private _isEnabled;
  26756. /**
  26757. * Define if the fresnel effect is enable or not.
  26758. */
  26759. get isEnabled(): boolean;
  26760. set isEnabled(value: boolean);
  26761. /**
  26762. * Define the color used on edges (grazing angle)
  26763. */
  26764. leftColor: Color3;
  26765. /**
  26766. * Define the color used on center
  26767. */
  26768. rightColor: Color3;
  26769. /**
  26770. * Define bias applied to computed fresnel term
  26771. */
  26772. bias: number;
  26773. /**
  26774. * Defined the power exponent applied to fresnel term
  26775. */
  26776. power: number;
  26777. /**
  26778. * Clones the current fresnel and its valuues
  26779. * @returns a clone fresnel configuration
  26780. */
  26781. clone(): FresnelParameters;
  26782. /**
  26783. * Serializes the current fresnel parameters to a JSON representation.
  26784. * @return the JSON serialization
  26785. */
  26786. serialize(): any;
  26787. /**
  26788. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26789. * @param parsedFresnelParameters Define the JSON representation
  26790. * @returns the parsed parameters
  26791. */
  26792. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26793. }
  26794. }
  26795. declare module "babylonjs/Materials/pushMaterial" {
  26796. import { Nullable } from "babylonjs/types";
  26797. import { Scene } from "babylonjs/scene";
  26798. import { Matrix } from "babylonjs/Maths/math.vector";
  26799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26800. import { Mesh } from "babylonjs/Meshes/mesh";
  26801. import { Material } from "babylonjs/Materials/material";
  26802. import { Effect } from "babylonjs/Materials/effect";
  26803. /**
  26804. * Base class of materials working in push mode in babylon JS
  26805. * @hidden
  26806. */
  26807. export class PushMaterial extends Material {
  26808. protected _activeEffect: Effect;
  26809. protected _normalMatrix: Matrix;
  26810. /**
  26811. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26812. * This means that the material can keep using a previous shader while a new one is being compiled.
  26813. * This is mostly used when shader parallel compilation is supported (true by default)
  26814. */
  26815. allowShaderHotSwapping: boolean;
  26816. constructor(name: string, scene: Scene);
  26817. getEffect(): Effect;
  26818. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26819. /**
  26820. * Binds the given world matrix to the active effect
  26821. *
  26822. * @param world the matrix to bind
  26823. */
  26824. bindOnlyWorldMatrix(world: Matrix): void;
  26825. /**
  26826. * Binds the given normal matrix to the active effect
  26827. *
  26828. * @param normalMatrix the matrix to bind
  26829. */
  26830. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26831. bind(world: Matrix, mesh?: Mesh): void;
  26832. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26833. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26834. }
  26835. }
  26836. declare module "babylonjs/Materials/materialFlags" {
  26837. /**
  26838. * This groups all the flags used to control the materials channel.
  26839. */
  26840. export class MaterialFlags {
  26841. private static _DiffuseTextureEnabled;
  26842. /**
  26843. * Are diffuse textures enabled in the application.
  26844. */
  26845. static get DiffuseTextureEnabled(): boolean;
  26846. static set DiffuseTextureEnabled(value: boolean);
  26847. private static _AmbientTextureEnabled;
  26848. /**
  26849. * Are ambient textures enabled in the application.
  26850. */
  26851. static get AmbientTextureEnabled(): boolean;
  26852. static set AmbientTextureEnabled(value: boolean);
  26853. private static _OpacityTextureEnabled;
  26854. /**
  26855. * Are opacity textures enabled in the application.
  26856. */
  26857. static get OpacityTextureEnabled(): boolean;
  26858. static set OpacityTextureEnabled(value: boolean);
  26859. private static _ReflectionTextureEnabled;
  26860. /**
  26861. * Are reflection textures enabled in the application.
  26862. */
  26863. static get ReflectionTextureEnabled(): boolean;
  26864. static set ReflectionTextureEnabled(value: boolean);
  26865. private static _EmissiveTextureEnabled;
  26866. /**
  26867. * Are emissive textures enabled in the application.
  26868. */
  26869. static get EmissiveTextureEnabled(): boolean;
  26870. static set EmissiveTextureEnabled(value: boolean);
  26871. private static _SpecularTextureEnabled;
  26872. /**
  26873. * Are specular textures enabled in the application.
  26874. */
  26875. static get SpecularTextureEnabled(): boolean;
  26876. static set SpecularTextureEnabled(value: boolean);
  26877. private static _BumpTextureEnabled;
  26878. /**
  26879. * Are bump textures enabled in the application.
  26880. */
  26881. static get BumpTextureEnabled(): boolean;
  26882. static set BumpTextureEnabled(value: boolean);
  26883. private static _LightmapTextureEnabled;
  26884. /**
  26885. * Are lightmap textures enabled in the application.
  26886. */
  26887. static get LightmapTextureEnabled(): boolean;
  26888. static set LightmapTextureEnabled(value: boolean);
  26889. private static _RefractionTextureEnabled;
  26890. /**
  26891. * Are refraction textures enabled in the application.
  26892. */
  26893. static get RefractionTextureEnabled(): boolean;
  26894. static set RefractionTextureEnabled(value: boolean);
  26895. private static _ColorGradingTextureEnabled;
  26896. /**
  26897. * Are color grading textures enabled in the application.
  26898. */
  26899. static get ColorGradingTextureEnabled(): boolean;
  26900. static set ColorGradingTextureEnabled(value: boolean);
  26901. private static _FresnelEnabled;
  26902. /**
  26903. * Are fresnels enabled in the application.
  26904. */
  26905. static get FresnelEnabled(): boolean;
  26906. static set FresnelEnabled(value: boolean);
  26907. private static _ClearCoatTextureEnabled;
  26908. /**
  26909. * Are clear coat textures enabled in the application.
  26910. */
  26911. static get ClearCoatTextureEnabled(): boolean;
  26912. static set ClearCoatTextureEnabled(value: boolean);
  26913. private static _ClearCoatBumpTextureEnabled;
  26914. /**
  26915. * Are clear coat bump textures enabled in the application.
  26916. */
  26917. static get ClearCoatBumpTextureEnabled(): boolean;
  26918. static set ClearCoatBumpTextureEnabled(value: boolean);
  26919. private static _ClearCoatTintTextureEnabled;
  26920. /**
  26921. * Are clear coat tint textures enabled in the application.
  26922. */
  26923. static get ClearCoatTintTextureEnabled(): boolean;
  26924. static set ClearCoatTintTextureEnabled(value: boolean);
  26925. private static _SheenTextureEnabled;
  26926. /**
  26927. * Are sheen textures enabled in the application.
  26928. */
  26929. static get SheenTextureEnabled(): boolean;
  26930. static set SheenTextureEnabled(value: boolean);
  26931. private static _AnisotropicTextureEnabled;
  26932. /**
  26933. * Are anisotropic textures enabled in the application.
  26934. */
  26935. static get AnisotropicTextureEnabled(): boolean;
  26936. static set AnisotropicTextureEnabled(value: boolean);
  26937. private static _ThicknessTextureEnabled;
  26938. /**
  26939. * Are thickness textures enabled in the application.
  26940. */
  26941. static get ThicknessTextureEnabled(): boolean;
  26942. static set ThicknessTextureEnabled(value: boolean);
  26943. }
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26946. /** @hidden */
  26947. export var defaultFragmentDeclaration: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26953. /** @hidden */
  26954. export var defaultUboDeclaration: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26960. /** @hidden */
  26961. export var lightFragmentDeclaration: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26967. /** @hidden */
  26968. export var lightUboDeclaration: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26974. /** @hidden */
  26975. export var lightsFragmentFunctions: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26981. /** @hidden */
  26982. export var shadowsFragmentFunctions: {
  26983. name: string;
  26984. shader: string;
  26985. };
  26986. }
  26987. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26988. /** @hidden */
  26989. export var fresnelFunction: {
  26990. name: string;
  26991. shader: string;
  26992. };
  26993. }
  26994. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26995. /** @hidden */
  26996. export var reflectionFunction: {
  26997. name: string;
  26998. shader: string;
  26999. };
  27000. }
  27001. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27002. /** @hidden */
  27003. export var bumpFragmentFunctions: {
  27004. name: string;
  27005. shader: string;
  27006. };
  27007. }
  27008. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27009. /** @hidden */
  27010. export var logDepthDeclaration: {
  27011. name: string;
  27012. shader: string;
  27013. };
  27014. }
  27015. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27016. /** @hidden */
  27017. export var bumpFragment: {
  27018. name: string;
  27019. shader: string;
  27020. };
  27021. }
  27022. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27023. /** @hidden */
  27024. export var depthPrePass: {
  27025. name: string;
  27026. shader: string;
  27027. };
  27028. }
  27029. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27030. /** @hidden */
  27031. export var lightFragment: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27037. /** @hidden */
  27038. export var logDepthFragment: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/default.fragment" {
  27044. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27045. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27046. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27047. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27048. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27049. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27050. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27051. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27052. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27053. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27054. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27055. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27056. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27057. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27058. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27059. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27060. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27061. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27062. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27063. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27064. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27065. /** @hidden */
  27066. export var defaultPixelShader: {
  27067. name: string;
  27068. shader: string;
  27069. };
  27070. }
  27071. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27072. /** @hidden */
  27073. export var defaultVertexDeclaration: {
  27074. name: string;
  27075. shader: string;
  27076. };
  27077. }
  27078. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27079. /** @hidden */
  27080. export var bumpVertexDeclaration: {
  27081. name: string;
  27082. shader: string;
  27083. };
  27084. }
  27085. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27086. /** @hidden */
  27087. export var bumpVertex: {
  27088. name: string;
  27089. shader: string;
  27090. };
  27091. }
  27092. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27093. /** @hidden */
  27094. export var fogVertex: {
  27095. name: string;
  27096. shader: string;
  27097. };
  27098. }
  27099. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27100. /** @hidden */
  27101. export var shadowsVertex: {
  27102. name: string;
  27103. shader: string;
  27104. };
  27105. }
  27106. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27107. /** @hidden */
  27108. export var pointCloudVertex: {
  27109. name: string;
  27110. shader: string;
  27111. };
  27112. }
  27113. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27114. /** @hidden */
  27115. export var logDepthVertex: {
  27116. name: string;
  27117. shader: string;
  27118. };
  27119. }
  27120. declare module "babylonjs/Shaders/default.vertex" {
  27121. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27122. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27123. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27125. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27126. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27127. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27128. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27129. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27130. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27131. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27132. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27133. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27134. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27135. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27136. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27137. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27138. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27139. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27140. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27141. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27142. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27143. /** @hidden */
  27144. export var defaultVertexShader: {
  27145. name: string;
  27146. shader: string;
  27147. };
  27148. }
  27149. declare module "babylonjs/Materials/standardMaterial" {
  27150. import { SmartArray } from "babylonjs/Misc/smartArray";
  27151. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27152. import { Nullable } from "babylonjs/types";
  27153. import { Scene } from "babylonjs/scene";
  27154. import { Matrix } from "babylonjs/Maths/math.vector";
  27155. import { Color3 } from "babylonjs/Maths/math.color";
  27156. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27158. import { Mesh } from "babylonjs/Meshes/mesh";
  27159. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27160. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27161. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27162. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27163. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27165. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27166. import "babylonjs/Shaders/default.fragment";
  27167. import "babylonjs/Shaders/default.vertex";
  27168. /** @hidden */
  27169. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27170. MAINUV1: boolean;
  27171. MAINUV2: boolean;
  27172. DIFFUSE: boolean;
  27173. DIFFUSEDIRECTUV: number;
  27174. AMBIENT: boolean;
  27175. AMBIENTDIRECTUV: number;
  27176. OPACITY: boolean;
  27177. OPACITYDIRECTUV: number;
  27178. OPACITYRGB: boolean;
  27179. REFLECTION: boolean;
  27180. EMISSIVE: boolean;
  27181. EMISSIVEDIRECTUV: number;
  27182. SPECULAR: boolean;
  27183. SPECULARDIRECTUV: number;
  27184. BUMP: boolean;
  27185. BUMPDIRECTUV: number;
  27186. PARALLAX: boolean;
  27187. PARALLAXOCCLUSION: boolean;
  27188. SPECULAROVERALPHA: boolean;
  27189. CLIPPLANE: boolean;
  27190. CLIPPLANE2: boolean;
  27191. CLIPPLANE3: boolean;
  27192. CLIPPLANE4: boolean;
  27193. CLIPPLANE5: boolean;
  27194. CLIPPLANE6: boolean;
  27195. ALPHATEST: boolean;
  27196. DEPTHPREPASS: boolean;
  27197. ALPHAFROMDIFFUSE: boolean;
  27198. POINTSIZE: boolean;
  27199. FOG: boolean;
  27200. SPECULARTERM: boolean;
  27201. DIFFUSEFRESNEL: boolean;
  27202. OPACITYFRESNEL: boolean;
  27203. REFLECTIONFRESNEL: boolean;
  27204. REFRACTIONFRESNEL: boolean;
  27205. EMISSIVEFRESNEL: boolean;
  27206. FRESNEL: boolean;
  27207. NORMAL: boolean;
  27208. UV1: boolean;
  27209. UV2: boolean;
  27210. VERTEXCOLOR: boolean;
  27211. VERTEXALPHA: boolean;
  27212. NUM_BONE_INFLUENCERS: number;
  27213. BonesPerMesh: number;
  27214. BONETEXTURE: boolean;
  27215. INSTANCES: boolean;
  27216. GLOSSINESS: boolean;
  27217. ROUGHNESS: boolean;
  27218. EMISSIVEASILLUMINATION: boolean;
  27219. LINKEMISSIVEWITHDIFFUSE: boolean;
  27220. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27221. LIGHTMAP: boolean;
  27222. LIGHTMAPDIRECTUV: number;
  27223. OBJECTSPACE_NORMALMAP: boolean;
  27224. USELIGHTMAPASSHADOWMAP: boolean;
  27225. REFLECTIONMAP_3D: boolean;
  27226. REFLECTIONMAP_SPHERICAL: boolean;
  27227. REFLECTIONMAP_PLANAR: boolean;
  27228. REFLECTIONMAP_CUBIC: boolean;
  27229. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27230. REFLECTIONMAP_PROJECTION: boolean;
  27231. REFLECTIONMAP_SKYBOX: boolean;
  27232. REFLECTIONMAP_EXPLICIT: boolean;
  27233. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27234. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27235. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27236. INVERTCUBICMAP: boolean;
  27237. LOGARITHMICDEPTH: boolean;
  27238. REFRACTION: boolean;
  27239. REFRACTIONMAP_3D: boolean;
  27240. REFLECTIONOVERALPHA: boolean;
  27241. TWOSIDEDLIGHTING: boolean;
  27242. SHADOWFLOAT: boolean;
  27243. MORPHTARGETS: boolean;
  27244. MORPHTARGETS_NORMAL: boolean;
  27245. MORPHTARGETS_TANGENT: boolean;
  27246. MORPHTARGETS_UV: boolean;
  27247. NUM_MORPH_INFLUENCERS: number;
  27248. NONUNIFORMSCALING: boolean;
  27249. PREMULTIPLYALPHA: boolean;
  27250. IMAGEPROCESSING: boolean;
  27251. VIGNETTE: boolean;
  27252. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27253. VIGNETTEBLENDMODEOPAQUE: boolean;
  27254. TONEMAPPING: boolean;
  27255. TONEMAPPING_ACES: boolean;
  27256. CONTRAST: boolean;
  27257. COLORCURVES: boolean;
  27258. COLORGRADING: boolean;
  27259. COLORGRADING3D: boolean;
  27260. SAMPLER3DGREENDEPTH: boolean;
  27261. SAMPLER3DBGRMAP: boolean;
  27262. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27263. MULTIVIEW: boolean;
  27264. /**
  27265. * If the reflection texture on this material is in linear color space
  27266. * @hidden
  27267. */
  27268. IS_REFLECTION_LINEAR: boolean;
  27269. /**
  27270. * If the refraction texture on this material is in linear color space
  27271. * @hidden
  27272. */
  27273. IS_REFRACTION_LINEAR: boolean;
  27274. EXPOSURE: boolean;
  27275. constructor();
  27276. setReflectionMode(modeToEnable: string): void;
  27277. }
  27278. /**
  27279. * This is the default material used in Babylon. It is the best trade off between quality
  27280. * and performances.
  27281. * @see http://doc.babylonjs.com/babylon101/materials
  27282. */
  27283. export class StandardMaterial extends PushMaterial {
  27284. private _diffuseTexture;
  27285. /**
  27286. * The basic texture of the material as viewed under a light.
  27287. */
  27288. diffuseTexture: Nullable<BaseTexture>;
  27289. private _ambientTexture;
  27290. /**
  27291. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27292. */
  27293. ambientTexture: Nullable<BaseTexture>;
  27294. private _opacityTexture;
  27295. /**
  27296. * Define the transparency of the material from a texture.
  27297. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27298. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27299. */
  27300. opacityTexture: Nullable<BaseTexture>;
  27301. private _reflectionTexture;
  27302. /**
  27303. * Define the texture used to display the reflection.
  27304. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27305. */
  27306. reflectionTexture: Nullable<BaseTexture>;
  27307. private _emissiveTexture;
  27308. /**
  27309. * Define texture of the material as if self lit.
  27310. * This will be mixed in the final result even in the absence of light.
  27311. */
  27312. emissiveTexture: Nullable<BaseTexture>;
  27313. private _specularTexture;
  27314. /**
  27315. * Define how the color and intensity of the highlight given by the light in the material.
  27316. */
  27317. specularTexture: Nullable<BaseTexture>;
  27318. private _bumpTexture;
  27319. /**
  27320. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27321. * 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.
  27322. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27323. */
  27324. bumpTexture: Nullable<BaseTexture>;
  27325. private _lightmapTexture;
  27326. /**
  27327. * Complex lighting can be computationally expensive to compute at runtime.
  27328. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27329. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27330. */
  27331. lightmapTexture: Nullable<BaseTexture>;
  27332. private _refractionTexture;
  27333. /**
  27334. * Define the texture used to display the refraction.
  27335. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27336. */
  27337. refractionTexture: Nullable<BaseTexture>;
  27338. /**
  27339. * The color of the material lit by the environmental background lighting.
  27340. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27341. */
  27342. ambientColor: Color3;
  27343. /**
  27344. * The basic color of the material as viewed under a light.
  27345. */
  27346. diffuseColor: Color3;
  27347. /**
  27348. * Define how the color and intensity of the highlight given by the light in the material.
  27349. */
  27350. specularColor: Color3;
  27351. /**
  27352. * Define the color of the material as if self lit.
  27353. * This will be mixed in the final result even in the absence of light.
  27354. */
  27355. emissiveColor: Color3;
  27356. /**
  27357. * Defines how sharp are the highlights in the material.
  27358. * The bigger the value the sharper giving a more glossy feeling to the result.
  27359. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27360. */
  27361. specularPower: number;
  27362. private _useAlphaFromDiffuseTexture;
  27363. /**
  27364. * Does the transparency come from the diffuse texture alpha channel.
  27365. */
  27366. useAlphaFromDiffuseTexture: boolean;
  27367. private _useEmissiveAsIllumination;
  27368. /**
  27369. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27370. */
  27371. useEmissiveAsIllumination: boolean;
  27372. private _linkEmissiveWithDiffuse;
  27373. /**
  27374. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27375. * the emissive level when the final color is close to one.
  27376. */
  27377. linkEmissiveWithDiffuse: boolean;
  27378. private _useSpecularOverAlpha;
  27379. /**
  27380. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27381. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27382. */
  27383. useSpecularOverAlpha: boolean;
  27384. private _useReflectionOverAlpha;
  27385. /**
  27386. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27387. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27388. */
  27389. useReflectionOverAlpha: boolean;
  27390. private _disableLighting;
  27391. /**
  27392. * Does lights from the scene impacts this material.
  27393. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27394. */
  27395. disableLighting: boolean;
  27396. private _useObjectSpaceNormalMap;
  27397. /**
  27398. * Allows using an object space normal map (instead of tangent space).
  27399. */
  27400. useObjectSpaceNormalMap: boolean;
  27401. private _useParallax;
  27402. /**
  27403. * Is parallax enabled or not.
  27404. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27405. */
  27406. useParallax: boolean;
  27407. private _useParallaxOcclusion;
  27408. /**
  27409. * Is parallax occlusion enabled or not.
  27410. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27411. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27412. */
  27413. useParallaxOcclusion: boolean;
  27414. /**
  27415. * 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.
  27416. */
  27417. parallaxScaleBias: number;
  27418. private _roughness;
  27419. /**
  27420. * Helps to define how blurry the reflections should appears in the material.
  27421. */
  27422. roughness: number;
  27423. /**
  27424. * In case of refraction, define the value of the index of refraction.
  27425. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27426. */
  27427. indexOfRefraction: number;
  27428. /**
  27429. * Invert the refraction texture alongside the y axis.
  27430. * It can be useful with procedural textures or probe for instance.
  27431. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27432. */
  27433. invertRefractionY: boolean;
  27434. /**
  27435. * Defines the alpha limits in alpha test mode.
  27436. */
  27437. alphaCutOff: number;
  27438. private _useLightmapAsShadowmap;
  27439. /**
  27440. * In case of light mapping, define whether the map contains light or shadow informations.
  27441. */
  27442. useLightmapAsShadowmap: boolean;
  27443. private _diffuseFresnelParameters;
  27444. /**
  27445. * Define the diffuse fresnel parameters of the material.
  27446. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27447. */
  27448. diffuseFresnelParameters: FresnelParameters;
  27449. private _opacityFresnelParameters;
  27450. /**
  27451. * Define the opacity fresnel parameters of the material.
  27452. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27453. */
  27454. opacityFresnelParameters: FresnelParameters;
  27455. private _reflectionFresnelParameters;
  27456. /**
  27457. * Define the reflection fresnel parameters of the material.
  27458. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27459. */
  27460. reflectionFresnelParameters: FresnelParameters;
  27461. private _refractionFresnelParameters;
  27462. /**
  27463. * Define the refraction fresnel parameters of the material.
  27464. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27465. */
  27466. refractionFresnelParameters: FresnelParameters;
  27467. private _emissiveFresnelParameters;
  27468. /**
  27469. * Define the emissive fresnel parameters of the material.
  27470. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27471. */
  27472. emissiveFresnelParameters: FresnelParameters;
  27473. private _useReflectionFresnelFromSpecular;
  27474. /**
  27475. * If true automatically deducts the fresnels values from the material specularity.
  27476. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27477. */
  27478. useReflectionFresnelFromSpecular: boolean;
  27479. private _useGlossinessFromSpecularMapAlpha;
  27480. /**
  27481. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27482. */
  27483. useGlossinessFromSpecularMapAlpha: boolean;
  27484. private _maxSimultaneousLights;
  27485. /**
  27486. * Defines the maximum number of lights that can be used in the material
  27487. */
  27488. maxSimultaneousLights: number;
  27489. private _invertNormalMapX;
  27490. /**
  27491. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27492. */
  27493. invertNormalMapX: boolean;
  27494. private _invertNormalMapY;
  27495. /**
  27496. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27497. */
  27498. invertNormalMapY: boolean;
  27499. private _twoSidedLighting;
  27500. /**
  27501. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27502. */
  27503. twoSidedLighting: boolean;
  27504. /**
  27505. * Default configuration related to image processing available in the standard Material.
  27506. */
  27507. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27508. /**
  27509. * Gets the image processing configuration used either in this material.
  27510. */
  27511. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27512. /**
  27513. * Sets the Default image processing configuration used either in the this material.
  27514. *
  27515. * If sets to null, the scene one is in use.
  27516. */
  27517. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27518. /**
  27519. * Keep track of the image processing observer to allow dispose and replace.
  27520. */
  27521. private _imageProcessingObserver;
  27522. /**
  27523. * Attaches a new image processing configuration to the Standard Material.
  27524. * @param configuration
  27525. */
  27526. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27527. /**
  27528. * Gets wether the color curves effect is enabled.
  27529. */
  27530. get cameraColorCurvesEnabled(): boolean;
  27531. /**
  27532. * Sets wether the color curves effect is enabled.
  27533. */
  27534. set cameraColorCurvesEnabled(value: boolean);
  27535. /**
  27536. * Gets wether the color grading effect is enabled.
  27537. */
  27538. get cameraColorGradingEnabled(): boolean;
  27539. /**
  27540. * Gets wether the color grading effect is enabled.
  27541. */
  27542. set cameraColorGradingEnabled(value: boolean);
  27543. /**
  27544. * Gets wether tonemapping is enabled or not.
  27545. */
  27546. get cameraToneMappingEnabled(): boolean;
  27547. /**
  27548. * Sets wether tonemapping is enabled or not
  27549. */
  27550. set cameraToneMappingEnabled(value: boolean);
  27551. /**
  27552. * The camera exposure used on this material.
  27553. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27554. * This corresponds to a photographic exposure.
  27555. */
  27556. get cameraExposure(): number;
  27557. /**
  27558. * The camera exposure used on this material.
  27559. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27560. * This corresponds to a photographic exposure.
  27561. */
  27562. set cameraExposure(value: number);
  27563. /**
  27564. * Gets The camera contrast used on this material.
  27565. */
  27566. get cameraContrast(): number;
  27567. /**
  27568. * Sets The camera contrast used on this material.
  27569. */
  27570. set cameraContrast(value: number);
  27571. /**
  27572. * Gets the Color Grading 2D Lookup Texture.
  27573. */
  27574. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27575. /**
  27576. * Sets the Color Grading 2D Lookup Texture.
  27577. */
  27578. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27579. /**
  27580. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27581. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27582. * 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;
  27583. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27584. */
  27585. get cameraColorCurves(): Nullable<ColorCurves>;
  27586. /**
  27587. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27588. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27589. * 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;
  27590. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27591. */
  27592. set cameraColorCurves(value: Nullable<ColorCurves>);
  27593. /**
  27594. * Custom callback helping to override the default shader used in the material.
  27595. */
  27596. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27597. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27598. protected _worldViewProjectionMatrix: Matrix;
  27599. protected _globalAmbientColor: Color3;
  27600. protected _useLogarithmicDepth: boolean;
  27601. protected _rebuildInParallel: boolean;
  27602. /**
  27603. * Instantiates a new standard material.
  27604. * This is the default material used in Babylon. It is the best trade off between quality
  27605. * and performances.
  27606. * @see http://doc.babylonjs.com/babylon101/materials
  27607. * @param name Define the name of the material in the scene
  27608. * @param scene Define the scene the material belong to
  27609. */
  27610. constructor(name: string, scene: Scene);
  27611. /**
  27612. * Gets a boolean indicating that current material needs to register RTT
  27613. */
  27614. get hasRenderTargetTextures(): boolean;
  27615. /**
  27616. * Gets the current class name of the material e.g. "StandardMaterial"
  27617. * Mainly use in serialization.
  27618. * @returns the class name
  27619. */
  27620. getClassName(): string;
  27621. /**
  27622. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27623. * You can try switching to logarithmic depth.
  27624. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27625. */
  27626. get useLogarithmicDepth(): boolean;
  27627. set useLogarithmicDepth(value: boolean);
  27628. /**
  27629. * Specifies if the material will require alpha blending
  27630. * @returns a boolean specifying if alpha blending is needed
  27631. */
  27632. needAlphaBlending(): boolean;
  27633. /**
  27634. * Specifies if this material should be rendered in alpha test mode
  27635. * @returns a boolean specifying if an alpha test is needed.
  27636. */
  27637. needAlphaTesting(): boolean;
  27638. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27639. /**
  27640. * Get the texture used for alpha test purpose.
  27641. * @returns the diffuse texture in case of the standard material.
  27642. */
  27643. getAlphaTestTexture(): Nullable<BaseTexture>;
  27644. /**
  27645. * Get if the submesh is ready to be used and all its information available.
  27646. * Child classes can use it to update shaders
  27647. * @param mesh defines the mesh to check
  27648. * @param subMesh defines which submesh to check
  27649. * @param useInstances specifies that instances should be used
  27650. * @returns a boolean indicating that the submesh is ready or not
  27651. */
  27652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27653. /**
  27654. * Builds the material UBO layouts.
  27655. * Used internally during the effect preparation.
  27656. */
  27657. buildUniformLayout(): void;
  27658. /**
  27659. * Unbinds the material from the mesh
  27660. */
  27661. unbind(): void;
  27662. /**
  27663. * Binds the submesh to this material by preparing the effect and shader to draw
  27664. * @param world defines the world transformation matrix
  27665. * @param mesh defines the mesh containing the submesh
  27666. * @param subMesh defines the submesh to bind the material to
  27667. */
  27668. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27669. /**
  27670. * Get the list of animatables in the material.
  27671. * @returns the list of animatables object used in the material
  27672. */
  27673. getAnimatables(): IAnimatable[];
  27674. /**
  27675. * Gets the active textures from the material
  27676. * @returns an array of textures
  27677. */
  27678. getActiveTextures(): BaseTexture[];
  27679. /**
  27680. * Specifies if the material uses a texture
  27681. * @param texture defines the texture to check against the material
  27682. * @returns a boolean specifying if the material uses the texture
  27683. */
  27684. hasTexture(texture: BaseTexture): boolean;
  27685. /**
  27686. * Disposes the material
  27687. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27688. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27689. */
  27690. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27691. /**
  27692. * Makes a duplicate of the material, and gives it a new name
  27693. * @param name defines the new name for the duplicated material
  27694. * @returns the cloned material
  27695. */
  27696. clone(name: string): StandardMaterial;
  27697. /**
  27698. * Serializes this material in a JSON representation
  27699. * @returns the serialized material object
  27700. */
  27701. serialize(): any;
  27702. /**
  27703. * Creates a standard material from parsed material data
  27704. * @param source defines the JSON representation of the material
  27705. * @param scene defines the hosting scene
  27706. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27707. * @returns a new standard material
  27708. */
  27709. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27710. /**
  27711. * Are diffuse textures enabled in the application.
  27712. */
  27713. static get DiffuseTextureEnabled(): boolean;
  27714. static set DiffuseTextureEnabled(value: boolean);
  27715. /**
  27716. * Are ambient textures enabled in the application.
  27717. */
  27718. static get AmbientTextureEnabled(): boolean;
  27719. static set AmbientTextureEnabled(value: boolean);
  27720. /**
  27721. * Are opacity textures enabled in the application.
  27722. */
  27723. static get OpacityTextureEnabled(): boolean;
  27724. static set OpacityTextureEnabled(value: boolean);
  27725. /**
  27726. * Are reflection textures enabled in the application.
  27727. */
  27728. static get ReflectionTextureEnabled(): boolean;
  27729. static set ReflectionTextureEnabled(value: boolean);
  27730. /**
  27731. * Are emissive textures enabled in the application.
  27732. */
  27733. static get EmissiveTextureEnabled(): boolean;
  27734. static set EmissiveTextureEnabled(value: boolean);
  27735. /**
  27736. * Are specular textures enabled in the application.
  27737. */
  27738. static get SpecularTextureEnabled(): boolean;
  27739. static set SpecularTextureEnabled(value: boolean);
  27740. /**
  27741. * Are bump textures enabled in the application.
  27742. */
  27743. static get BumpTextureEnabled(): boolean;
  27744. static set BumpTextureEnabled(value: boolean);
  27745. /**
  27746. * Are lightmap textures enabled in the application.
  27747. */
  27748. static get LightmapTextureEnabled(): boolean;
  27749. static set LightmapTextureEnabled(value: boolean);
  27750. /**
  27751. * Are refraction textures enabled in the application.
  27752. */
  27753. static get RefractionTextureEnabled(): boolean;
  27754. static set RefractionTextureEnabled(value: boolean);
  27755. /**
  27756. * Are color grading textures enabled in the application.
  27757. */
  27758. static get ColorGradingTextureEnabled(): boolean;
  27759. static set ColorGradingTextureEnabled(value: boolean);
  27760. /**
  27761. * Are fresnels enabled in the application.
  27762. */
  27763. static get FresnelEnabled(): boolean;
  27764. static set FresnelEnabled(value: boolean);
  27765. }
  27766. }
  27767. declare module "babylonjs/Particles/solidParticleSystem" {
  27768. import { Nullable } from "babylonjs/types";
  27769. import { Vector3 } from "babylonjs/Maths/math.vector";
  27770. import { Mesh } from "babylonjs/Meshes/mesh";
  27771. import { Scene, IDisposable } from "babylonjs/scene";
  27772. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27773. import { Material } from "babylonjs/Materials/material";
  27774. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27775. /**
  27776. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27777. *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.
  27778. * The SPS is also a particle system. It provides some methods to manage the particles.
  27779. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27780. *
  27781. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27782. */
  27783. export class SolidParticleSystem implements IDisposable {
  27784. /**
  27785. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27786. * Example : var p = SPS.particles[i];
  27787. */
  27788. particles: SolidParticle[];
  27789. /**
  27790. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27791. */
  27792. nbParticles: number;
  27793. /**
  27794. * If the particles must ever face the camera (default false). Useful for planar particles.
  27795. */
  27796. billboard: boolean;
  27797. /**
  27798. * Recompute normals when adding a shape
  27799. */
  27800. recomputeNormals: boolean;
  27801. /**
  27802. * This a counter ofr your own usage. It's not set by any SPS functions.
  27803. */
  27804. counter: number;
  27805. /**
  27806. * The SPS name. This name is also given to the underlying mesh.
  27807. */
  27808. name: string;
  27809. /**
  27810. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27811. */
  27812. mesh: Mesh;
  27813. /**
  27814. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27815. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27816. */
  27817. vars: any;
  27818. /**
  27819. * This array is populated when the SPS is set as 'pickable'.
  27820. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27821. * Each element of this array is an object `{idx: int, faceId: int}`.
  27822. * `idx` is the picked particle index in the `SPS.particles` array
  27823. * `faceId` is the picked face index counted within this particle.
  27824. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27825. */
  27826. pickedParticles: {
  27827. idx: number;
  27828. faceId: number;
  27829. }[];
  27830. /**
  27831. * This array is populated when `enableDepthSort` is set to true.
  27832. * Each element of this array is an instance of the class DepthSortedParticle.
  27833. */
  27834. depthSortedParticles: DepthSortedParticle[];
  27835. /**
  27836. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27837. * @hidden
  27838. */
  27839. _bSphereOnly: boolean;
  27840. /**
  27841. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27842. * @hidden
  27843. */
  27844. _bSphereRadiusFactor: number;
  27845. private _scene;
  27846. private _positions;
  27847. private _indices;
  27848. private _normals;
  27849. private _colors;
  27850. private _uvs;
  27851. private _indices32;
  27852. private _positions32;
  27853. private _normals32;
  27854. private _fixedNormal32;
  27855. private _colors32;
  27856. private _uvs32;
  27857. private _index;
  27858. private _updatable;
  27859. private _pickable;
  27860. private _isVisibilityBoxLocked;
  27861. private _alwaysVisible;
  27862. private _depthSort;
  27863. private _expandable;
  27864. private _shapeCounter;
  27865. private _copy;
  27866. private _color;
  27867. private _computeParticleColor;
  27868. private _computeParticleTexture;
  27869. private _computeParticleRotation;
  27870. private _computeParticleVertex;
  27871. private _computeBoundingBox;
  27872. private _depthSortParticles;
  27873. private _camera;
  27874. private _mustUnrotateFixedNormals;
  27875. private _particlesIntersect;
  27876. private _needs32Bits;
  27877. private _isNotBuilt;
  27878. private _lastParticleId;
  27879. private _idxOfId;
  27880. private _multimaterialEnabled;
  27881. private _useModelMaterial;
  27882. private _indicesByMaterial;
  27883. private _materialIndexes;
  27884. private _depthSortFunction;
  27885. private _materialSortFunction;
  27886. private _materials;
  27887. private _multimaterial;
  27888. private _materialIndexesById;
  27889. private _defaultMaterial;
  27890. private _autoUpdateSubMeshes;
  27891. /**
  27892. * Creates a SPS (Solid Particle System) object.
  27893. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27894. * @param scene (Scene) is the scene in which the SPS is added.
  27895. * @param options defines the options of the sps e.g.
  27896. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27897. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27898. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27899. * * 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.
  27900. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27901. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27902. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27903. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27904. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27905. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27906. */
  27907. constructor(name: string, scene: Scene, options?: {
  27908. updatable?: boolean;
  27909. isPickable?: boolean;
  27910. enableDepthSort?: boolean;
  27911. particleIntersection?: boolean;
  27912. boundingSphereOnly?: boolean;
  27913. bSphereRadiusFactor?: number;
  27914. expandable?: boolean;
  27915. useModelMaterial?: boolean;
  27916. enableMultiMaterial?: boolean;
  27917. });
  27918. /**
  27919. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27920. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27921. * @returns the created mesh
  27922. */
  27923. buildMesh(): Mesh;
  27924. /**
  27925. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27926. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27927. * Thus the particles generated from `digest()` have their property `position` set yet.
  27928. * @param mesh ( Mesh ) is the mesh to be digested
  27929. * @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
  27930. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27931. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27932. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27933. * @returns the current SPS
  27934. */
  27935. digest(mesh: Mesh, options?: {
  27936. facetNb?: number;
  27937. number?: number;
  27938. delta?: number;
  27939. storage?: [];
  27940. }): SolidParticleSystem;
  27941. /**
  27942. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27943. * @hidden
  27944. */
  27945. private _unrotateFixedNormals;
  27946. /**
  27947. * Resets the temporary working copy particle
  27948. * @hidden
  27949. */
  27950. private _resetCopy;
  27951. /**
  27952. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27953. * @param p the current index in the positions array to be updated
  27954. * @param ind the current index in the indices array
  27955. * @param shape a Vector3 array, the shape geometry
  27956. * @param positions the positions array to be updated
  27957. * @param meshInd the shape indices array
  27958. * @param indices the indices array to be updated
  27959. * @param meshUV the shape uv array
  27960. * @param uvs the uv array to be updated
  27961. * @param meshCol the shape color array
  27962. * @param colors the color array to be updated
  27963. * @param meshNor the shape normals array
  27964. * @param normals the normals array to be updated
  27965. * @param idx the particle index
  27966. * @param idxInShape the particle index in its shape
  27967. * @param options the addShape() method passed options
  27968. * @model the particle model
  27969. * @hidden
  27970. */
  27971. private _meshBuilder;
  27972. /**
  27973. * Returns a shape Vector3 array from positions float array
  27974. * @param positions float array
  27975. * @returns a vector3 array
  27976. * @hidden
  27977. */
  27978. private _posToShape;
  27979. /**
  27980. * Returns a shapeUV array from a float uvs (array deep copy)
  27981. * @param uvs as a float array
  27982. * @returns a shapeUV array
  27983. * @hidden
  27984. */
  27985. private _uvsToShapeUV;
  27986. /**
  27987. * Adds a new particle object in the particles array
  27988. * @param idx particle index in particles array
  27989. * @param id particle id
  27990. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27991. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27992. * @param model particle ModelShape object
  27993. * @param shapeId model shape identifier
  27994. * @param idxInShape index of the particle in the current model
  27995. * @param bInfo model bounding info object
  27996. * @param storage target storage array, if any
  27997. * @hidden
  27998. */
  27999. private _addParticle;
  28000. /**
  28001. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28002. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28003. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28004. * @param nb (positive integer) the number of particles to be created from this model
  28005. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28006. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28007. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28008. * @returns the number of shapes in the system
  28009. */
  28010. addShape(mesh: Mesh, nb: number, options?: {
  28011. positionFunction?: any;
  28012. vertexFunction?: any;
  28013. storage?: [];
  28014. }): number;
  28015. /**
  28016. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28017. * @hidden
  28018. */
  28019. private _rebuildParticle;
  28020. /**
  28021. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28022. * @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.
  28023. * @returns the SPS.
  28024. */
  28025. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28026. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28027. * Returns an array with the removed particles.
  28028. * 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.
  28029. * The SPS can't be empty so at least one particle needs to remain in place.
  28030. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28031. * @param start index of the first particle to remove
  28032. * @param end index of the last particle to remove (included)
  28033. * @returns an array populated with the removed particles
  28034. */
  28035. removeParticles(start: number, end: number): SolidParticle[];
  28036. /**
  28037. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28038. * @param solidParticleArray an array populated with Solid Particles objects
  28039. * @returns the SPS
  28040. */
  28041. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28042. /**
  28043. * Creates a new particle and modifies the SPS mesh geometry :
  28044. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28045. * - calls _addParticle() to populate the particle array
  28046. * factorized code from addShape() and insertParticlesFromArray()
  28047. * @param idx particle index in the particles array
  28048. * @param i particle index in its shape
  28049. * @param modelShape particle ModelShape object
  28050. * @param shape shape vertex array
  28051. * @param meshInd shape indices array
  28052. * @param meshUV shape uv array
  28053. * @param meshCol shape color array
  28054. * @param meshNor shape normals array
  28055. * @param bbInfo shape bounding info
  28056. * @param storage target particle storage
  28057. * @options addShape() passed options
  28058. * @hidden
  28059. */
  28060. private _insertNewParticle;
  28061. /**
  28062. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28063. * This method calls `updateParticle()` for each particle of the SPS.
  28064. * For an animated SPS, it is usually called within the render loop.
  28065. * 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.
  28066. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28067. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28068. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28069. * @returns the SPS.
  28070. */
  28071. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28072. /**
  28073. * Disposes the SPS.
  28074. */
  28075. dispose(): void;
  28076. /**
  28077. * Returns a SolidParticle object from its identifier : particle.id
  28078. * @param id (integer) the particle Id
  28079. * @returns the searched particle or null if not found in the SPS.
  28080. */
  28081. getParticleById(id: number): Nullable<SolidParticle>;
  28082. /**
  28083. * Returns a new array populated with the particles having the passed shapeId.
  28084. * @param shapeId (integer) the shape identifier
  28085. * @returns a new solid particle array
  28086. */
  28087. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28088. /**
  28089. * Populates the passed array "ref" with the particles having the passed shapeId.
  28090. * @param shapeId the shape identifier
  28091. * @returns the SPS
  28092. * @param ref
  28093. */
  28094. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28095. /**
  28096. * Computes the required SubMeshes according the materials assigned to the particles.
  28097. * @returns the solid particle system.
  28098. * Does nothing if called before the SPS mesh is built.
  28099. */
  28100. computeSubMeshes(): SolidParticleSystem;
  28101. /**
  28102. * Sorts the solid particles by material when MultiMaterial is enabled.
  28103. * Updates the indices32 array.
  28104. * Updates the indicesByMaterial array.
  28105. * Updates the mesh indices array.
  28106. * @returns the SPS
  28107. * @hidden
  28108. */
  28109. private _sortParticlesByMaterial;
  28110. /**
  28111. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28112. * @hidden
  28113. */
  28114. private _setMaterialIndexesById;
  28115. /**
  28116. * Returns an array with unique values of Materials from the passed array
  28117. * @param array the material array to be checked and filtered
  28118. * @hidden
  28119. */
  28120. private _filterUniqueMaterialId;
  28121. /**
  28122. * Sets a new Standard Material as _defaultMaterial if not already set.
  28123. * @hidden
  28124. */
  28125. private _setDefaultMaterial;
  28126. /**
  28127. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28128. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28129. * @returns the SPS.
  28130. */
  28131. refreshVisibleSize(): SolidParticleSystem;
  28132. /**
  28133. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28134. * @param size the size (float) of the visibility box
  28135. * note : this doesn't lock the SPS mesh bounding box.
  28136. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28137. */
  28138. setVisibilityBox(size: number): void;
  28139. /**
  28140. * Gets whether the SPS as always visible or not
  28141. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28142. */
  28143. get isAlwaysVisible(): boolean;
  28144. /**
  28145. * Sets the SPS as always visible or not
  28146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28147. */
  28148. set isAlwaysVisible(val: boolean);
  28149. /**
  28150. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28151. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28152. */
  28153. set isVisibilityBoxLocked(val: boolean);
  28154. /**
  28155. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28156. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28157. */
  28158. get isVisibilityBoxLocked(): boolean;
  28159. /**
  28160. * Tells to `setParticles()` to compute 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. set computeParticleRotation(val: boolean);
  28165. /**
  28166. * Tells to `setParticles()` to compute 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. set computeParticleColor(val: boolean);
  28171. set computeParticleTexture(val: boolean);
  28172. /**
  28173. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28174. * Default value : false. The SPS is faster when it's set to false.
  28175. * Note : the particle custom vertex positions aren't stored values.
  28176. */
  28177. set computeParticleVertex(val: boolean);
  28178. /**
  28179. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28180. */
  28181. set computeBoundingBox(val: boolean);
  28182. /**
  28183. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28184. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28185. * Default : `true`
  28186. */
  28187. set depthSortParticles(val: boolean);
  28188. /**
  28189. * Gets if `setParticles()` computes the particle rotations or not.
  28190. * Default value : true. The SPS is faster when it's set to false.
  28191. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28192. */
  28193. get computeParticleRotation(): boolean;
  28194. /**
  28195. * Gets if `setParticles()` computes the particle colors or not.
  28196. * Default value : true. The SPS is faster when it's set to false.
  28197. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28198. */
  28199. get computeParticleColor(): boolean;
  28200. /**
  28201. * Gets if `setParticles()` computes the particle textures or not.
  28202. * Default value : true. The SPS is faster when it's set to false.
  28203. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28204. */
  28205. get computeParticleTexture(): boolean;
  28206. /**
  28207. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28208. * Default value : false. The SPS is faster when it's set to false.
  28209. * Note : the particle custom vertex positions aren't stored values.
  28210. */
  28211. get computeParticleVertex(): boolean;
  28212. /**
  28213. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28214. */
  28215. get computeBoundingBox(): boolean;
  28216. /**
  28217. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28218. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28219. * Default : `true`
  28220. */
  28221. get depthSortParticles(): boolean;
  28222. /**
  28223. * Gets if the SPS is created as expandable at construction time.
  28224. * Default : `false`
  28225. */
  28226. get expandable(): boolean;
  28227. /**
  28228. * Gets if the SPS supports the Multi Materials
  28229. */
  28230. get multimaterialEnabled(): boolean;
  28231. /**
  28232. * Gets if the SPS uses the model materials for its own multimaterial.
  28233. */
  28234. get useModelMaterial(): boolean;
  28235. /**
  28236. * The SPS used material array.
  28237. */
  28238. get materials(): Material[];
  28239. /**
  28240. * Sets the SPS MultiMaterial from the passed materials.
  28241. * Note : the passed array is internally copied and not used then by reference.
  28242. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28243. */
  28244. setMultiMaterial(materials: Material[]): void;
  28245. /**
  28246. * The SPS computed multimaterial object
  28247. */
  28248. get multimaterial(): MultiMaterial;
  28249. set multimaterial(mm: MultiMaterial);
  28250. /**
  28251. * If the subMeshes must be updated on the next call to setParticles()
  28252. */
  28253. get autoUpdateSubMeshes(): boolean;
  28254. set autoUpdateSubMeshes(val: boolean);
  28255. /**
  28256. * This function does nothing. It may be overwritten to set all the particle first values.
  28257. * The SPS doesn't call this function, you may have to call it by your own.
  28258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28259. */
  28260. initParticles(): void;
  28261. /**
  28262. * This function does nothing. It may be overwritten to recycle a particle.
  28263. * The SPS doesn't call this function, you may have to call it by your own.
  28264. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28265. * @param particle The particle to recycle
  28266. * @returns the recycled particle
  28267. */
  28268. recycleParticle(particle: SolidParticle): SolidParticle;
  28269. /**
  28270. * Updates a particle : this function should be overwritten by the user.
  28271. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28272. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28273. * @example : just set a particle position or velocity and recycle conditions
  28274. * @param particle The particle to update
  28275. * @returns the updated particle
  28276. */
  28277. updateParticle(particle: SolidParticle): SolidParticle;
  28278. /**
  28279. * Updates a vertex of a particle : it can be overwritten by the user.
  28280. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28281. * @param particle the current particle
  28282. * @param vertex the current index of the current particle
  28283. * @param pt the index of the current vertex in the particle shape
  28284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28285. * @example : just set a vertex particle position
  28286. * @returns the updated vertex
  28287. */
  28288. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28289. /**
  28290. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28291. * This does nothing and may be overwritten by the user.
  28292. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28293. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28294. * @param update the boolean update value actually passed to setParticles()
  28295. */
  28296. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28297. /**
  28298. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28299. * This will be passed three parameters.
  28300. * This does nothing and may be overwritten by the user.
  28301. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28302. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28303. * @param update the boolean update value actually passed to setParticles()
  28304. */
  28305. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28306. }
  28307. }
  28308. declare module "babylonjs/Particles/solidParticle" {
  28309. import { Nullable } from "babylonjs/types";
  28310. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28311. import { Color4 } from "babylonjs/Maths/math.color";
  28312. import { Mesh } from "babylonjs/Meshes/mesh";
  28313. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28314. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28315. import { Plane } from "babylonjs/Maths/math.plane";
  28316. import { Material } from "babylonjs/Materials/material";
  28317. /**
  28318. * Represents one particle of a solid particle system.
  28319. */
  28320. export class SolidParticle {
  28321. /**
  28322. * particle global index
  28323. */
  28324. idx: number;
  28325. /**
  28326. * particle identifier
  28327. */
  28328. id: number;
  28329. /**
  28330. * The color of the particle
  28331. */
  28332. color: Nullable<Color4>;
  28333. /**
  28334. * The world space position of the particle.
  28335. */
  28336. position: Vector3;
  28337. /**
  28338. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28339. */
  28340. rotation: Vector3;
  28341. /**
  28342. * The world space rotation quaternion of the particle.
  28343. */
  28344. rotationQuaternion: Nullable<Quaternion>;
  28345. /**
  28346. * The scaling of the particle.
  28347. */
  28348. scaling: Vector3;
  28349. /**
  28350. * The uvs of the particle.
  28351. */
  28352. uvs: Vector4;
  28353. /**
  28354. * The current speed of the particle.
  28355. */
  28356. velocity: Vector3;
  28357. /**
  28358. * The pivot point in the particle local space.
  28359. */
  28360. pivot: Vector3;
  28361. /**
  28362. * Must the particle be translated from its pivot point in its local space ?
  28363. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28364. * Default : false
  28365. */
  28366. translateFromPivot: boolean;
  28367. /**
  28368. * Is the particle active or not ?
  28369. */
  28370. alive: boolean;
  28371. /**
  28372. * Is the particle visible or not ?
  28373. */
  28374. isVisible: boolean;
  28375. /**
  28376. * Index of this particle in the global "positions" array (Internal use)
  28377. * @hidden
  28378. */
  28379. _pos: number;
  28380. /**
  28381. * @hidden Index of this particle in the global "indices" array (Internal use)
  28382. */
  28383. _ind: number;
  28384. /**
  28385. * @hidden ModelShape of this particle (Internal use)
  28386. */
  28387. _model: ModelShape;
  28388. /**
  28389. * ModelShape id of this particle
  28390. */
  28391. shapeId: number;
  28392. /**
  28393. * Index of the particle in its shape id
  28394. */
  28395. idxInShape: number;
  28396. /**
  28397. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28398. */
  28399. _modelBoundingInfo: BoundingInfo;
  28400. /**
  28401. * @hidden Particle BoundingInfo object (Internal use)
  28402. */
  28403. _boundingInfo: BoundingInfo;
  28404. /**
  28405. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28406. */
  28407. _sps: SolidParticleSystem;
  28408. /**
  28409. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28410. */
  28411. _stillInvisible: boolean;
  28412. /**
  28413. * @hidden Last computed particle rotation matrix
  28414. */
  28415. _rotationMatrix: number[];
  28416. /**
  28417. * Parent particle Id, if any.
  28418. * Default null.
  28419. */
  28420. parentId: Nullable<number>;
  28421. /**
  28422. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28423. */
  28424. materialIndex: Nullable<number>;
  28425. /**
  28426. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28427. * The possible values are :
  28428. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28429. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28430. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28431. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28432. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28433. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28434. * */
  28435. cullingStrategy: number;
  28436. /**
  28437. * @hidden Internal global position in the SPS.
  28438. */
  28439. _globalPosition: Vector3;
  28440. /**
  28441. * Creates a Solid Particle object.
  28442. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28443. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28444. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28445. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28446. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28447. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28448. * @param shapeId (integer) is the model shape identifier in the SPS.
  28449. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28450. * @param sps defines the sps it is associated to
  28451. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28452. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28453. */
  28454. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28455. /**
  28456. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28457. * @param target the particle target
  28458. * @returns the current particle
  28459. */
  28460. copyToRef(target: SolidParticle): SolidParticle;
  28461. /**
  28462. * Legacy support, changed scale to scaling
  28463. */
  28464. get scale(): Vector3;
  28465. /**
  28466. * Legacy support, changed scale to scaling
  28467. */
  28468. set scale(scale: Vector3);
  28469. /**
  28470. * Legacy support, changed quaternion to rotationQuaternion
  28471. */
  28472. get quaternion(): Nullable<Quaternion>;
  28473. /**
  28474. * Legacy support, changed quaternion to rotationQuaternion
  28475. */
  28476. set quaternion(q: Nullable<Quaternion>);
  28477. /**
  28478. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28479. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28480. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28481. * @returns true if it intersects
  28482. */
  28483. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28484. /**
  28485. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28486. * A particle is in the frustum if its bounding box intersects the frustum
  28487. * @param frustumPlanes defines the frustum to test
  28488. * @returns true if the particle is in the frustum planes
  28489. */
  28490. isInFrustum(frustumPlanes: Plane[]): boolean;
  28491. /**
  28492. * get the rotation matrix of the particle
  28493. * @hidden
  28494. */
  28495. getRotationMatrix(m: Matrix): void;
  28496. }
  28497. /**
  28498. * Represents the shape of the model used by one particle of a solid particle system.
  28499. * SPS internal tool, don't use it manually.
  28500. */
  28501. export class ModelShape {
  28502. /**
  28503. * The shape id
  28504. * @hidden
  28505. */
  28506. shapeID: number;
  28507. /**
  28508. * flat array of model positions (internal use)
  28509. * @hidden
  28510. */
  28511. _shape: Vector3[];
  28512. /**
  28513. * flat array of model UVs (internal use)
  28514. * @hidden
  28515. */
  28516. _shapeUV: number[];
  28517. /**
  28518. * color array of the model
  28519. * @hidden
  28520. */
  28521. _shapeColors: number[];
  28522. /**
  28523. * indices array of the model
  28524. * @hidden
  28525. */
  28526. _indices: number[];
  28527. /**
  28528. * normals array of the model
  28529. * @hidden
  28530. */
  28531. _normals: number[];
  28532. /**
  28533. * length of the shape in the model indices array (internal use)
  28534. * @hidden
  28535. */
  28536. _indicesLength: number;
  28537. /**
  28538. * Custom position function (internal use)
  28539. * @hidden
  28540. */
  28541. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28542. /**
  28543. * Custom vertex function (internal use)
  28544. * @hidden
  28545. */
  28546. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28547. /**
  28548. * Model material (internal use)
  28549. * @hidden
  28550. */
  28551. _material: Nullable<Material>;
  28552. /**
  28553. * 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.
  28554. * SPS internal tool, don't use it manually.
  28555. * @hidden
  28556. */
  28557. 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>);
  28558. }
  28559. /**
  28560. * Represents a Depth Sorted Particle in the solid particle system.
  28561. * @hidden
  28562. */
  28563. export class DepthSortedParticle {
  28564. /**
  28565. * Index of the particle in the "indices" array
  28566. */
  28567. ind: number;
  28568. /**
  28569. * Length of the particle shape in the "indices" array
  28570. */
  28571. indicesLength: number;
  28572. /**
  28573. * Squared distance from the particle to the camera
  28574. */
  28575. sqDistance: number;
  28576. /**
  28577. * Material index when used with MultiMaterials
  28578. */
  28579. materialIndex: number;
  28580. /**
  28581. * Creates a new sorted particle
  28582. * @param materialIndex
  28583. */
  28584. constructor(ind: number, indLength: number, materialIndex: number);
  28585. }
  28586. }
  28587. declare module "babylonjs/Collisions/meshCollisionData" {
  28588. import { Collider } from "babylonjs/Collisions/collider";
  28589. import { Vector3 } from "babylonjs/Maths/math.vector";
  28590. import { Nullable } from "babylonjs/types";
  28591. import { Observer } from "babylonjs/Misc/observable";
  28592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28593. /**
  28594. * @hidden
  28595. */
  28596. export class _MeshCollisionData {
  28597. _checkCollisions: boolean;
  28598. _collisionMask: number;
  28599. _collisionGroup: number;
  28600. _collider: Nullable<Collider>;
  28601. _oldPositionForCollisions: Vector3;
  28602. _diffPositionForCollisions: Vector3;
  28603. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28604. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28605. }
  28606. }
  28607. declare module "babylonjs/Meshes/abstractMesh" {
  28608. import { Observable } from "babylonjs/Misc/observable";
  28609. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28610. import { Camera } from "babylonjs/Cameras/camera";
  28611. import { Scene, IDisposable } from "babylonjs/scene";
  28612. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28613. import { Node } from "babylonjs/node";
  28614. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28615. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28616. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28617. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28618. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28619. import { Material } from "babylonjs/Materials/material";
  28620. import { Light } from "babylonjs/Lights/light";
  28621. import { Skeleton } from "babylonjs/Bones/skeleton";
  28622. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28623. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28624. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28625. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28626. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28627. import { Plane } from "babylonjs/Maths/math.plane";
  28628. import { Ray } from "babylonjs/Culling/ray";
  28629. import { Collider } from "babylonjs/Collisions/collider";
  28630. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28631. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28632. /** @hidden */
  28633. class _FacetDataStorage {
  28634. facetPositions: Vector3[];
  28635. facetNormals: Vector3[];
  28636. facetPartitioning: number[][];
  28637. facetNb: number;
  28638. partitioningSubdivisions: number;
  28639. partitioningBBoxRatio: number;
  28640. facetDataEnabled: boolean;
  28641. facetParameters: any;
  28642. bbSize: Vector3;
  28643. subDiv: {
  28644. max: number;
  28645. X: number;
  28646. Y: number;
  28647. Z: number;
  28648. };
  28649. facetDepthSort: boolean;
  28650. facetDepthSortEnabled: boolean;
  28651. depthSortedIndices: IndicesArray;
  28652. depthSortedFacets: {
  28653. ind: number;
  28654. sqDistance: number;
  28655. }[];
  28656. facetDepthSortFunction: (f1: {
  28657. ind: number;
  28658. sqDistance: number;
  28659. }, f2: {
  28660. ind: number;
  28661. sqDistance: number;
  28662. }) => number;
  28663. facetDepthSortFrom: Vector3;
  28664. facetDepthSortOrigin: Vector3;
  28665. invertedMatrix: Matrix;
  28666. }
  28667. /**
  28668. * @hidden
  28669. **/
  28670. class _InternalAbstractMeshDataInfo {
  28671. _hasVertexAlpha: boolean;
  28672. _useVertexColors: boolean;
  28673. _numBoneInfluencers: number;
  28674. _applyFog: boolean;
  28675. _receiveShadows: boolean;
  28676. _facetData: _FacetDataStorage;
  28677. _visibility: number;
  28678. _skeleton: Nullable<Skeleton>;
  28679. _layerMask: number;
  28680. _computeBonesUsingShaders: boolean;
  28681. _isActive: boolean;
  28682. _onlyForInstances: boolean;
  28683. _isActiveIntermediate: boolean;
  28684. _onlyForInstancesIntermediate: boolean;
  28685. _actAsRegularMesh: boolean;
  28686. }
  28687. /**
  28688. * Class used to store all common mesh properties
  28689. */
  28690. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28691. /** No occlusion */
  28692. static OCCLUSION_TYPE_NONE: number;
  28693. /** Occlusion set to optimisitic */
  28694. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28695. /** Occlusion set to strict */
  28696. static OCCLUSION_TYPE_STRICT: number;
  28697. /** Use an accurante occlusion algorithm */
  28698. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28699. /** Use a conservative occlusion algorithm */
  28700. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28701. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28702. * Test order :
  28703. * Is the bounding sphere outside the frustum ?
  28704. * If not, are the bounding box vertices outside the frustum ?
  28705. * It not, then the cullable object is in the frustum.
  28706. */
  28707. static readonly CULLINGSTRATEGY_STANDARD: number;
  28708. /** Culling strategy : Bounding Sphere Only.
  28709. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28710. * It's also less accurate than the standard because some not visible objects can still be selected.
  28711. * Test : is the bounding sphere outside the frustum ?
  28712. * If not, then the cullable object is in the frustum.
  28713. */
  28714. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28715. /** Culling strategy : Optimistic Inclusion.
  28716. * This in an inclusion test first, then the standard exclusion test.
  28717. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28718. * 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.
  28719. * Anyway, it's as accurate as the standard strategy.
  28720. * Test :
  28721. * Is the cullable object bounding sphere center in the frustum ?
  28722. * If not, apply the default culling strategy.
  28723. */
  28724. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28725. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28726. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28727. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28728. * 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.
  28729. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28730. * Test :
  28731. * Is the cullable object bounding sphere center in the frustum ?
  28732. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28733. */
  28734. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28735. /**
  28736. * No billboard
  28737. */
  28738. static get BILLBOARDMODE_NONE(): number;
  28739. /** Billboard on X axis */
  28740. static get BILLBOARDMODE_X(): number;
  28741. /** Billboard on Y axis */
  28742. static get BILLBOARDMODE_Y(): number;
  28743. /** Billboard on Z axis */
  28744. static get BILLBOARDMODE_Z(): number;
  28745. /** Billboard on all axes */
  28746. static get BILLBOARDMODE_ALL(): number;
  28747. /** Billboard on using position instead of orientation */
  28748. static get BILLBOARDMODE_USE_POSITION(): number;
  28749. /** @hidden */
  28750. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28751. /**
  28752. * The culling strategy to use to check whether the mesh must be rendered or not.
  28753. * This value can be changed at any time and will be used on the next render mesh selection.
  28754. * The possible values are :
  28755. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28756. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28758. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28759. * Please read each static variable documentation to get details about the culling process.
  28760. * */
  28761. cullingStrategy: number;
  28762. /**
  28763. * Gets the number of facets in the mesh
  28764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28765. */
  28766. get facetNb(): number;
  28767. /**
  28768. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28769. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28770. */
  28771. get partitioningSubdivisions(): number;
  28772. set partitioningSubdivisions(nb: number);
  28773. /**
  28774. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28775. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28777. */
  28778. get partitioningBBoxRatio(): number;
  28779. set partitioningBBoxRatio(ratio: number);
  28780. /**
  28781. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28782. * Works only for updatable meshes.
  28783. * Doesn't work with multi-materials
  28784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28785. */
  28786. get mustDepthSortFacets(): boolean;
  28787. set mustDepthSortFacets(sort: boolean);
  28788. /**
  28789. * The location (Vector3) where the facet depth sort must be computed from.
  28790. * By default, the active camera position.
  28791. * Used only when facet depth sort is enabled
  28792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28793. */
  28794. get facetDepthSortFrom(): Vector3;
  28795. set facetDepthSortFrom(location: Vector3);
  28796. /**
  28797. * gets a boolean indicating if facetData is enabled
  28798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28799. */
  28800. get isFacetDataEnabled(): boolean;
  28801. /** @hidden */
  28802. _updateNonUniformScalingState(value: boolean): boolean;
  28803. /**
  28804. * An event triggered when this mesh collides with another one
  28805. */
  28806. onCollideObservable: Observable<AbstractMesh>;
  28807. /** Set a function to call when this mesh collides with another one */
  28808. set onCollide(callback: () => void);
  28809. /**
  28810. * An event triggered when the collision's position changes
  28811. */
  28812. onCollisionPositionChangeObservable: Observable<Vector3>;
  28813. /** Set a function to call when the collision's position changes */
  28814. set onCollisionPositionChange(callback: () => void);
  28815. /**
  28816. * An event triggered when material is changed
  28817. */
  28818. onMaterialChangedObservable: Observable<AbstractMesh>;
  28819. /**
  28820. * Gets or sets the orientation for POV movement & rotation
  28821. */
  28822. definedFacingForward: boolean;
  28823. /** @hidden */
  28824. _occlusionQuery: Nullable<WebGLQuery>;
  28825. /** @hidden */
  28826. _renderingGroup: Nullable<RenderingGroup>;
  28827. /**
  28828. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28829. */
  28830. get visibility(): number;
  28831. /**
  28832. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28833. */
  28834. set visibility(value: number);
  28835. /** Gets or sets the alpha index used to sort transparent meshes
  28836. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28837. */
  28838. alphaIndex: number;
  28839. /**
  28840. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28841. */
  28842. isVisible: boolean;
  28843. /**
  28844. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28845. */
  28846. isPickable: boolean;
  28847. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28848. showSubMeshesBoundingBox: boolean;
  28849. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28850. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28851. */
  28852. isBlocker: boolean;
  28853. /**
  28854. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28855. */
  28856. enablePointerMoveEvents: boolean;
  28857. /**
  28858. * Specifies the rendering group id for this mesh (0 by default)
  28859. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28860. */
  28861. renderingGroupId: number;
  28862. private _material;
  28863. /** Gets or sets current material */
  28864. get material(): Nullable<Material>;
  28865. set material(value: Nullable<Material>);
  28866. /**
  28867. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28868. * @see http://doc.babylonjs.com/babylon101/shadows
  28869. */
  28870. get receiveShadows(): boolean;
  28871. set receiveShadows(value: boolean);
  28872. /** Defines color to use when rendering outline */
  28873. outlineColor: Color3;
  28874. /** Define width to use when rendering outline */
  28875. outlineWidth: number;
  28876. /** Defines color to use when rendering overlay */
  28877. overlayColor: Color3;
  28878. /** Defines alpha to use when rendering overlay */
  28879. overlayAlpha: number;
  28880. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28881. get hasVertexAlpha(): boolean;
  28882. set hasVertexAlpha(value: boolean);
  28883. /** 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) */
  28884. get useVertexColors(): boolean;
  28885. set useVertexColors(value: boolean);
  28886. /**
  28887. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28888. */
  28889. get computeBonesUsingShaders(): boolean;
  28890. set computeBonesUsingShaders(value: boolean);
  28891. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28892. get numBoneInfluencers(): number;
  28893. set numBoneInfluencers(value: number);
  28894. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28895. get applyFog(): boolean;
  28896. set applyFog(value: boolean);
  28897. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28898. useOctreeForRenderingSelection: boolean;
  28899. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28900. useOctreeForPicking: boolean;
  28901. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28902. useOctreeForCollisions: boolean;
  28903. /**
  28904. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28905. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28906. */
  28907. get layerMask(): number;
  28908. set layerMask(value: number);
  28909. /**
  28910. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28911. */
  28912. alwaysSelectAsActiveMesh: boolean;
  28913. /**
  28914. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28915. */
  28916. doNotSyncBoundingInfo: boolean;
  28917. /**
  28918. * Gets or sets the current action manager
  28919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28920. */
  28921. actionManager: Nullable<AbstractActionManager>;
  28922. private _meshCollisionData;
  28923. /**
  28924. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28925. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28926. */
  28927. ellipsoid: Vector3;
  28928. /**
  28929. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28930. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28931. */
  28932. ellipsoidOffset: Vector3;
  28933. /**
  28934. * Gets or sets a collision mask used to mask collisions (default is -1).
  28935. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28936. */
  28937. get collisionMask(): number;
  28938. set collisionMask(mask: number);
  28939. /**
  28940. * Gets or sets the current collision group mask (-1 by default).
  28941. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28942. */
  28943. get collisionGroup(): number;
  28944. set collisionGroup(mask: number);
  28945. /**
  28946. * Defines edge width used when edgesRenderer is enabled
  28947. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28948. */
  28949. edgesWidth: number;
  28950. /**
  28951. * Defines edge color used when edgesRenderer is enabled
  28952. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28953. */
  28954. edgesColor: Color4;
  28955. /** @hidden */
  28956. _edgesRenderer: Nullable<IEdgesRenderer>;
  28957. /** @hidden */
  28958. _masterMesh: Nullable<AbstractMesh>;
  28959. /** @hidden */
  28960. _boundingInfo: Nullable<BoundingInfo>;
  28961. /** @hidden */
  28962. _renderId: number;
  28963. /**
  28964. * Gets or sets the list of subMeshes
  28965. * @see http://doc.babylonjs.com/how_to/multi_materials
  28966. */
  28967. subMeshes: SubMesh[];
  28968. /** @hidden */
  28969. _intersectionsInProgress: AbstractMesh[];
  28970. /** @hidden */
  28971. _unIndexed: boolean;
  28972. /** @hidden */
  28973. _lightSources: Light[];
  28974. /** Gets the list of lights affecting that mesh */
  28975. get lightSources(): Light[];
  28976. /** @hidden */
  28977. get _positions(): Nullable<Vector3[]>;
  28978. /** @hidden */
  28979. _waitingData: {
  28980. lods: Nullable<any>;
  28981. actions: Nullable<any>;
  28982. freezeWorldMatrix: Nullable<boolean>;
  28983. };
  28984. /** @hidden */
  28985. _bonesTransformMatrices: Nullable<Float32Array>;
  28986. /** @hidden */
  28987. _transformMatrixTexture: Nullable<RawTexture>;
  28988. /**
  28989. * Gets or sets a skeleton to apply skining transformations
  28990. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28991. */
  28992. set skeleton(value: Nullable<Skeleton>);
  28993. get skeleton(): Nullable<Skeleton>;
  28994. /**
  28995. * An event triggered when the mesh is rebuilt.
  28996. */
  28997. onRebuildObservable: Observable<AbstractMesh>;
  28998. /**
  28999. * Creates a new AbstractMesh
  29000. * @param name defines the name of the mesh
  29001. * @param scene defines the hosting scene
  29002. */
  29003. constructor(name: string, scene?: Nullable<Scene>);
  29004. /**
  29005. * Returns the string "AbstractMesh"
  29006. * @returns "AbstractMesh"
  29007. */
  29008. getClassName(): string;
  29009. /**
  29010. * Gets a string representation of the current mesh
  29011. * @param fullDetails defines a boolean indicating if full details must be included
  29012. * @returns a string representation of the current mesh
  29013. */
  29014. toString(fullDetails?: boolean): string;
  29015. /**
  29016. * @hidden
  29017. */
  29018. protected _getEffectiveParent(): Nullable<Node>;
  29019. /** @hidden */
  29020. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29021. /** @hidden */
  29022. _rebuild(): void;
  29023. /** @hidden */
  29024. _resyncLightSources(): void;
  29025. /** @hidden */
  29026. _resyncLightSource(light: Light): void;
  29027. /** @hidden */
  29028. _unBindEffect(): void;
  29029. /** @hidden */
  29030. _removeLightSource(light: Light, dispose: boolean): void;
  29031. private _markSubMeshesAsDirty;
  29032. /** @hidden */
  29033. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29034. /** @hidden */
  29035. _markSubMeshesAsAttributesDirty(): void;
  29036. /** @hidden */
  29037. _markSubMeshesAsMiscDirty(): void;
  29038. /**
  29039. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29040. */
  29041. get scaling(): Vector3;
  29042. set scaling(newScaling: Vector3);
  29043. /**
  29044. * Returns true if the mesh is blocked. Implemented by child classes
  29045. */
  29046. get isBlocked(): boolean;
  29047. /**
  29048. * Returns the mesh itself by default. Implemented by child classes
  29049. * @param camera defines the camera to use to pick the right LOD level
  29050. * @returns the currentAbstractMesh
  29051. */
  29052. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29053. /**
  29054. * Returns 0 by default. Implemented by child classes
  29055. * @returns an integer
  29056. */
  29057. getTotalVertices(): number;
  29058. /**
  29059. * Returns a positive integer : the total number of indices in this mesh geometry.
  29060. * @returns the numner of indices or zero if the mesh has no geometry.
  29061. */
  29062. getTotalIndices(): number;
  29063. /**
  29064. * Returns null by default. Implemented by child classes
  29065. * @returns null
  29066. */
  29067. getIndices(): Nullable<IndicesArray>;
  29068. /**
  29069. * Returns the array of the requested vertex data kind. Implemented by child classes
  29070. * @param kind defines the vertex data kind to use
  29071. * @returns null
  29072. */
  29073. getVerticesData(kind: string): Nullable<FloatArray>;
  29074. /**
  29075. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29076. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29077. * Note that a new underlying VertexBuffer object is created each call.
  29078. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29079. * @param kind defines vertex data kind:
  29080. * * VertexBuffer.PositionKind
  29081. * * VertexBuffer.UVKind
  29082. * * VertexBuffer.UV2Kind
  29083. * * VertexBuffer.UV3Kind
  29084. * * VertexBuffer.UV4Kind
  29085. * * VertexBuffer.UV5Kind
  29086. * * VertexBuffer.UV6Kind
  29087. * * VertexBuffer.ColorKind
  29088. * * VertexBuffer.MatricesIndicesKind
  29089. * * VertexBuffer.MatricesIndicesExtraKind
  29090. * * VertexBuffer.MatricesWeightsKind
  29091. * * VertexBuffer.MatricesWeightsExtraKind
  29092. * @param data defines the data source
  29093. * @param updatable defines if the data must be flagged as updatable (or static)
  29094. * @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
  29095. * @returns the current mesh
  29096. */
  29097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29098. /**
  29099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29100. * If the mesh has no geometry, it is simply returned as it is.
  29101. * @param kind defines vertex data kind:
  29102. * * VertexBuffer.PositionKind
  29103. * * VertexBuffer.UVKind
  29104. * * VertexBuffer.UV2Kind
  29105. * * VertexBuffer.UV3Kind
  29106. * * VertexBuffer.UV4Kind
  29107. * * VertexBuffer.UV5Kind
  29108. * * VertexBuffer.UV6Kind
  29109. * * VertexBuffer.ColorKind
  29110. * * VertexBuffer.MatricesIndicesKind
  29111. * * VertexBuffer.MatricesIndicesExtraKind
  29112. * * VertexBuffer.MatricesWeightsKind
  29113. * * VertexBuffer.MatricesWeightsExtraKind
  29114. * @param data defines the data source
  29115. * @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
  29116. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29117. * @returns the current mesh
  29118. */
  29119. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29120. /**
  29121. * Sets the mesh indices,
  29122. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29123. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29124. * @param totalVertices Defines the total number of vertices
  29125. * @returns the current mesh
  29126. */
  29127. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29128. /**
  29129. * Gets a boolean indicating if specific vertex data is present
  29130. * @param kind defines the vertex data kind to use
  29131. * @returns true is data kind is present
  29132. */
  29133. isVerticesDataPresent(kind: string): boolean;
  29134. /**
  29135. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29136. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29137. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29138. * @returns a BoundingInfo
  29139. */
  29140. getBoundingInfo(): BoundingInfo;
  29141. /**
  29142. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29143. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29144. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29145. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29146. * @returns the current mesh
  29147. */
  29148. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29149. /**
  29150. * Overwrite the current bounding info
  29151. * @param boundingInfo defines the new bounding info
  29152. * @returns the current mesh
  29153. */
  29154. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29155. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29156. get useBones(): boolean;
  29157. /** @hidden */
  29158. _preActivate(): void;
  29159. /** @hidden */
  29160. _preActivateForIntermediateRendering(renderId: number): void;
  29161. /** @hidden */
  29162. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29163. /** @hidden */
  29164. _postActivate(): void;
  29165. /** @hidden */
  29166. _freeze(): void;
  29167. /** @hidden */
  29168. _unFreeze(): void;
  29169. /**
  29170. * Gets the current world matrix
  29171. * @returns a Matrix
  29172. */
  29173. getWorldMatrix(): Matrix;
  29174. /** @hidden */
  29175. _getWorldMatrixDeterminant(): number;
  29176. /**
  29177. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29178. */
  29179. get isAnInstance(): boolean;
  29180. /**
  29181. * Gets a boolean indicating if this mesh has instances
  29182. */
  29183. get hasInstances(): boolean;
  29184. /**
  29185. * Perform relative position change from the point of view of behind the front of the mesh.
  29186. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29187. * Supports definition of mesh facing forward or backward
  29188. * @param amountRight defines the distance on the right axis
  29189. * @param amountUp defines the distance on the up axis
  29190. * @param amountForward defines the distance on the forward axis
  29191. * @returns the current mesh
  29192. */
  29193. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29194. /**
  29195. * Calculate relative position change from the point of view of behind the front of the mesh.
  29196. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29197. * Supports definition of mesh facing forward or backward
  29198. * @param amountRight defines the distance on the right axis
  29199. * @param amountUp defines the distance on the up axis
  29200. * @param amountForward defines the distance on the forward axis
  29201. * @returns the new displacement vector
  29202. */
  29203. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29204. /**
  29205. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29206. * Supports definition of mesh facing forward or backward
  29207. * @param flipBack defines the flip
  29208. * @param twirlClockwise defines the twirl
  29209. * @param tiltRight defines the tilt
  29210. * @returns the current mesh
  29211. */
  29212. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29213. /**
  29214. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29215. * Supports definition of mesh facing forward or backward.
  29216. * @param flipBack defines the flip
  29217. * @param twirlClockwise defines the twirl
  29218. * @param tiltRight defines the tilt
  29219. * @returns the new rotation vector
  29220. */
  29221. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29222. /**
  29223. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29224. * This means the mesh underlying bounding box and sphere are recomputed.
  29225. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29226. * @returns the current mesh
  29227. */
  29228. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29229. /** @hidden */
  29230. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29231. /** @hidden */
  29232. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29233. /** @hidden */
  29234. _updateBoundingInfo(): AbstractMesh;
  29235. /** @hidden */
  29236. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29237. /** @hidden */
  29238. protected _afterComputeWorldMatrix(): void;
  29239. /** @hidden */
  29240. get _effectiveMesh(): AbstractMesh;
  29241. /**
  29242. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29243. * A mesh is in the frustum if its bounding box intersects the frustum
  29244. * @param frustumPlanes defines the frustum to test
  29245. * @returns true if the mesh is in the frustum planes
  29246. */
  29247. isInFrustum(frustumPlanes: Plane[]): boolean;
  29248. /**
  29249. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29250. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29251. * @param frustumPlanes defines the frustum to test
  29252. * @returns true if the mesh is completely in the frustum planes
  29253. */
  29254. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29255. /**
  29256. * True if the mesh intersects another mesh or a SolidParticle object
  29257. * @param mesh defines a target mesh or SolidParticle to test
  29258. * @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)
  29259. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29260. * @returns true if there is an intersection
  29261. */
  29262. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29263. /**
  29264. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29265. * @param point defines the point to test
  29266. * @returns true if there is an intersection
  29267. */
  29268. intersectsPoint(point: Vector3): boolean;
  29269. /**
  29270. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29271. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29272. */
  29273. get checkCollisions(): boolean;
  29274. set checkCollisions(collisionEnabled: boolean);
  29275. /**
  29276. * Gets Collider object used to compute collisions (not physics)
  29277. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29278. */
  29279. get collider(): Nullable<Collider>;
  29280. /**
  29281. * Move the mesh using collision engine
  29282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29283. * @param displacement defines the requested displacement vector
  29284. * @returns the current mesh
  29285. */
  29286. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29287. private _onCollisionPositionChange;
  29288. /** @hidden */
  29289. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29290. /** @hidden */
  29291. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29292. /** @hidden */
  29293. _checkCollision(collider: Collider): AbstractMesh;
  29294. /** @hidden */
  29295. _generatePointsArray(): boolean;
  29296. /**
  29297. * Checks if the passed Ray intersects with the mesh
  29298. * @param ray defines the ray to use
  29299. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29300. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29301. * @returns the picking info
  29302. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29303. */
  29304. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29305. /**
  29306. * Clones the current mesh
  29307. * @param name defines the mesh name
  29308. * @param newParent defines the new mesh parent
  29309. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29310. * @returns the new mesh
  29311. */
  29312. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29313. /**
  29314. * Disposes all the submeshes of the current meshnp
  29315. * @returns the current mesh
  29316. */
  29317. releaseSubMeshes(): AbstractMesh;
  29318. /**
  29319. * Releases resources associated with this abstract mesh.
  29320. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29321. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29322. */
  29323. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29324. /**
  29325. * Adds the passed mesh as a child to the current mesh
  29326. * @param mesh defines the child mesh
  29327. * @returns the current mesh
  29328. */
  29329. addChild(mesh: AbstractMesh): AbstractMesh;
  29330. /**
  29331. * Removes the passed mesh from the current mesh children list
  29332. * @param mesh defines the child mesh
  29333. * @returns the current mesh
  29334. */
  29335. removeChild(mesh: AbstractMesh): AbstractMesh;
  29336. /** @hidden */
  29337. private _initFacetData;
  29338. /**
  29339. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29340. * This method can be called within the render loop.
  29341. * 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
  29342. * @returns the current mesh
  29343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29344. */
  29345. updateFacetData(): AbstractMesh;
  29346. /**
  29347. * Returns the facetLocalNormals array.
  29348. * The normals are expressed in the mesh local spac
  29349. * @returns an array of Vector3
  29350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29351. */
  29352. getFacetLocalNormals(): Vector3[];
  29353. /**
  29354. * Returns the facetLocalPositions array.
  29355. * The facet positions are expressed in the mesh local space
  29356. * @returns an array of Vector3
  29357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29358. */
  29359. getFacetLocalPositions(): Vector3[];
  29360. /**
  29361. * Returns the facetLocalPartioning array
  29362. * @returns an array of array of numbers
  29363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29364. */
  29365. getFacetLocalPartitioning(): number[][];
  29366. /**
  29367. * Returns the i-th facet position in the world system.
  29368. * This method allocates a new Vector3 per call
  29369. * @param i defines the facet index
  29370. * @returns a new Vector3
  29371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29372. */
  29373. getFacetPosition(i: number): Vector3;
  29374. /**
  29375. * Sets the reference Vector3 with the i-th facet position in the world system
  29376. * @param i defines the facet index
  29377. * @param ref defines the target vector
  29378. * @returns the current mesh
  29379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29380. */
  29381. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29382. /**
  29383. * Returns the i-th facet normal in the world system.
  29384. * This method allocates a new Vector3 per call
  29385. * @param i defines the facet index
  29386. * @returns a new Vector3
  29387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29388. */
  29389. getFacetNormal(i: number): Vector3;
  29390. /**
  29391. * Sets the reference Vector3 with the i-th facet normal in the world system
  29392. * @param i defines the facet index
  29393. * @param ref defines the target vector
  29394. * @returns the current mesh
  29395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29396. */
  29397. getFacetNormalToRef(i: number, ref: Vector3): this;
  29398. /**
  29399. * 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)
  29400. * @param x defines x coordinate
  29401. * @param y defines y coordinate
  29402. * @param z defines z coordinate
  29403. * @returns the array of facet indexes
  29404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29405. */
  29406. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29407. /**
  29408. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29409. * @param projected sets as the (x,y,z) world projection on the facet
  29410. * @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
  29411. * @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
  29412. * @param x defines x coordinate
  29413. * @param y defines y coordinate
  29414. * @param z defines z coordinate
  29415. * @returns the face index if found (or null instead)
  29416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29417. */
  29418. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29419. /**
  29420. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29421. * @param projected sets as the (x,y,z) local projection on the facet
  29422. * @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
  29423. * @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
  29424. * @param x defines x coordinate
  29425. * @param y defines y coordinate
  29426. * @param z defines z coordinate
  29427. * @returns the face index if found (or null instead)
  29428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29429. */
  29430. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29431. /**
  29432. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29433. * @returns the parameters
  29434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29435. */
  29436. getFacetDataParameters(): any;
  29437. /**
  29438. * Disables the feature FacetData and frees the related memory
  29439. * @returns the current mesh
  29440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29441. */
  29442. disableFacetData(): AbstractMesh;
  29443. /**
  29444. * Updates the AbstractMesh indices array
  29445. * @param indices defines the data source
  29446. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29447. * @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)
  29448. * @returns the current mesh
  29449. */
  29450. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29451. /**
  29452. * Creates new normals data for the mesh
  29453. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29454. * @returns the current mesh
  29455. */
  29456. createNormals(updatable: boolean): AbstractMesh;
  29457. /**
  29458. * Align the mesh with a normal
  29459. * @param normal defines the normal to use
  29460. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29461. * @returns the current mesh
  29462. */
  29463. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29464. /** @hidden */
  29465. _checkOcclusionQuery(): boolean;
  29466. /**
  29467. * Disables the mesh edge rendering mode
  29468. * @returns the currentAbstractMesh
  29469. */
  29470. disableEdgesRendering(): AbstractMesh;
  29471. /**
  29472. * Enables the edge rendering mode on the mesh.
  29473. * This mode makes the mesh edges visible
  29474. * @param epsilon defines the maximal distance between two angles to detect a face
  29475. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29476. * @returns the currentAbstractMesh
  29477. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29478. */
  29479. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29480. }
  29481. }
  29482. declare module "babylonjs/Actions/actionEvent" {
  29483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29484. import { Nullable } from "babylonjs/types";
  29485. import { Sprite } from "babylonjs/Sprites/sprite";
  29486. import { Scene } from "babylonjs/scene";
  29487. import { Vector2 } from "babylonjs/Maths/math.vector";
  29488. /**
  29489. * Interface used to define ActionEvent
  29490. */
  29491. export interface IActionEvent {
  29492. /** The mesh or sprite that triggered the action */
  29493. source: any;
  29494. /** The X mouse cursor position at the time of the event */
  29495. pointerX: number;
  29496. /** The Y mouse cursor position at the time of the event */
  29497. pointerY: number;
  29498. /** The mesh that is currently pointed at (can be null) */
  29499. meshUnderPointer: Nullable<AbstractMesh>;
  29500. /** the original (browser) event that triggered the ActionEvent */
  29501. sourceEvent?: any;
  29502. /** additional data for the event */
  29503. additionalData?: any;
  29504. }
  29505. /**
  29506. * ActionEvent is the event being sent when an action is triggered.
  29507. */
  29508. export class ActionEvent implements IActionEvent {
  29509. /** The mesh or sprite that triggered the action */
  29510. source: any;
  29511. /** The X mouse cursor position at the time of the event */
  29512. pointerX: number;
  29513. /** The Y mouse cursor position at the time of the event */
  29514. pointerY: number;
  29515. /** The mesh that is currently pointed at (can be null) */
  29516. meshUnderPointer: Nullable<AbstractMesh>;
  29517. /** the original (browser) event that triggered the ActionEvent */
  29518. sourceEvent?: any;
  29519. /** additional data for the event */
  29520. additionalData?: any;
  29521. /**
  29522. * Creates a new ActionEvent
  29523. * @param source The mesh or sprite that triggered the action
  29524. * @param pointerX The X mouse cursor position at the time of the event
  29525. * @param pointerY The Y mouse cursor position at the time of the event
  29526. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29527. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29528. * @param additionalData additional data for the event
  29529. */
  29530. constructor(
  29531. /** The mesh or sprite that triggered the action */
  29532. source: any,
  29533. /** The X mouse cursor position at the time of the event */
  29534. pointerX: number,
  29535. /** The Y mouse cursor position at the time of the event */
  29536. pointerY: number,
  29537. /** The mesh that is currently pointed at (can be null) */
  29538. meshUnderPointer: Nullable<AbstractMesh>,
  29539. /** the original (browser) event that triggered the ActionEvent */
  29540. sourceEvent?: any,
  29541. /** additional data for the event */
  29542. additionalData?: any);
  29543. /**
  29544. * Helper function to auto-create an ActionEvent from a source mesh.
  29545. * @param source The source mesh that triggered the event
  29546. * @param evt The original (browser) event
  29547. * @param additionalData additional data for the event
  29548. * @returns the new ActionEvent
  29549. */
  29550. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29551. /**
  29552. * Helper function to auto-create an ActionEvent from a source sprite
  29553. * @param source The source sprite that triggered the event
  29554. * @param scene Scene associated with the sprite
  29555. * @param evt The original (browser) event
  29556. * @param additionalData additional data for the event
  29557. * @returns the new ActionEvent
  29558. */
  29559. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29560. /**
  29561. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29562. * @param scene the scene where the event occurred
  29563. * @param evt The original (browser) event
  29564. * @returns the new ActionEvent
  29565. */
  29566. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29567. /**
  29568. * Helper function to auto-create an ActionEvent from a primitive
  29569. * @param prim defines the target primitive
  29570. * @param pointerPos defines the pointer position
  29571. * @param evt The original (browser) event
  29572. * @param additionalData additional data for the event
  29573. * @returns the new ActionEvent
  29574. */
  29575. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29576. }
  29577. }
  29578. declare module "babylonjs/Actions/abstractActionManager" {
  29579. import { IDisposable } from "babylonjs/scene";
  29580. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29581. import { IAction } from "babylonjs/Actions/action";
  29582. import { Nullable } from "babylonjs/types";
  29583. /**
  29584. * Abstract class used to decouple action Manager from scene and meshes.
  29585. * Do not instantiate.
  29586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29587. */
  29588. export abstract class AbstractActionManager implements IDisposable {
  29589. /** Gets the list of active triggers */
  29590. static Triggers: {
  29591. [key: string]: number;
  29592. };
  29593. /** Gets the cursor to use when hovering items */
  29594. hoverCursor: string;
  29595. /** Gets the list of actions */
  29596. actions: IAction[];
  29597. /**
  29598. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29599. */
  29600. isRecursive: boolean;
  29601. /**
  29602. * Releases all associated resources
  29603. */
  29604. abstract dispose(): void;
  29605. /**
  29606. * Does this action manager has pointer triggers
  29607. */
  29608. abstract get hasPointerTriggers(): boolean;
  29609. /**
  29610. * Does this action manager has pick triggers
  29611. */
  29612. abstract get hasPickTriggers(): boolean;
  29613. /**
  29614. * Process a specific trigger
  29615. * @param trigger defines the trigger to process
  29616. * @param evt defines the event details to be processed
  29617. */
  29618. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29619. /**
  29620. * Does this action manager handles actions of any of the given triggers
  29621. * @param triggers defines the triggers to be tested
  29622. * @return a boolean indicating whether one (or more) of the triggers is handled
  29623. */
  29624. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29625. /**
  29626. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29627. * speed.
  29628. * @param triggerA defines the trigger to be tested
  29629. * @param triggerB defines the trigger to be tested
  29630. * @return a boolean indicating whether one (or more) of the triggers is handled
  29631. */
  29632. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29633. /**
  29634. * Does this action manager handles actions of a given trigger
  29635. * @param trigger defines the trigger to be tested
  29636. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29637. * @return whether the trigger is handled
  29638. */
  29639. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29640. /**
  29641. * Serialize this manager to a JSON object
  29642. * @param name defines the property name to store this manager
  29643. * @returns a JSON representation of this manager
  29644. */
  29645. abstract serialize(name: string): any;
  29646. /**
  29647. * Registers an action to this action manager
  29648. * @param action defines the action to be registered
  29649. * @return the action amended (prepared) after registration
  29650. */
  29651. abstract registerAction(action: IAction): Nullable<IAction>;
  29652. /**
  29653. * Unregisters an action to this action manager
  29654. * @param action defines the action to be unregistered
  29655. * @return a boolean indicating whether the action has been unregistered
  29656. */
  29657. abstract unregisterAction(action: IAction): Boolean;
  29658. /**
  29659. * Does exist one action manager with at least one trigger
  29660. **/
  29661. static get HasTriggers(): boolean;
  29662. /**
  29663. * Does exist one action manager with at least one pick trigger
  29664. **/
  29665. static get HasPickTriggers(): boolean;
  29666. /**
  29667. * Does exist one action manager that handles actions of a given trigger
  29668. * @param trigger defines the trigger to be tested
  29669. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29670. **/
  29671. static HasSpecificTrigger(trigger: number): boolean;
  29672. }
  29673. }
  29674. declare module "babylonjs/node" {
  29675. import { Scene } from "babylonjs/scene";
  29676. import { Nullable } from "babylonjs/types";
  29677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29678. import { Engine } from "babylonjs/Engines/engine";
  29679. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29680. import { Observable } from "babylonjs/Misc/observable";
  29681. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29682. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29683. import { Animatable } from "babylonjs/Animations/animatable";
  29684. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29685. import { Animation } from "babylonjs/Animations/animation";
  29686. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29688. /**
  29689. * Defines how a node can be built from a string name.
  29690. */
  29691. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29692. /**
  29693. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29694. */
  29695. export class Node implements IBehaviorAware<Node> {
  29696. /** @hidden */
  29697. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29698. private static _NodeConstructors;
  29699. /**
  29700. * Add a new node constructor
  29701. * @param type defines the type name of the node to construct
  29702. * @param constructorFunc defines the constructor function
  29703. */
  29704. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29705. /**
  29706. * Returns a node constructor based on type name
  29707. * @param type defines the type name
  29708. * @param name defines the new node name
  29709. * @param scene defines the hosting scene
  29710. * @param options defines optional options to transmit to constructors
  29711. * @returns the new constructor or null
  29712. */
  29713. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29714. /**
  29715. * Gets or sets the name of the node
  29716. */
  29717. name: string;
  29718. /**
  29719. * Gets or sets the id of the node
  29720. */
  29721. id: string;
  29722. /**
  29723. * Gets or sets the unique id of the node
  29724. */
  29725. uniqueId: number;
  29726. /**
  29727. * Gets or sets a string used to store user defined state for the node
  29728. */
  29729. state: string;
  29730. /**
  29731. * Gets or sets an object used to store user defined information for the node
  29732. */
  29733. metadata: any;
  29734. /**
  29735. * For internal use only. Please do not use.
  29736. */
  29737. reservedDataStore: any;
  29738. /**
  29739. * List of inspectable custom properties (used by the Inspector)
  29740. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29741. */
  29742. inspectableCustomProperties: IInspectable[];
  29743. private _doNotSerialize;
  29744. /**
  29745. * Gets or sets a boolean used to define if the node must be serialized
  29746. */
  29747. get doNotSerialize(): boolean;
  29748. set doNotSerialize(value: boolean);
  29749. /** @hidden */
  29750. _isDisposed: boolean;
  29751. /**
  29752. * Gets a list of Animations associated with the node
  29753. */
  29754. animations: import("babylonjs/Animations/animation").Animation[];
  29755. protected _ranges: {
  29756. [name: string]: Nullable<AnimationRange>;
  29757. };
  29758. /**
  29759. * Callback raised when the node is ready to be used
  29760. */
  29761. onReady: Nullable<(node: Node) => void>;
  29762. private _isEnabled;
  29763. private _isParentEnabled;
  29764. private _isReady;
  29765. /** @hidden */
  29766. _currentRenderId: number;
  29767. private _parentUpdateId;
  29768. /** @hidden */
  29769. _childUpdateId: number;
  29770. /** @hidden */
  29771. _waitingParentId: Nullable<string>;
  29772. /** @hidden */
  29773. _scene: Scene;
  29774. /** @hidden */
  29775. _cache: any;
  29776. private _parentNode;
  29777. private _children;
  29778. /** @hidden */
  29779. _worldMatrix: Matrix;
  29780. /** @hidden */
  29781. _worldMatrixDeterminant: number;
  29782. /** @hidden */
  29783. _worldMatrixDeterminantIsDirty: boolean;
  29784. /** @hidden */
  29785. private _sceneRootNodesIndex;
  29786. /**
  29787. * Gets a boolean indicating if the node has been disposed
  29788. * @returns true if the node was disposed
  29789. */
  29790. isDisposed(): boolean;
  29791. /**
  29792. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29793. * @see https://doc.babylonjs.com/how_to/parenting
  29794. */
  29795. set parent(parent: Nullable<Node>);
  29796. get parent(): Nullable<Node>;
  29797. /** @hidden */
  29798. _addToSceneRootNodes(): void;
  29799. /** @hidden */
  29800. _removeFromSceneRootNodes(): void;
  29801. private _animationPropertiesOverride;
  29802. /**
  29803. * Gets or sets the animation properties override
  29804. */
  29805. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29806. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29807. /**
  29808. * Gets a string idenfifying the name of the class
  29809. * @returns "Node" string
  29810. */
  29811. getClassName(): string;
  29812. /** @hidden */
  29813. readonly _isNode: boolean;
  29814. /**
  29815. * An event triggered when the mesh is disposed
  29816. */
  29817. onDisposeObservable: Observable<Node>;
  29818. private _onDisposeObserver;
  29819. /**
  29820. * Sets a callback that will be raised when the node will be disposed
  29821. */
  29822. set onDispose(callback: () => void);
  29823. /**
  29824. * Creates a new Node
  29825. * @param name the name and id to be given to this node
  29826. * @param scene the scene this node will be added to
  29827. */
  29828. constructor(name: string, scene?: Nullable<Scene>);
  29829. /**
  29830. * Gets the scene of the node
  29831. * @returns a scene
  29832. */
  29833. getScene(): Scene;
  29834. /**
  29835. * Gets the engine of the node
  29836. * @returns a Engine
  29837. */
  29838. getEngine(): Engine;
  29839. private _behaviors;
  29840. /**
  29841. * Attach a behavior to the node
  29842. * @see http://doc.babylonjs.com/features/behaviour
  29843. * @param behavior defines the behavior to attach
  29844. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29845. * @returns the current Node
  29846. */
  29847. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29848. /**
  29849. * Remove an attached behavior
  29850. * @see http://doc.babylonjs.com/features/behaviour
  29851. * @param behavior defines the behavior to attach
  29852. * @returns the current Node
  29853. */
  29854. removeBehavior(behavior: Behavior<Node>): Node;
  29855. /**
  29856. * Gets the list of attached behaviors
  29857. * @see http://doc.babylonjs.com/features/behaviour
  29858. */
  29859. get behaviors(): Behavior<Node>[];
  29860. /**
  29861. * Gets an attached behavior by name
  29862. * @param name defines the name of the behavior to look for
  29863. * @see http://doc.babylonjs.com/features/behaviour
  29864. * @returns null if behavior was not found else the requested behavior
  29865. */
  29866. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29867. /**
  29868. * Returns the latest update of the World matrix
  29869. * @returns a Matrix
  29870. */
  29871. getWorldMatrix(): Matrix;
  29872. /** @hidden */
  29873. _getWorldMatrixDeterminant(): number;
  29874. /**
  29875. * Returns directly the latest state of the mesh World matrix.
  29876. * A Matrix is returned.
  29877. */
  29878. get worldMatrixFromCache(): Matrix;
  29879. /** @hidden */
  29880. _initCache(): void;
  29881. /** @hidden */
  29882. updateCache(force?: boolean): void;
  29883. /** @hidden */
  29884. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29885. /** @hidden */
  29886. _updateCache(ignoreParentClass?: boolean): void;
  29887. /** @hidden */
  29888. _isSynchronized(): boolean;
  29889. /** @hidden */
  29890. _markSyncedWithParent(): void;
  29891. /** @hidden */
  29892. isSynchronizedWithParent(): boolean;
  29893. /** @hidden */
  29894. isSynchronized(): boolean;
  29895. /**
  29896. * Is this node ready to be used/rendered
  29897. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29898. * @return true if the node is ready
  29899. */
  29900. isReady(completeCheck?: boolean): boolean;
  29901. /**
  29902. * Is this node enabled?
  29903. * 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
  29904. * @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
  29905. * @return whether this node (and its parent) is enabled
  29906. */
  29907. isEnabled(checkAncestors?: boolean): boolean;
  29908. /** @hidden */
  29909. protected _syncParentEnabledState(): void;
  29910. /**
  29911. * Set the enabled state of this node
  29912. * @param value defines the new enabled state
  29913. */
  29914. setEnabled(value: boolean): void;
  29915. /**
  29916. * Is this node a descendant of the given node?
  29917. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29918. * @param ancestor defines the parent node to inspect
  29919. * @returns a boolean indicating if this node is a descendant of the given node
  29920. */
  29921. isDescendantOf(ancestor: Node): boolean;
  29922. /** @hidden */
  29923. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29924. /**
  29925. * Will return all nodes that have this node as ascendant
  29926. * @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
  29927. * @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
  29928. * @return all children nodes of all types
  29929. */
  29930. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29931. /**
  29932. * Get all child-meshes of this node
  29933. * @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)
  29934. * @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
  29935. * @returns an array of AbstractMesh
  29936. */
  29937. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29938. /**
  29939. * Get all direct children of this node
  29940. * @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
  29941. * @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)
  29942. * @returns an array of Node
  29943. */
  29944. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29945. /** @hidden */
  29946. _setReady(state: boolean): void;
  29947. /**
  29948. * Get an animation by name
  29949. * @param name defines the name of the animation to look for
  29950. * @returns null if not found else the requested animation
  29951. */
  29952. getAnimationByName(name: string): Nullable<Animation>;
  29953. /**
  29954. * Creates an animation range for this node
  29955. * @param name defines the name of the range
  29956. * @param from defines the starting key
  29957. * @param to defines the end key
  29958. */
  29959. createAnimationRange(name: string, from: number, to: number): void;
  29960. /**
  29961. * Delete a specific animation range
  29962. * @param name defines the name of the range to delete
  29963. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29964. */
  29965. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29966. /**
  29967. * Get an animation range by name
  29968. * @param name defines the name of the animation range to look for
  29969. * @returns null if not found else the requested animation range
  29970. */
  29971. getAnimationRange(name: string): Nullable<AnimationRange>;
  29972. /**
  29973. * Gets the list of all animation ranges defined on this node
  29974. * @returns an array
  29975. */
  29976. getAnimationRanges(): Nullable<AnimationRange>[];
  29977. /**
  29978. * Will start the animation sequence
  29979. * @param name defines the range frames for animation sequence
  29980. * @param loop defines if the animation should loop (false by default)
  29981. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29982. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29983. * @returns the object created for this animation. If range does not exist, it will return null
  29984. */
  29985. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29986. /**
  29987. * Serialize animation ranges into a JSON compatible object
  29988. * @returns serialization object
  29989. */
  29990. serializeAnimationRanges(): any;
  29991. /**
  29992. * Computes the world matrix of the node
  29993. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29994. * @returns the world matrix
  29995. */
  29996. computeWorldMatrix(force?: boolean): Matrix;
  29997. /**
  29998. * Releases resources associated with this node.
  29999. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30000. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30001. */
  30002. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30003. /**
  30004. * Parse animation range data from a serialization object and store them into a given node
  30005. * @param node defines where to store the animation ranges
  30006. * @param parsedNode defines the serialization object to read data from
  30007. * @param scene defines the hosting scene
  30008. */
  30009. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30010. /**
  30011. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30012. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30013. * @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
  30014. * @returns the new bounding vectors
  30015. */
  30016. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30017. min: Vector3;
  30018. max: Vector3;
  30019. };
  30020. }
  30021. }
  30022. declare module "babylonjs/Animations/animation" {
  30023. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30024. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30025. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30026. import { Nullable } from "babylonjs/types";
  30027. import { Scene } from "babylonjs/scene";
  30028. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30029. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30030. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30031. import { Node } from "babylonjs/node";
  30032. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30033. import { Size } from "babylonjs/Maths/math.size";
  30034. import { Animatable } from "babylonjs/Animations/animatable";
  30035. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30036. /**
  30037. * @hidden
  30038. */
  30039. export class _IAnimationState {
  30040. key: number;
  30041. repeatCount: number;
  30042. workValue?: any;
  30043. loopMode?: number;
  30044. offsetValue?: any;
  30045. highLimitValue?: any;
  30046. }
  30047. /**
  30048. * Class used to store any kind of animation
  30049. */
  30050. export class Animation {
  30051. /**Name of the animation */
  30052. name: string;
  30053. /**Property to animate */
  30054. targetProperty: string;
  30055. /**The frames per second of the animation */
  30056. framePerSecond: number;
  30057. /**The data type of the animation */
  30058. dataType: number;
  30059. /**The loop mode of the animation */
  30060. loopMode?: number | undefined;
  30061. /**Specifies if blending should be enabled */
  30062. enableBlending?: boolean | undefined;
  30063. /**
  30064. * Use matrix interpolation instead of using direct key value when animating matrices
  30065. */
  30066. static AllowMatricesInterpolation: boolean;
  30067. /**
  30068. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30069. */
  30070. static AllowMatrixDecomposeForInterpolation: boolean;
  30071. /**
  30072. * Stores the key frames of the animation
  30073. */
  30074. private _keys;
  30075. /**
  30076. * Stores the easing function of the animation
  30077. */
  30078. private _easingFunction;
  30079. /**
  30080. * @hidden Internal use only
  30081. */
  30082. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30083. /**
  30084. * The set of event that will be linked to this animation
  30085. */
  30086. private _events;
  30087. /**
  30088. * Stores an array of target property paths
  30089. */
  30090. targetPropertyPath: string[];
  30091. /**
  30092. * Stores the blending speed of the animation
  30093. */
  30094. blendingSpeed: number;
  30095. /**
  30096. * Stores the animation ranges for the animation
  30097. */
  30098. private _ranges;
  30099. /**
  30100. * @hidden Internal use
  30101. */
  30102. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30103. /**
  30104. * Sets up an animation
  30105. * @param property The property to animate
  30106. * @param animationType The animation type to apply
  30107. * @param framePerSecond The frames per second of the animation
  30108. * @param easingFunction The easing function used in the animation
  30109. * @returns The created animation
  30110. */
  30111. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30112. /**
  30113. * Create and start an animation on a node
  30114. * @param name defines the name of the global animation that will be run on all nodes
  30115. * @param node defines the root node where the animation will take place
  30116. * @param targetProperty defines property to animate
  30117. * @param framePerSecond defines the number of frame per second yo use
  30118. * @param totalFrame defines the number of frames in total
  30119. * @param from defines the initial value
  30120. * @param to defines the final value
  30121. * @param loopMode defines which loop mode you want to use (off by default)
  30122. * @param easingFunction defines the easing function to use (linear by default)
  30123. * @param onAnimationEnd defines the callback to call when animation end
  30124. * @returns the animatable created for this animation
  30125. */
  30126. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30127. /**
  30128. * Create and start an animation on a node and its descendants
  30129. * @param name defines the name of the global animation that will be run on all nodes
  30130. * @param node defines the root node where the animation will take place
  30131. * @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
  30132. * @param targetProperty defines property to animate
  30133. * @param framePerSecond defines the number of frame per second to use
  30134. * @param totalFrame defines the number of frames in total
  30135. * @param from defines the initial value
  30136. * @param to defines the final value
  30137. * @param loopMode defines which loop mode you want to use (off by default)
  30138. * @param easingFunction defines the easing function to use (linear by default)
  30139. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30140. * @returns the list of animatables created for all nodes
  30141. * @example https://www.babylonjs-playground.com/#MH0VLI
  30142. */
  30143. 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[]>;
  30144. /**
  30145. * Creates a new animation, merges it with the existing animations and starts it
  30146. * @param name Name of the animation
  30147. * @param node Node which contains the scene that begins the animations
  30148. * @param targetProperty Specifies which property to animate
  30149. * @param framePerSecond The frames per second of the animation
  30150. * @param totalFrame The total number of frames
  30151. * @param from The frame at the beginning of the animation
  30152. * @param to The frame at the end of the animation
  30153. * @param loopMode Specifies the loop mode of the animation
  30154. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30155. * @param onAnimationEnd Callback to run once the animation is complete
  30156. * @returns Nullable animation
  30157. */
  30158. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30159. /**
  30160. * Transition property of an host to the target Value
  30161. * @param property The property to transition
  30162. * @param targetValue The target Value of the property
  30163. * @param host The object where the property to animate belongs
  30164. * @param scene Scene used to run the animation
  30165. * @param frameRate Framerate (in frame/s) to use
  30166. * @param transition The transition type we want to use
  30167. * @param duration The duration of the animation, in milliseconds
  30168. * @param onAnimationEnd Callback trigger at the end of the animation
  30169. * @returns Nullable animation
  30170. */
  30171. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30172. /**
  30173. * Return the array of runtime animations currently using this animation
  30174. */
  30175. get runtimeAnimations(): RuntimeAnimation[];
  30176. /**
  30177. * Specifies if any of the runtime animations are currently running
  30178. */
  30179. get hasRunningRuntimeAnimations(): boolean;
  30180. /**
  30181. * Initializes the animation
  30182. * @param name Name of the animation
  30183. * @param targetProperty Property to animate
  30184. * @param framePerSecond The frames per second of the animation
  30185. * @param dataType The data type of the animation
  30186. * @param loopMode The loop mode of the animation
  30187. * @param enableBlending Specifies if blending should be enabled
  30188. */
  30189. constructor(
  30190. /**Name of the animation */
  30191. name: string,
  30192. /**Property to animate */
  30193. targetProperty: string,
  30194. /**The frames per second of the animation */
  30195. framePerSecond: number,
  30196. /**The data type of the animation */
  30197. dataType: number,
  30198. /**The loop mode of the animation */
  30199. loopMode?: number | undefined,
  30200. /**Specifies if blending should be enabled */
  30201. enableBlending?: boolean | undefined);
  30202. /**
  30203. * Converts the animation to a string
  30204. * @param fullDetails support for multiple levels of logging within scene loading
  30205. * @returns String form of the animation
  30206. */
  30207. toString(fullDetails?: boolean): string;
  30208. /**
  30209. * Add an event to this animation
  30210. * @param event Event to add
  30211. */
  30212. addEvent(event: AnimationEvent): void;
  30213. /**
  30214. * Remove all events found at the given frame
  30215. * @param frame The frame to remove events from
  30216. */
  30217. removeEvents(frame: number): void;
  30218. /**
  30219. * Retrieves all the events from the animation
  30220. * @returns Events from the animation
  30221. */
  30222. getEvents(): AnimationEvent[];
  30223. /**
  30224. * Creates an animation range
  30225. * @param name Name of the animation range
  30226. * @param from Starting frame of the animation range
  30227. * @param to Ending frame of the animation
  30228. */
  30229. createRange(name: string, from: number, to: number): void;
  30230. /**
  30231. * Deletes an animation range by name
  30232. * @param name Name of the animation range to delete
  30233. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30234. */
  30235. deleteRange(name: string, deleteFrames?: boolean): void;
  30236. /**
  30237. * Gets the animation range by name, or null if not defined
  30238. * @param name Name of the animation range
  30239. * @returns Nullable animation range
  30240. */
  30241. getRange(name: string): Nullable<AnimationRange>;
  30242. /**
  30243. * Gets the key frames from the animation
  30244. * @returns The key frames of the animation
  30245. */
  30246. getKeys(): Array<IAnimationKey>;
  30247. /**
  30248. * Gets the highest frame rate of the animation
  30249. * @returns Highest frame rate of the animation
  30250. */
  30251. getHighestFrame(): number;
  30252. /**
  30253. * Gets the easing function of the animation
  30254. * @returns Easing function of the animation
  30255. */
  30256. getEasingFunction(): IEasingFunction;
  30257. /**
  30258. * Sets the easing function of the animation
  30259. * @param easingFunction A custom mathematical formula for animation
  30260. */
  30261. setEasingFunction(easingFunction: EasingFunction): void;
  30262. /**
  30263. * Interpolates a scalar linearly
  30264. * @param startValue Start value of the animation curve
  30265. * @param endValue End value of the animation curve
  30266. * @param gradient Scalar amount to interpolate
  30267. * @returns Interpolated scalar value
  30268. */
  30269. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30270. /**
  30271. * Interpolates a scalar cubically
  30272. * @param startValue Start value of the animation curve
  30273. * @param outTangent End tangent of the animation
  30274. * @param endValue End value of the animation curve
  30275. * @param inTangent Start tangent of the animation curve
  30276. * @param gradient Scalar amount to interpolate
  30277. * @returns Interpolated scalar value
  30278. */
  30279. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30280. /**
  30281. * Interpolates a quaternion using a spherical linear interpolation
  30282. * @param startValue Start value of the animation curve
  30283. * @param endValue End value of the animation curve
  30284. * @param gradient Scalar amount to interpolate
  30285. * @returns Interpolated quaternion value
  30286. */
  30287. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30288. /**
  30289. * Interpolates a quaternion cubically
  30290. * @param startValue Start value of the animation curve
  30291. * @param outTangent End tangent of the animation curve
  30292. * @param endValue End value of the animation curve
  30293. * @param inTangent Start tangent of the animation curve
  30294. * @param gradient Scalar amount to interpolate
  30295. * @returns Interpolated quaternion value
  30296. */
  30297. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30298. /**
  30299. * Interpolates a Vector3 linearl
  30300. * @param startValue Start value of the animation curve
  30301. * @param endValue End value of the animation curve
  30302. * @param gradient Scalar amount to interpolate
  30303. * @returns Interpolated scalar value
  30304. */
  30305. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30306. /**
  30307. * Interpolates a Vector3 cubically
  30308. * @param startValue Start value of the animation curve
  30309. * @param outTangent End tangent of the animation
  30310. * @param endValue End value of the animation curve
  30311. * @param inTangent Start tangent of the animation curve
  30312. * @param gradient Scalar amount to interpolate
  30313. * @returns InterpolatedVector3 value
  30314. */
  30315. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30316. /**
  30317. * Interpolates a Vector2 linearly
  30318. * @param startValue Start value of the animation curve
  30319. * @param endValue End value of the animation curve
  30320. * @param gradient Scalar amount to interpolate
  30321. * @returns Interpolated Vector2 value
  30322. */
  30323. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30324. /**
  30325. * Interpolates a Vector2 cubically
  30326. * @param startValue Start value of the animation curve
  30327. * @param outTangent End tangent of the animation
  30328. * @param endValue End value of the animation curve
  30329. * @param inTangent Start tangent of the animation curve
  30330. * @param gradient Scalar amount to interpolate
  30331. * @returns Interpolated Vector2 value
  30332. */
  30333. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30334. /**
  30335. * Interpolates a size linearly
  30336. * @param startValue Start value of the animation curve
  30337. * @param endValue End value of the animation curve
  30338. * @param gradient Scalar amount to interpolate
  30339. * @returns Interpolated Size value
  30340. */
  30341. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30342. /**
  30343. * Interpolates a Color3 linearly
  30344. * @param startValue Start value of the animation curve
  30345. * @param endValue End value of the animation curve
  30346. * @param gradient Scalar amount to interpolate
  30347. * @returns Interpolated Color3 value
  30348. */
  30349. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30350. /**
  30351. * Interpolates a Color4 linearly
  30352. * @param startValue Start value of the animation curve
  30353. * @param endValue End value of the animation curve
  30354. * @param gradient Scalar amount to interpolate
  30355. * @returns Interpolated Color3 value
  30356. */
  30357. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30358. /**
  30359. * @hidden Internal use only
  30360. */
  30361. _getKeyValue(value: any): any;
  30362. /**
  30363. * @hidden Internal use only
  30364. */
  30365. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30366. /**
  30367. * Defines the function to use to interpolate matrices
  30368. * @param startValue defines the start matrix
  30369. * @param endValue defines the end matrix
  30370. * @param gradient defines the gradient between both matrices
  30371. * @param result defines an optional target matrix where to store the interpolation
  30372. * @returns the interpolated matrix
  30373. */
  30374. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30375. /**
  30376. * Makes a copy of the animation
  30377. * @returns Cloned animation
  30378. */
  30379. clone(): Animation;
  30380. /**
  30381. * Sets the key frames of the animation
  30382. * @param values The animation key frames to set
  30383. */
  30384. setKeys(values: Array<IAnimationKey>): void;
  30385. /**
  30386. * Serializes the animation to an object
  30387. * @returns Serialized object
  30388. */
  30389. serialize(): any;
  30390. /**
  30391. * Float animation type
  30392. */
  30393. static readonly ANIMATIONTYPE_FLOAT: number;
  30394. /**
  30395. * Vector3 animation type
  30396. */
  30397. static readonly ANIMATIONTYPE_VECTOR3: number;
  30398. /**
  30399. * Quaternion animation type
  30400. */
  30401. static readonly ANIMATIONTYPE_QUATERNION: number;
  30402. /**
  30403. * Matrix animation type
  30404. */
  30405. static readonly ANIMATIONTYPE_MATRIX: number;
  30406. /**
  30407. * Color3 animation type
  30408. */
  30409. static readonly ANIMATIONTYPE_COLOR3: number;
  30410. /**
  30411. * Color3 animation type
  30412. */
  30413. static readonly ANIMATIONTYPE_COLOR4: number;
  30414. /**
  30415. * Vector2 animation type
  30416. */
  30417. static readonly ANIMATIONTYPE_VECTOR2: number;
  30418. /**
  30419. * Size animation type
  30420. */
  30421. static readonly ANIMATIONTYPE_SIZE: number;
  30422. /**
  30423. * Relative Loop Mode
  30424. */
  30425. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30426. /**
  30427. * Cycle Loop Mode
  30428. */
  30429. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30430. /**
  30431. * Constant Loop Mode
  30432. */
  30433. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30434. /** @hidden */
  30435. static _UniversalLerp(left: any, right: any, amount: number): any;
  30436. /**
  30437. * Parses an animation object and creates an animation
  30438. * @param parsedAnimation Parsed animation object
  30439. * @returns Animation object
  30440. */
  30441. static Parse(parsedAnimation: any): Animation;
  30442. /**
  30443. * Appends the serialized animations from the source animations
  30444. * @param source Source containing the animations
  30445. * @param destination Target to store the animations
  30446. */
  30447. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30448. }
  30449. }
  30450. declare module "babylonjs/Animations/animatable.interface" {
  30451. import { Nullable } from "babylonjs/types";
  30452. import { Animation } from "babylonjs/Animations/animation";
  30453. /**
  30454. * Interface containing an array of animations
  30455. */
  30456. export interface IAnimatable {
  30457. /**
  30458. * Array of animations
  30459. */
  30460. animations: Nullable<Array<Animation>>;
  30461. }
  30462. }
  30463. declare module "babylonjs/Misc/decorators" {
  30464. import { Nullable } from "babylonjs/types";
  30465. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30466. import { Scene } from "babylonjs/scene";
  30467. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30468. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30469. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30470. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30471. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30472. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30473. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30474. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30475. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30476. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30477. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30478. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30479. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30480. /**
  30481. * Decorator used to define property that can be serialized as reference to a camera
  30482. * @param sourceName defines the name of the property to decorate
  30483. */
  30484. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30485. /**
  30486. * Class used to help serialization objects
  30487. */
  30488. export class SerializationHelper {
  30489. /** @hidden */
  30490. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30491. /** @hidden */
  30492. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30493. /** @hidden */
  30494. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30495. /** @hidden */
  30496. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30497. /**
  30498. * Appends the serialized animations from the source animations
  30499. * @param source Source containing the animations
  30500. * @param destination Target to store the animations
  30501. */
  30502. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30503. /**
  30504. * Static function used to serialized a specific entity
  30505. * @param entity defines the entity to serialize
  30506. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30507. * @returns a JSON compatible object representing the serialization of the entity
  30508. */
  30509. static Serialize<T>(entity: T, serializationObject?: any): any;
  30510. /**
  30511. * Creates a new entity from a serialization data object
  30512. * @param creationFunction defines a function used to instanciated the new entity
  30513. * @param source defines the source serialization data
  30514. * @param scene defines the hosting scene
  30515. * @param rootUrl defines the root url for resources
  30516. * @returns a new entity
  30517. */
  30518. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30519. /**
  30520. * Clones an object
  30521. * @param creationFunction defines the function used to instanciate the new object
  30522. * @param source defines the source object
  30523. * @returns the cloned object
  30524. */
  30525. static Clone<T>(creationFunction: () => T, source: T): T;
  30526. /**
  30527. * Instanciates a new object based on a source one (some data will be shared between both object)
  30528. * @param creationFunction defines the function used to instanciate the new object
  30529. * @param source defines the source object
  30530. * @returns the new object
  30531. */
  30532. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30533. }
  30534. }
  30535. declare module "babylonjs/Misc/guid" {
  30536. /**
  30537. * Class used to manipulate GUIDs
  30538. */
  30539. export class GUID {
  30540. /**
  30541. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30542. * Be aware Math.random() could cause collisions, but:
  30543. * "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"
  30544. * @returns a pseudo random id
  30545. */
  30546. static RandomId(): string;
  30547. }
  30548. }
  30549. declare module "babylonjs/Materials/Textures/baseTexture" {
  30550. import { Observable } from "babylonjs/Misc/observable";
  30551. import { Nullable } from "babylonjs/types";
  30552. import { Scene } from "babylonjs/scene";
  30553. import { Matrix } from "babylonjs/Maths/math.vector";
  30554. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30555. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30556. import { ISize } from "babylonjs/Maths/math.size";
  30557. import "babylonjs/Misc/fileTools";
  30558. /**
  30559. * Base class of all the textures in babylon.
  30560. * It groups all the common properties the materials, post process, lights... might need
  30561. * in order to make a correct use of the texture.
  30562. */
  30563. export class BaseTexture implements IAnimatable {
  30564. /**
  30565. * Default anisotropic filtering level for the application.
  30566. * It is set to 4 as a good tradeoff between perf and quality.
  30567. */
  30568. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30569. /**
  30570. * Gets or sets the unique id of the texture
  30571. */
  30572. uniqueId: number;
  30573. /**
  30574. * Define the name of the texture.
  30575. */
  30576. name: string;
  30577. /**
  30578. * Gets or sets an object used to store user defined information.
  30579. */
  30580. metadata: any;
  30581. /**
  30582. * For internal use only. Please do not use.
  30583. */
  30584. reservedDataStore: any;
  30585. private _hasAlpha;
  30586. /**
  30587. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30588. */
  30589. set hasAlpha(value: boolean);
  30590. get hasAlpha(): boolean;
  30591. /**
  30592. * Defines if the alpha value should be determined via the rgb values.
  30593. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30594. */
  30595. getAlphaFromRGB: boolean;
  30596. /**
  30597. * Intensity or strength of the texture.
  30598. * It is commonly used by materials to fine tune the intensity of the texture
  30599. */
  30600. level: number;
  30601. /**
  30602. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30603. * This is part of the texture as textures usually maps to one uv set.
  30604. */
  30605. coordinatesIndex: number;
  30606. private _coordinatesMode;
  30607. /**
  30608. * How a texture is mapped.
  30609. *
  30610. * | Value | Type | Description |
  30611. * | ----- | ----------------------------------- | ----------- |
  30612. * | 0 | EXPLICIT_MODE | |
  30613. * | 1 | SPHERICAL_MODE | |
  30614. * | 2 | PLANAR_MODE | |
  30615. * | 3 | CUBIC_MODE | |
  30616. * | 4 | PROJECTION_MODE | |
  30617. * | 5 | SKYBOX_MODE | |
  30618. * | 6 | INVCUBIC_MODE | |
  30619. * | 7 | EQUIRECTANGULAR_MODE | |
  30620. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30621. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30622. */
  30623. set coordinatesMode(value: number);
  30624. get coordinatesMode(): number;
  30625. /**
  30626. * | Value | Type | Description |
  30627. * | ----- | ------------------ | ----------- |
  30628. * | 0 | CLAMP_ADDRESSMODE | |
  30629. * | 1 | WRAP_ADDRESSMODE | |
  30630. * | 2 | MIRROR_ADDRESSMODE | |
  30631. */
  30632. wrapU: number;
  30633. /**
  30634. * | Value | Type | Description |
  30635. * | ----- | ------------------ | ----------- |
  30636. * | 0 | CLAMP_ADDRESSMODE | |
  30637. * | 1 | WRAP_ADDRESSMODE | |
  30638. * | 2 | MIRROR_ADDRESSMODE | |
  30639. */
  30640. wrapV: number;
  30641. /**
  30642. * | Value | Type | Description |
  30643. * | ----- | ------------------ | ----------- |
  30644. * | 0 | CLAMP_ADDRESSMODE | |
  30645. * | 1 | WRAP_ADDRESSMODE | |
  30646. * | 2 | MIRROR_ADDRESSMODE | |
  30647. */
  30648. wrapR: number;
  30649. /**
  30650. * With compliant hardware and browser (supporting anisotropic filtering)
  30651. * this defines the level of anisotropic filtering in the texture.
  30652. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30653. */
  30654. anisotropicFilteringLevel: number;
  30655. /**
  30656. * Define if the texture is a cube texture or if false a 2d texture.
  30657. */
  30658. get isCube(): boolean;
  30659. set isCube(value: boolean);
  30660. /**
  30661. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30662. */
  30663. get is3D(): boolean;
  30664. set is3D(value: boolean);
  30665. /**
  30666. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30667. */
  30668. get is2DArray(): boolean;
  30669. set is2DArray(value: boolean);
  30670. /**
  30671. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30672. * HDR texture are usually stored in linear space.
  30673. * This only impacts the PBR and Background materials
  30674. */
  30675. gammaSpace: boolean;
  30676. /**
  30677. * Gets or sets whether or not the texture contains RGBD data.
  30678. */
  30679. get isRGBD(): boolean;
  30680. set isRGBD(value: boolean);
  30681. /**
  30682. * Is Z inverted in the texture (useful in a cube texture).
  30683. */
  30684. invertZ: boolean;
  30685. /**
  30686. * Are mip maps generated for this texture or not.
  30687. */
  30688. get noMipmap(): boolean;
  30689. /**
  30690. * @hidden
  30691. */
  30692. lodLevelInAlpha: boolean;
  30693. /**
  30694. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30695. */
  30696. get lodGenerationOffset(): number;
  30697. set lodGenerationOffset(value: number);
  30698. /**
  30699. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30700. */
  30701. get lodGenerationScale(): number;
  30702. set lodGenerationScale(value: number);
  30703. /**
  30704. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30705. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30706. * average roughness values.
  30707. */
  30708. get linearSpecularLOD(): boolean;
  30709. set linearSpecularLOD(value: boolean);
  30710. /**
  30711. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30712. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30713. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30714. */
  30715. get irradianceTexture(): Nullable<BaseTexture>;
  30716. set irradianceTexture(value: Nullable<BaseTexture>);
  30717. /**
  30718. * Define if the texture is a render target.
  30719. */
  30720. isRenderTarget: boolean;
  30721. /**
  30722. * Define the unique id of the texture in the scene.
  30723. */
  30724. get uid(): string;
  30725. /**
  30726. * Return a string representation of the texture.
  30727. * @returns the texture as a string
  30728. */
  30729. toString(): string;
  30730. /**
  30731. * Get the class name of the texture.
  30732. * @returns "BaseTexture"
  30733. */
  30734. getClassName(): string;
  30735. /**
  30736. * Define the list of animation attached to the texture.
  30737. */
  30738. animations: import("babylonjs/Animations/animation").Animation[];
  30739. /**
  30740. * An event triggered when the texture is disposed.
  30741. */
  30742. onDisposeObservable: Observable<BaseTexture>;
  30743. private _onDisposeObserver;
  30744. /**
  30745. * Callback triggered when the texture has been disposed.
  30746. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30747. */
  30748. set onDispose(callback: () => void);
  30749. /**
  30750. * Define the current state of the loading sequence when in delayed load mode.
  30751. */
  30752. delayLoadState: number;
  30753. private _scene;
  30754. /** @hidden */
  30755. _texture: Nullable<InternalTexture>;
  30756. private _uid;
  30757. /**
  30758. * Define if the texture is preventinga material to render or not.
  30759. * If not and the texture is not ready, the engine will use a default black texture instead.
  30760. */
  30761. get isBlocking(): boolean;
  30762. /**
  30763. * Instantiates a new BaseTexture.
  30764. * Base class of all the textures in babylon.
  30765. * It groups all the common properties the materials, post process, lights... might need
  30766. * in order to make a correct use of the texture.
  30767. * @param scene Define the scene the texture blongs to
  30768. */
  30769. constructor(scene: Nullable<Scene>);
  30770. /**
  30771. * Get the scene the texture belongs to.
  30772. * @returns the scene or null if undefined
  30773. */
  30774. getScene(): Nullable<Scene>;
  30775. /**
  30776. * Get the texture transform matrix used to offset tile the texture for istance.
  30777. * @returns the transformation matrix
  30778. */
  30779. getTextureMatrix(): Matrix;
  30780. /**
  30781. * Get the texture reflection matrix used to rotate/transform the reflection.
  30782. * @returns the reflection matrix
  30783. */
  30784. getReflectionTextureMatrix(): Matrix;
  30785. /**
  30786. * Get the underlying lower level texture from Babylon.
  30787. * @returns the insternal texture
  30788. */
  30789. getInternalTexture(): Nullable<InternalTexture>;
  30790. /**
  30791. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30792. * @returns true if ready or not blocking
  30793. */
  30794. isReadyOrNotBlocking(): boolean;
  30795. /**
  30796. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30797. * @returns true if fully ready
  30798. */
  30799. isReady(): boolean;
  30800. private _cachedSize;
  30801. /**
  30802. * Get the size of the texture.
  30803. * @returns the texture size.
  30804. */
  30805. getSize(): ISize;
  30806. /**
  30807. * Get the base size of the texture.
  30808. * It can be different from the size if the texture has been resized for POT for instance
  30809. * @returns the base size
  30810. */
  30811. getBaseSize(): ISize;
  30812. /**
  30813. * Update the sampling mode of the texture.
  30814. * Default is Trilinear mode.
  30815. *
  30816. * | Value | Type | Description |
  30817. * | ----- | ------------------ | ----------- |
  30818. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30819. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30820. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30821. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30822. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30823. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30824. * | 7 | NEAREST_LINEAR | |
  30825. * | 8 | NEAREST_NEAREST | |
  30826. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30827. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30828. * | 11 | LINEAR_LINEAR | |
  30829. * | 12 | LINEAR_NEAREST | |
  30830. *
  30831. * > _mag_: magnification filter (close to the viewer)
  30832. * > _min_: minification filter (far from the viewer)
  30833. * > _mip_: filter used between mip map levels
  30834. *@param samplingMode Define the new sampling mode of the texture
  30835. */
  30836. updateSamplingMode(samplingMode: number): void;
  30837. /**
  30838. * Scales the texture if is `canRescale()`
  30839. * @param ratio the resize factor we want to use to rescale
  30840. */
  30841. scale(ratio: number): void;
  30842. /**
  30843. * Get if the texture can rescale.
  30844. */
  30845. get canRescale(): boolean;
  30846. /** @hidden */
  30847. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30848. /** @hidden */
  30849. _rebuild(): void;
  30850. /**
  30851. * Triggers the load sequence in delayed load mode.
  30852. */
  30853. delayLoad(): void;
  30854. /**
  30855. * Clones the texture.
  30856. * @returns the cloned texture
  30857. */
  30858. clone(): Nullable<BaseTexture>;
  30859. /**
  30860. * Get the texture underlying type (INT, FLOAT...)
  30861. */
  30862. get textureType(): number;
  30863. /**
  30864. * Get the texture underlying format (RGB, RGBA...)
  30865. */
  30866. get textureFormat(): number;
  30867. /**
  30868. * Indicates that textures need to be re-calculated for all materials
  30869. */
  30870. protected _markAllSubMeshesAsTexturesDirty(): void;
  30871. /**
  30872. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30873. * This will returns an RGBA array buffer containing either in values (0-255) or
  30874. * float values (0-1) depending of the underlying buffer type.
  30875. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30876. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30877. * @param buffer defines a user defined buffer to fill with data (can be null)
  30878. * @returns The Array buffer containing the pixels data.
  30879. */
  30880. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30881. /**
  30882. * Release and destroy the underlying lower level texture aka internalTexture.
  30883. */
  30884. releaseInternalTexture(): void;
  30885. /** @hidden */
  30886. get _lodTextureHigh(): Nullable<BaseTexture>;
  30887. /** @hidden */
  30888. get _lodTextureMid(): Nullable<BaseTexture>;
  30889. /** @hidden */
  30890. get _lodTextureLow(): Nullable<BaseTexture>;
  30891. /**
  30892. * Dispose the texture and release its associated resources.
  30893. */
  30894. dispose(): void;
  30895. /**
  30896. * Serialize the texture into a JSON representation that can be parsed later on.
  30897. * @returns the JSON representation of the texture
  30898. */
  30899. serialize(): any;
  30900. /**
  30901. * Helper function to be called back once a list of texture contains only ready textures.
  30902. * @param textures Define the list of textures to wait for
  30903. * @param callback Define the callback triggered once the entire list will be ready
  30904. */
  30905. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30906. }
  30907. }
  30908. declare module "babylonjs/Materials/effect" {
  30909. import { Observable } from "babylonjs/Misc/observable";
  30910. import { Nullable } from "babylonjs/types";
  30911. import { IDisposable } from "babylonjs/scene";
  30912. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30913. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30914. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30915. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30916. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30917. import { Engine } from "babylonjs/Engines/engine";
  30918. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30920. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30921. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30922. /**
  30923. * Options to be used when creating an effect.
  30924. */
  30925. export interface IEffectCreationOptions {
  30926. /**
  30927. * Atrributes that will be used in the shader.
  30928. */
  30929. attributes: string[];
  30930. /**
  30931. * Uniform varible names that will be set in the shader.
  30932. */
  30933. uniformsNames: string[];
  30934. /**
  30935. * Uniform buffer variable names that will be set in the shader.
  30936. */
  30937. uniformBuffersNames: string[];
  30938. /**
  30939. * Sampler texture variable names that will be set in the shader.
  30940. */
  30941. samplers: string[];
  30942. /**
  30943. * Define statements that will be set in the shader.
  30944. */
  30945. defines: any;
  30946. /**
  30947. * Possible fallbacks for this effect to improve performance when needed.
  30948. */
  30949. fallbacks: Nullable<IEffectFallbacks>;
  30950. /**
  30951. * Callback that will be called when the shader is compiled.
  30952. */
  30953. onCompiled: Nullable<(effect: Effect) => void>;
  30954. /**
  30955. * Callback that will be called if an error occurs during shader compilation.
  30956. */
  30957. onError: Nullable<(effect: Effect, errors: string) => void>;
  30958. /**
  30959. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30960. */
  30961. indexParameters?: any;
  30962. /**
  30963. * Max number of lights that can be used in the shader.
  30964. */
  30965. maxSimultaneousLights?: number;
  30966. /**
  30967. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30968. */
  30969. transformFeedbackVaryings?: Nullable<string[]>;
  30970. }
  30971. /**
  30972. * Effect containing vertex and fragment shader that can be executed on an object.
  30973. */
  30974. export class Effect implements IDisposable {
  30975. /**
  30976. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30977. */
  30978. static ShadersRepository: string;
  30979. /**
  30980. * Enable logging of the shader code when a compilation error occurs
  30981. */
  30982. static LogShaderCodeOnCompilationError: boolean;
  30983. /**
  30984. * Name of the effect.
  30985. */
  30986. name: any;
  30987. /**
  30988. * String container all the define statements that should be set on the shader.
  30989. */
  30990. defines: string;
  30991. /**
  30992. * Callback that will be called when the shader is compiled.
  30993. */
  30994. onCompiled: Nullable<(effect: Effect) => void>;
  30995. /**
  30996. * Callback that will be called if an error occurs during shader compilation.
  30997. */
  30998. onError: Nullable<(effect: Effect, errors: string) => void>;
  30999. /**
  31000. * Callback that will be called when effect is bound.
  31001. */
  31002. onBind: Nullable<(effect: Effect) => void>;
  31003. /**
  31004. * Unique ID of the effect.
  31005. */
  31006. uniqueId: number;
  31007. /**
  31008. * Observable that will be called when the shader is compiled.
  31009. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31010. */
  31011. onCompileObservable: Observable<Effect>;
  31012. /**
  31013. * Observable that will be called if an error occurs during shader compilation.
  31014. */
  31015. onErrorObservable: Observable<Effect>;
  31016. /** @hidden */
  31017. _onBindObservable: Nullable<Observable<Effect>>;
  31018. /**
  31019. * @hidden
  31020. * Specifies if the effect was previously ready
  31021. */
  31022. _wasPreviouslyReady: boolean;
  31023. /**
  31024. * Observable that will be called when effect is bound.
  31025. */
  31026. get onBindObservable(): Observable<Effect>;
  31027. /** @hidden */
  31028. _bonesComputationForcedToCPU: boolean;
  31029. private static _uniqueIdSeed;
  31030. private _engine;
  31031. private _uniformBuffersNames;
  31032. private _uniformsNames;
  31033. private _samplerList;
  31034. private _samplers;
  31035. private _isReady;
  31036. private _compilationError;
  31037. private _allFallbacksProcessed;
  31038. private _attributesNames;
  31039. private _attributes;
  31040. private _attributeLocationByName;
  31041. private _uniforms;
  31042. /**
  31043. * Key for the effect.
  31044. * @hidden
  31045. */
  31046. _key: string;
  31047. private _indexParameters;
  31048. private _fallbacks;
  31049. private _vertexSourceCode;
  31050. private _fragmentSourceCode;
  31051. private _vertexSourceCodeOverride;
  31052. private _fragmentSourceCodeOverride;
  31053. private _transformFeedbackVaryings;
  31054. /**
  31055. * Compiled shader to webGL program.
  31056. * @hidden
  31057. */
  31058. _pipelineContext: Nullable<IPipelineContext>;
  31059. private _valueCache;
  31060. private static _baseCache;
  31061. /**
  31062. * Instantiates an effect.
  31063. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31064. * @param baseName Name of the effect.
  31065. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31066. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31067. * @param samplers List of sampler variables that will be passed to the shader.
  31068. * @param engine Engine to be used to render the effect
  31069. * @param defines Define statements to be added to the shader.
  31070. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31071. * @param onCompiled Callback that will be called when the shader is compiled.
  31072. * @param onError Callback that will be called if an error occurs during shader compilation.
  31073. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31074. */
  31075. 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);
  31076. private _useFinalCode;
  31077. /**
  31078. * Unique key for this effect
  31079. */
  31080. get key(): string;
  31081. /**
  31082. * If the effect has been compiled and prepared.
  31083. * @returns if the effect is compiled and prepared.
  31084. */
  31085. isReady(): boolean;
  31086. private _isReadyInternal;
  31087. /**
  31088. * The engine the effect was initialized with.
  31089. * @returns the engine.
  31090. */
  31091. getEngine(): Engine;
  31092. /**
  31093. * The pipeline context for this effect
  31094. * @returns the associated pipeline context
  31095. */
  31096. getPipelineContext(): Nullable<IPipelineContext>;
  31097. /**
  31098. * The set of names of attribute variables for the shader.
  31099. * @returns An array of attribute names.
  31100. */
  31101. getAttributesNames(): string[];
  31102. /**
  31103. * Returns the attribute at the given index.
  31104. * @param index The index of the attribute.
  31105. * @returns The location of the attribute.
  31106. */
  31107. getAttributeLocation(index: number): number;
  31108. /**
  31109. * Returns the attribute based on the name of the variable.
  31110. * @param name of the attribute to look up.
  31111. * @returns the attribute location.
  31112. */
  31113. getAttributeLocationByName(name: string): number;
  31114. /**
  31115. * The number of attributes.
  31116. * @returns the numnber of attributes.
  31117. */
  31118. getAttributesCount(): number;
  31119. /**
  31120. * Gets the index of a uniform variable.
  31121. * @param uniformName of the uniform to look up.
  31122. * @returns the index.
  31123. */
  31124. getUniformIndex(uniformName: string): number;
  31125. /**
  31126. * Returns the attribute based on the name of the variable.
  31127. * @param uniformName of the uniform to look up.
  31128. * @returns the location of the uniform.
  31129. */
  31130. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31131. /**
  31132. * Returns an array of sampler variable names
  31133. * @returns The array of sampler variable neames.
  31134. */
  31135. getSamplers(): string[];
  31136. /**
  31137. * The error from the last compilation.
  31138. * @returns the error string.
  31139. */
  31140. getCompilationError(): string;
  31141. /**
  31142. * Gets a boolean indicating that all fallbacks were used during compilation
  31143. * @returns true if all fallbacks were used
  31144. */
  31145. allFallbacksProcessed(): boolean;
  31146. /**
  31147. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31148. * @param func The callback to be used.
  31149. */
  31150. executeWhenCompiled(func: (effect: Effect) => void): void;
  31151. private _checkIsReady;
  31152. private _loadShader;
  31153. /**
  31154. * Recompiles the webGL program
  31155. * @param vertexSourceCode The source code for the vertex shader.
  31156. * @param fragmentSourceCode The source code for the fragment shader.
  31157. * @param onCompiled Callback called when completed.
  31158. * @param onError Callback called on error.
  31159. * @hidden
  31160. */
  31161. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31162. /**
  31163. * Prepares the effect
  31164. * @hidden
  31165. */
  31166. _prepareEffect(): void;
  31167. private _getShaderCodeAndErrorLine;
  31168. private _processCompilationErrors;
  31169. /**
  31170. * Checks if the effect is supported. (Must be called after compilation)
  31171. */
  31172. get isSupported(): boolean;
  31173. /**
  31174. * Binds a texture to the engine to be used as output of the shader.
  31175. * @param channel Name of the output variable.
  31176. * @param texture Texture to bind.
  31177. * @hidden
  31178. */
  31179. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31180. /**
  31181. * Sets a texture on the engine to be used in the shader.
  31182. * @param channel Name of the sampler variable.
  31183. * @param texture Texture to set.
  31184. */
  31185. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31186. /**
  31187. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31188. * @param channel Name of the sampler variable.
  31189. * @param texture Texture to set.
  31190. */
  31191. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31192. /**
  31193. * Sets an array of textures on the engine to be used in the shader.
  31194. * @param channel Name of the variable.
  31195. * @param textures Textures to set.
  31196. */
  31197. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31198. /**
  31199. * 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)
  31200. * @param channel Name of the sampler variable.
  31201. * @param postProcess Post process to get the input texture from.
  31202. */
  31203. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31204. /**
  31205. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31206. * 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)
  31207. * @param channel Name of the sampler variable.
  31208. * @param postProcess Post process to get the output texture from.
  31209. */
  31210. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31211. /** @hidden */
  31212. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31213. /** @hidden */
  31214. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31215. /** @hidden */
  31216. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31217. /** @hidden */
  31218. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31219. /**
  31220. * Binds a buffer to a uniform.
  31221. * @param buffer Buffer to bind.
  31222. * @param name Name of the uniform variable to bind to.
  31223. */
  31224. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31225. /**
  31226. * Binds block to a uniform.
  31227. * @param blockName Name of the block to bind.
  31228. * @param index Index to bind.
  31229. */
  31230. bindUniformBlock(blockName: string, index: number): void;
  31231. /**
  31232. * Sets an interger value on a uniform variable.
  31233. * @param uniformName Name of the variable.
  31234. * @param value Value to be set.
  31235. * @returns this effect.
  31236. */
  31237. setInt(uniformName: string, value: number): Effect;
  31238. /**
  31239. * Sets an int array on a uniform variable.
  31240. * @param uniformName Name of the variable.
  31241. * @param array array to be set.
  31242. * @returns this effect.
  31243. */
  31244. setIntArray(uniformName: string, array: Int32Array): Effect;
  31245. /**
  31246. * 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)
  31247. * @param uniformName Name of the variable.
  31248. * @param array array to be set.
  31249. * @returns this effect.
  31250. */
  31251. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31252. /**
  31253. * 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)
  31254. * @param uniformName Name of the variable.
  31255. * @param array array to be set.
  31256. * @returns this effect.
  31257. */
  31258. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31259. /**
  31260. * 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)
  31261. * @param uniformName Name of the variable.
  31262. * @param array array to be set.
  31263. * @returns this effect.
  31264. */
  31265. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31266. /**
  31267. * Sets an float array on a uniform variable.
  31268. * @param uniformName Name of the variable.
  31269. * @param array array to be set.
  31270. * @returns this effect.
  31271. */
  31272. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31273. /**
  31274. * 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)
  31275. * @param uniformName Name of the variable.
  31276. * @param array array to be set.
  31277. * @returns this effect.
  31278. */
  31279. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31280. /**
  31281. * 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)
  31282. * @param uniformName Name of the variable.
  31283. * @param array array to be set.
  31284. * @returns this effect.
  31285. */
  31286. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31287. /**
  31288. * 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)
  31289. * @param uniformName Name of the variable.
  31290. * @param array array to be set.
  31291. * @returns this effect.
  31292. */
  31293. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31294. /**
  31295. * Sets an array on a uniform variable.
  31296. * @param uniformName Name of the variable.
  31297. * @param array array to be set.
  31298. * @returns this effect.
  31299. */
  31300. setArray(uniformName: string, array: number[]): Effect;
  31301. /**
  31302. * 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)
  31303. * @param uniformName Name of the variable.
  31304. * @param array array to be set.
  31305. * @returns this effect.
  31306. */
  31307. setArray2(uniformName: string, array: number[]): Effect;
  31308. /**
  31309. * 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)
  31310. * @param uniformName Name of the variable.
  31311. * @param array array to be set.
  31312. * @returns this effect.
  31313. */
  31314. setArray3(uniformName: string, array: number[]): Effect;
  31315. /**
  31316. * 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)
  31317. * @param uniformName Name of the variable.
  31318. * @param array array to be set.
  31319. * @returns this effect.
  31320. */
  31321. setArray4(uniformName: string, array: number[]): Effect;
  31322. /**
  31323. * Sets matrices on a uniform variable.
  31324. * @param uniformName Name of the variable.
  31325. * @param matrices matrices to be set.
  31326. * @returns this effect.
  31327. */
  31328. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31329. /**
  31330. * Sets matrix on a uniform variable.
  31331. * @param uniformName Name of the variable.
  31332. * @param matrix matrix to be set.
  31333. * @returns this effect.
  31334. */
  31335. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31336. /**
  31337. * 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)
  31338. * @param uniformName Name of the variable.
  31339. * @param matrix matrix to be set.
  31340. * @returns this effect.
  31341. */
  31342. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31343. /**
  31344. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31345. * @param uniformName Name of the variable.
  31346. * @param matrix matrix to be set.
  31347. * @returns this effect.
  31348. */
  31349. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31350. /**
  31351. * Sets a float on a uniform variable.
  31352. * @param uniformName Name of the variable.
  31353. * @param value value to be set.
  31354. * @returns this effect.
  31355. */
  31356. setFloat(uniformName: string, value: number): Effect;
  31357. /**
  31358. * Sets a boolean on a uniform variable.
  31359. * @param uniformName Name of the variable.
  31360. * @param bool value to be set.
  31361. * @returns this effect.
  31362. */
  31363. setBool(uniformName: string, bool: boolean): Effect;
  31364. /**
  31365. * Sets a Vector2 on a uniform variable.
  31366. * @param uniformName Name of the variable.
  31367. * @param vector2 vector2 to be set.
  31368. * @returns this effect.
  31369. */
  31370. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31371. /**
  31372. * Sets a float2 on a uniform variable.
  31373. * @param uniformName Name of the variable.
  31374. * @param x First float in float2.
  31375. * @param y Second float in float2.
  31376. * @returns this effect.
  31377. */
  31378. setFloat2(uniformName: string, x: number, y: number): Effect;
  31379. /**
  31380. * Sets a Vector3 on a uniform variable.
  31381. * @param uniformName Name of the variable.
  31382. * @param vector3 Value to be set.
  31383. * @returns this effect.
  31384. */
  31385. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31386. /**
  31387. * Sets a float3 on a uniform variable.
  31388. * @param uniformName Name of the variable.
  31389. * @param x First float in float3.
  31390. * @param y Second float in float3.
  31391. * @param z Third float in float3.
  31392. * @returns this effect.
  31393. */
  31394. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31395. /**
  31396. * Sets a Vector4 on a uniform variable.
  31397. * @param uniformName Name of the variable.
  31398. * @param vector4 Value to be set.
  31399. * @returns this effect.
  31400. */
  31401. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31402. /**
  31403. * Sets a float4 on a uniform variable.
  31404. * @param uniformName Name of the variable.
  31405. * @param x First float in float4.
  31406. * @param y Second float in float4.
  31407. * @param z Third float in float4.
  31408. * @param w Fourth float in float4.
  31409. * @returns this effect.
  31410. */
  31411. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31412. /**
  31413. * Sets a Color3 on a uniform variable.
  31414. * @param uniformName Name of the variable.
  31415. * @param color3 Value to be set.
  31416. * @returns this effect.
  31417. */
  31418. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31419. /**
  31420. * Sets a Color4 on a uniform variable.
  31421. * @param uniformName Name of the variable.
  31422. * @param color3 Value to be set.
  31423. * @param alpha Alpha value to be set.
  31424. * @returns this effect.
  31425. */
  31426. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31427. /**
  31428. * Sets a Color4 on a uniform variable
  31429. * @param uniformName defines the name of the variable
  31430. * @param color4 defines the value to be set
  31431. * @returns this effect.
  31432. */
  31433. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31434. /** Release all associated resources */
  31435. dispose(): void;
  31436. /**
  31437. * This function will add a new shader to the shader store
  31438. * @param name the name of the shader
  31439. * @param pixelShader optional pixel shader content
  31440. * @param vertexShader optional vertex shader content
  31441. */
  31442. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31443. /**
  31444. * Store of each shader (The can be looked up using effect.key)
  31445. */
  31446. static ShadersStore: {
  31447. [key: string]: string;
  31448. };
  31449. /**
  31450. * Store of each included file for a shader (The can be looked up using effect.key)
  31451. */
  31452. static IncludesShadersStore: {
  31453. [key: string]: string;
  31454. };
  31455. /**
  31456. * Resets the cache of effects.
  31457. */
  31458. static ResetCache(): void;
  31459. }
  31460. }
  31461. declare module "babylonjs/Engines/engineCapabilities" {
  31462. /**
  31463. * Interface used to describe the capabilities of the engine relatively to the current browser
  31464. */
  31465. export interface EngineCapabilities {
  31466. /** Maximum textures units per fragment shader */
  31467. maxTexturesImageUnits: number;
  31468. /** Maximum texture units per vertex shader */
  31469. maxVertexTextureImageUnits: number;
  31470. /** Maximum textures units in the entire pipeline */
  31471. maxCombinedTexturesImageUnits: number;
  31472. /** Maximum texture size */
  31473. maxTextureSize: number;
  31474. /** Maximum texture samples */
  31475. maxSamples?: number;
  31476. /** Maximum cube texture size */
  31477. maxCubemapTextureSize: number;
  31478. /** Maximum render texture size */
  31479. maxRenderTextureSize: number;
  31480. /** Maximum number of vertex attributes */
  31481. maxVertexAttribs: number;
  31482. /** Maximum number of varyings */
  31483. maxVaryingVectors: number;
  31484. /** Maximum number of uniforms per vertex shader */
  31485. maxVertexUniformVectors: number;
  31486. /** Maximum number of uniforms per fragment shader */
  31487. maxFragmentUniformVectors: number;
  31488. /** Defines if standard derivates (dx/dy) are supported */
  31489. standardDerivatives: boolean;
  31490. /** Defines if s3tc texture compression is supported */
  31491. s3tc?: WEBGL_compressed_texture_s3tc;
  31492. /** Defines if pvrtc texture compression is supported */
  31493. pvrtc: any;
  31494. /** Defines if etc1 texture compression is supported */
  31495. etc1: any;
  31496. /** Defines if etc2 texture compression is supported */
  31497. etc2: any;
  31498. /** Defines if astc texture compression is supported */
  31499. astc: any;
  31500. /** Defines if float textures are supported */
  31501. textureFloat: boolean;
  31502. /** Defines if vertex array objects are supported */
  31503. vertexArrayObject: boolean;
  31504. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31505. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31506. /** Gets the maximum level of anisotropy supported */
  31507. maxAnisotropy: number;
  31508. /** Defines if instancing is supported */
  31509. instancedArrays: boolean;
  31510. /** Defines if 32 bits indices are supported */
  31511. uintIndices: boolean;
  31512. /** Defines if high precision shaders are supported */
  31513. highPrecisionShaderSupported: boolean;
  31514. /** Defines if depth reading in the fragment shader is supported */
  31515. fragmentDepthSupported: boolean;
  31516. /** Defines if float texture linear filtering is supported*/
  31517. textureFloatLinearFiltering: boolean;
  31518. /** Defines if rendering to float textures is supported */
  31519. textureFloatRender: boolean;
  31520. /** Defines if half float textures are supported*/
  31521. textureHalfFloat: boolean;
  31522. /** Defines if half float texture linear filtering is supported*/
  31523. textureHalfFloatLinearFiltering: boolean;
  31524. /** Defines if rendering to half float textures is supported */
  31525. textureHalfFloatRender: boolean;
  31526. /** Defines if textureLOD shader command is supported */
  31527. textureLOD: boolean;
  31528. /** Defines if draw buffers extension is supported */
  31529. drawBuffersExtension: boolean;
  31530. /** Defines if depth textures are supported */
  31531. depthTextureExtension: boolean;
  31532. /** Defines if float color buffer are supported */
  31533. colorBufferFloat: boolean;
  31534. /** Gets disjoint timer query extension (null if not supported) */
  31535. timerQuery?: EXT_disjoint_timer_query;
  31536. /** Defines if timestamp can be used with timer query */
  31537. canUseTimestampForTimerQuery: boolean;
  31538. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31539. multiview?: any;
  31540. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31541. oculusMultiview?: any;
  31542. /** Function used to let the system compiles shaders in background */
  31543. parallelShaderCompile?: {
  31544. COMPLETION_STATUS_KHR: number;
  31545. };
  31546. /** Max number of texture samples for MSAA */
  31547. maxMSAASamples: number;
  31548. /** Defines if the blend min max extension is supported */
  31549. blendMinMax: boolean;
  31550. }
  31551. }
  31552. declare module "babylonjs/States/depthCullingState" {
  31553. import { Nullable } from "babylonjs/types";
  31554. /**
  31555. * @hidden
  31556. **/
  31557. export class DepthCullingState {
  31558. private _isDepthTestDirty;
  31559. private _isDepthMaskDirty;
  31560. private _isDepthFuncDirty;
  31561. private _isCullFaceDirty;
  31562. private _isCullDirty;
  31563. private _isZOffsetDirty;
  31564. private _isFrontFaceDirty;
  31565. private _depthTest;
  31566. private _depthMask;
  31567. private _depthFunc;
  31568. private _cull;
  31569. private _cullFace;
  31570. private _zOffset;
  31571. private _frontFace;
  31572. /**
  31573. * Initializes the state.
  31574. */
  31575. constructor();
  31576. get isDirty(): boolean;
  31577. get zOffset(): number;
  31578. set zOffset(value: number);
  31579. get cullFace(): Nullable<number>;
  31580. set cullFace(value: Nullable<number>);
  31581. get cull(): Nullable<boolean>;
  31582. set cull(value: Nullable<boolean>);
  31583. get depthFunc(): Nullable<number>;
  31584. set depthFunc(value: Nullable<number>);
  31585. get depthMask(): boolean;
  31586. set depthMask(value: boolean);
  31587. get depthTest(): boolean;
  31588. set depthTest(value: boolean);
  31589. get frontFace(): Nullable<number>;
  31590. set frontFace(value: Nullable<number>);
  31591. reset(): void;
  31592. apply(gl: WebGLRenderingContext): void;
  31593. }
  31594. }
  31595. declare module "babylonjs/States/stencilState" {
  31596. /**
  31597. * @hidden
  31598. **/
  31599. export class StencilState {
  31600. /** 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 */
  31601. static readonly ALWAYS: number;
  31602. /** Passed to stencilOperation to specify that stencil value must be kept */
  31603. static readonly KEEP: number;
  31604. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31605. static readonly REPLACE: number;
  31606. private _isStencilTestDirty;
  31607. private _isStencilMaskDirty;
  31608. private _isStencilFuncDirty;
  31609. private _isStencilOpDirty;
  31610. private _stencilTest;
  31611. private _stencilMask;
  31612. private _stencilFunc;
  31613. private _stencilFuncRef;
  31614. private _stencilFuncMask;
  31615. private _stencilOpStencilFail;
  31616. private _stencilOpDepthFail;
  31617. private _stencilOpStencilDepthPass;
  31618. get isDirty(): boolean;
  31619. get stencilFunc(): number;
  31620. set stencilFunc(value: number);
  31621. get stencilFuncRef(): number;
  31622. set stencilFuncRef(value: number);
  31623. get stencilFuncMask(): number;
  31624. set stencilFuncMask(value: number);
  31625. get stencilOpStencilFail(): number;
  31626. set stencilOpStencilFail(value: number);
  31627. get stencilOpDepthFail(): number;
  31628. set stencilOpDepthFail(value: number);
  31629. get stencilOpStencilDepthPass(): number;
  31630. set stencilOpStencilDepthPass(value: number);
  31631. get stencilMask(): number;
  31632. set stencilMask(value: number);
  31633. get stencilTest(): boolean;
  31634. set stencilTest(value: boolean);
  31635. constructor();
  31636. reset(): void;
  31637. apply(gl: WebGLRenderingContext): void;
  31638. }
  31639. }
  31640. declare module "babylonjs/States/alphaCullingState" {
  31641. /**
  31642. * @hidden
  31643. **/
  31644. export class AlphaState {
  31645. private _isAlphaBlendDirty;
  31646. private _isBlendFunctionParametersDirty;
  31647. private _isBlendEquationParametersDirty;
  31648. private _isBlendConstantsDirty;
  31649. private _alphaBlend;
  31650. private _blendFunctionParameters;
  31651. private _blendEquationParameters;
  31652. private _blendConstants;
  31653. /**
  31654. * Initializes the state.
  31655. */
  31656. constructor();
  31657. get isDirty(): boolean;
  31658. get alphaBlend(): boolean;
  31659. set alphaBlend(value: boolean);
  31660. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31661. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31662. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31663. reset(): void;
  31664. apply(gl: WebGLRenderingContext): void;
  31665. }
  31666. }
  31667. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31668. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31669. /** @hidden */
  31670. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31671. attributeProcessor(attribute: string): string;
  31672. varyingProcessor(varying: string, isFragment: boolean): string;
  31673. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31674. }
  31675. }
  31676. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31677. /**
  31678. * Interface for attribute information associated with buffer instanciation
  31679. */
  31680. export interface InstancingAttributeInfo {
  31681. /**
  31682. * Name of the GLSL attribute
  31683. * if attribute index is not specified, this is used to retrieve the index from the effect
  31684. */
  31685. attributeName: string;
  31686. /**
  31687. * Index/offset of the attribute in the vertex shader
  31688. * if not specified, this will be computes from the name.
  31689. */
  31690. index?: number;
  31691. /**
  31692. * size of the attribute, 1, 2, 3 or 4
  31693. */
  31694. attributeSize: number;
  31695. /**
  31696. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31697. */
  31698. offset: number;
  31699. /**
  31700. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31701. * default to 1
  31702. */
  31703. divisor?: number;
  31704. /**
  31705. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31706. * default is FLOAT
  31707. */
  31708. attributeType?: number;
  31709. /**
  31710. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31711. */
  31712. normalized?: boolean;
  31713. }
  31714. }
  31715. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31717. import { Nullable } from "babylonjs/types";
  31718. module "babylonjs/Engines/thinEngine" {
  31719. interface ThinEngine {
  31720. /**
  31721. * Update a video texture
  31722. * @param texture defines the texture to update
  31723. * @param video defines the video element to use
  31724. * @param invertY defines if data must be stored with Y axis inverted
  31725. */
  31726. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31727. }
  31728. }
  31729. }
  31730. declare module "babylonjs/Materials/Textures/videoTexture" {
  31731. import { Observable } from "babylonjs/Misc/observable";
  31732. import { Nullable } from "babylonjs/types";
  31733. import { Scene } from "babylonjs/scene";
  31734. import { Texture } from "babylonjs/Materials/Textures/texture";
  31735. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31736. /**
  31737. * Settings for finer control over video usage
  31738. */
  31739. export interface VideoTextureSettings {
  31740. /**
  31741. * Applies `autoplay` to video, if specified
  31742. */
  31743. autoPlay?: boolean;
  31744. /**
  31745. * Applies `loop` to video, if specified
  31746. */
  31747. loop?: boolean;
  31748. /**
  31749. * Automatically updates internal texture from video at every frame in the render loop
  31750. */
  31751. autoUpdateTexture: boolean;
  31752. /**
  31753. * Image src displayed during the video loading or until the user interacts with the video.
  31754. */
  31755. poster?: string;
  31756. }
  31757. /**
  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. */
  31762. export class VideoTexture extends Texture {
  31763. /**
  31764. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31765. */
  31766. readonly autoUpdateTexture: boolean;
  31767. /**
  31768. * The video instance used by the texture internally
  31769. */
  31770. readonly video: HTMLVideoElement;
  31771. private _onUserActionRequestedObservable;
  31772. /**
  31773. * Event triggerd when a dom action is required by the user to play the video.
  31774. * This happens due to recent changes in browser policies preventing video to auto start.
  31775. */
  31776. get onUserActionRequestedObservable(): Observable<Texture>;
  31777. private _generateMipMaps;
  31778. private _engine;
  31779. private _stillImageCaptured;
  31780. private _displayingPosterTexture;
  31781. private _settings;
  31782. private _createInternalTextureOnEvent;
  31783. private _frameId;
  31784. private _currentSrc;
  31785. /**
  31786. * Creates a video texture.
  31787. * If you want to display a video in your scene, this is the special texture for that.
  31788. * This special texture works similar to other textures, with the exception of a few parameters.
  31789. * @see https://doc.babylonjs.com/how_to/video_texture
  31790. * @param name optional name, will detect from video source, if not defined
  31791. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31792. * @param scene is obviously the current scene.
  31793. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31794. * @param invertY is false by default but can be used to invert video on Y axis
  31795. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31796. * @param settings allows finer control over video usage
  31797. */
  31798. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31799. private _getName;
  31800. private _getVideo;
  31801. private _createInternalTexture;
  31802. private reset;
  31803. /**
  31804. * @hidden Internal method to initiate `update`.
  31805. */
  31806. _rebuild(): void;
  31807. /**
  31808. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31809. */
  31810. update(): void;
  31811. /**
  31812. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31813. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31814. */
  31815. updateTexture(isVisible: boolean): void;
  31816. protected _updateInternalTexture: () => void;
  31817. /**
  31818. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31819. * @param url New url.
  31820. */
  31821. updateURL(url: string): void;
  31822. /**
  31823. * Clones the texture.
  31824. * @returns the cloned texture
  31825. */
  31826. clone(): VideoTexture;
  31827. /**
  31828. * Dispose the texture and release its associated resources.
  31829. */
  31830. dispose(): void;
  31831. /**
  31832. * Creates a video texture straight from a stream.
  31833. * @param scene Define the scene the texture should be created in
  31834. * @param stream Define the stream the texture should be created from
  31835. * @returns The created video texture as a promise
  31836. */
  31837. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31838. /**
  31839. * Creates a video texture straight from your WebCam video feed.
  31840. * @param scene Define the scene the texture should be created in
  31841. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31842. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31843. * @returns The created video texture as a promise
  31844. */
  31845. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31846. minWidth: number;
  31847. maxWidth: number;
  31848. minHeight: number;
  31849. maxHeight: number;
  31850. deviceId: string;
  31851. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31852. /**
  31853. * Creates a video texture straight from your WebCam video feed.
  31854. * @param scene Define the scene the texture should be created in
  31855. * @param onReady Define a callback to triggered once the texture will be ready
  31856. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31857. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31858. */
  31859. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31860. minWidth: number;
  31861. maxWidth: number;
  31862. minHeight: number;
  31863. maxHeight: number;
  31864. deviceId: string;
  31865. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31866. }
  31867. }
  31868. declare module "babylonjs/Engines/thinEngine" {
  31869. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31870. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31871. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31872. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31873. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31874. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31875. import { Observable } from "babylonjs/Misc/observable";
  31876. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31877. import { StencilState } from "babylonjs/States/stencilState";
  31878. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31879. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31880. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31881. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31882. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31883. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31884. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31885. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31886. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31888. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31889. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31890. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31891. import { WebRequest } from "babylonjs/Misc/webRequest";
  31892. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31893. /**
  31894. * Defines the interface used by objects working like Scene
  31895. * @hidden
  31896. */
  31897. export interface ISceneLike {
  31898. _addPendingData(data: any): void;
  31899. _removePendingData(data: any): void;
  31900. offlineProvider: IOfflineProvider;
  31901. }
  31902. /** Interface defining initialization parameters for Engine class */
  31903. export interface EngineOptions extends WebGLContextAttributes {
  31904. /**
  31905. * Defines if the engine should no exceed a specified device ratio
  31906. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31907. */
  31908. limitDeviceRatio?: number;
  31909. /**
  31910. * Defines if webvr should be enabled automatically
  31911. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31912. */
  31913. autoEnableWebVR?: boolean;
  31914. /**
  31915. * Defines if webgl2 should be turned off even if supported
  31916. * @see http://doc.babylonjs.com/features/webgl2
  31917. */
  31918. disableWebGL2Support?: boolean;
  31919. /**
  31920. * Defines if webaudio should be initialized as well
  31921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31922. */
  31923. audioEngine?: boolean;
  31924. /**
  31925. * Defines if animations should run using a deterministic lock step
  31926. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31927. */
  31928. deterministicLockstep?: boolean;
  31929. /** Defines the maximum steps to use with deterministic lock step mode */
  31930. lockstepMaxSteps?: number;
  31931. /** Defines the seconds between each deterministic lock step */
  31932. timeStep?: number;
  31933. /**
  31934. * Defines that engine should ignore context lost events
  31935. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31936. */
  31937. doNotHandleContextLost?: boolean;
  31938. /**
  31939. * Defines that engine should ignore modifying touch action attribute and style
  31940. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31941. */
  31942. doNotHandleTouchAction?: boolean;
  31943. /**
  31944. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31945. */
  31946. useHighPrecisionFloats?: boolean;
  31947. }
  31948. /**
  31949. * The base engine class (root of all engines)
  31950. */
  31951. export class ThinEngine {
  31952. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31953. static ExceptionList: ({
  31954. key: string;
  31955. capture: string;
  31956. captureConstraint: number;
  31957. targets: string[];
  31958. } | {
  31959. key: string;
  31960. capture: null;
  31961. captureConstraint: null;
  31962. targets: string[];
  31963. })[];
  31964. /** @hidden */
  31965. static _TextureLoaders: IInternalTextureLoader[];
  31966. /**
  31967. * Returns the current npm package of the sdk
  31968. */
  31969. static get NpmPackage(): string;
  31970. /**
  31971. * Returns the current version of the framework
  31972. */
  31973. static get Version(): string;
  31974. /**
  31975. * Returns a string describing the current engine
  31976. */
  31977. get description(): string;
  31978. /**
  31979. * Gets or sets the epsilon value used by collision engine
  31980. */
  31981. static CollisionsEpsilon: number;
  31982. /**
  31983. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31984. */
  31985. static get ShadersRepository(): string;
  31986. static set ShadersRepository(value: string);
  31987. /** @hidden */
  31988. _shaderProcessor: IShaderProcessor;
  31989. /**
  31990. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31991. */
  31992. forcePOTTextures: boolean;
  31993. /**
  31994. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31995. */
  31996. isFullscreen: boolean;
  31997. /**
  31998. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31999. */
  32000. cullBackFaces: boolean;
  32001. /**
  32002. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32003. */
  32004. renderEvenInBackground: boolean;
  32005. /**
  32006. * Gets or sets a boolean indicating that cache can be kept between frames
  32007. */
  32008. preventCacheWipeBetweenFrames: boolean;
  32009. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32010. validateShaderPrograms: boolean;
  32011. /**
  32012. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32013. * This can provide greater z depth for distant objects.
  32014. */
  32015. useReverseDepthBuffer: boolean;
  32016. /**
  32017. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32018. */
  32019. disableUniformBuffers: boolean;
  32020. /** @hidden */
  32021. _uniformBuffers: UniformBuffer[];
  32022. /**
  32023. * Gets a boolean indicating that the engine supports uniform buffers
  32024. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32025. */
  32026. get supportsUniformBuffers(): boolean;
  32027. /** @hidden */
  32028. _gl: WebGLRenderingContext;
  32029. /** @hidden */
  32030. _webGLVersion: number;
  32031. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32032. protected _windowIsBackground: boolean;
  32033. protected _creationOptions: EngineOptions;
  32034. protected _highPrecisionShadersAllowed: boolean;
  32035. /** @hidden */
  32036. get _shouldUseHighPrecisionShader(): boolean;
  32037. /**
  32038. * Gets a boolean indicating that only power of 2 textures are supported
  32039. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32040. */
  32041. get needPOTTextures(): boolean;
  32042. /** @hidden */
  32043. _badOS: boolean;
  32044. /** @hidden */
  32045. _badDesktopOS: boolean;
  32046. private _hardwareScalingLevel;
  32047. /** @hidden */
  32048. _caps: EngineCapabilities;
  32049. private _isStencilEnable;
  32050. private _glVersion;
  32051. private _glRenderer;
  32052. private _glVendor;
  32053. /** @hidden */
  32054. _videoTextureSupported: boolean;
  32055. protected _renderingQueueLaunched: boolean;
  32056. protected _activeRenderLoops: (() => void)[];
  32057. /**
  32058. * Observable signaled when a context lost event is raised
  32059. */
  32060. onContextLostObservable: Observable<ThinEngine>;
  32061. /**
  32062. * Observable signaled when a context restored event is raised
  32063. */
  32064. onContextRestoredObservable: Observable<ThinEngine>;
  32065. private _onContextLost;
  32066. private _onContextRestored;
  32067. protected _contextWasLost: boolean;
  32068. /** @hidden */
  32069. _doNotHandleContextLost: boolean;
  32070. /**
  32071. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32073. */
  32074. get doNotHandleContextLost(): boolean;
  32075. set doNotHandleContextLost(value: boolean);
  32076. /**
  32077. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32078. */
  32079. disableVertexArrayObjects: boolean;
  32080. /** @hidden */
  32081. protected _colorWrite: boolean;
  32082. /** @hidden */
  32083. protected _colorWriteChanged: boolean;
  32084. /** @hidden */
  32085. protected _depthCullingState: DepthCullingState;
  32086. /** @hidden */
  32087. protected _stencilState: StencilState;
  32088. /** @hidden */
  32089. _alphaState: AlphaState;
  32090. /** @hidden */
  32091. _alphaMode: number;
  32092. /** @hidden */
  32093. _alphaEquation: number;
  32094. /** @hidden */
  32095. _internalTexturesCache: InternalTexture[];
  32096. /** @hidden */
  32097. protected _activeChannel: number;
  32098. private _currentTextureChannel;
  32099. /** @hidden */
  32100. protected _boundTexturesCache: {
  32101. [key: string]: Nullable<InternalTexture>;
  32102. };
  32103. /** @hidden */
  32104. protected _currentEffect: Nullable<Effect>;
  32105. /** @hidden */
  32106. protected _currentProgram: Nullable<WebGLProgram>;
  32107. private _compiledEffects;
  32108. private _vertexAttribArraysEnabled;
  32109. /** @hidden */
  32110. protected _cachedViewport: Nullable<IViewportLike>;
  32111. private _cachedVertexArrayObject;
  32112. /** @hidden */
  32113. protected _cachedVertexBuffers: any;
  32114. /** @hidden */
  32115. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32116. /** @hidden */
  32117. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32118. /** @hidden */
  32119. _currentRenderTarget: Nullable<InternalTexture>;
  32120. private _uintIndicesCurrentlySet;
  32121. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32122. /** @hidden */
  32123. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32124. private _currentBufferPointers;
  32125. private _currentInstanceLocations;
  32126. private _currentInstanceBuffers;
  32127. private _textureUnits;
  32128. /** @hidden */
  32129. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32130. /** @hidden */
  32131. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32132. /** @hidden */
  32133. _boundRenderFunction: any;
  32134. private _vaoRecordInProgress;
  32135. private _mustWipeVertexAttributes;
  32136. private _emptyTexture;
  32137. private _emptyCubeTexture;
  32138. private _emptyTexture3D;
  32139. private _emptyTexture2DArray;
  32140. /** @hidden */
  32141. _frameHandler: number;
  32142. private _nextFreeTextureSlots;
  32143. private _maxSimultaneousTextures;
  32144. private _activeRequests;
  32145. protected _texturesSupported: string[];
  32146. /** @hidden */
  32147. _textureFormatInUse: Nullable<string>;
  32148. protected get _supportsHardwareTextureRescaling(): boolean;
  32149. private _framebufferDimensionsObject;
  32150. /**
  32151. * sets the object from which width and height will be taken from when getting render width and height
  32152. * Will fallback to the gl object
  32153. * @param dimensions the framebuffer width and height that will be used.
  32154. */
  32155. set framebufferDimensionsObject(dimensions: Nullable<{
  32156. framebufferWidth: number;
  32157. framebufferHeight: number;
  32158. }>);
  32159. /**
  32160. * Gets the list of texture formats supported
  32161. */
  32162. get texturesSupported(): Array<string>;
  32163. /**
  32164. * Gets the list of texture formats in use
  32165. */
  32166. get textureFormatInUse(): Nullable<string>;
  32167. /**
  32168. * Gets the current viewport
  32169. */
  32170. get currentViewport(): Nullable<IViewportLike>;
  32171. /**
  32172. * Gets the default empty texture
  32173. */
  32174. get emptyTexture(): InternalTexture;
  32175. /**
  32176. * Gets the default empty 3D texture
  32177. */
  32178. get emptyTexture3D(): InternalTexture;
  32179. /**
  32180. * Gets the default empty 2D array texture
  32181. */
  32182. get emptyTexture2DArray(): InternalTexture;
  32183. /**
  32184. * Gets the default empty cube texture
  32185. */
  32186. get emptyCubeTexture(): InternalTexture;
  32187. /**
  32188. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32189. */
  32190. readonly premultipliedAlpha: boolean;
  32191. /**
  32192. * Observable event triggered before each texture is initialized
  32193. */
  32194. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32195. /**
  32196. * Creates a new engine
  32197. * @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
  32198. * @param antialias defines enable antialiasing (default: false)
  32199. * @param options defines further options to be sent to the getContext() function
  32200. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32201. */
  32202. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32203. private _rebuildInternalTextures;
  32204. private _rebuildEffects;
  32205. /**
  32206. * Gets a boolean indicating if all created effects are ready
  32207. * @returns true if all effects are ready
  32208. */
  32209. areAllEffectsReady(): boolean;
  32210. protected _rebuildBuffers(): void;
  32211. private _initGLContext;
  32212. /**
  32213. * Gets version of the current webGL context
  32214. */
  32215. get webGLVersion(): number;
  32216. /**
  32217. * Gets a string idenfifying the name of the class
  32218. * @returns "Engine" string
  32219. */
  32220. getClassName(): string;
  32221. /**
  32222. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32223. */
  32224. get isStencilEnable(): boolean;
  32225. /** @hidden */
  32226. _prepareWorkingCanvas(): void;
  32227. /**
  32228. * Reset the texture cache to empty state
  32229. */
  32230. resetTextureCache(): void;
  32231. /**
  32232. * Gets an object containing information about the current webGL context
  32233. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32234. */
  32235. getGlInfo(): {
  32236. vendor: string;
  32237. renderer: string;
  32238. version: string;
  32239. };
  32240. /**
  32241. * Defines the hardware scaling level.
  32242. * By default the hardware scaling level is computed from the window device ratio.
  32243. * 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.
  32244. * @param level defines the level to use
  32245. */
  32246. setHardwareScalingLevel(level: number): void;
  32247. /**
  32248. * Gets the current hardware scaling level.
  32249. * By default the hardware scaling level is computed from the window device ratio.
  32250. * 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.
  32251. * @returns a number indicating the current hardware scaling level
  32252. */
  32253. getHardwareScalingLevel(): number;
  32254. /**
  32255. * Gets the list of loaded textures
  32256. * @returns an array containing all loaded textures
  32257. */
  32258. getLoadedTexturesCache(): InternalTexture[];
  32259. /**
  32260. * Gets the object containing all engine capabilities
  32261. * @returns the EngineCapabilities object
  32262. */
  32263. getCaps(): EngineCapabilities;
  32264. /**
  32265. * stop executing a render loop function and remove it from the execution array
  32266. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32267. */
  32268. stopRenderLoop(renderFunction?: () => void): void;
  32269. /** @hidden */
  32270. _renderLoop(): void;
  32271. /**
  32272. * Gets the HTML canvas attached with the current webGL context
  32273. * @returns a HTML canvas
  32274. */
  32275. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32276. /**
  32277. * Gets host window
  32278. * @returns the host window object
  32279. */
  32280. getHostWindow(): Nullable<Window>;
  32281. /**
  32282. * Gets the current render width
  32283. * @param useScreen defines if screen size must be used (or the current render target if any)
  32284. * @returns a number defining the current render width
  32285. */
  32286. getRenderWidth(useScreen?: boolean): number;
  32287. /**
  32288. * Gets the current render height
  32289. * @param useScreen defines if screen size must be used (or the current render target if any)
  32290. * @returns a number defining the current render height
  32291. */
  32292. getRenderHeight(useScreen?: boolean): number;
  32293. /**
  32294. * Can be used to override the current requestAnimationFrame requester.
  32295. * @hidden
  32296. */
  32297. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32298. /**
  32299. * Register and execute a render loop. The engine can have more than one render function
  32300. * @param renderFunction defines the function to continuously execute
  32301. */
  32302. runRenderLoop(renderFunction: () => void): void;
  32303. /**
  32304. * Clear the current render buffer or the current render target (if any is set up)
  32305. * @param color defines the color to use
  32306. * @param backBuffer defines if the back buffer must be cleared
  32307. * @param depth defines if the depth buffer must be cleared
  32308. * @param stencil defines if the stencil buffer must be cleared
  32309. */
  32310. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32311. private _viewportCached;
  32312. /** @hidden */
  32313. _viewport(x: number, y: number, width: number, height: number): void;
  32314. /**
  32315. * Set the WebGL's viewport
  32316. * @param viewport defines the viewport element to be used
  32317. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32318. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32319. */
  32320. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32321. /**
  32322. * Begin a new frame
  32323. */
  32324. beginFrame(): void;
  32325. /**
  32326. * Enf the current frame
  32327. */
  32328. endFrame(): void;
  32329. /**
  32330. * Resize the view according to the canvas' size
  32331. */
  32332. resize(): void;
  32333. /**
  32334. * Force a specific size of the canvas
  32335. * @param width defines the new canvas' width
  32336. * @param height defines the new canvas' height
  32337. */
  32338. setSize(width: number, height: number): void;
  32339. /**
  32340. * Binds the frame buffer to the specified texture.
  32341. * @param texture The texture to render to or null for the default canvas
  32342. * @param faceIndex The face of the texture to render to in case of cube texture
  32343. * @param requiredWidth The width of the target to render to
  32344. * @param requiredHeight The height of the target to render to
  32345. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32346. * @param lodLevel defines the lod level to bind to the frame buffer
  32347. * @param layer defines the 2d array index to bind to frame buffer to
  32348. */
  32349. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32350. /** @hidden */
  32351. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32352. /**
  32353. * Unbind the current render target texture from the webGL context
  32354. * @param texture defines the render target texture to unbind
  32355. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32356. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32357. */
  32358. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32359. /**
  32360. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32361. */
  32362. flushFramebuffer(): void;
  32363. /**
  32364. * Unbind the current render target and bind the default framebuffer
  32365. */
  32366. restoreDefaultFramebuffer(): void;
  32367. /** @hidden */
  32368. protected _resetVertexBufferBinding(): void;
  32369. /**
  32370. * Creates a vertex buffer
  32371. * @param data the data for the vertex buffer
  32372. * @returns the new WebGL static buffer
  32373. */
  32374. createVertexBuffer(data: DataArray): DataBuffer;
  32375. private _createVertexBuffer;
  32376. /**
  32377. * Creates a dynamic vertex buffer
  32378. * @param data the data for the dynamic vertex buffer
  32379. * @returns the new WebGL dynamic buffer
  32380. */
  32381. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32382. protected _resetIndexBufferBinding(): void;
  32383. /**
  32384. * Creates a new index buffer
  32385. * @param indices defines the content of the index buffer
  32386. * @param updatable defines if the index buffer must be updatable
  32387. * @returns a new webGL buffer
  32388. */
  32389. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32390. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32391. /**
  32392. * Bind a webGL buffer to the webGL context
  32393. * @param buffer defines the buffer to bind
  32394. */
  32395. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32396. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32397. private bindBuffer;
  32398. /**
  32399. * update the bound buffer with the given data
  32400. * @param data defines the data to update
  32401. */
  32402. updateArrayBuffer(data: Float32Array): void;
  32403. private _vertexAttribPointer;
  32404. /** @hidden */
  32405. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32406. private _bindVertexBuffersAttributes;
  32407. /**
  32408. * Records a vertex array object
  32409. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32410. * @param vertexBuffers defines the list of vertex buffers to store
  32411. * @param indexBuffer defines the index buffer to store
  32412. * @param effect defines the effect to store
  32413. * @returns the new vertex array object
  32414. */
  32415. recordVertexArrayObject(vertexBuffers: {
  32416. [key: string]: VertexBuffer;
  32417. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32418. /**
  32419. * Bind a specific vertex array object
  32420. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32421. * @param vertexArrayObject defines the vertex array object to bind
  32422. * @param indexBuffer defines the index buffer to bind
  32423. */
  32424. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32425. /**
  32426. * Bind webGl buffers directly to the webGL context
  32427. * @param vertexBuffer defines the vertex buffer to bind
  32428. * @param indexBuffer defines the index buffer to bind
  32429. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32430. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32431. * @param effect defines the effect associated with the vertex buffer
  32432. */
  32433. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32434. private _unbindVertexArrayObject;
  32435. /**
  32436. * Bind a list of vertex buffers to the webGL context
  32437. * @param vertexBuffers defines the list of vertex buffers to bind
  32438. * @param indexBuffer defines the index buffer to bind
  32439. * @param effect defines the effect associated with the vertex buffers
  32440. */
  32441. bindBuffers(vertexBuffers: {
  32442. [key: string]: Nullable<VertexBuffer>;
  32443. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32444. /**
  32445. * Unbind all instance attributes
  32446. */
  32447. unbindInstanceAttributes(): void;
  32448. /**
  32449. * Release and free the memory of a vertex array object
  32450. * @param vao defines the vertex array object to delete
  32451. */
  32452. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32453. /** @hidden */
  32454. _releaseBuffer(buffer: DataBuffer): boolean;
  32455. protected _deleteBuffer(buffer: DataBuffer): void;
  32456. /**
  32457. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32458. * @param instancesBuffer defines the webGL buffer to update and bind
  32459. * @param data defines the data to store in the buffer
  32460. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32461. */
  32462. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32463. /**
  32464. * Bind the content of a webGL buffer used with instantiation
  32465. * @param instancesBuffer defines the webGL buffer to bind
  32466. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32467. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32468. */
  32469. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32470. /**
  32471. * Disable the instance attribute corresponding to the name in parameter
  32472. * @param name defines the name of the attribute to disable
  32473. */
  32474. disableInstanceAttributeByName(name: string): void;
  32475. /**
  32476. * Disable the instance attribute corresponding to the location in parameter
  32477. * @param attributeLocation defines the attribute location of the attribute to disable
  32478. */
  32479. disableInstanceAttribute(attributeLocation: number): void;
  32480. /**
  32481. * Disable the attribute corresponding to the location in parameter
  32482. * @param attributeLocation defines the attribute location of the attribute to disable
  32483. */
  32484. disableAttributeByIndex(attributeLocation: number): void;
  32485. /**
  32486. * Send a draw order
  32487. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32488. * @param indexStart defines the starting index
  32489. * @param indexCount defines the number of index to draw
  32490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32491. */
  32492. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32493. /**
  32494. * Draw a list of points
  32495. * @param verticesStart defines the index of first vertex to draw
  32496. * @param verticesCount defines the count of vertices to draw
  32497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32498. */
  32499. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32500. /**
  32501. * Draw a list of unindexed primitives
  32502. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32503. * @param verticesStart defines the index of first vertex to draw
  32504. * @param verticesCount defines the count of vertices to draw
  32505. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32506. */
  32507. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32508. /**
  32509. * Draw a list of indexed primitives
  32510. * @param fillMode defines the primitive to use
  32511. * @param indexStart defines the starting index
  32512. * @param indexCount defines the number of index to draw
  32513. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32514. */
  32515. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32516. /**
  32517. * Draw a list of unindexed primitives
  32518. * @param fillMode defines the primitive to use
  32519. * @param verticesStart defines the index of first vertex to draw
  32520. * @param verticesCount defines the count of vertices to draw
  32521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32522. */
  32523. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32524. private _drawMode;
  32525. /** @hidden */
  32526. protected _reportDrawCall(): void;
  32527. /** @hidden */
  32528. _releaseEffect(effect: Effect): void;
  32529. /** @hidden */
  32530. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32531. /**
  32532. * Create a new effect (used to store vertex/fragment shaders)
  32533. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32534. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32535. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32536. * @param samplers defines an array of string used to represent textures
  32537. * @param defines defines the string containing the defines to use to compile the shaders
  32538. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32539. * @param onCompiled defines a function to call when the effect creation is successful
  32540. * @param onError defines a function to call when the effect creation has failed
  32541. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32542. * @returns the new Effect
  32543. */
  32544. 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;
  32545. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32546. private _compileShader;
  32547. private _compileRawShader;
  32548. /** @hidden */
  32549. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32550. /**
  32551. * Directly creates a webGL program
  32552. * @param pipelineContext defines the pipeline context to attach to
  32553. * @param vertexCode defines the vertex shader code to use
  32554. * @param fragmentCode defines the fragment shader code to use
  32555. * @param context defines the webGL context to use (if not set, the current one will be used)
  32556. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32557. * @returns the new webGL program
  32558. */
  32559. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32560. /**
  32561. * Creates a webGL program
  32562. * @param pipelineContext defines the pipeline context to attach to
  32563. * @param vertexCode defines the vertex shader code to use
  32564. * @param fragmentCode defines the fragment shader code to use
  32565. * @param defines defines the string containing the defines to use to compile the shaders
  32566. * @param context defines the webGL context to use (if not set, the current one will be used)
  32567. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32568. * @returns the new webGL program
  32569. */
  32570. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32571. /**
  32572. * Creates a new pipeline context
  32573. * @returns the new pipeline
  32574. */
  32575. createPipelineContext(): IPipelineContext;
  32576. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32577. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32578. /** @hidden */
  32579. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32580. /** @hidden */
  32581. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32582. /** @hidden */
  32583. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32584. /**
  32585. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32586. * @param pipelineContext defines the pipeline context to use
  32587. * @param uniformsNames defines the list of uniform names
  32588. * @returns an array of webGL uniform locations
  32589. */
  32590. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32591. /**
  32592. * Gets the lsit of active attributes for a given webGL program
  32593. * @param pipelineContext defines the pipeline context to use
  32594. * @param attributesNames defines the list of attribute names to get
  32595. * @returns an array of indices indicating the offset of each attribute
  32596. */
  32597. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32598. /**
  32599. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32600. * @param effect defines the effect to activate
  32601. */
  32602. enableEffect(effect: Nullable<Effect>): void;
  32603. /**
  32604. * Set the value of an uniform to a number (int)
  32605. * @param uniform defines the webGL uniform location where to store the value
  32606. * @param value defines the int number to store
  32607. */
  32608. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32609. /**
  32610. * Set the value of an uniform to an array of int32
  32611. * @param uniform defines the webGL uniform location where to store the value
  32612. * @param array defines the array of int32 to store
  32613. */
  32614. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32615. /**
  32616. * Set the value of an uniform to an array of int32 (stored as vec2)
  32617. * @param uniform defines the webGL uniform location where to store the value
  32618. * @param array defines the array of int32 to store
  32619. */
  32620. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32621. /**
  32622. * Set the value of an uniform to an array of int32 (stored as vec3)
  32623. * @param uniform defines the webGL uniform location where to store the value
  32624. * @param array defines the array of int32 to store
  32625. */
  32626. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32627. /**
  32628. * Set the value of an uniform to an array of int32 (stored as vec4)
  32629. * @param uniform defines the webGL uniform location where to store the value
  32630. * @param array defines the array of int32 to store
  32631. */
  32632. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32633. /**
  32634. * Set the value of an uniform to an array of number
  32635. * @param uniform defines the webGL uniform location where to store the value
  32636. * @param array defines the array of number to store
  32637. */
  32638. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32639. /**
  32640. * Set the value of an uniform to an array of number (stored as vec2)
  32641. * @param uniform defines the webGL uniform location where to store the value
  32642. * @param array defines the array of number to store
  32643. */
  32644. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32645. /**
  32646. * Set the value of an uniform to an array of number (stored as vec3)
  32647. * @param uniform defines the webGL uniform location where to store the value
  32648. * @param array defines the array of number to store
  32649. */
  32650. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32651. /**
  32652. * Set the value of an uniform to an array of number (stored as vec4)
  32653. * @param uniform defines the webGL uniform location where to store the value
  32654. * @param array defines the array of number to store
  32655. */
  32656. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32657. /**
  32658. * Set the value of an uniform to an array of float32 (stored as matrices)
  32659. * @param uniform defines the webGL uniform location where to store the value
  32660. * @param matrices defines the array of float32 to store
  32661. */
  32662. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32663. /**
  32664. * Set the value of an uniform to a matrix (3x3)
  32665. * @param uniform defines the webGL uniform location where to store the value
  32666. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32667. */
  32668. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32669. /**
  32670. * Set the value of an uniform to a matrix (2x2)
  32671. * @param uniform defines the webGL uniform location where to store the value
  32672. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32673. */
  32674. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32675. /**
  32676. * Set the value of an uniform to a number (float)
  32677. * @param uniform defines the webGL uniform location where to store the value
  32678. * @param value defines the float number to store
  32679. */
  32680. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32681. /**
  32682. * Set the value of an uniform to a vec2
  32683. * @param uniform defines the webGL uniform location where to store the value
  32684. * @param x defines the 1st component of the value
  32685. * @param y defines the 2nd component of the value
  32686. */
  32687. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32688. /**
  32689. * Set the value of an uniform to a vec3
  32690. * @param uniform defines the webGL uniform location where to store the value
  32691. * @param x defines the 1st component of the value
  32692. * @param y defines the 2nd component of the value
  32693. * @param z defines the 3rd component of the value
  32694. */
  32695. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32696. /**
  32697. * Set the value of an uniform to a vec4
  32698. * @param uniform defines the webGL uniform location where to store the value
  32699. * @param x defines the 1st component of the value
  32700. * @param y defines the 2nd component of the value
  32701. * @param z defines the 3rd component of the value
  32702. * @param w defines the 4th component of the value
  32703. */
  32704. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32705. /**
  32706. * Apply all cached states (depth, culling, stencil and alpha)
  32707. */
  32708. applyStates(): void;
  32709. /**
  32710. * Enable or disable color writing
  32711. * @param enable defines the state to set
  32712. */
  32713. setColorWrite(enable: boolean): void;
  32714. /**
  32715. * Gets a boolean indicating if color writing is enabled
  32716. * @returns the current color writing state
  32717. */
  32718. getColorWrite(): boolean;
  32719. /**
  32720. * Gets the depth culling state manager
  32721. */
  32722. get depthCullingState(): DepthCullingState;
  32723. /**
  32724. * Gets the alpha state manager
  32725. */
  32726. get alphaState(): AlphaState;
  32727. /**
  32728. * Gets the stencil state manager
  32729. */
  32730. get stencilState(): StencilState;
  32731. /**
  32732. * Clears the list of texture accessible through engine.
  32733. * This can help preventing texture load conflict due to name collision.
  32734. */
  32735. clearInternalTexturesCache(): void;
  32736. /**
  32737. * Force the entire cache to be cleared
  32738. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32739. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32740. */
  32741. wipeCaches(bruteForce?: boolean): void;
  32742. /** @hidden */
  32743. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32744. min: number;
  32745. mag: number;
  32746. };
  32747. /** @hidden */
  32748. _createTexture(): WebGLTexture;
  32749. /**
  32750. * Usually called from Texture.ts.
  32751. * Passed information to create a WebGLTexture
  32752. * @param urlArg defines a value which contains one of the following:
  32753. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32754. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32755. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32756. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32757. * @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)
  32758. * @param scene needed for loading to the correct scene
  32759. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32760. * @param onLoad optional callback to be called upon successful completion
  32761. * @param onError optional callback to be called upon failure
  32762. * @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
  32763. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32764. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32765. * @param forcedExtension defines the extension to use to pick the right loader
  32766. * @param mimeType defines an optional mime type
  32767. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32768. */
  32769. 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;
  32770. /**
  32771. * Loads an image as an HTMLImageElement.
  32772. * @param input url string, ArrayBuffer, or Blob to load
  32773. * @param onLoad callback called when the image successfully loads
  32774. * @param onError callback called when the image fails to load
  32775. * @param offlineProvider offline provider for caching
  32776. * @param mimeType optional mime type
  32777. * @returns the HTMLImageElement of the loaded image
  32778. * @hidden
  32779. */
  32780. 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>;
  32781. /**
  32782. * @hidden
  32783. */
  32784. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32785. /**
  32786. * Creates a raw texture
  32787. * @param data defines the data to store in the texture
  32788. * @param width defines the width of the texture
  32789. * @param height defines the height of the texture
  32790. * @param format defines the format of the data
  32791. * @param generateMipMaps defines if the engine should generate the mip levels
  32792. * @param invertY defines if data must be stored with Y axis inverted
  32793. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32794. * @param compression defines the compression used (null by default)
  32795. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32796. * @returns the raw texture inside an InternalTexture
  32797. */
  32798. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32799. /**
  32800. * Creates a new raw cube texture
  32801. * @param data defines the array of data to use to create each face
  32802. * @param size defines the size of the textures
  32803. * @param format defines the format of the data
  32804. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32805. * @param generateMipMaps defines if the engine should generate the 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 compression used (null by default)
  32809. * @returns the cube texture as an InternalTexture
  32810. */
  32811. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32812. /**
  32813. * Creates a new raw 3D texture
  32814. * @param data defines the data used to create the texture
  32815. * @param width defines the width of the texture
  32816. * @param height defines the height of the texture
  32817. * @param depth defines the depth of the texture
  32818. * @param format defines the format of the texture
  32819. * @param generateMipMaps defines if the engine must generate mip levels
  32820. * @param invertY defines if data must be stored with Y axis inverted
  32821. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32822. * @param compression defines the compressed used (can be null)
  32823. * @param textureType defines the compressed used (can be null)
  32824. * @returns a new raw 3D texture (stored in an InternalTexture)
  32825. */
  32826. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32827. /**
  32828. * Creates a new raw 2D array texture
  32829. * @param data defines the data used to create the texture
  32830. * @param width defines the width of the texture
  32831. * @param height defines the height of the texture
  32832. * @param depth defines the number of layers of the texture
  32833. * @param format defines the format of the texture
  32834. * @param generateMipMaps defines if the engine must generate mip levels
  32835. * @param invertY defines if data must be stored with Y axis inverted
  32836. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32837. * @param compression defines the compressed used (can be null)
  32838. * @param textureType defines the compressed used (can be null)
  32839. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32840. */
  32841. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32842. private _unpackFlipYCached;
  32843. /**
  32844. * In case you are sharing the context with other applications, it might
  32845. * be interested to not cache the unpack flip y state to ensure a consistent
  32846. * value would be set.
  32847. */
  32848. enableUnpackFlipYCached: boolean;
  32849. /** @hidden */
  32850. _unpackFlipY(value: boolean): void;
  32851. /** @hidden */
  32852. _getUnpackAlignement(): number;
  32853. private _getTextureTarget;
  32854. /**
  32855. * Update the sampling mode of a given texture
  32856. * @param samplingMode defines the required sampling mode
  32857. * @param texture defines the texture to update
  32858. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32859. */
  32860. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32861. /**
  32862. * Update the sampling mode of a given texture
  32863. * @param texture defines the texture to update
  32864. * @param wrapU defines the texture wrap mode of the u coordinates
  32865. * @param wrapV defines the texture wrap mode of the v coordinates
  32866. * @param wrapR defines the texture wrap mode of the r coordinates
  32867. */
  32868. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32869. /** @hidden */
  32870. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32871. width: number;
  32872. height: number;
  32873. layers?: number;
  32874. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32875. /** @hidden */
  32876. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32877. /** @hidden */
  32878. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32879. /**
  32880. * Update a portion of an internal texture
  32881. * @param texture defines the texture to update
  32882. * @param imageData defines the data to store into the texture
  32883. * @param xOffset defines the x coordinates of the update rectangle
  32884. * @param yOffset defines the y coordinates of the update rectangle
  32885. * @param width defines the width of the update rectangle
  32886. * @param height defines the height of the update rectangle
  32887. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32888. * @param lod defines the lod level to update (0 by default)
  32889. */
  32890. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32891. /** @hidden */
  32892. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32893. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32894. private _prepareWebGLTexture;
  32895. /** @hidden */
  32896. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32897. private _getDepthStencilBuffer;
  32898. /** @hidden */
  32899. _releaseFramebufferObjects(texture: InternalTexture): void;
  32900. /** @hidden */
  32901. _releaseTexture(texture: InternalTexture): void;
  32902. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32903. protected _setProgram(program: WebGLProgram): void;
  32904. protected _boundUniforms: {
  32905. [key: number]: WebGLUniformLocation;
  32906. };
  32907. /**
  32908. * Binds an effect to the webGL context
  32909. * @param effect defines the effect to bind
  32910. */
  32911. bindSamplers(effect: Effect): void;
  32912. private _activateCurrentTexture;
  32913. /** @hidden */
  32914. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32915. /** @hidden */
  32916. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32917. /**
  32918. * Unbind all textures from the webGL context
  32919. */
  32920. unbindAllTextures(): void;
  32921. /**
  32922. * Sets a texture to the according uniform.
  32923. * @param channel The texture channel
  32924. * @param uniform The uniform to set
  32925. * @param texture The texture to apply
  32926. */
  32927. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32928. private _bindSamplerUniformToChannel;
  32929. private _getTextureWrapMode;
  32930. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32931. /**
  32932. * Sets an array of texture to the webGL context
  32933. * @param channel defines the channel where the texture array must be set
  32934. * @param uniform defines the associated uniform location
  32935. * @param textures defines the array of textures to bind
  32936. */
  32937. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32938. /** @hidden */
  32939. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32940. private _setTextureParameterFloat;
  32941. private _setTextureParameterInteger;
  32942. /**
  32943. * Unbind all vertex attributes from the webGL context
  32944. */
  32945. unbindAllAttributes(): void;
  32946. /**
  32947. * 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
  32948. */
  32949. releaseEffects(): void;
  32950. /**
  32951. * Dispose and release all associated resources
  32952. */
  32953. dispose(): void;
  32954. /**
  32955. * Attach a new callback raised when context lost event is fired
  32956. * @param callback defines the callback to call
  32957. */
  32958. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32959. /**
  32960. * Attach a new callback raised when context restored event is fired
  32961. * @param callback defines the callback to call
  32962. */
  32963. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32964. /**
  32965. * Get the current error code of the webGL context
  32966. * @returns the error code
  32967. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32968. */
  32969. getError(): number;
  32970. private _canRenderToFloatFramebuffer;
  32971. private _canRenderToHalfFloatFramebuffer;
  32972. private _canRenderToFramebuffer;
  32973. /** @hidden */
  32974. _getWebGLTextureType(type: number): number;
  32975. /** @hidden */
  32976. _getInternalFormat(format: number): number;
  32977. /** @hidden */
  32978. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32979. /** @hidden */
  32980. _getRGBAMultiSampleBufferFormat(type: number): number;
  32981. /** @hidden */
  32982. _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;
  32983. /**
  32984. * Loads a file from a url
  32985. * @param url url to load
  32986. * @param onSuccess callback called when the file successfully loads
  32987. * @param onProgress callback called while file is loading (if the server supports this mode)
  32988. * @param offlineProvider defines the offline provider for caching
  32989. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32990. * @param onError callback called when the file fails to load
  32991. * @returns a file request object
  32992. * @hidden
  32993. */
  32994. 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;
  32995. /**
  32996. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32997. * @param x defines the x coordinate of the rectangle where pixels must be read
  32998. * @param y defines the y coordinate of the rectangle where pixels must be read
  32999. * @param width defines the width of the rectangle where pixels must be read
  33000. * @param height defines the height of the rectangle where pixels must be read
  33001. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33002. * @returns a Uint8Array containing RGBA colors
  33003. */
  33004. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33005. private static _isSupported;
  33006. /**
  33007. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33008. * @returns true if the engine can be created
  33009. * @ignorenaming
  33010. */
  33011. static isSupported(): boolean;
  33012. /**
  33013. * Find the next highest power of two.
  33014. * @param x Number to start search from.
  33015. * @return Next highest power of two.
  33016. */
  33017. static CeilingPOT(x: number): number;
  33018. /**
  33019. * Find the next lowest power of two.
  33020. * @param x Number to start search from.
  33021. * @return Next lowest power of two.
  33022. */
  33023. static FloorPOT(x: number): number;
  33024. /**
  33025. * Find the nearest power of two.
  33026. * @param x Number to start search from.
  33027. * @return Next nearest power of two.
  33028. */
  33029. static NearestPOT(x: number): number;
  33030. /**
  33031. * Get the closest exponent of two
  33032. * @param value defines the value to approximate
  33033. * @param max defines the maximum value to return
  33034. * @param mode defines how to define the closest value
  33035. * @returns closest exponent of two of the given value
  33036. */
  33037. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33038. /**
  33039. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33040. * @param func - the function to be called
  33041. * @param requester - the object that will request the next frame. Falls back to window.
  33042. * @returns frame number
  33043. */
  33044. static QueueNewFrame(func: () => void, requester?: any): number;
  33045. /**
  33046. * Gets host document
  33047. * @returns the host document object
  33048. */
  33049. getHostDocument(): Nullable<Document>;
  33050. }
  33051. }
  33052. declare module "babylonjs/Maths/sphericalPolynomial" {
  33053. import { Vector3 } from "babylonjs/Maths/math.vector";
  33054. import { Color3 } from "babylonjs/Maths/math.color";
  33055. /**
  33056. * Class representing spherical harmonics coefficients to the 3rd degree
  33057. */
  33058. export class SphericalHarmonics {
  33059. /**
  33060. * Defines whether or not the harmonics have been prescaled for rendering.
  33061. */
  33062. preScaled: boolean;
  33063. /**
  33064. * The l0,0 coefficients of the spherical harmonics
  33065. */
  33066. l00: Vector3;
  33067. /**
  33068. * The l1,-1 coefficients of the spherical harmonics
  33069. */
  33070. l1_1: Vector3;
  33071. /**
  33072. * The l1,0 coefficients of the spherical harmonics
  33073. */
  33074. l10: Vector3;
  33075. /**
  33076. * The l1,1 coefficients of the spherical harmonics
  33077. */
  33078. l11: Vector3;
  33079. /**
  33080. * The l2,-2 coefficients of the spherical harmonics
  33081. */
  33082. l2_2: Vector3;
  33083. /**
  33084. * The l2,-1 coefficients of the spherical harmonics
  33085. */
  33086. l2_1: Vector3;
  33087. /**
  33088. * The l2,0 coefficients of the spherical harmonics
  33089. */
  33090. l20: Vector3;
  33091. /**
  33092. * The l2,1 coefficients of the spherical harmonics
  33093. */
  33094. l21: Vector3;
  33095. /**
  33096. * The l2,2 coefficients of the spherical harmonics
  33097. */
  33098. l22: Vector3;
  33099. /**
  33100. * Adds a light to the spherical harmonics
  33101. * @param direction the direction of the light
  33102. * @param color the color of the light
  33103. * @param deltaSolidAngle the delta solid angle of the light
  33104. */
  33105. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33106. /**
  33107. * Scales the spherical harmonics by the given amount
  33108. * @param scale the amount to scale
  33109. */
  33110. scaleInPlace(scale: number): void;
  33111. /**
  33112. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33113. *
  33114. * ```
  33115. * E_lm = A_l * L_lm
  33116. * ```
  33117. *
  33118. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33119. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33120. * the scaling factors are given in equation 9.
  33121. */
  33122. convertIncidentRadianceToIrradiance(): void;
  33123. /**
  33124. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33125. *
  33126. * ```
  33127. * L = (1/pi) * E * rho
  33128. * ```
  33129. *
  33130. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33131. */
  33132. convertIrradianceToLambertianRadiance(): void;
  33133. /**
  33134. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33135. * required operations at run time.
  33136. *
  33137. * This is simply done by scaling back the SH with Ylm constants parameter.
  33138. * The trigonometric part being applied by the shader at run time.
  33139. */
  33140. preScaleForRendering(): void;
  33141. /**
  33142. * Constructs a spherical harmonics from an array.
  33143. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33144. * @returns the spherical harmonics
  33145. */
  33146. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33147. /**
  33148. * Gets the spherical harmonics from polynomial
  33149. * @param polynomial the spherical polynomial
  33150. * @returns the spherical harmonics
  33151. */
  33152. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33153. }
  33154. /**
  33155. * Class representing spherical polynomial coefficients to the 3rd degree
  33156. */
  33157. export class SphericalPolynomial {
  33158. private _harmonics;
  33159. /**
  33160. * The spherical harmonics used to create the polynomials.
  33161. */
  33162. get preScaledHarmonics(): SphericalHarmonics;
  33163. /**
  33164. * The x coefficients of the spherical polynomial
  33165. */
  33166. x: Vector3;
  33167. /**
  33168. * The y coefficients of the spherical polynomial
  33169. */
  33170. y: Vector3;
  33171. /**
  33172. * The z coefficients of the spherical polynomial
  33173. */
  33174. z: Vector3;
  33175. /**
  33176. * The xx coefficients of the spherical polynomial
  33177. */
  33178. xx: Vector3;
  33179. /**
  33180. * The yy coefficients of the spherical polynomial
  33181. */
  33182. yy: Vector3;
  33183. /**
  33184. * The zz coefficients of the spherical polynomial
  33185. */
  33186. zz: Vector3;
  33187. /**
  33188. * The xy coefficients of the spherical polynomial
  33189. */
  33190. xy: Vector3;
  33191. /**
  33192. * The yz coefficients of the spherical polynomial
  33193. */
  33194. yz: Vector3;
  33195. /**
  33196. * The zx coefficients of the spherical polynomial
  33197. */
  33198. zx: Vector3;
  33199. /**
  33200. * Adds an ambient color to the spherical polynomial
  33201. * @param color the color to add
  33202. */
  33203. addAmbient(color: Color3): void;
  33204. /**
  33205. * Scales the spherical polynomial by the given amount
  33206. * @param scale the amount to scale
  33207. */
  33208. scaleInPlace(scale: number): void;
  33209. /**
  33210. * Gets the spherical polynomial from harmonics
  33211. * @param harmonics the spherical harmonics
  33212. * @returns the spherical polynomial
  33213. */
  33214. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33215. /**
  33216. * Constructs a spherical polynomial from an array.
  33217. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33218. * @returns the spherical polynomial
  33219. */
  33220. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33221. }
  33222. }
  33223. declare module "babylonjs/Materials/Textures/internalTexture" {
  33224. import { Observable } from "babylonjs/Misc/observable";
  33225. import { Nullable, int } from "babylonjs/types";
  33226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33228. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33229. /**
  33230. * Defines the source of the internal texture
  33231. */
  33232. export enum InternalTextureSource {
  33233. /**
  33234. * The source of the texture data is unknown
  33235. */
  33236. Unknown = 0,
  33237. /**
  33238. * Texture data comes from an URL
  33239. */
  33240. Url = 1,
  33241. /**
  33242. * Texture data is only used for temporary storage
  33243. */
  33244. Temp = 2,
  33245. /**
  33246. * Texture data comes from raw data (ArrayBuffer)
  33247. */
  33248. Raw = 3,
  33249. /**
  33250. * Texture content is dynamic (video or dynamic texture)
  33251. */
  33252. Dynamic = 4,
  33253. /**
  33254. * Texture content is generated by rendering to it
  33255. */
  33256. RenderTarget = 5,
  33257. /**
  33258. * Texture content is part of a multi render target process
  33259. */
  33260. MultiRenderTarget = 6,
  33261. /**
  33262. * Texture data comes from a cube data file
  33263. */
  33264. Cube = 7,
  33265. /**
  33266. * Texture data comes from a raw cube data
  33267. */
  33268. CubeRaw = 8,
  33269. /**
  33270. * Texture data come from a prefiltered cube data file
  33271. */
  33272. CubePrefiltered = 9,
  33273. /**
  33274. * Texture content is raw 3D data
  33275. */
  33276. Raw3D = 10,
  33277. /**
  33278. * Texture content is raw 2D array data
  33279. */
  33280. Raw2DArray = 11,
  33281. /**
  33282. * Texture content is a depth texture
  33283. */
  33284. Depth = 12,
  33285. /**
  33286. * Texture data comes from a raw cube data encoded with RGBD
  33287. */
  33288. CubeRawRGBD = 13
  33289. }
  33290. /**
  33291. * Class used to store data associated with WebGL texture data for the engine
  33292. * This class should not be used directly
  33293. */
  33294. export class InternalTexture {
  33295. /** @hidden */
  33296. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33297. /**
  33298. * Defines if the texture is ready
  33299. */
  33300. isReady: boolean;
  33301. /**
  33302. * Defines if the texture is a cube texture
  33303. */
  33304. isCube: boolean;
  33305. /**
  33306. * Defines if the texture contains 3D data
  33307. */
  33308. is3D: boolean;
  33309. /**
  33310. * Defines if the texture contains 2D array data
  33311. */
  33312. is2DArray: boolean;
  33313. /**
  33314. * Defines if the texture contains multiview data
  33315. */
  33316. isMultiview: boolean;
  33317. /**
  33318. * Gets the URL used to load this texture
  33319. */
  33320. url: string;
  33321. /**
  33322. * Gets the sampling mode of the texture
  33323. */
  33324. samplingMode: number;
  33325. /**
  33326. * Gets a boolean indicating if the texture needs mipmaps generation
  33327. */
  33328. generateMipMaps: boolean;
  33329. /**
  33330. * Gets the number of samples used by the texture (WebGL2+ only)
  33331. */
  33332. samples: number;
  33333. /**
  33334. * Gets the type of the texture (int, float...)
  33335. */
  33336. type: number;
  33337. /**
  33338. * Gets the format of the texture (RGB, RGBA...)
  33339. */
  33340. format: number;
  33341. /**
  33342. * Observable called when the texture is loaded
  33343. */
  33344. onLoadedObservable: Observable<InternalTexture>;
  33345. /**
  33346. * Gets the width of the texture
  33347. */
  33348. width: number;
  33349. /**
  33350. * Gets the height of the texture
  33351. */
  33352. height: number;
  33353. /**
  33354. * Gets the depth of the texture
  33355. */
  33356. depth: number;
  33357. /**
  33358. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33359. */
  33360. baseWidth: number;
  33361. /**
  33362. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33363. */
  33364. baseHeight: number;
  33365. /**
  33366. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33367. */
  33368. baseDepth: number;
  33369. /**
  33370. * Gets a boolean indicating if the texture is inverted on Y axis
  33371. */
  33372. invertY: boolean;
  33373. /** @hidden */
  33374. _invertVScale: boolean;
  33375. /** @hidden */
  33376. _associatedChannel: number;
  33377. /** @hidden */
  33378. _source: InternalTextureSource;
  33379. /** @hidden */
  33380. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33381. /** @hidden */
  33382. _bufferView: Nullable<ArrayBufferView>;
  33383. /** @hidden */
  33384. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33385. /** @hidden */
  33386. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33387. /** @hidden */
  33388. _size: number;
  33389. /** @hidden */
  33390. _extension: string;
  33391. /** @hidden */
  33392. _files: Nullable<string[]>;
  33393. /** @hidden */
  33394. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33395. /** @hidden */
  33396. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33397. /** @hidden */
  33398. _framebuffer: Nullable<WebGLFramebuffer>;
  33399. /** @hidden */
  33400. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33401. /** @hidden */
  33402. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33403. /** @hidden */
  33404. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33405. /** @hidden */
  33406. _attachments: Nullable<number[]>;
  33407. /** @hidden */
  33408. _cachedCoordinatesMode: Nullable<number>;
  33409. /** @hidden */
  33410. _cachedWrapU: Nullable<number>;
  33411. /** @hidden */
  33412. _cachedWrapV: Nullable<number>;
  33413. /** @hidden */
  33414. _cachedWrapR: Nullable<number>;
  33415. /** @hidden */
  33416. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33417. /** @hidden */
  33418. _isDisabled: boolean;
  33419. /** @hidden */
  33420. _compression: Nullable<string>;
  33421. /** @hidden */
  33422. _generateStencilBuffer: boolean;
  33423. /** @hidden */
  33424. _generateDepthBuffer: boolean;
  33425. /** @hidden */
  33426. _comparisonFunction: number;
  33427. /** @hidden */
  33428. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33429. /** @hidden */
  33430. _lodGenerationScale: number;
  33431. /** @hidden */
  33432. _lodGenerationOffset: number;
  33433. /** @hidden */
  33434. _depthStencilTexture: Nullable<InternalTexture>;
  33435. /** @hidden */
  33436. _colorTextureArray: Nullable<WebGLTexture>;
  33437. /** @hidden */
  33438. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33439. /** @hidden */
  33440. _lodTextureHigh: Nullable<BaseTexture>;
  33441. /** @hidden */
  33442. _lodTextureMid: Nullable<BaseTexture>;
  33443. /** @hidden */
  33444. _lodTextureLow: Nullable<BaseTexture>;
  33445. /** @hidden */
  33446. _isRGBD: boolean;
  33447. /** @hidden */
  33448. _linearSpecularLOD: boolean;
  33449. /** @hidden */
  33450. _irradianceTexture: Nullable<BaseTexture>;
  33451. /** @hidden */
  33452. _webGLTexture: Nullable<WebGLTexture>;
  33453. /** @hidden */
  33454. _references: number;
  33455. private _engine;
  33456. /**
  33457. * Gets the Engine the texture belongs to.
  33458. * @returns The babylon engine
  33459. */
  33460. getEngine(): ThinEngine;
  33461. /**
  33462. * Gets the data source type of the texture
  33463. */
  33464. get source(): InternalTextureSource;
  33465. /**
  33466. * Creates a new InternalTexture
  33467. * @param engine defines the engine to use
  33468. * @param source defines the type of data that will be used
  33469. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33470. */
  33471. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33472. /**
  33473. * Increments the number of references (ie. the number of Texture that point to it)
  33474. */
  33475. incrementReferences(): void;
  33476. /**
  33477. * Change the size of the texture (not the size of the content)
  33478. * @param width defines the new width
  33479. * @param height defines the new height
  33480. * @param depth defines the new depth (1 by default)
  33481. */
  33482. updateSize(width: int, height: int, depth?: int): void;
  33483. /** @hidden */
  33484. _rebuild(): void;
  33485. /** @hidden */
  33486. _swapAndDie(target: InternalTexture): void;
  33487. /**
  33488. * Dispose the current allocated resources
  33489. */
  33490. dispose(): void;
  33491. }
  33492. }
  33493. declare module "babylonjs/Audio/analyser" {
  33494. import { Scene } from "babylonjs/scene";
  33495. /**
  33496. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33498. */
  33499. export class Analyser {
  33500. /**
  33501. * Gets or sets the smoothing
  33502. * @ignorenaming
  33503. */
  33504. SMOOTHING: number;
  33505. /**
  33506. * Gets or sets the FFT table size
  33507. * @ignorenaming
  33508. */
  33509. FFT_SIZE: number;
  33510. /**
  33511. * Gets or sets the bar graph amplitude
  33512. * @ignorenaming
  33513. */
  33514. BARGRAPHAMPLITUDE: number;
  33515. /**
  33516. * Gets or sets the position of the debug canvas
  33517. * @ignorenaming
  33518. */
  33519. DEBUGCANVASPOS: {
  33520. x: number;
  33521. y: number;
  33522. };
  33523. /**
  33524. * Gets or sets the debug canvas size
  33525. * @ignorenaming
  33526. */
  33527. DEBUGCANVASSIZE: {
  33528. width: number;
  33529. height: number;
  33530. };
  33531. private _byteFreqs;
  33532. private _byteTime;
  33533. private _floatFreqs;
  33534. private _webAudioAnalyser;
  33535. private _debugCanvas;
  33536. private _debugCanvasContext;
  33537. private _scene;
  33538. private _registerFunc;
  33539. private _audioEngine;
  33540. /**
  33541. * Creates a new analyser
  33542. * @param scene defines hosting scene
  33543. */
  33544. constructor(scene: Scene);
  33545. /**
  33546. * Get the number of data values you will have to play with for the visualization
  33547. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33548. * @returns a number
  33549. */
  33550. getFrequencyBinCount(): number;
  33551. /**
  33552. * Gets the current frequency data as a byte array
  33553. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33554. * @returns a Uint8Array
  33555. */
  33556. getByteFrequencyData(): Uint8Array;
  33557. /**
  33558. * Gets the current waveform as a byte array
  33559. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33560. * @returns a Uint8Array
  33561. */
  33562. getByteTimeDomainData(): Uint8Array;
  33563. /**
  33564. * Gets the current frequency data as a float array
  33565. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33566. * @returns a Float32Array
  33567. */
  33568. getFloatFrequencyData(): Float32Array;
  33569. /**
  33570. * Renders the debug canvas
  33571. */
  33572. drawDebugCanvas(): void;
  33573. /**
  33574. * Stops rendering the debug canvas and removes it
  33575. */
  33576. stopDebugCanvas(): void;
  33577. /**
  33578. * Connects two audio nodes
  33579. * @param inputAudioNode defines first node to connect
  33580. * @param outputAudioNode defines second node to connect
  33581. */
  33582. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33583. /**
  33584. * Releases all associated resources
  33585. */
  33586. dispose(): void;
  33587. }
  33588. }
  33589. declare module "babylonjs/Audio/audioEngine" {
  33590. import { IDisposable } from "babylonjs/scene";
  33591. import { Analyser } from "babylonjs/Audio/analyser";
  33592. import { Nullable } from "babylonjs/types";
  33593. import { Observable } from "babylonjs/Misc/observable";
  33594. /**
  33595. * This represents an audio engine and it is responsible
  33596. * to play, synchronize and analyse sounds throughout the application.
  33597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33598. */
  33599. export interface IAudioEngine extends IDisposable {
  33600. /**
  33601. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33602. */
  33603. readonly canUseWebAudio: boolean;
  33604. /**
  33605. * Gets the current AudioContext if available.
  33606. */
  33607. readonly audioContext: Nullable<AudioContext>;
  33608. /**
  33609. * The master gain node defines the global audio volume of your audio engine.
  33610. */
  33611. readonly masterGain: GainNode;
  33612. /**
  33613. * Gets whether or not mp3 are supported by your browser.
  33614. */
  33615. readonly isMP3supported: boolean;
  33616. /**
  33617. * Gets whether or not ogg are supported by your browser.
  33618. */
  33619. readonly isOGGsupported: boolean;
  33620. /**
  33621. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33622. * @ignoreNaming
  33623. */
  33624. WarnedWebAudioUnsupported: boolean;
  33625. /**
  33626. * Defines if the audio engine relies on a custom unlocked button.
  33627. * In this case, the embedded button will not be displayed.
  33628. */
  33629. useCustomUnlockedButton: boolean;
  33630. /**
  33631. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33632. */
  33633. readonly unlocked: boolean;
  33634. /**
  33635. * Event raised when audio has been unlocked on the browser.
  33636. */
  33637. onAudioUnlockedObservable: Observable<AudioEngine>;
  33638. /**
  33639. * Event raised when audio has been locked on the browser.
  33640. */
  33641. onAudioLockedObservable: Observable<AudioEngine>;
  33642. /**
  33643. * Flags the audio engine in Locked state.
  33644. * This happens due to new browser policies preventing audio to autoplay.
  33645. */
  33646. lock(): void;
  33647. /**
  33648. * Unlocks the audio engine once a user action has been done on the dom.
  33649. * This is helpful to resume play once browser policies have been satisfied.
  33650. */
  33651. unlock(): void;
  33652. /**
  33653. * Gets the global volume sets on the master gain.
  33654. * @returns the global volume if set or -1 otherwise
  33655. */
  33656. getGlobalVolume(): number;
  33657. /**
  33658. * Sets the global volume of your experience (sets on the master gain).
  33659. * @param newVolume Defines the new global volume of the application
  33660. */
  33661. setGlobalVolume(newVolume: number): void;
  33662. /**
  33663. * Connect the audio engine to an audio analyser allowing some amazing
  33664. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33666. * @param analyser The analyser to connect to the engine
  33667. */
  33668. connectToAnalyser(analyser: Analyser): void;
  33669. }
  33670. /**
  33671. * This represents the default audio engine used in babylon.
  33672. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33674. */
  33675. export class AudioEngine implements IAudioEngine {
  33676. private _audioContext;
  33677. private _audioContextInitialized;
  33678. private _muteButton;
  33679. private _hostElement;
  33680. /**
  33681. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33682. */
  33683. canUseWebAudio: boolean;
  33684. /**
  33685. * The master gain node defines the global audio volume of your audio engine.
  33686. */
  33687. masterGain: GainNode;
  33688. /**
  33689. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33690. * @ignoreNaming
  33691. */
  33692. WarnedWebAudioUnsupported: boolean;
  33693. /**
  33694. * Gets whether or not mp3 are supported by your browser.
  33695. */
  33696. isMP3supported: boolean;
  33697. /**
  33698. * Gets whether or not ogg are supported by your browser.
  33699. */
  33700. isOGGsupported: boolean;
  33701. /**
  33702. * Gets whether audio has been unlocked on the device.
  33703. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33704. * a user interaction has happened.
  33705. */
  33706. unlocked: boolean;
  33707. /**
  33708. * Defines if the audio engine relies on a custom unlocked button.
  33709. * In this case, the embedded button will not be displayed.
  33710. */
  33711. useCustomUnlockedButton: boolean;
  33712. /**
  33713. * Event raised when audio has been unlocked on the browser.
  33714. */
  33715. onAudioUnlockedObservable: Observable<AudioEngine>;
  33716. /**
  33717. * Event raised when audio has been locked on the browser.
  33718. */
  33719. onAudioLockedObservable: Observable<AudioEngine>;
  33720. /**
  33721. * Gets the current AudioContext if available.
  33722. */
  33723. get audioContext(): Nullable<AudioContext>;
  33724. private _connectedAnalyser;
  33725. /**
  33726. * Instantiates a new audio engine.
  33727. *
  33728. * There should be only one per page as some browsers restrict the number
  33729. * of audio contexts you can create.
  33730. * @param hostElement defines the host element where to display the mute icon if necessary
  33731. */
  33732. constructor(hostElement?: Nullable<HTMLElement>);
  33733. /**
  33734. * Flags the audio engine in Locked state.
  33735. * This happens due to new browser policies preventing audio to autoplay.
  33736. */
  33737. lock(): void;
  33738. /**
  33739. * Unlocks the audio engine once a user action has been done on the dom.
  33740. * This is helpful to resume play once browser policies have been satisfied.
  33741. */
  33742. unlock(): void;
  33743. private _resumeAudioContext;
  33744. private _initializeAudioContext;
  33745. private _tryToRun;
  33746. private _triggerRunningState;
  33747. private _triggerSuspendedState;
  33748. private _displayMuteButton;
  33749. private _moveButtonToTopLeft;
  33750. private _onResize;
  33751. private _hideMuteButton;
  33752. /**
  33753. * Destroy and release the resources associated with the audio ccontext.
  33754. */
  33755. dispose(): void;
  33756. /**
  33757. * Gets the global volume sets on the master gain.
  33758. * @returns the global volume if set or -1 otherwise
  33759. */
  33760. getGlobalVolume(): number;
  33761. /**
  33762. * Sets the global volume of your experience (sets on the master gain).
  33763. * @param newVolume Defines the new global volume of the application
  33764. */
  33765. setGlobalVolume(newVolume: number): void;
  33766. /**
  33767. * Connect the audio engine to an audio analyser allowing some amazing
  33768. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33770. * @param analyser The analyser to connect to the engine
  33771. */
  33772. connectToAnalyser(analyser: Analyser): void;
  33773. }
  33774. }
  33775. declare module "babylonjs/Loading/loadingScreen" {
  33776. /**
  33777. * Interface used to present a loading screen while loading a scene
  33778. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33779. */
  33780. export interface ILoadingScreen {
  33781. /**
  33782. * Function called to display the loading screen
  33783. */
  33784. displayLoadingUI: () => void;
  33785. /**
  33786. * Function called to hide the loading screen
  33787. */
  33788. hideLoadingUI: () => void;
  33789. /**
  33790. * Gets or sets the color to use for the background
  33791. */
  33792. loadingUIBackgroundColor: string;
  33793. /**
  33794. * Gets or sets the text to display while loading
  33795. */
  33796. loadingUIText: string;
  33797. }
  33798. /**
  33799. * Class used for the default loading screen
  33800. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33801. */
  33802. export class DefaultLoadingScreen implements ILoadingScreen {
  33803. private _renderingCanvas;
  33804. private _loadingText;
  33805. private _loadingDivBackgroundColor;
  33806. private _loadingDiv;
  33807. private _loadingTextDiv;
  33808. /** Gets or sets the logo url to use for the default loading screen */
  33809. static DefaultLogoUrl: string;
  33810. /** Gets or sets the spinner url to use for the default loading screen */
  33811. static DefaultSpinnerUrl: string;
  33812. /**
  33813. * Creates a new default loading screen
  33814. * @param _renderingCanvas defines the canvas used to render the scene
  33815. * @param _loadingText defines the default text to display
  33816. * @param _loadingDivBackgroundColor defines the default background color
  33817. */
  33818. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33819. /**
  33820. * Function called to display the loading screen
  33821. */
  33822. displayLoadingUI(): void;
  33823. /**
  33824. * Function called to hide the loading screen
  33825. */
  33826. hideLoadingUI(): void;
  33827. /**
  33828. * Gets or sets the text to display while loading
  33829. */
  33830. set loadingUIText(text: string);
  33831. get loadingUIText(): string;
  33832. /**
  33833. * Gets or sets the color to use for the background
  33834. */
  33835. get loadingUIBackgroundColor(): string;
  33836. set loadingUIBackgroundColor(color: string);
  33837. private _resizeLoadingUI;
  33838. }
  33839. }
  33840. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33841. /**
  33842. * Interface for any object that can request an animation frame
  33843. */
  33844. export interface ICustomAnimationFrameRequester {
  33845. /**
  33846. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33847. */
  33848. renderFunction?: Function;
  33849. /**
  33850. * Called to request the next frame to render to
  33851. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33852. */
  33853. requestAnimationFrame: Function;
  33854. /**
  33855. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33856. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33857. */
  33858. requestID?: number;
  33859. }
  33860. }
  33861. declare module "babylonjs/Misc/performanceMonitor" {
  33862. /**
  33863. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33864. */
  33865. export class PerformanceMonitor {
  33866. private _enabled;
  33867. private _rollingFrameTime;
  33868. private _lastFrameTimeMs;
  33869. /**
  33870. * constructor
  33871. * @param frameSampleSize The number of samples required to saturate the sliding window
  33872. */
  33873. constructor(frameSampleSize?: number);
  33874. /**
  33875. * Samples current frame
  33876. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33877. */
  33878. sampleFrame(timeMs?: number): void;
  33879. /**
  33880. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33881. */
  33882. get averageFrameTime(): number;
  33883. /**
  33884. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33885. */
  33886. get averageFrameTimeVariance(): number;
  33887. /**
  33888. * Returns the frame time of the most recent frame
  33889. */
  33890. get instantaneousFrameTime(): number;
  33891. /**
  33892. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33893. */
  33894. get averageFPS(): number;
  33895. /**
  33896. * Returns the average framerate in frames per second using the most recent frame time
  33897. */
  33898. get instantaneousFPS(): number;
  33899. /**
  33900. * Returns true if enough samples have been taken to completely fill the sliding window
  33901. */
  33902. get isSaturated(): boolean;
  33903. /**
  33904. * Enables contributions to the sliding window sample set
  33905. */
  33906. enable(): void;
  33907. /**
  33908. * Disables contributions to the sliding window sample set
  33909. * Samples will not be interpolated over the disabled period
  33910. */
  33911. disable(): void;
  33912. /**
  33913. * Returns true if sampling is enabled
  33914. */
  33915. get isEnabled(): boolean;
  33916. /**
  33917. * Resets performance monitor
  33918. */
  33919. reset(): void;
  33920. }
  33921. /**
  33922. * RollingAverage
  33923. *
  33924. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33925. */
  33926. export class RollingAverage {
  33927. /**
  33928. * Current average
  33929. */
  33930. average: number;
  33931. /**
  33932. * Current variance
  33933. */
  33934. variance: number;
  33935. protected _samples: Array<number>;
  33936. protected _sampleCount: number;
  33937. protected _pos: number;
  33938. protected _m2: number;
  33939. /**
  33940. * constructor
  33941. * @param length The number of samples required to saturate the sliding window
  33942. */
  33943. constructor(length: number);
  33944. /**
  33945. * Adds a sample to the sample set
  33946. * @param v The sample value
  33947. */
  33948. add(v: number): void;
  33949. /**
  33950. * Returns previously added values or null if outside of history or outside the sliding window domain
  33951. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33952. * @return Value previously recorded with add() or null if outside of range
  33953. */
  33954. history(i: number): number;
  33955. /**
  33956. * Returns true if enough samples have been taken to completely fill the sliding window
  33957. * @return true if sample-set saturated
  33958. */
  33959. isSaturated(): boolean;
  33960. /**
  33961. * Resets the rolling average (equivalent to 0 samples taken so far)
  33962. */
  33963. reset(): void;
  33964. /**
  33965. * Wraps a value around the sample range boundaries
  33966. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33967. * @return Wrapped position in sample range
  33968. */
  33969. protected _wrapPosition(i: number): number;
  33970. }
  33971. }
  33972. declare module "babylonjs/Misc/perfCounter" {
  33973. /**
  33974. * This class is used to track a performance counter which is number based.
  33975. * The user has access to many properties which give statistics of different nature.
  33976. *
  33977. * The implementer can track two kinds of Performance Counter: time and count.
  33978. * 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.
  33979. * 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.
  33980. */
  33981. export class PerfCounter {
  33982. /**
  33983. * Gets or sets a global boolean to turn on and off all the counters
  33984. */
  33985. static Enabled: boolean;
  33986. /**
  33987. * Returns the smallest value ever
  33988. */
  33989. get min(): number;
  33990. /**
  33991. * Returns the biggest value ever
  33992. */
  33993. get max(): number;
  33994. /**
  33995. * Returns the average value since the performance counter is running
  33996. */
  33997. get average(): number;
  33998. /**
  33999. * Returns the average value of the last second the counter was monitored
  34000. */
  34001. get lastSecAverage(): number;
  34002. /**
  34003. * Returns the current value
  34004. */
  34005. get current(): number;
  34006. /**
  34007. * Gets the accumulated total
  34008. */
  34009. get total(): number;
  34010. /**
  34011. * Gets the total value count
  34012. */
  34013. get count(): number;
  34014. /**
  34015. * Creates a new counter
  34016. */
  34017. constructor();
  34018. /**
  34019. * Call this method to start monitoring a new frame.
  34020. * 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.
  34021. */
  34022. fetchNewFrame(): void;
  34023. /**
  34024. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34025. * @param newCount the count value to add to the monitored count
  34026. * @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.
  34027. */
  34028. addCount(newCount: number, fetchResult: boolean): void;
  34029. /**
  34030. * Start monitoring this performance counter
  34031. */
  34032. beginMonitoring(): void;
  34033. /**
  34034. * Compute the time lapsed since the previous beginMonitoring() call.
  34035. * @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
  34036. */
  34037. endMonitoring(newFrame?: boolean): void;
  34038. private _fetchResult;
  34039. private _startMonitoringTime;
  34040. private _min;
  34041. private _max;
  34042. private _average;
  34043. private _current;
  34044. private _totalValueCount;
  34045. private _totalAccumulated;
  34046. private _lastSecAverage;
  34047. private _lastSecAccumulated;
  34048. private _lastSecTime;
  34049. private _lastSecValueCount;
  34050. }
  34051. }
  34052. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34053. module "babylonjs/Engines/thinEngine" {
  34054. interface ThinEngine {
  34055. /**
  34056. * Sets alpha constants used by some alpha blending modes
  34057. * @param r defines the red component
  34058. * @param g defines the green component
  34059. * @param b defines the blue component
  34060. * @param a defines the alpha component
  34061. */
  34062. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34063. /**
  34064. * Sets the current alpha mode
  34065. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34066. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34067. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34068. */
  34069. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34070. /**
  34071. * Gets the current alpha mode
  34072. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34073. * @returns the current alpha mode
  34074. */
  34075. getAlphaMode(): number;
  34076. /**
  34077. * Sets the current alpha equation
  34078. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34079. */
  34080. setAlphaEquation(equation: number): void;
  34081. /**
  34082. * Gets the current alpha equation.
  34083. * @returns the current alpha equation
  34084. */
  34085. getAlphaEquation(): number;
  34086. }
  34087. }
  34088. }
  34089. declare module "babylonjs/Engines/engine" {
  34090. import { Observable } from "babylonjs/Misc/observable";
  34091. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34092. import { Scene } from "babylonjs/scene";
  34093. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34094. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34095. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34096. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34097. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34098. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34099. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34100. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34101. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34102. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34103. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34104. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34105. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34106. import "babylonjs/Engines/Extensions/engine.alpha";
  34107. import { Material } from "babylonjs/Materials/material";
  34108. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34109. /**
  34110. * Defines the interface used by display changed events
  34111. */
  34112. export interface IDisplayChangedEventArgs {
  34113. /** Gets the vrDisplay object (if any) */
  34114. vrDisplay: Nullable<any>;
  34115. /** Gets a boolean indicating if webVR is supported */
  34116. vrSupported: boolean;
  34117. }
  34118. /**
  34119. * Defines the interface used by objects containing a viewport (like a camera)
  34120. */
  34121. interface IViewportOwnerLike {
  34122. /**
  34123. * Gets or sets the viewport
  34124. */
  34125. viewport: IViewportLike;
  34126. }
  34127. /**
  34128. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34129. */
  34130. export class Engine extends ThinEngine {
  34131. /** Defines that alpha blending is disabled */
  34132. static readonly ALPHA_DISABLE: number;
  34133. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34134. static readonly ALPHA_ADD: number;
  34135. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34136. static readonly ALPHA_COMBINE: number;
  34137. /** Defines that alpha blending to DEST - SRC * DEST */
  34138. static readonly ALPHA_SUBTRACT: number;
  34139. /** Defines that alpha blending to SRC * DEST */
  34140. static readonly ALPHA_MULTIPLY: number;
  34141. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34142. static readonly ALPHA_MAXIMIZED: number;
  34143. /** Defines that alpha blending to SRC + DEST */
  34144. static readonly ALPHA_ONEONE: number;
  34145. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34146. static readonly ALPHA_PREMULTIPLIED: number;
  34147. /**
  34148. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34149. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34150. */
  34151. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34152. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34153. static readonly ALPHA_INTERPOLATE: number;
  34154. /**
  34155. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34156. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34157. */
  34158. static readonly ALPHA_SCREENMODE: number;
  34159. /** Defines that the ressource is not delayed*/
  34160. static readonly DELAYLOADSTATE_NONE: number;
  34161. /** Defines that the ressource was successfully delay loaded */
  34162. static readonly DELAYLOADSTATE_LOADED: number;
  34163. /** Defines that the ressource is currently delay loading */
  34164. static readonly DELAYLOADSTATE_LOADING: number;
  34165. /** Defines that the ressource is delayed and has not started loading */
  34166. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34167. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34168. static readonly NEVER: number;
  34169. /** 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 */
  34170. static readonly ALWAYS: number;
  34171. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34172. static readonly LESS: number;
  34173. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34174. static readonly EQUAL: number;
  34175. /** 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 */
  34176. static readonly LEQUAL: number;
  34177. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34178. static readonly GREATER: number;
  34179. /** 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 */
  34180. static readonly GEQUAL: number;
  34181. /** 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 */
  34182. static readonly NOTEQUAL: number;
  34183. /** Passed to stencilOperation to specify that stencil value must be kept */
  34184. static readonly KEEP: number;
  34185. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34186. static readonly REPLACE: number;
  34187. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34188. static readonly INCR: number;
  34189. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34190. static readonly DECR: number;
  34191. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34192. static readonly INVERT: number;
  34193. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34194. static readonly INCR_WRAP: number;
  34195. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34196. static readonly DECR_WRAP: number;
  34197. /** Texture is not repeating outside of 0..1 UVs */
  34198. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34199. /** Texture is repeating outside of 0..1 UVs */
  34200. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34201. /** Texture is repeating and mirrored */
  34202. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34203. /** ALPHA */
  34204. static readonly TEXTUREFORMAT_ALPHA: number;
  34205. /** LUMINANCE */
  34206. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34207. /** LUMINANCE_ALPHA */
  34208. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34209. /** RGB */
  34210. static readonly TEXTUREFORMAT_RGB: number;
  34211. /** RGBA */
  34212. static readonly TEXTUREFORMAT_RGBA: number;
  34213. /** RED */
  34214. static readonly TEXTUREFORMAT_RED: number;
  34215. /** RED (2nd reference) */
  34216. static readonly TEXTUREFORMAT_R: number;
  34217. /** RG */
  34218. static readonly TEXTUREFORMAT_RG: number;
  34219. /** RED_INTEGER */
  34220. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34221. /** RED_INTEGER (2nd reference) */
  34222. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34223. /** RG_INTEGER */
  34224. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34225. /** RGB_INTEGER */
  34226. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34227. /** RGBA_INTEGER */
  34228. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34229. /** UNSIGNED_BYTE */
  34230. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34231. /** UNSIGNED_BYTE (2nd reference) */
  34232. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34233. /** FLOAT */
  34234. static readonly TEXTURETYPE_FLOAT: number;
  34235. /** HALF_FLOAT */
  34236. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34237. /** BYTE */
  34238. static readonly TEXTURETYPE_BYTE: number;
  34239. /** SHORT */
  34240. static readonly TEXTURETYPE_SHORT: number;
  34241. /** UNSIGNED_SHORT */
  34242. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34243. /** INT */
  34244. static readonly TEXTURETYPE_INT: number;
  34245. /** UNSIGNED_INT */
  34246. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34247. /** UNSIGNED_SHORT_4_4_4_4 */
  34248. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34249. /** UNSIGNED_SHORT_5_5_5_1 */
  34250. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34251. /** UNSIGNED_SHORT_5_6_5 */
  34252. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34253. /** UNSIGNED_INT_2_10_10_10_REV */
  34254. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34255. /** UNSIGNED_INT_24_8 */
  34256. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34257. /** UNSIGNED_INT_10F_11F_11F_REV */
  34258. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34259. /** UNSIGNED_INT_5_9_9_9_REV */
  34260. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34261. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34262. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34263. /** nearest is mag = nearest and min = nearest and mip = linear */
  34264. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34265. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34266. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34267. /** Trilinear is mag = linear and min = linear and mip = linear */
  34268. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34269. /** nearest is mag = nearest and min = nearest and mip = linear */
  34270. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34271. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34272. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34273. /** Trilinear is mag = linear and min = linear and mip = linear */
  34274. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34275. /** mag = nearest and min = nearest and mip = nearest */
  34276. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34277. /** mag = nearest and min = linear and mip = nearest */
  34278. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34279. /** mag = nearest and min = linear and mip = linear */
  34280. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34281. /** mag = nearest and min = linear and mip = none */
  34282. static readonly TEXTURE_NEAREST_LINEAR: number;
  34283. /** mag = nearest and min = nearest and mip = none */
  34284. static readonly TEXTURE_NEAREST_NEAREST: number;
  34285. /** mag = linear and min = nearest and mip = nearest */
  34286. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34287. /** mag = linear and min = nearest and mip = linear */
  34288. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34289. /** mag = linear and min = linear and mip = none */
  34290. static readonly TEXTURE_LINEAR_LINEAR: number;
  34291. /** mag = linear and min = nearest and mip = none */
  34292. static readonly TEXTURE_LINEAR_NEAREST: number;
  34293. /** Explicit coordinates mode */
  34294. static readonly TEXTURE_EXPLICIT_MODE: number;
  34295. /** Spherical coordinates mode */
  34296. static readonly TEXTURE_SPHERICAL_MODE: number;
  34297. /** Planar coordinates mode */
  34298. static readonly TEXTURE_PLANAR_MODE: number;
  34299. /** Cubic coordinates mode */
  34300. static readonly TEXTURE_CUBIC_MODE: number;
  34301. /** Projection coordinates mode */
  34302. static readonly TEXTURE_PROJECTION_MODE: number;
  34303. /** Skybox coordinates mode */
  34304. static readonly TEXTURE_SKYBOX_MODE: number;
  34305. /** Inverse Cubic coordinates mode */
  34306. static readonly TEXTURE_INVCUBIC_MODE: number;
  34307. /** Equirectangular coordinates mode */
  34308. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34309. /** Equirectangular Fixed coordinates mode */
  34310. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34311. /** Equirectangular Fixed Mirrored coordinates mode */
  34312. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34313. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34314. static readonly SCALEMODE_FLOOR: number;
  34315. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34316. static readonly SCALEMODE_NEAREST: number;
  34317. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34318. static readonly SCALEMODE_CEILING: number;
  34319. /**
  34320. * Returns the current npm package of the sdk
  34321. */
  34322. static get NpmPackage(): string;
  34323. /**
  34324. * Returns the current version of the framework
  34325. */
  34326. static get Version(): string;
  34327. /** Gets the list of created engines */
  34328. static get Instances(): Engine[];
  34329. /**
  34330. * Gets the latest created engine
  34331. */
  34332. static get LastCreatedEngine(): Nullable<Engine>;
  34333. /**
  34334. * Gets the latest created scene
  34335. */
  34336. static get LastCreatedScene(): Nullable<Scene>;
  34337. /**
  34338. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34339. * @param flag defines which part of the materials must be marked as dirty
  34340. * @param predicate defines a predicate used to filter which materials should be affected
  34341. */
  34342. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34343. /**
  34344. * Method called to create the default loading screen.
  34345. * This can be overriden in your own app.
  34346. * @param canvas The rendering canvas element
  34347. * @returns The loading screen
  34348. */
  34349. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34350. /**
  34351. * Method called to create the default rescale post process on each engine.
  34352. */
  34353. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34354. /**
  34355. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34356. **/
  34357. enableOfflineSupport: boolean;
  34358. /**
  34359. * 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)
  34360. **/
  34361. disableManifestCheck: boolean;
  34362. /**
  34363. * Gets the list of created scenes
  34364. */
  34365. scenes: Scene[];
  34366. /**
  34367. * Event raised when a new scene is created
  34368. */
  34369. onNewSceneAddedObservable: Observable<Scene>;
  34370. /**
  34371. * Gets the list of created postprocesses
  34372. */
  34373. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34374. /**
  34375. * Gets a boolean indicating if the pointer is currently locked
  34376. */
  34377. isPointerLock: boolean;
  34378. /**
  34379. * Observable event triggered each time the rendering canvas is resized
  34380. */
  34381. onResizeObservable: Observable<Engine>;
  34382. /**
  34383. * Observable event triggered each time the canvas loses focus
  34384. */
  34385. onCanvasBlurObservable: Observable<Engine>;
  34386. /**
  34387. * Observable event triggered each time the canvas gains focus
  34388. */
  34389. onCanvasFocusObservable: Observable<Engine>;
  34390. /**
  34391. * Observable event triggered each time the canvas receives pointerout event
  34392. */
  34393. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34394. /**
  34395. * Observable raised when the engine begins a new frame
  34396. */
  34397. onBeginFrameObservable: Observable<Engine>;
  34398. /**
  34399. * If set, will be used to request the next animation frame for the render loop
  34400. */
  34401. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34402. /**
  34403. * Observable raised when the engine ends the current frame
  34404. */
  34405. onEndFrameObservable: Observable<Engine>;
  34406. /**
  34407. * Observable raised when the engine is about to compile a shader
  34408. */
  34409. onBeforeShaderCompilationObservable: Observable<Engine>;
  34410. /**
  34411. * Observable raised when the engine has jsut compiled a shader
  34412. */
  34413. onAfterShaderCompilationObservable: Observable<Engine>;
  34414. /**
  34415. * Gets the audio engine
  34416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34417. * @ignorenaming
  34418. */
  34419. static audioEngine: IAudioEngine;
  34420. /**
  34421. * Default AudioEngine factory responsible of creating the Audio Engine.
  34422. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34423. */
  34424. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34425. /**
  34426. * Default offline support factory responsible of creating a tool used to store data locally.
  34427. * By default, this will create a Database object if the workload has been embedded.
  34428. */
  34429. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34430. private _loadingScreen;
  34431. private _pointerLockRequested;
  34432. private _dummyFramebuffer;
  34433. private _rescalePostProcess;
  34434. private _deterministicLockstep;
  34435. private _lockstepMaxSteps;
  34436. private _timeStep;
  34437. protected get _supportsHardwareTextureRescaling(): boolean;
  34438. private _fps;
  34439. private _deltaTime;
  34440. /** @hidden */
  34441. _drawCalls: PerfCounter;
  34442. /** 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 */
  34443. canvasTabIndex: number;
  34444. /**
  34445. * Turn this value on if you want to pause FPS computation when in background
  34446. */
  34447. disablePerformanceMonitorInBackground: boolean;
  34448. private _performanceMonitor;
  34449. /**
  34450. * Gets the performance monitor attached to this engine
  34451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34452. */
  34453. get performanceMonitor(): PerformanceMonitor;
  34454. private _onFocus;
  34455. private _onBlur;
  34456. private _onCanvasPointerOut;
  34457. private _onCanvasBlur;
  34458. private _onCanvasFocus;
  34459. private _onFullscreenChange;
  34460. private _onPointerLockChange;
  34461. /**
  34462. * Gets the HTML element used to attach event listeners
  34463. * @returns a HTML element
  34464. */
  34465. getInputElement(): Nullable<HTMLElement>;
  34466. /**
  34467. * Creates a new engine
  34468. * @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
  34469. * @param antialias defines enable antialiasing (default: false)
  34470. * @param options defines further options to be sent to the getContext() function
  34471. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34472. */
  34473. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34474. /**
  34475. * Gets current aspect ratio
  34476. * @param viewportOwner defines the camera to use to get the aspect ratio
  34477. * @param useScreen defines if screen size must be used (or the current render target if any)
  34478. * @returns a number defining the aspect ratio
  34479. */
  34480. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34481. /**
  34482. * Gets current screen aspect ratio
  34483. * @returns a number defining the aspect ratio
  34484. */
  34485. getScreenAspectRatio(): number;
  34486. /**
  34487. * Gets the client rect of the HTML canvas attached with the current webGL context
  34488. * @returns a client rectanglee
  34489. */
  34490. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34491. /**
  34492. * Gets the client rect of the HTML element used for events
  34493. * @returns a client rectanglee
  34494. */
  34495. getInputElementClientRect(): Nullable<ClientRect>;
  34496. /**
  34497. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34498. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34499. * @returns true if engine is in deterministic lock step mode
  34500. */
  34501. isDeterministicLockStep(): boolean;
  34502. /**
  34503. * Gets the max steps when engine is running in deterministic lock step
  34504. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34505. * @returns the max steps
  34506. */
  34507. getLockstepMaxSteps(): number;
  34508. /**
  34509. * Returns the time in ms between steps when using deterministic lock step.
  34510. * @returns time step in (ms)
  34511. */
  34512. getTimeStep(): number;
  34513. /**
  34514. * Force the mipmap generation for the given render target texture
  34515. * @param texture defines the render target texture to use
  34516. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34517. */
  34518. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34519. /** States */
  34520. /**
  34521. * Set various states to the webGL context
  34522. * @param culling defines backface culling state
  34523. * @param zOffset defines the value to apply to zOffset (0 by default)
  34524. * @param force defines if states must be applied even if cache is up to date
  34525. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34526. */
  34527. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34528. /**
  34529. * Set the z offset to apply to current rendering
  34530. * @param value defines the offset to apply
  34531. */
  34532. setZOffset(value: number): void;
  34533. /**
  34534. * Gets the current value of the zOffset
  34535. * @returns the current zOffset state
  34536. */
  34537. getZOffset(): number;
  34538. /**
  34539. * Enable or disable depth buffering
  34540. * @param enable defines the state to set
  34541. */
  34542. setDepthBuffer(enable: boolean): void;
  34543. /**
  34544. * Gets a boolean indicating if depth writing is enabled
  34545. * @returns the current depth writing state
  34546. */
  34547. getDepthWrite(): boolean;
  34548. /**
  34549. * Enable or disable depth writing
  34550. * @param enable defines the state to set
  34551. */
  34552. setDepthWrite(enable: boolean): void;
  34553. /**
  34554. * Gets a boolean indicating if stencil buffer is enabled
  34555. * @returns the current stencil buffer state
  34556. */
  34557. getStencilBuffer(): boolean;
  34558. /**
  34559. * Enable or disable the stencil buffer
  34560. * @param enable defines if the stencil buffer must be enabled or disabled
  34561. */
  34562. setStencilBuffer(enable: boolean): void;
  34563. /**
  34564. * Gets the current stencil mask
  34565. * @returns a number defining the new stencil mask to use
  34566. */
  34567. getStencilMask(): number;
  34568. /**
  34569. * Sets the current stencil mask
  34570. * @param mask defines the new stencil mask to use
  34571. */
  34572. setStencilMask(mask: number): void;
  34573. /**
  34574. * Gets the current stencil function
  34575. * @returns a number defining the stencil function to use
  34576. */
  34577. getStencilFunction(): number;
  34578. /**
  34579. * Gets the current stencil reference value
  34580. * @returns a number defining the stencil reference value to use
  34581. */
  34582. getStencilFunctionReference(): number;
  34583. /**
  34584. * Gets the current stencil mask
  34585. * @returns a number defining the stencil mask to use
  34586. */
  34587. getStencilFunctionMask(): number;
  34588. /**
  34589. * Sets the current stencil function
  34590. * @param stencilFunc defines the new stencil function to use
  34591. */
  34592. setStencilFunction(stencilFunc: number): void;
  34593. /**
  34594. * Sets the current stencil reference
  34595. * @param reference defines the new stencil reference to use
  34596. */
  34597. setStencilFunctionReference(reference: number): void;
  34598. /**
  34599. * Sets the current stencil mask
  34600. * @param mask defines the new stencil mask to use
  34601. */
  34602. setStencilFunctionMask(mask: number): void;
  34603. /**
  34604. * Gets the current stencil operation when stencil fails
  34605. * @returns a number defining stencil operation to use when stencil fails
  34606. */
  34607. getStencilOperationFail(): number;
  34608. /**
  34609. * Gets the current stencil operation when depth fails
  34610. * @returns a number defining stencil operation to use when depth fails
  34611. */
  34612. getStencilOperationDepthFail(): number;
  34613. /**
  34614. * Gets the current stencil operation when stencil passes
  34615. * @returns a number defining stencil operation to use when stencil passes
  34616. */
  34617. getStencilOperationPass(): number;
  34618. /**
  34619. * Sets the stencil operation to use when stencil fails
  34620. * @param operation defines the stencil operation to use when stencil fails
  34621. */
  34622. setStencilOperationFail(operation: number): void;
  34623. /**
  34624. * Sets the stencil operation to use when depth fails
  34625. * @param operation defines the stencil operation to use when depth fails
  34626. */
  34627. setStencilOperationDepthFail(operation: number): void;
  34628. /**
  34629. * Sets the stencil operation to use when stencil passes
  34630. * @param operation defines the stencil operation to use when stencil passes
  34631. */
  34632. setStencilOperationPass(operation: number): void;
  34633. /**
  34634. * Sets a boolean indicating if the dithering state is enabled or disabled
  34635. * @param value defines the dithering state
  34636. */
  34637. setDitheringState(value: boolean): void;
  34638. /**
  34639. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34640. * @param value defines the rasterizer state
  34641. */
  34642. setRasterizerState(value: boolean): void;
  34643. /**
  34644. * Gets the current depth function
  34645. * @returns a number defining the depth function
  34646. */
  34647. getDepthFunction(): Nullable<number>;
  34648. /**
  34649. * Sets the current depth function
  34650. * @param depthFunc defines the function to use
  34651. */
  34652. setDepthFunction(depthFunc: number): void;
  34653. /**
  34654. * Sets the current depth function to GREATER
  34655. */
  34656. setDepthFunctionToGreater(): void;
  34657. /**
  34658. * Sets the current depth function to GEQUAL
  34659. */
  34660. setDepthFunctionToGreaterOrEqual(): void;
  34661. /**
  34662. * Sets the current depth function to LESS
  34663. */
  34664. setDepthFunctionToLess(): void;
  34665. /**
  34666. * Sets the current depth function to LEQUAL
  34667. */
  34668. setDepthFunctionToLessOrEqual(): void;
  34669. private _cachedStencilBuffer;
  34670. private _cachedStencilFunction;
  34671. private _cachedStencilMask;
  34672. private _cachedStencilOperationPass;
  34673. private _cachedStencilOperationFail;
  34674. private _cachedStencilOperationDepthFail;
  34675. private _cachedStencilReference;
  34676. /**
  34677. * Caches the the state of the stencil buffer
  34678. */
  34679. cacheStencilState(): void;
  34680. /**
  34681. * Restores the state of the stencil buffer
  34682. */
  34683. restoreStencilState(): void;
  34684. /**
  34685. * Directly set the WebGL Viewport
  34686. * @param x defines the x coordinate of the viewport (in screen space)
  34687. * @param y defines the y coordinate of the viewport (in screen space)
  34688. * @param width defines the width of the viewport (in screen space)
  34689. * @param height defines the height of the viewport (in screen space)
  34690. * @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
  34691. */
  34692. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34693. /**
  34694. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34695. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34696. * @param y defines the y-coordinate of the corner of the clear rectangle
  34697. * @param width defines the width of the clear rectangle
  34698. * @param height defines the height of the clear rectangle
  34699. * @param clearColor defines the clear color
  34700. */
  34701. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34702. /**
  34703. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34704. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34705. * @param y defines the y-coordinate of the corner of the clear rectangle
  34706. * @param width defines the width of the clear rectangle
  34707. * @param height defines the height of the clear rectangle
  34708. */
  34709. enableScissor(x: number, y: number, width: number, height: number): void;
  34710. /**
  34711. * Disable previously set scissor test rectangle
  34712. */
  34713. disableScissor(): void;
  34714. protected _reportDrawCall(): void;
  34715. /**
  34716. * Initializes a webVR display and starts listening to display change events
  34717. * The onVRDisplayChangedObservable will be notified upon these changes
  34718. * @returns The onVRDisplayChangedObservable
  34719. */
  34720. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34721. /** @hidden */
  34722. _prepareVRComponent(): void;
  34723. /** @hidden */
  34724. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34725. /** @hidden */
  34726. _submitVRFrame(): void;
  34727. /**
  34728. * Call this function to leave webVR mode
  34729. * Will do nothing if webVR is not supported or if there is no webVR device
  34730. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34731. */
  34732. disableVR(): void;
  34733. /**
  34734. * Gets a boolean indicating that the system is in VR mode and is presenting
  34735. * @returns true if VR mode is engaged
  34736. */
  34737. isVRPresenting(): boolean;
  34738. /** @hidden */
  34739. _requestVRFrame(): void;
  34740. /** @hidden */
  34741. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34742. /**
  34743. * Gets the source code of the vertex shader associated with a specific webGL program
  34744. * @param program defines the program to use
  34745. * @returns a string containing the source code of the vertex shader associated with the program
  34746. */
  34747. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34748. /**
  34749. * Gets the source code of the fragment shader associated with a specific webGL program
  34750. * @param program defines the program to use
  34751. * @returns a string containing the source code of the fragment shader associated with the program
  34752. */
  34753. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34754. /**
  34755. * Sets a depth stencil texture from a render target to the according uniform.
  34756. * @param channel The texture channel
  34757. * @param uniform The uniform to set
  34758. * @param texture The render target texture containing the depth stencil texture to apply
  34759. */
  34760. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34761. /**
  34762. * Sets a texture to the webGL context from a postprocess
  34763. * @param channel defines the channel to use
  34764. * @param postProcess defines the source postprocess
  34765. */
  34766. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34767. /**
  34768. * Binds the output of the passed in post process to the texture channel specified
  34769. * @param channel The channel the texture should be bound to
  34770. * @param postProcess The post process which's output should be bound
  34771. */
  34772. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34773. /** @hidden */
  34774. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34775. protected _rebuildBuffers(): void;
  34776. /** @hidden */
  34777. _renderFrame(): void;
  34778. _renderLoop(): void;
  34779. /** @hidden */
  34780. _renderViews(): boolean;
  34781. /**
  34782. * Toggle full screen mode
  34783. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34784. */
  34785. switchFullscreen(requestPointerLock: boolean): void;
  34786. /**
  34787. * Enters full screen mode
  34788. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34789. */
  34790. enterFullscreen(requestPointerLock: boolean): void;
  34791. /**
  34792. * Exits full screen mode
  34793. */
  34794. exitFullscreen(): void;
  34795. /**
  34796. * Enters Pointerlock mode
  34797. */
  34798. enterPointerlock(): void;
  34799. /**
  34800. * Exits Pointerlock mode
  34801. */
  34802. exitPointerlock(): void;
  34803. /**
  34804. * Begin a new frame
  34805. */
  34806. beginFrame(): void;
  34807. /**
  34808. * Enf the current frame
  34809. */
  34810. endFrame(): void;
  34811. resize(): void;
  34812. /**
  34813. * Force a specific size of the canvas
  34814. * @param width defines the new canvas' width
  34815. * @param height defines the new canvas' height
  34816. */
  34817. setSize(width: number, height: number): void;
  34818. /**
  34819. * Updates a dynamic vertex buffer.
  34820. * @param vertexBuffer the vertex buffer to update
  34821. * @param data the data used to update the vertex buffer
  34822. * @param byteOffset the byte offset of the data
  34823. * @param byteLength the byte length of the data
  34824. */
  34825. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34826. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34827. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34828. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34829. _releaseTexture(texture: InternalTexture): void;
  34830. /**
  34831. * @hidden
  34832. * Rescales a texture
  34833. * @param source input texutre
  34834. * @param destination destination texture
  34835. * @param scene scene to use to render the resize
  34836. * @param internalFormat format to use when resizing
  34837. * @param onComplete callback to be called when resize has completed
  34838. */
  34839. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34840. /**
  34841. * Gets the current framerate
  34842. * @returns a number representing the framerate
  34843. */
  34844. getFps(): number;
  34845. /**
  34846. * Gets the time spent between current and previous frame
  34847. * @returns a number representing the delta time in ms
  34848. */
  34849. getDeltaTime(): number;
  34850. private _measureFps;
  34851. /** @hidden */
  34852. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34853. /**
  34854. * Update a dynamic index buffer
  34855. * @param indexBuffer defines the target index buffer
  34856. * @param indices defines the data to update
  34857. * @param offset defines the offset in the target index buffer where update should start
  34858. */
  34859. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34860. /**
  34861. * Updates the sample count of a render target texture
  34862. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34863. * @param texture defines the texture to update
  34864. * @param samples defines the sample count to set
  34865. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34866. */
  34867. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34868. /**
  34869. * Updates a depth texture Comparison Mode and Function.
  34870. * If the comparison Function is equal to 0, the mode will be set to none.
  34871. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34872. * @param texture The texture to set the comparison function for
  34873. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34874. */
  34875. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34876. /**
  34877. * Creates a webGL buffer to use with instanciation
  34878. * @param capacity defines the size of the buffer
  34879. * @returns the webGL buffer
  34880. */
  34881. createInstancesBuffer(capacity: number): DataBuffer;
  34882. /**
  34883. * Delete a webGL buffer used with instanciation
  34884. * @param buffer defines the webGL buffer to delete
  34885. */
  34886. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34887. private _clientWaitAsync;
  34888. /** @hidden */
  34889. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34890. /** @hidden */
  34891. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34892. dispose(): void;
  34893. private _disableTouchAction;
  34894. /**
  34895. * Display the loading screen
  34896. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34897. */
  34898. displayLoadingUI(): void;
  34899. /**
  34900. * Hide the loading screen
  34901. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34902. */
  34903. hideLoadingUI(): void;
  34904. /**
  34905. * Gets the current loading screen object
  34906. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34907. */
  34908. get loadingScreen(): ILoadingScreen;
  34909. /**
  34910. * Sets the current loading screen object
  34911. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34912. */
  34913. set loadingScreen(loadingScreen: ILoadingScreen);
  34914. /**
  34915. * Sets the current loading screen text
  34916. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34917. */
  34918. set loadingUIText(text: string);
  34919. /**
  34920. * Sets the current loading screen background color
  34921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34922. */
  34923. set loadingUIBackgroundColor(color: string);
  34924. /** Pointerlock and fullscreen */
  34925. /**
  34926. * Ask the browser to promote the current element to pointerlock mode
  34927. * @param element defines the DOM element to promote
  34928. */
  34929. static _RequestPointerlock(element: HTMLElement): void;
  34930. /**
  34931. * Asks the browser to exit pointerlock mode
  34932. */
  34933. static _ExitPointerlock(): void;
  34934. /**
  34935. * Ask the browser to promote the current element to fullscreen rendering mode
  34936. * @param element defines the DOM element to promote
  34937. */
  34938. static _RequestFullscreen(element: HTMLElement): void;
  34939. /**
  34940. * Asks the browser to exit fullscreen mode
  34941. */
  34942. static _ExitFullscreen(): void;
  34943. }
  34944. }
  34945. declare module "babylonjs/Engines/engineStore" {
  34946. import { Nullable } from "babylonjs/types";
  34947. import { Engine } from "babylonjs/Engines/engine";
  34948. import { Scene } from "babylonjs/scene";
  34949. /**
  34950. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34951. * during the life time of the application.
  34952. */
  34953. export class EngineStore {
  34954. /** Gets the list of created engines */
  34955. static Instances: import("babylonjs/Engines/engine").Engine[];
  34956. /** @hidden */
  34957. static _LastCreatedScene: Nullable<Scene>;
  34958. /**
  34959. * Gets the latest created engine
  34960. */
  34961. static get LastCreatedEngine(): Nullable<Engine>;
  34962. /**
  34963. * Gets the latest created scene
  34964. */
  34965. static get LastCreatedScene(): Nullable<Scene>;
  34966. /**
  34967. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34968. * @ignorenaming
  34969. */
  34970. static UseFallbackTexture: boolean;
  34971. /**
  34972. * Texture content used if a texture cannot loaded
  34973. * @ignorenaming
  34974. */
  34975. static FallbackTexture: string;
  34976. }
  34977. }
  34978. declare module "babylonjs/Misc/promise" {
  34979. /**
  34980. * Helper class that provides a small promise polyfill
  34981. */
  34982. export class PromisePolyfill {
  34983. /**
  34984. * Static function used to check if the polyfill is required
  34985. * If this is the case then the function will inject the polyfill to window.Promise
  34986. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34987. */
  34988. static Apply(force?: boolean): void;
  34989. }
  34990. }
  34991. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34992. /**
  34993. * Interface for screenshot methods with describe argument called `size` as object with options
  34994. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34995. */
  34996. export interface IScreenshotSize {
  34997. /**
  34998. * number in pixels for canvas height
  34999. */
  35000. height?: number;
  35001. /**
  35002. * multiplier allowing render at a higher or lower resolution
  35003. * If value is defined then height and width will be ignored and taken from camera
  35004. */
  35005. precision?: number;
  35006. /**
  35007. * number in pixels for canvas width
  35008. */
  35009. width?: number;
  35010. }
  35011. }
  35012. declare module "babylonjs/Misc/tools" {
  35013. import { Nullable, float } from "babylonjs/types";
  35014. import { DomManagement } from "babylonjs/Misc/domManagement";
  35015. import { WebRequest } from "babylonjs/Misc/webRequest";
  35016. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35017. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35018. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35019. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35020. import { Camera } from "babylonjs/Cameras/camera";
  35021. import { Engine } from "babylonjs/Engines/engine";
  35022. interface IColor4Like {
  35023. r: float;
  35024. g: float;
  35025. b: float;
  35026. a: float;
  35027. }
  35028. /**
  35029. * Class containing a set of static utilities functions
  35030. */
  35031. export class Tools {
  35032. /**
  35033. * Gets or sets the base URL to use to load assets
  35034. */
  35035. static get BaseUrl(): string;
  35036. static set BaseUrl(value: string);
  35037. /**
  35038. * Enable/Disable Custom HTTP Request Headers globally.
  35039. * default = false
  35040. * @see CustomRequestHeaders
  35041. */
  35042. static UseCustomRequestHeaders: boolean;
  35043. /**
  35044. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35045. * i.e. when loading files, where the server/service expects an Authorization header
  35046. */
  35047. static CustomRequestHeaders: {
  35048. [key: string]: string;
  35049. };
  35050. /**
  35051. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35052. */
  35053. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35054. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35055. /**
  35056. * Default behaviour for cors in the application.
  35057. * It can be a string if the expected behavior is identical in the entire app.
  35058. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35059. */
  35060. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35061. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35062. /**
  35063. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35064. * @ignorenaming
  35065. */
  35066. static get UseFallbackTexture(): boolean;
  35067. static set UseFallbackTexture(value: boolean);
  35068. /**
  35069. * Use this object to register external classes like custom textures or material
  35070. * to allow the laoders to instantiate them
  35071. */
  35072. static get RegisteredExternalClasses(): {
  35073. [key: string]: Object;
  35074. };
  35075. static set RegisteredExternalClasses(classes: {
  35076. [key: string]: Object;
  35077. });
  35078. /**
  35079. * Texture content used if a texture cannot loaded
  35080. * @ignorenaming
  35081. */
  35082. static get fallbackTexture(): string;
  35083. static set fallbackTexture(value: string);
  35084. /**
  35085. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35086. * @param u defines the coordinate on X axis
  35087. * @param v defines the coordinate on Y axis
  35088. * @param width defines the width of the source data
  35089. * @param height defines the height of the source data
  35090. * @param pixels defines the source byte array
  35091. * @param color defines the output color
  35092. */
  35093. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35094. /**
  35095. * Interpolates between a and b via alpha
  35096. * @param a The lower value (returned when alpha = 0)
  35097. * @param b The upper value (returned when alpha = 1)
  35098. * @param alpha The interpolation-factor
  35099. * @return The mixed value
  35100. */
  35101. static Mix(a: number, b: number, alpha: number): number;
  35102. /**
  35103. * Tries to instantiate a new object from a given class name
  35104. * @param className defines the class name to instantiate
  35105. * @returns the new object or null if the system was not able to do the instantiation
  35106. */
  35107. static Instantiate(className: string): any;
  35108. /**
  35109. * Provides a slice function that will work even on IE
  35110. * @param data defines the array to slice
  35111. * @param start defines the start of the data (optional)
  35112. * @param end defines the end of the data (optional)
  35113. * @returns the new sliced array
  35114. */
  35115. static Slice<T>(data: T, start?: number, end?: number): T;
  35116. /**
  35117. * Polyfill for setImmediate
  35118. * @param action defines the action to execute after the current execution block
  35119. */
  35120. static SetImmediate(action: () => void): void;
  35121. /**
  35122. * Function indicating if a number is an exponent of 2
  35123. * @param value defines the value to test
  35124. * @returns true if the value is an exponent of 2
  35125. */
  35126. static IsExponentOfTwo(value: number): boolean;
  35127. private static _tmpFloatArray;
  35128. /**
  35129. * Returns the nearest 32-bit single precision float representation of a Number
  35130. * @param value A Number. If the parameter is of a different type, it will get converted
  35131. * to a number or to NaN if it cannot be converted
  35132. * @returns number
  35133. */
  35134. static FloatRound(value: number): number;
  35135. /**
  35136. * Extracts the filename from a path
  35137. * @param path defines the path to use
  35138. * @returns the filename
  35139. */
  35140. static GetFilename(path: string): string;
  35141. /**
  35142. * Extracts the "folder" part of a path (everything before the filename).
  35143. * @param uri The URI to extract the info from
  35144. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35145. * @returns The "folder" part of the path
  35146. */
  35147. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35148. /**
  35149. * Extracts text content from a DOM element hierarchy
  35150. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35151. */
  35152. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35153. /**
  35154. * Convert an angle in radians to degrees
  35155. * @param angle defines the angle to convert
  35156. * @returns the angle in degrees
  35157. */
  35158. static ToDegrees(angle: number): number;
  35159. /**
  35160. * Convert an angle in degrees to radians
  35161. * @param angle defines the angle to convert
  35162. * @returns the angle in radians
  35163. */
  35164. static ToRadians(angle: number): number;
  35165. /**
  35166. * Returns an array if obj is not an array
  35167. * @param obj defines the object to evaluate as an array
  35168. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35169. * @returns either obj directly if obj is an array or a new array containing obj
  35170. */
  35171. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35172. /**
  35173. * Gets the pointer prefix to use
  35174. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35175. */
  35176. static GetPointerPrefix(): string;
  35177. /**
  35178. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35179. * @param url define the url we are trying
  35180. * @param element define the dom element where to configure the cors policy
  35181. */
  35182. static SetCorsBehavior(url: string | string[], element: {
  35183. crossOrigin: string | null;
  35184. }): void;
  35185. /**
  35186. * Removes unwanted characters from an url
  35187. * @param url defines the url to clean
  35188. * @returns the cleaned url
  35189. */
  35190. static CleanUrl(url: string): string;
  35191. /**
  35192. * Gets or sets a function used to pre-process url before using them to load assets
  35193. */
  35194. static get PreprocessUrl(): (url: string) => string;
  35195. static set PreprocessUrl(processor: (url: string) => string);
  35196. /**
  35197. * Loads an image as an HTMLImageElement.
  35198. * @param input url string, ArrayBuffer, or Blob to load
  35199. * @param onLoad callback called when the image successfully loads
  35200. * @param onError callback called when the image fails to load
  35201. * @param offlineProvider offline provider for caching
  35202. * @param mimeType optional mime type
  35203. * @returns the HTMLImageElement of the loaded image
  35204. */
  35205. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35206. /**
  35207. * Loads a file from a url
  35208. * @param url url string, ArrayBuffer, or Blob to load
  35209. * @param onSuccess callback called when the file successfully loads
  35210. * @param onProgress callback called while file is loading (if the server supports this mode)
  35211. * @param offlineProvider defines the offline provider for caching
  35212. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35213. * @param onError callback called when the file fails to load
  35214. * @returns a file request object
  35215. */
  35216. 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;
  35217. /**
  35218. * Loads a file from a url
  35219. * @param url the file url to load
  35220. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35221. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35222. */
  35223. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35224. /**
  35225. * Load a script (identified by an url). When the url returns, the
  35226. * content of this file is added into a new script element, attached to the DOM (body element)
  35227. * @param scriptUrl defines the url of the script to laod
  35228. * @param onSuccess defines the callback called when the script is loaded
  35229. * @param onError defines the callback to call if an error occurs
  35230. * @param scriptId defines the id of the script element
  35231. */
  35232. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35233. /**
  35234. * Load an asynchronous script (identified by an url). When the url returns, the
  35235. * content of this file is added into a new script element, attached to the DOM (body element)
  35236. * @param scriptUrl defines the url of the script to laod
  35237. * @param scriptId defines the id of the script element
  35238. * @returns a promise request object
  35239. */
  35240. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35241. /**
  35242. * Loads a file from a blob
  35243. * @param fileToLoad defines the blob to use
  35244. * @param callback defines the callback to call when data is loaded
  35245. * @param progressCallback defines the callback to call during loading process
  35246. * @returns a file request object
  35247. */
  35248. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35249. /**
  35250. * Reads a file from a File object
  35251. * @param file defines the file to load
  35252. * @param onSuccess defines the callback to call when data is loaded
  35253. * @param onProgress defines the callback to call during loading process
  35254. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35255. * @param onError defines the callback to call when an error occurs
  35256. * @returns a file request object
  35257. */
  35258. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35259. /**
  35260. * Creates a data url from a given string content
  35261. * @param content defines the content to convert
  35262. * @returns the new data url link
  35263. */
  35264. static FileAsURL(content: string): string;
  35265. /**
  35266. * Format the given number to a specific decimal format
  35267. * @param value defines the number to format
  35268. * @param decimals defines the number of decimals to use
  35269. * @returns the formatted string
  35270. */
  35271. static Format(value: number, decimals?: number): string;
  35272. /**
  35273. * Tries to copy an object by duplicating every property
  35274. * @param source defines the source object
  35275. * @param destination defines the target object
  35276. * @param doNotCopyList defines a list of properties to avoid
  35277. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35278. */
  35279. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35280. /**
  35281. * Gets a boolean indicating if the given object has no own property
  35282. * @param obj defines the object to test
  35283. * @returns true if object has no own property
  35284. */
  35285. static IsEmpty(obj: any): boolean;
  35286. /**
  35287. * Function used to register events at window level
  35288. * @param windowElement defines the Window object to use
  35289. * @param events defines the events to register
  35290. */
  35291. static RegisterTopRootEvents(windowElement: Window, events: {
  35292. name: string;
  35293. handler: Nullable<(e: FocusEvent) => any>;
  35294. }[]): void;
  35295. /**
  35296. * Function used to unregister events from window level
  35297. * @param windowElement defines the Window object to use
  35298. * @param events defines the events to unregister
  35299. */
  35300. static UnregisterTopRootEvents(windowElement: Window, events: {
  35301. name: string;
  35302. handler: Nullable<(e: FocusEvent) => any>;
  35303. }[]): void;
  35304. /**
  35305. * @ignore
  35306. */
  35307. static _ScreenshotCanvas: HTMLCanvasElement;
  35308. /**
  35309. * Dumps the current bound framebuffer
  35310. * @param width defines the rendering width
  35311. * @param height defines the rendering height
  35312. * @param engine defines the hosting engine
  35313. * @param successCallback defines the callback triggered once the data are available
  35314. * @param mimeType defines the mime type of the result
  35315. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35316. */
  35317. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35318. /**
  35319. * Converts the canvas data to blob.
  35320. * This acts as a polyfill for browsers not supporting the to blob function.
  35321. * @param canvas Defines the canvas to extract the data from
  35322. * @param successCallback Defines the callback triggered once the data are available
  35323. * @param mimeType Defines the mime type of the result
  35324. */
  35325. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35326. /**
  35327. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35328. * @param successCallback defines the callback triggered once the data are available
  35329. * @param mimeType defines the mime type of the result
  35330. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35331. */
  35332. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35333. /**
  35334. * Downloads a blob in the browser
  35335. * @param blob defines the blob to download
  35336. * @param fileName defines the name of the downloaded file
  35337. */
  35338. static Download(blob: Blob, fileName: string): void;
  35339. /**
  35340. * Captures a screenshot of the current rendering
  35341. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35342. * @param engine defines the rendering engine
  35343. * @param camera defines the source camera
  35344. * @param size This parameter can be set to a single number or to an object with the
  35345. * following (optional) properties: precision, width, height. If a single number is passed,
  35346. * it will be used for both width and height. If an object is passed, the screenshot size
  35347. * will be derived from the parameters. The precision property is a multiplier allowing
  35348. * rendering at a higher or lower resolution
  35349. * @param successCallback defines the callback receives a single parameter which contains the
  35350. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35351. * src parameter of an <img> to display it
  35352. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35353. * Check your browser for supported MIME types
  35354. */
  35355. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35356. /**
  35357. * Captures a screenshot of the current rendering
  35358. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35359. * @param engine defines the rendering engine
  35360. * @param camera defines the source camera
  35361. * @param size This parameter can be set to a single number or to an object with the
  35362. * following (optional) properties: precision, width, height. If a single number is passed,
  35363. * it will be used for both width and height. If an object is passed, the screenshot size
  35364. * will be derived from the parameters. The precision property is a multiplier allowing
  35365. * rendering at a higher or lower resolution
  35366. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35367. * Check your browser for supported MIME types
  35368. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35369. * to the src parameter of an <img> to display it
  35370. */
  35371. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35372. /**
  35373. * Generates an image screenshot from the specified camera.
  35374. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35375. * @param engine The engine to use for rendering
  35376. * @param camera The camera to use for rendering
  35377. * @param size This parameter can be set to a single number or to an object with the
  35378. * following (optional) properties: precision, width, height. If a single number is passed,
  35379. * it will be used for both width and height. If an object is passed, the screenshot size
  35380. * will be derived from the parameters. The precision property is a multiplier allowing
  35381. * rendering at a higher or lower resolution
  35382. * @param successCallback The callback receives a single parameter which contains the
  35383. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35384. * src parameter of an <img> to display it
  35385. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35386. * Check your browser for supported MIME types
  35387. * @param samples Texture samples (default: 1)
  35388. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35389. * @param fileName A name for for the downloaded file.
  35390. */
  35391. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35392. /**
  35393. * Generates an image screenshot from the specified camera.
  35394. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35395. * @param engine The engine to use for rendering
  35396. * @param camera The camera to use for rendering
  35397. * @param size This parameter can be set to a single number or to an object with the
  35398. * following (optional) properties: precision, width, height. If a single number is passed,
  35399. * it will be used for both width and height. If an object is passed, the screenshot size
  35400. * will be derived from the parameters. The precision property is a multiplier allowing
  35401. * rendering at a higher or lower resolution
  35402. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35403. * Check your browser for supported MIME types
  35404. * @param samples Texture samples (default: 1)
  35405. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35406. * @param fileName A name for for the downloaded file.
  35407. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35408. * to the src parameter of an <img> to display it
  35409. */
  35410. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35411. /**
  35412. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35413. * Be aware Math.random() could cause collisions, but:
  35414. * "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"
  35415. * @returns a pseudo random id
  35416. */
  35417. static RandomId(): string;
  35418. /**
  35419. * Test if the given uri is a base64 string
  35420. * @param uri The uri to test
  35421. * @return True if the uri is a base64 string or false otherwise
  35422. */
  35423. static IsBase64(uri: string): boolean;
  35424. /**
  35425. * Decode the given base64 uri.
  35426. * @param uri The uri to decode
  35427. * @return The decoded base64 data.
  35428. */
  35429. static DecodeBase64(uri: string): ArrayBuffer;
  35430. /**
  35431. * Gets the absolute url.
  35432. * @param url the input url
  35433. * @return the absolute url
  35434. */
  35435. static GetAbsoluteUrl(url: string): string;
  35436. /**
  35437. * No log
  35438. */
  35439. static readonly NoneLogLevel: number;
  35440. /**
  35441. * Only message logs
  35442. */
  35443. static readonly MessageLogLevel: number;
  35444. /**
  35445. * Only warning logs
  35446. */
  35447. static readonly WarningLogLevel: number;
  35448. /**
  35449. * Only error logs
  35450. */
  35451. static readonly ErrorLogLevel: number;
  35452. /**
  35453. * All logs
  35454. */
  35455. static readonly AllLogLevel: number;
  35456. /**
  35457. * Gets a value indicating the number of loading errors
  35458. * @ignorenaming
  35459. */
  35460. static get errorsCount(): number;
  35461. /**
  35462. * Callback called when a new log is added
  35463. */
  35464. static OnNewCacheEntry: (entry: string) => void;
  35465. /**
  35466. * Log a message to the console
  35467. * @param message defines the message to log
  35468. */
  35469. static Log(message: string): void;
  35470. /**
  35471. * Write a warning message to the console
  35472. * @param message defines the message to log
  35473. */
  35474. static Warn(message: string): void;
  35475. /**
  35476. * Write an error message to the console
  35477. * @param message defines the message to log
  35478. */
  35479. static Error(message: string): void;
  35480. /**
  35481. * Gets current log cache (list of logs)
  35482. */
  35483. static get LogCache(): string;
  35484. /**
  35485. * Clears the log cache
  35486. */
  35487. static ClearLogCache(): void;
  35488. /**
  35489. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35490. */
  35491. static set LogLevels(level: number);
  35492. /**
  35493. * Checks if the window object exists
  35494. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35495. */
  35496. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35497. /**
  35498. * No performance log
  35499. */
  35500. static readonly PerformanceNoneLogLevel: number;
  35501. /**
  35502. * Use user marks to log performance
  35503. */
  35504. static readonly PerformanceUserMarkLogLevel: number;
  35505. /**
  35506. * Log performance to the console
  35507. */
  35508. static readonly PerformanceConsoleLogLevel: number;
  35509. private static _performance;
  35510. /**
  35511. * Sets the current performance log level
  35512. */
  35513. static set PerformanceLogLevel(level: number);
  35514. private static _StartPerformanceCounterDisabled;
  35515. private static _EndPerformanceCounterDisabled;
  35516. private static _StartUserMark;
  35517. private static _EndUserMark;
  35518. private static _StartPerformanceConsole;
  35519. private static _EndPerformanceConsole;
  35520. /**
  35521. * Starts a performance counter
  35522. */
  35523. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35524. /**
  35525. * Ends a specific performance coutner
  35526. */
  35527. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35528. /**
  35529. * Gets either window.performance.now() if supported or Date.now() else
  35530. */
  35531. static get Now(): number;
  35532. /**
  35533. * This method will return the name of the class used to create the instance of the given object.
  35534. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35535. * @param object the object to get the class name from
  35536. * @param isType defines if the object is actually a type
  35537. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35538. */
  35539. static GetClassName(object: any, isType?: boolean): string;
  35540. /**
  35541. * Gets the first element of an array satisfying a given predicate
  35542. * @param array defines the array to browse
  35543. * @param predicate defines the predicate to use
  35544. * @returns null if not found or the element
  35545. */
  35546. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35547. /**
  35548. * This method will return the name of the full name of the class, including its owning module (if any).
  35549. * 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).
  35550. * @param object the object to get the class name from
  35551. * @param isType defines if the object is actually a type
  35552. * @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.
  35553. * @ignorenaming
  35554. */
  35555. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35556. /**
  35557. * Returns a promise that resolves after the given amount of time.
  35558. * @param delay Number of milliseconds to delay
  35559. * @returns Promise that resolves after the given amount of time
  35560. */
  35561. static DelayAsync(delay: number): Promise<void>;
  35562. /**
  35563. * Utility function to detect if the current user agent is Safari
  35564. * @returns whether or not the current user agent is safari
  35565. */
  35566. static IsSafari(): boolean;
  35567. }
  35568. /**
  35569. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35570. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35571. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35572. * @param name The name of the class, case should be preserved
  35573. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35574. */
  35575. export function className(name: string, module?: string): (target: Object) => void;
  35576. /**
  35577. * An implementation of a loop for asynchronous functions.
  35578. */
  35579. export class AsyncLoop {
  35580. /**
  35581. * Defines the number of iterations for the loop
  35582. */
  35583. iterations: number;
  35584. /**
  35585. * Defines the current index of the loop.
  35586. */
  35587. index: number;
  35588. private _done;
  35589. private _fn;
  35590. private _successCallback;
  35591. /**
  35592. * Constructor.
  35593. * @param iterations the number of iterations.
  35594. * @param func the function to run each iteration
  35595. * @param successCallback the callback that will be called upon succesful execution
  35596. * @param offset starting offset.
  35597. */
  35598. constructor(
  35599. /**
  35600. * Defines the number of iterations for the loop
  35601. */
  35602. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35603. /**
  35604. * Execute the next iteration. Must be called after the last iteration was finished.
  35605. */
  35606. executeNext(): void;
  35607. /**
  35608. * Break the loop and run the success callback.
  35609. */
  35610. breakLoop(): void;
  35611. /**
  35612. * Create and run an async loop.
  35613. * @param iterations the number of iterations.
  35614. * @param fn the function to run each iteration
  35615. * @param successCallback the callback that will be called upon succesful execution
  35616. * @param offset starting offset.
  35617. * @returns the created async loop object
  35618. */
  35619. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35620. /**
  35621. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35622. * @param iterations total number of iterations
  35623. * @param syncedIterations number of synchronous iterations in each async iteration.
  35624. * @param fn the function to call each iteration.
  35625. * @param callback a success call back that will be called when iterating stops.
  35626. * @param breakFunction a break condition (optional)
  35627. * @param timeout timeout settings for the setTimeout function. default - 0.
  35628. * @returns the created async loop object
  35629. */
  35630. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35631. }
  35632. }
  35633. declare module "babylonjs/Misc/stringDictionary" {
  35634. import { Nullable } from "babylonjs/types";
  35635. /**
  35636. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35637. * The underlying implementation relies on an associative array to ensure the best performances.
  35638. * The value can be anything including 'null' but except 'undefined'
  35639. */
  35640. export class StringDictionary<T> {
  35641. /**
  35642. * This will clear this dictionary and copy the content from the 'source' one.
  35643. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35644. * @param source the dictionary to take the content from and copy to this dictionary
  35645. */
  35646. copyFrom(source: StringDictionary<T>): void;
  35647. /**
  35648. * Get a value based from its key
  35649. * @param key the given key to get the matching value from
  35650. * @return the value if found, otherwise undefined is returned
  35651. */
  35652. get(key: string): T | undefined;
  35653. /**
  35654. * Get a value from its key or add it if it doesn't exist.
  35655. * This method will ensure you that a given key/data will be present in the dictionary.
  35656. * @param key the given key to get the matching value from
  35657. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35658. * The factory will only be invoked if there's no data for the given key.
  35659. * @return the value corresponding to the key.
  35660. */
  35661. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35662. /**
  35663. * Get a value from its key if present in the dictionary otherwise add it
  35664. * @param key the key to get the value from
  35665. * @param val if there's no such key/value pair in the dictionary add it with this value
  35666. * @return the value corresponding to the key
  35667. */
  35668. getOrAdd(key: string, val: T): T;
  35669. /**
  35670. * Check if there's a given key in the dictionary
  35671. * @param key the key to check for
  35672. * @return true if the key is present, false otherwise
  35673. */
  35674. contains(key: string): boolean;
  35675. /**
  35676. * Add a new key and its corresponding value
  35677. * @param key the key to add
  35678. * @param value the value corresponding to the key
  35679. * @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
  35680. */
  35681. add(key: string, value: T): boolean;
  35682. /**
  35683. * Update a specific value associated to a key
  35684. * @param key defines the key to use
  35685. * @param value defines the value to store
  35686. * @returns true if the value was updated (or false if the key was not found)
  35687. */
  35688. set(key: string, value: T): boolean;
  35689. /**
  35690. * Get the element of the given key and remove it from the dictionary
  35691. * @param key defines the key to search
  35692. * @returns the value associated with the key or null if not found
  35693. */
  35694. getAndRemove(key: string): Nullable<T>;
  35695. /**
  35696. * Remove a key/value from the dictionary.
  35697. * @param key the key to remove
  35698. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35699. */
  35700. remove(key: string): boolean;
  35701. /**
  35702. * Clear the whole content of the dictionary
  35703. */
  35704. clear(): void;
  35705. /**
  35706. * Gets the current count
  35707. */
  35708. get count(): number;
  35709. /**
  35710. * Execute a callback on each key/val of the dictionary.
  35711. * Note that you can remove any element in this dictionary in the callback implementation
  35712. * @param callback the callback to execute on a given key/value pair
  35713. */
  35714. forEach(callback: (key: string, val: T) => void): void;
  35715. /**
  35716. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35717. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35718. * Note that you can remove any element in this dictionary in the callback implementation
  35719. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35720. * @returns the first item
  35721. */
  35722. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35723. private _count;
  35724. private _data;
  35725. }
  35726. }
  35727. declare module "babylonjs/Collisions/collisionCoordinator" {
  35728. import { Nullable } from "babylonjs/types";
  35729. import { Scene } from "babylonjs/scene";
  35730. import { Vector3 } from "babylonjs/Maths/math.vector";
  35731. import { Collider } from "babylonjs/Collisions/collider";
  35732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35733. /** @hidden */
  35734. export interface ICollisionCoordinator {
  35735. createCollider(): Collider;
  35736. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35737. init(scene: Scene): void;
  35738. }
  35739. /** @hidden */
  35740. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35741. private _scene;
  35742. private _scaledPosition;
  35743. private _scaledVelocity;
  35744. private _finalPosition;
  35745. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35746. createCollider(): Collider;
  35747. init(scene: Scene): void;
  35748. private _collideWithWorld;
  35749. }
  35750. }
  35751. declare module "babylonjs/Inputs/scene.inputManager" {
  35752. import { Nullable } from "babylonjs/types";
  35753. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35754. import { Vector2 } from "babylonjs/Maths/math.vector";
  35755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35756. import { Scene } from "babylonjs/scene";
  35757. /**
  35758. * Class used to manage all inputs for the scene.
  35759. */
  35760. export class InputManager {
  35761. /** The distance in pixel that you have to move to prevent some events */
  35762. static DragMovementThreshold: number;
  35763. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35764. static LongPressDelay: number;
  35765. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35766. static DoubleClickDelay: number;
  35767. /** If you need to check double click without raising a single click at first click, enable this flag */
  35768. static ExclusiveDoubleClickMode: boolean;
  35769. private _wheelEventName;
  35770. private _onPointerMove;
  35771. private _onPointerDown;
  35772. private _onPointerUp;
  35773. private _initClickEvent;
  35774. private _initActionManager;
  35775. private _delayedSimpleClick;
  35776. private _delayedSimpleClickTimeout;
  35777. private _previousDelayedSimpleClickTimeout;
  35778. private _meshPickProceed;
  35779. private _previousButtonPressed;
  35780. private _currentPickResult;
  35781. private _previousPickResult;
  35782. private _totalPointersPressed;
  35783. private _doubleClickOccured;
  35784. private _pointerOverMesh;
  35785. private _pickedDownMesh;
  35786. private _pickedUpMesh;
  35787. private _pointerX;
  35788. private _pointerY;
  35789. private _unTranslatedPointerX;
  35790. private _unTranslatedPointerY;
  35791. private _startingPointerPosition;
  35792. private _previousStartingPointerPosition;
  35793. private _startingPointerTime;
  35794. private _previousStartingPointerTime;
  35795. private _pointerCaptures;
  35796. private _onKeyDown;
  35797. private _onKeyUp;
  35798. private _onCanvasFocusObserver;
  35799. private _onCanvasBlurObserver;
  35800. private _scene;
  35801. /**
  35802. * Creates a new InputManager
  35803. * @param scene defines the hosting scene
  35804. */
  35805. constructor(scene: Scene);
  35806. /**
  35807. * Gets the mesh that is currently under the pointer
  35808. */
  35809. get meshUnderPointer(): Nullable<AbstractMesh>;
  35810. /**
  35811. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35812. */
  35813. get unTranslatedPointer(): Vector2;
  35814. /**
  35815. * Gets or sets the current on-screen X position of the pointer
  35816. */
  35817. get pointerX(): number;
  35818. set pointerX(value: number);
  35819. /**
  35820. * Gets or sets the current on-screen Y position of the pointer
  35821. */
  35822. get pointerY(): number;
  35823. set pointerY(value: number);
  35824. private _updatePointerPosition;
  35825. private _processPointerMove;
  35826. private _setRayOnPointerInfo;
  35827. private _checkPrePointerObservable;
  35828. /**
  35829. * Use this method to simulate a pointer move on a mesh
  35830. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35831. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35832. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35833. */
  35834. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35835. /**
  35836. * Use this method to simulate a pointer down on a mesh
  35837. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35838. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35839. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35840. */
  35841. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35842. private _processPointerDown;
  35843. /** @hidden */
  35844. _isPointerSwiping(): boolean;
  35845. /**
  35846. * Use this method to simulate a pointer up on a mesh
  35847. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35848. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35849. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35850. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35851. */
  35852. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35853. private _processPointerUp;
  35854. /**
  35855. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35856. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35857. * @returns true if the pointer was captured
  35858. */
  35859. isPointerCaptured(pointerId?: number): boolean;
  35860. /**
  35861. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35862. * @param attachUp defines if you want to attach events to pointerup
  35863. * @param attachDown defines if you want to attach events to pointerdown
  35864. * @param attachMove defines if you want to attach events to pointermove
  35865. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35866. */
  35867. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35868. /**
  35869. * Detaches all event handlers
  35870. */
  35871. detachControl(): void;
  35872. /**
  35873. * Force the value of meshUnderPointer
  35874. * @param mesh defines the mesh to use
  35875. */
  35876. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35877. /**
  35878. * Gets the mesh under the pointer
  35879. * @returns a Mesh or null if no mesh is under the pointer
  35880. */
  35881. getPointerOverMesh(): Nullable<AbstractMesh>;
  35882. }
  35883. }
  35884. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35885. /**
  35886. * Helper class used to generate session unique ID
  35887. */
  35888. export class UniqueIdGenerator {
  35889. private static _UniqueIdCounter;
  35890. /**
  35891. * Gets an unique (relatively to the current scene) Id
  35892. */
  35893. static get UniqueId(): number;
  35894. }
  35895. }
  35896. declare module "babylonjs/Animations/animationGroup" {
  35897. import { Animatable } from "babylonjs/Animations/animatable";
  35898. import { Animation } from "babylonjs/Animations/animation";
  35899. import { Scene, IDisposable } from "babylonjs/scene";
  35900. import { Observable } from "babylonjs/Misc/observable";
  35901. import { Nullable } from "babylonjs/types";
  35902. import "babylonjs/Animations/animatable";
  35903. /**
  35904. * This class defines the direct association between an animation and a target
  35905. */
  35906. export class TargetedAnimation {
  35907. /**
  35908. * Animation to perform
  35909. */
  35910. animation: Animation;
  35911. /**
  35912. * Target to animate
  35913. */
  35914. target: any;
  35915. /**
  35916. * Serialize the object
  35917. * @returns the JSON object representing the current entity
  35918. */
  35919. serialize(): any;
  35920. }
  35921. /**
  35922. * Use this class to create coordinated animations on multiple targets
  35923. */
  35924. export class AnimationGroup implements IDisposable {
  35925. /** The name of the animation group */
  35926. name: string;
  35927. private _scene;
  35928. private _targetedAnimations;
  35929. private _animatables;
  35930. private _from;
  35931. private _to;
  35932. private _isStarted;
  35933. private _isPaused;
  35934. private _speedRatio;
  35935. private _loopAnimation;
  35936. /**
  35937. * Gets or sets the unique id of the node
  35938. */
  35939. uniqueId: number;
  35940. /**
  35941. * This observable will notify when one animation have ended
  35942. */
  35943. onAnimationEndObservable: Observable<TargetedAnimation>;
  35944. /**
  35945. * Observer raised when one animation loops
  35946. */
  35947. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35948. /**
  35949. * Observer raised when all animations have looped
  35950. */
  35951. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35952. /**
  35953. * This observable will notify when all animations have ended.
  35954. */
  35955. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35956. /**
  35957. * This observable will notify when all animations have paused.
  35958. */
  35959. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35960. /**
  35961. * This observable will notify when all animations are playing.
  35962. */
  35963. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35964. /**
  35965. * Gets the first frame
  35966. */
  35967. get from(): number;
  35968. /**
  35969. * Gets the last frame
  35970. */
  35971. get to(): number;
  35972. /**
  35973. * Define if the animations are started
  35974. */
  35975. get isStarted(): boolean;
  35976. /**
  35977. * Gets a value indicating that the current group is playing
  35978. */
  35979. get isPlaying(): boolean;
  35980. /**
  35981. * Gets or sets the speed ratio to use for all animations
  35982. */
  35983. get speedRatio(): number;
  35984. /**
  35985. * Gets or sets the speed ratio to use for all animations
  35986. */
  35987. set speedRatio(value: number);
  35988. /**
  35989. * Gets or sets if all animations should loop or not
  35990. */
  35991. get loopAnimation(): boolean;
  35992. set loopAnimation(value: boolean);
  35993. /**
  35994. * Gets the targeted animations for this animation group
  35995. */
  35996. get targetedAnimations(): Array<TargetedAnimation>;
  35997. /**
  35998. * returning the list of animatables controlled by this animation group.
  35999. */
  36000. get animatables(): Array<Animatable>;
  36001. /**
  36002. * Instantiates a new Animation Group.
  36003. * This helps managing several animations at once.
  36004. * @see http://doc.babylonjs.com/how_to/group
  36005. * @param name Defines the name of the group
  36006. * @param scene Defines the scene the group belongs to
  36007. */
  36008. constructor(
  36009. /** The name of the animation group */
  36010. name: string, scene?: Nullable<Scene>);
  36011. /**
  36012. * Add an animation (with its target) in the group
  36013. * @param animation defines the animation we want to add
  36014. * @param target defines the target of the animation
  36015. * @returns the TargetedAnimation object
  36016. */
  36017. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36018. /**
  36019. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36020. * It can add constant keys at begin or end
  36021. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36022. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36023. * @returns the animation group
  36024. */
  36025. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36026. private _animationLoopCount;
  36027. private _animationLoopFlags;
  36028. private _processLoop;
  36029. /**
  36030. * Start all animations on given targets
  36031. * @param loop defines if animations must loop
  36032. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36033. * @param from defines the from key (optional)
  36034. * @param to defines the to key (optional)
  36035. * @returns the current animation group
  36036. */
  36037. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  36038. /**
  36039. * Pause all animations
  36040. * @returns the animation group
  36041. */
  36042. pause(): AnimationGroup;
  36043. /**
  36044. * Play all animations to initial state
  36045. * This function will start() the animations if they were not started or will restart() them if they were paused
  36046. * @param loop defines if animations must loop
  36047. * @returns the animation group
  36048. */
  36049. play(loop?: boolean): AnimationGroup;
  36050. /**
  36051. * Reset all animations to initial state
  36052. * @returns the animation group
  36053. */
  36054. reset(): AnimationGroup;
  36055. /**
  36056. * Restart animations from key 0
  36057. * @returns the animation group
  36058. */
  36059. restart(): AnimationGroup;
  36060. /**
  36061. * Stop all animations
  36062. * @returns the animation group
  36063. */
  36064. stop(): AnimationGroup;
  36065. /**
  36066. * Set animation weight for all animatables
  36067. * @param weight defines the weight to use
  36068. * @return the animationGroup
  36069. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36070. */
  36071. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36072. /**
  36073. * Synchronize and normalize all animatables with a source animatable
  36074. * @param root defines the root animatable to synchronize with
  36075. * @return the animationGroup
  36076. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36077. */
  36078. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36079. /**
  36080. * Goes to a specific frame in this animation group
  36081. * @param frame the frame number to go to
  36082. * @return the animationGroup
  36083. */
  36084. goToFrame(frame: number): AnimationGroup;
  36085. /**
  36086. * Dispose all associated resources
  36087. */
  36088. dispose(): void;
  36089. private _checkAnimationGroupEnded;
  36090. /**
  36091. * Clone the current animation group and returns a copy
  36092. * @param newName defines the name of the new group
  36093. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36094. * @returns the new aniamtion group
  36095. */
  36096. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36097. /**
  36098. * Serializes the animationGroup to an object
  36099. * @returns Serialized object
  36100. */
  36101. serialize(): any;
  36102. /**
  36103. * Returns a new AnimationGroup object parsed from the source provided.
  36104. * @param parsedAnimationGroup defines the source
  36105. * @param scene defines the scene that will receive the animationGroup
  36106. * @returns a new AnimationGroup
  36107. */
  36108. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36109. /**
  36110. * Returns the string "AnimationGroup"
  36111. * @returns "AnimationGroup"
  36112. */
  36113. getClassName(): string;
  36114. /**
  36115. * Creates a detailled string about the object
  36116. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36117. * @returns a string representing the object
  36118. */
  36119. toString(fullDetails?: boolean): string;
  36120. }
  36121. }
  36122. declare module "babylonjs/scene" {
  36123. import { Nullable } from "babylonjs/types";
  36124. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36125. import { Observable } from "babylonjs/Misc/observable";
  36126. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36127. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36128. import { Geometry } from "babylonjs/Meshes/geometry";
  36129. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36132. import { Mesh } from "babylonjs/Meshes/mesh";
  36133. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36134. import { Bone } from "babylonjs/Bones/bone";
  36135. import { Skeleton } from "babylonjs/Bones/skeleton";
  36136. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36137. import { Camera } from "babylonjs/Cameras/camera";
  36138. import { AbstractScene } from "babylonjs/abstractScene";
  36139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36140. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36141. import { Material } from "babylonjs/Materials/material";
  36142. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36143. import { Effect } from "babylonjs/Materials/effect";
  36144. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36145. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36146. import { Light } from "babylonjs/Lights/light";
  36147. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36148. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36149. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36150. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36151. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36152. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36153. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36154. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36155. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36156. import { Engine } from "babylonjs/Engines/engine";
  36157. import { Node } from "babylonjs/node";
  36158. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36159. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36160. import { WebRequest } from "babylonjs/Misc/webRequest";
  36161. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36162. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36163. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36164. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36165. import { Plane } from "babylonjs/Maths/math.plane";
  36166. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36167. import { Ray } from "babylonjs/Culling/ray";
  36168. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36169. import { Animation } from "babylonjs/Animations/animation";
  36170. import { Animatable } from "babylonjs/Animations/animatable";
  36171. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36172. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36173. import { Collider } from "babylonjs/Collisions/collider";
  36174. /**
  36175. * Define an interface for all classes that will hold resources
  36176. */
  36177. export interface IDisposable {
  36178. /**
  36179. * Releases all held resources
  36180. */
  36181. dispose(): void;
  36182. }
  36183. /** Interface defining initialization parameters for Scene class */
  36184. export interface SceneOptions {
  36185. /**
  36186. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36187. * It will improve performance when the number of geometries becomes important.
  36188. */
  36189. useGeometryUniqueIdsMap?: boolean;
  36190. /**
  36191. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36192. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36193. */
  36194. useMaterialMeshMap?: boolean;
  36195. /**
  36196. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36197. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36198. */
  36199. useClonedMeshMap?: boolean;
  36200. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36201. virtual?: boolean;
  36202. }
  36203. /**
  36204. * Represents a scene to be rendered by the engine.
  36205. * @see http://doc.babylonjs.com/features/scene
  36206. */
  36207. export class Scene extends AbstractScene implements IAnimatable {
  36208. /** The fog is deactivated */
  36209. static readonly FOGMODE_NONE: number;
  36210. /** The fog density is following an exponential function */
  36211. static readonly FOGMODE_EXP: number;
  36212. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36213. static readonly FOGMODE_EXP2: number;
  36214. /** The fog density is following a linear function. */
  36215. static readonly FOGMODE_LINEAR: number;
  36216. /**
  36217. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36218. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36219. */
  36220. static MinDeltaTime: number;
  36221. /**
  36222. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36223. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36224. */
  36225. static MaxDeltaTime: number;
  36226. /**
  36227. * Factory used to create the default material.
  36228. * @param name The name of the material to create
  36229. * @param scene The scene to create the material for
  36230. * @returns The default material
  36231. */
  36232. static DefaultMaterialFactory(scene: Scene): Material;
  36233. /**
  36234. * Factory used to create the a collision coordinator.
  36235. * @returns The collision coordinator
  36236. */
  36237. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36238. /** @hidden */
  36239. _inputManager: InputManager;
  36240. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36241. cameraToUseForPointers: Nullable<Camera>;
  36242. /** @hidden */
  36243. readonly _isScene: boolean;
  36244. /** @hidden */
  36245. _blockEntityCollection: boolean;
  36246. /**
  36247. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36248. */
  36249. autoClear: boolean;
  36250. /**
  36251. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36252. */
  36253. autoClearDepthAndStencil: boolean;
  36254. /**
  36255. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36256. */
  36257. clearColor: Color4;
  36258. /**
  36259. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36260. */
  36261. ambientColor: Color3;
  36262. /**
  36263. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36264. * It should only be one of the following (if not the default embedded one):
  36265. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36266. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36267. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36268. * The material properties need to be setup according to the type of texture in use.
  36269. */
  36270. environmentBRDFTexture: BaseTexture;
  36271. /** @hidden */
  36272. protected _environmentTexture: Nullable<BaseTexture>;
  36273. /**
  36274. * Texture used in all pbr material as the reflection texture.
  36275. * As in the majority of the scene they are the same (exception for multi room and so on),
  36276. * this is easier to reference from here than from all the materials.
  36277. */
  36278. get environmentTexture(): Nullable<BaseTexture>;
  36279. /**
  36280. * Texture used in all pbr material as the reflection texture.
  36281. * As in the majority of the scene they are the same (exception for multi room and so on),
  36282. * this is easier to set here than in all the materials.
  36283. */
  36284. set environmentTexture(value: Nullable<BaseTexture>);
  36285. /** @hidden */
  36286. protected _environmentIntensity: number;
  36287. /**
  36288. * Intensity of the environment in all pbr material.
  36289. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36290. * As in the majority of the scene they are the same (exception for multi room and so on),
  36291. * this is easier to reference from here than from all the materials.
  36292. */
  36293. get environmentIntensity(): number;
  36294. /**
  36295. * Intensity of the environment in all pbr material.
  36296. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36297. * As in the majority of the scene they are the same (exception for multi room and so on),
  36298. * this is easier to set here than in all the materials.
  36299. */
  36300. set environmentIntensity(value: number);
  36301. /** @hidden */
  36302. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36303. /**
  36304. * Default image processing configuration used either in the rendering
  36305. * Forward main pass or through the imageProcessingPostProcess if present.
  36306. * As in the majority of the scene they are the same (exception for multi camera),
  36307. * this is easier to reference from here than from all the materials and post process.
  36308. *
  36309. * No setter as we it is a shared configuration, you can set the values instead.
  36310. */
  36311. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36312. private _forceWireframe;
  36313. /**
  36314. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36315. */
  36316. set forceWireframe(value: boolean);
  36317. get forceWireframe(): boolean;
  36318. private _skipFrustumClipping;
  36319. /**
  36320. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36321. */
  36322. set skipFrustumClipping(value: boolean);
  36323. get skipFrustumClipping(): boolean;
  36324. private _forcePointsCloud;
  36325. /**
  36326. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36327. */
  36328. set forcePointsCloud(value: boolean);
  36329. get forcePointsCloud(): boolean;
  36330. /**
  36331. * Gets or sets the active clipplane 1
  36332. */
  36333. clipPlane: Nullable<Plane>;
  36334. /**
  36335. * Gets or sets the active clipplane 2
  36336. */
  36337. clipPlane2: Nullable<Plane>;
  36338. /**
  36339. * Gets or sets the active clipplane 3
  36340. */
  36341. clipPlane3: Nullable<Plane>;
  36342. /**
  36343. * Gets or sets the active clipplane 4
  36344. */
  36345. clipPlane4: Nullable<Plane>;
  36346. /**
  36347. * Gets or sets the active clipplane 5
  36348. */
  36349. clipPlane5: Nullable<Plane>;
  36350. /**
  36351. * Gets or sets the active clipplane 6
  36352. */
  36353. clipPlane6: Nullable<Plane>;
  36354. /**
  36355. * Gets or sets a boolean indicating if animations are enabled
  36356. */
  36357. animationsEnabled: boolean;
  36358. private _animationPropertiesOverride;
  36359. /**
  36360. * Gets or sets the animation properties override
  36361. */
  36362. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36363. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36364. /**
  36365. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36366. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36367. */
  36368. useConstantAnimationDeltaTime: boolean;
  36369. /**
  36370. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36371. * Please note that it requires to run a ray cast through the scene on every frame
  36372. */
  36373. constantlyUpdateMeshUnderPointer: boolean;
  36374. /**
  36375. * Defines the HTML cursor to use when hovering over interactive elements
  36376. */
  36377. hoverCursor: string;
  36378. /**
  36379. * Defines the HTML default cursor to use (empty by default)
  36380. */
  36381. defaultCursor: string;
  36382. /**
  36383. * Defines whether cursors are handled by the scene.
  36384. */
  36385. doNotHandleCursors: boolean;
  36386. /**
  36387. * This is used to call preventDefault() on pointer down
  36388. * in order to block unwanted artifacts like system double clicks
  36389. */
  36390. preventDefaultOnPointerDown: boolean;
  36391. /**
  36392. * This is used to call preventDefault() on pointer up
  36393. * in order to block unwanted artifacts like system double clicks
  36394. */
  36395. preventDefaultOnPointerUp: boolean;
  36396. /**
  36397. * Gets or sets user defined metadata
  36398. */
  36399. metadata: any;
  36400. /**
  36401. * For internal use only. Please do not use.
  36402. */
  36403. reservedDataStore: any;
  36404. /**
  36405. * Gets the name of the plugin used to load this scene (null by default)
  36406. */
  36407. loadingPluginName: string;
  36408. /**
  36409. * Use this array to add regular expressions used to disable offline support for specific urls
  36410. */
  36411. disableOfflineSupportExceptionRules: RegExp[];
  36412. /**
  36413. * An event triggered when the scene is disposed.
  36414. */
  36415. onDisposeObservable: Observable<Scene>;
  36416. private _onDisposeObserver;
  36417. /** Sets a function to be executed when this scene is disposed. */
  36418. set onDispose(callback: () => void);
  36419. /**
  36420. * An event triggered before rendering the scene (right after animations and physics)
  36421. */
  36422. onBeforeRenderObservable: Observable<Scene>;
  36423. private _onBeforeRenderObserver;
  36424. /** Sets a function to be executed before rendering this scene */
  36425. set beforeRender(callback: Nullable<() => void>);
  36426. /**
  36427. * An event triggered after rendering the scene
  36428. */
  36429. onAfterRenderObservable: Observable<Scene>;
  36430. /**
  36431. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36432. */
  36433. onAfterRenderCameraObservable: Observable<Camera>;
  36434. private _onAfterRenderObserver;
  36435. /** Sets a function to be executed after rendering this scene */
  36436. set afterRender(callback: Nullable<() => void>);
  36437. /**
  36438. * An event triggered before animating the scene
  36439. */
  36440. onBeforeAnimationsObservable: Observable<Scene>;
  36441. /**
  36442. * An event triggered after animations processing
  36443. */
  36444. onAfterAnimationsObservable: Observable<Scene>;
  36445. /**
  36446. * An event triggered before draw calls are ready to be sent
  36447. */
  36448. onBeforeDrawPhaseObservable: Observable<Scene>;
  36449. /**
  36450. * An event triggered after draw calls have been sent
  36451. */
  36452. onAfterDrawPhaseObservable: Observable<Scene>;
  36453. /**
  36454. * An event triggered when the scene is ready
  36455. */
  36456. onReadyObservable: Observable<Scene>;
  36457. /**
  36458. * An event triggered before rendering a camera
  36459. */
  36460. onBeforeCameraRenderObservable: Observable<Camera>;
  36461. private _onBeforeCameraRenderObserver;
  36462. /** Sets a function to be executed before rendering a camera*/
  36463. set beforeCameraRender(callback: () => void);
  36464. /**
  36465. * An event triggered after rendering a camera
  36466. */
  36467. onAfterCameraRenderObservable: Observable<Camera>;
  36468. private _onAfterCameraRenderObserver;
  36469. /** Sets a function to be executed after rendering a camera*/
  36470. set afterCameraRender(callback: () => void);
  36471. /**
  36472. * An event triggered when active meshes evaluation is about to start
  36473. */
  36474. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36475. /**
  36476. * An event triggered when active meshes evaluation is done
  36477. */
  36478. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36479. /**
  36480. * An event triggered when particles rendering is about to start
  36481. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36482. */
  36483. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36484. /**
  36485. * An event triggered when particles rendering is done
  36486. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36487. */
  36488. onAfterParticlesRenderingObservable: Observable<Scene>;
  36489. /**
  36490. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36491. */
  36492. onDataLoadedObservable: Observable<Scene>;
  36493. /**
  36494. * An event triggered when a camera is created
  36495. */
  36496. onNewCameraAddedObservable: Observable<Camera>;
  36497. /**
  36498. * An event triggered when a camera is removed
  36499. */
  36500. onCameraRemovedObservable: Observable<Camera>;
  36501. /**
  36502. * An event triggered when a light is created
  36503. */
  36504. onNewLightAddedObservable: Observable<Light>;
  36505. /**
  36506. * An event triggered when a light is removed
  36507. */
  36508. onLightRemovedObservable: Observable<Light>;
  36509. /**
  36510. * An event triggered when a geometry is created
  36511. */
  36512. onNewGeometryAddedObservable: Observable<Geometry>;
  36513. /**
  36514. * An event triggered when a geometry is removed
  36515. */
  36516. onGeometryRemovedObservable: Observable<Geometry>;
  36517. /**
  36518. * An event triggered when a transform node is created
  36519. */
  36520. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36521. /**
  36522. * An event triggered when a transform node is removed
  36523. */
  36524. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36525. /**
  36526. * An event triggered when a mesh is created
  36527. */
  36528. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36529. /**
  36530. * An event triggered when a mesh is removed
  36531. */
  36532. onMeshRemovedObservable: Observable<AbstractMesh>;
  36533. /**
  36534. * An event triggered when a skeleton is created
  36535. */
  36536. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36537. /**
  36538. * An event triggered when a skeleton is removed
  36539. */
  36540. onSkeletonRemovedObservable: Observable<Skeleton>;
  36541. /**
  36542. * An event triggered when a material is created
  36543. */
  36544. onNewMaterialAddedObservable: Observable<Material>;
  36545. /**
  36546. * An event triggered when a material is removed
  36547. */
  36548. onMaterialRemovedObservable: Observable<Material>;
  36549. /**
  36550. * An event triggered when a texture is created
  36551. */
  36552. onNewTextureAddedObservable: Observable<BaseTexture>;
  36553. /**
  36554. * An event triggered when a texture is removed
  36555. */
  36556. onTextureRemovedObservable: Observable<BaseTexture>;
  36557. /**
  36558. * An event triggered when render targets are about to be rendered
  36559. * Can happen multiple times per frame.
  36560. */
  36561. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36562. /**
  36563. * An event triggered when render targets were rendered.
  36564. * Can happen multiple times per frame.
  36565. */
  36566. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36567. /**
  36568. * An event triggered before calculating deterministic simulation step
  36569. */
  36570. onBeforeStepObservable: Observable<Scene>;
  36571. /**
  36572. * An event triggered after calculating deterministic simulation step
  36573. */
  36574. onAfterStepObservable: Observable<Scene>;
  36575. /**
  36576. * An event triggered when the activeCamera property is updated
  36577. */
  36578. onActiveCameraChanged: Observable<Scene>;
  36579. /**
  36580. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36581. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36582. * 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)
  36583. */
  36584. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36585. /**
  36586. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36587. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36588. * 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)
  36589. */
  36590. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36591. /**
  36592. * This Observable will when a mesh has been imported into the scene.
  36593. */
  36594. onMeshImportedObservable: Observable<AbstractMesh>;
  36595. /**
  36596. * This Observable will when an animation file has been imported into the scene.
  36597. */
  36598. onAnimationFileImportedObservable: Observable<Scene>;
  36599. /**
  36600. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36601. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36602. */
  36603. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36604. /** @hidden */
  36605. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36606. /**
  36607. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36608. */
  36609. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36610. /**
  36611. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36612. */
  36613. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36614. /**
  36615. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36616. */
  36617. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36618. /** Callback called when a pointer move is detected */
  36619. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36620. /** Callback called when a pointer down is detected */
  36621. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36622. /** Callback called when a pointer up is detected */
  36623. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36624. /** Callback called when a pointer pick is detected */
  36625. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36626. /**
  36627. * 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).
  36628. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36629. */
  36630. onPrePointerObservable: Observable<PointerInfoPre>;
  36631. /**
  36632. * Observable event triggered each time an input event is received from the rendering canvas
  36633. */
  36634. onPointerObservable: Observable<PointerInfo>;
  36635. /**
  36636. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36637. */
  36638. get unTranslatedPointer(): Vector2;
  36639. /**
  36640. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36641. */
  36642. static get DragMovementThreshold(): number;
  36643. static set DragMovementThreshold(value: number);
  36644. /**
  36645. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36646. */
  36647. static get LongPressDelay(): number;
  36648. static set LongPressDelay(value: number);
  36649. /**
  36650. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36651. */
  36652. static get DoubleClickDelay(): number;
  36653. static set DoubleClickDelay(value: number);
  36654. /** If you need to check double click without raising a single click at first click, enable this flag */
  36655. static get ExclusiveDoubleClickMode(): boolean;
  36656. static set ExclusiveDoubleClickMode(value: boolean);
  36657. /** @hidden */
  36658. _mirroredCameraPosition: Nullable<Vector3>;
  36659. /**
  36660. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36661. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36662. */
  36663. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36664. /**
  36665. * Observable event triggered each time an keyboard event is received from the hosting window
  36666. */
  36667. onKeyboardObservable: Observable<KeyboardInfo>;
  36668. private _useRightHandedSystem;
  36669. /**
  36670. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36671. */
  36672. set useRightHandedSystem(value: boolean);
  36673. get useRightHandedSystem(): boolean;
  36674. private _timeAccumulator;
  36675. private _currentStepId;
  36676. private _currentInternalStep;
  36677. /**
  36678. * Sets the step Id used by deterministic lock step
  36679. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36680. * @param newStepId defines the step Id
  36681. */
  36682. setStepId(newStepId: number): void;
  36683. /**
  36684. * Gets the step Id used by deterministic lock step
  36685. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36686. * @returns the step Id
  36687. */
  36688. getStepId(): number;
  36689. /**
  36690. * Gets the internal step used by deterministic lock step
  36691. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36692. * @returns the internal step
  36693. */
  36694. getInternalStep(): number;
  36695. private _fogEnabled;
  36696. /**
  36697. * Gets or sets a boolean indicating if fog is enabled on this scene
  36698. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36699. * (Default is true)
  36700. */
  36701. set fogEnabled(value: boolean);
  36702. get fogEnabled(): boolean;
  36703. private _fogMode;
  36704. /**
  36705. * Gets or sets the fog mode to use
  36706. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36707. * | mode | value |
  36708. * | --- | --- |
  36709. * | FOGMODE_NONE | 0 |
  36710. * | FOGMODE_EXP | 1 |
  36711. * | FOGMODE_EXP2 | 2 |
  36712. * | FOGMODE_LINEAR | 3 |
  36713. */
  36714. set fogMode(value: number);
  36715. get fogMode(): number;
  36716. /**
  36717. * Gets or sets the fog color to use
  36718. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36719. * (Default is Color3(0.2, 0.2, 0.3))
  36720. */
  36721. fogColor: Color3;
  36722. /**
  36723. * Gets or sets the fog density to use
  36724. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36725. * (Default is 0.1)
  36726. */
  36727. fogDensity: number;
  36728. /**
  36729. * Gets or sets the fog start distance to use
  36730. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36731. * (Default is 0)
  36732. */
  36733. fogStart: number;
  36734. /**
  36735. * Gets or sets the fog end distance to use
  36736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36737. * (Default is 1000)
  36738. */
  36739. fogEnd: number;
  36740. private _shadowsEnabled;
  36741. /**
  36742. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36743. */
  36744. set shadowsEnabled(value: boolean);
  36745. get shadowsEnabled(): boolean;
  36746. private _lightsEnabled;
  36747. /**
  36748. * Gets or sets a boolean indicating if lights are enabled on this scene
  36749. */
  36750. set lightsEnabled(value: boolean);
  36751. get lightsEnabled(): boolean;
  36752. /** All of the active cameras added to this scene. */
  36753. activeCameras: Camera[];
  36754. /** @hidden */
  36755. _activeCamera: Nullable<Camera>;
  36756. /** Gets or sets the current active camera */
  36757. get activeCamera(): Nullable<Camera>;
  36758. set activeCamera(value: Nullable<Camera>);
  36759. private _defaultMaterial;
  36760. /** The default material used on meshes when no material is affected */
  36761. get defaultMaterial(): Material;
  36762. /** The default material used on meshes when no material is affected */
  36763. set defaultMaterial(value: Material);
  36764. private _texturesEnabled;
  36765. /**
  36766. * Gets or sets a boolean indicating if textures are enabled on this scene
  36767. */
  36768. set texturesEnabled(value: boolean);
  36769. get texturesEnabled(): boolean;
  36770. /**
  36771. * Gets or sets a boolean indicating if particles are enabled on this scene
  36772. */
  36773. particlesEnabled: boolean;
  36774. /**
  36775. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36776. */
  36777. spritesEnabled: boolean;
  36778. private _skeletonsEnabled;
  36779. /**
  36780. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36781. */
  36782. set skeletonsEnabled(value: boolean);
  36783. get skeletonsEnabled(): boolean;
  36784. /**
  36785. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36786. */
  36787. lensFlaresEnabled: boolean;
  36788. /**
  36789. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36790. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36791. */
  36792. collisionsEnabled: boolean;
  36793. private _collisionCoordinator;
  36794. /** @hidden */
  36795. get collisionCoordinator(): ICollisionCoordinator;
  36796. /**
  36797. * Defines the gravity applied to this scene (used only for collisions)
  36798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36799. */
  36800. gravity: Vector3;
  36801. /**
  36802. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36803. */
  36804. postProcessesEnabled: boolean;
  36805. /**
  36806. * The list of postprocesses added to the scene
  36807. */
  36808. postProcesses: PostProcess[];
  36809. /**
  36810. * Gets the current postprocess manager
  36811. */
  36812. postProcessManager: PostProcessManager;
  36813. /**
  36814. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36815. */
  36816. renderTargetsEnabled: boolean;
  36817. /**
  36818. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36819. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36820. */
  36821. dumpNextRenderTargets: boolean;
  36822. /**
  36823. * The list of user defined render targets added to the scene
  36824. */
  36825. customRenderTargets: RenderTargetTexture[];
  36826. /**
  36827. * Defines if texture loading must be delayed
  36828. * If true, textures will only be loaded when they need to be rendered
  36829. */
  36830. useDelayedTextureLoading: boolean;
  36831. /**
  36832. * Gets the list of meshes imported to the scene through SceneLoader
  36833. */
  36834. importedMeshesFiles: String[];
  36835. /**
  36836. * Gets or sets a boolean indicating if probes are enabled on this scene
  36837. */
  36838. probesEnabled: boolean;
  36839. /**
  36840. * Gets or sets the current offline provider to use to store scene data
  36841. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36842. */
  36843. offlineProvider: IOfflineProvider;
  36844. /**
  36845. * Gets or sets the action manager associated with the scene
  36846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36847. */
  36848. actionManager: AbstractActionManager;
  36849. private _meshesForIntersections;
  36850. /**
  36851. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36852. */
  36853. proceduralTexturesEnabled: boolean;
  36854. private _engine;
  36855. private _totalVertices;
  36856. /** @hidden */
  36857. _activeIndices: PerfCounter;
  36858. /** @hidden */
  36859. _activeParticles: PerfCounter;
  36860. /** @hidden */
  36861. _activeBones: PerfCounter;
  36862. private _animationRatio;
  36863. /** @hidden */
  36864. _animationTimeLast: number;
  36865. /** @hidden */
  36866. _animationTime: number;
  36867. /**
  36868. * Gets or sets a general scale for animation speed
  36869. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36870. */
  36871. animationTimeScale: number;
  36872. /** @hidden */
  36873. _cachedMaterial: Nullable<Material>;
  36874. /** @hidden */
  36875. _cachedEffect: Nullable<Effect>;
  36876. /** @hidden */
  36877. _cachedVisibility: Nullable<number>;
  36878. private _renderId;
  36879. private _frameId;
  36880. private _executeWhenReadyTimeoutId;
  36881. private _intermediateRendering;
  36882. private _viewUpdateFlag;
  36883. private _projectionUpdateFlag;
  36884. /** @hidden */
  36885. _toBeDisposed: Nullable<IDisposable>[];
  36886. private _activeRequests;
  36887. /** @hidden */
  36888. _pendingData: any[];
  36889. private _isDisposed;
  36890. /**
  36891. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36892. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36893. */
  36894. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36895. private _activeMeshes;
  36896. private _processedMaterials;
  36897. private _renderTargets;
  36898. /** @hidden */
  36899. _activeParticleSystems: SmartArray<IParticleSystem>;
  36900. private _activeSkeletons;
  36901. private _softwareSkinnedMeshes;
  36902. private _renderingManager;
  36903. /** @hidden */
  36904. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36905. private _transformMatrix;
  36906. private _sceneUbo;
  36907. /** @hidden */
  36908. _viewMatrix: Matrix;
  36909. private _projectionMatrix;
  36910. /** @hidden */
  36911. _forcedViewPosition: Nullable<Vector3>;
  36912. /** @hidden */
  36913. _frustumPlanes: Plane[];
  36914. /**
  36915. * Gets the list of frustum planes (built from the active camera)
  36916. */
  36917. get frustumPlanes(): Plane[];
  36918. /**
  36919. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36920. * This is useful if there are more lights that the maximum simulteanous authorized
  36921. */
  36922. requireLightSorting: boolean;
  36923. /** @hidden */
  36924. readonly useMaterialMeshMap: boolean;
  36925. /** @hidden */
  36926. readonly useClonedMeshMap: boolean;
  36927. private _externalData;
  36928. private _uid;
  36929. /**
  36930. * @hidden
  36931. * Backing store of defined scene components.
  36932. */
  36933. _components: ISceneComponent[];
  36934. /**
  36935. * @hidden
  36936. * Backing store of defined scene components.
  36937. */
  36938. _serializableComponents: ISceneSerializableComponent[];
  36939. /**
  36940. * List of components to register on the next registration step.
  36941. */
  36942. private _transientComponents;
  36943. /**
  36944. * Registers the transient components if needed.
  36945. */
  36946. private _registerTransientComponents;
  36947. /**
  36948. * @hidden
  36949. * Add a component to the scene.
  36950. * Note that the ccomponent could be registered on th next frame if this is called after
  36951. * the register component stage.
  36952. * @param component Defines the component to add to the scene
  36953. */
  36954. _addComponent(component: ISceneComponent): void;
  36955. /**
  36956. * @hidden
  36957. * Gets a component from the scene.
  36958. * @param name defines the name of the component to retrieve
  36959. * @returns the component or null if not present
  36960. */
  36961. _getComponent(name: string): Nullable<ISceneComponent>;
  36962. /**
  36963. * @hidden
  36964. * Defines the actions happening before camera updates.
  36965. */
  36966. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36967. /**
  36968. * @hidden
  36969. * Defines the actions happening before clear the canvas.
  36970. */
  36971. _beforeClearStage: Stage<SimpleStageAction>;
  36972. /**
  36973. * @hidden
  36974. * Defines the actions when collecting render targets for the frame.
  36975. */
  36976. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36977. /**
  36978. * @hidden
  36979. * Defines the actions happening for one camera in the frame.
  36980. */
  36981. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36982. /**
  36983. * @hidden
  36984. * Defines the actions happening during the per mesh ready checks.
  36985. */
  36986. _isReadyForMeshStage: Stage<MeshStageAction>;
  36987. /**
  36988. * @hidden
  36989. * Defines the actions happening before evaluate active mesh checks.
  36990. */
  36991. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36992. /**
  36993. * @hidden
  36994. * Defines the actions happening during the evaluate sub mesh checks.
  36995. */
  36996. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36997. /**
  36998. * @hidden
  36999. * Defines the actions happening during the active mesh stage.
  37000. */
  37001. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37002. /**
  37003. * @hidden
  37004. * Defines the actions happening during the per camera render target step.
  37005. */
  37006. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37007. /**
  37008. * @hidden
  37009. * Defines the actions happening just before the active camera is drawing.
  37010. */
  37011. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37012. /**
  37013. * @hidden
  37014. * Defines the actions happening just before a render target is drawing.
  37015. */
  37016. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37017. /**
  37018. * @hidden
  37019. * Defines the actions happening just before a rendering group is drawing.
  37020. */
  37021. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37022. /**
  37023. * @hidden
  37024. * Defines the actions happening just before a mesh is drawing.
  37025. */
  37026. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37027. /**
  37028. * @hidden
  37029. * Defines the actions happening just after a mesh has been drawn.
  37030. */
  37031. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37032. /**
  37033. * @hidden
  37034. * Defines the actions happening just after a rendering group has been drawn.
  37035. */
  37036. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37037. /**
  37038. * @hidden
  37039. * Defines the actions happening just after the active camera has been drawn.
  37040. */
  37041. _afterCameraDrawStage: Stage<CameraStageAction>;
  37042. /**
  37043. * @hidden
  37044. * Defines the actions happening just after a render target has been drawn.
  37045. */
  37046. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37047. /**
  37048. * @hidden
  37049. * Defines the actions happening just after rendering all cameras and computing intersections.
  37050. */
  37051. _afterRenderStage: Stage<SimpleStageAction>;
  37052. /**
  37053. * @hidden
  37054. * Defines the actions happening when a pointer move event happens.
  37055. */
  37056. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37057. /**
  37058. * @hidden
  37059. * Defines the actions happening when a pointer down event happens.
  37060. */
  37061. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37062. /**
  37063. * @hidden
  37064. * Defines the actions happening when a pointer up event happens.
  37065. */
  37066. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37067. /**
  37068. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37069. */
  37070. private geometriesByUniqueId;
  37071. /**
  37072. * Creates a new Scene
  37073. * @param engine defines the engine to use to render this scene
  37074. * @param options defines the scene options
  37075. */
  37076. constructor(engine: Engine, options?: SceneOptions);
  37077. /**
  37078. * Gets a string idenfifying the name of the class
  37079. * @returns "Scene" string
  37080. */
  37081. getClassName(): string;
  37082. private _defaultMeshCandidates;
  37083. /**
  37084. * @hidden
  37085. */
  37086. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37087. private _defaultSubMeshCandidates;
  37088. /**
  37089. * @hidden
  37090. */
  37091. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37092. /**
  37093. * Sets the default candidate providers for the scene.
  37094. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37095. * and getCollidingSubMeshCandidates to their default function
  37096. */
  37097. setDefaultCandidateProviders(): void;
  37098. /**
  37099. * Gets the mesh that is currently under the pointer
  37100. */
  37101. get meshUnderPointer(): Nullable<AbstractMesh>;
  37102. /**
  37103. * Gets or sets the current on-screen X position of the pointer
  37104. */
  37105. get pointerX(): number;
  37106. set pointerX(value: number);
  37107. /**
  37108. * Gets or sets the current on-screen Y position of the pointer
  37109. */
  37110. get pointerY(): number;
  37111. set pointerY(value: number);
  37112. /**
  37113. * Gets the cached material (ie. the latest rendered one)
  37114. * @returns the cached material
  37115. */
  37116. getCachedMaterial(): Nullable<Material>;
  37117. /**
  37118. * Gets the cached effect (ie. the latest rendered one)
  37119. * @returns the cached effect
  37120. */
  37121. getCachedEffect(): Nullable<Effect>;
  37122. /**
  37123. * Gets the cached visibility state (ie. the latest rendered one)
  37124. * @returns the cached visibility state
  37125. */
  37126. getCachedVisibility(): Nullable<number>;
  37127. /**
  37128. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37129. * @param material defines the current material
  37130. * @param effect defines the current effect
  37131. * @param visibility defines the current visibility state
  37132. * @returns true if one parameter is not cached
  37133. */
  37134. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37135. /**
  37136. * Gets the engine associated with the scene
  37137. * @returns an Engine
  37138. */
  37139. getEngine(): Engine;
  37140. /**
  37141. * Gets the total number of vertices rendered per frame
  37142. * @returns the total number of vertices rendered per frame
  37143. */
  37144. getTotalVertices(): number;
  37145. /**
  37146. * Gets the performance counter for total vertices
  37147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37148. */
  37149. get totalVerticesPerfCounter(): PerfCounter;
  37150. /**
  37151. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37152. * @returns the total number of active indices rendered per frame
  37153. */
  37154. getActiveIndices(): number;
  37155. /**
  37156. * Gets the performance counter for active indices
  37157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37158. */
  37159. get totalActiveIndicesPerfCounter(): PerfCounter;
  37160. /**
  37161. * Gets the total number of active particles rendered per frame
  37162. * @returns the total number of active particles rendered per frame
  37163. */
  37164. getActiveParticles(): number;
  37165. /**
  37166. * Gets the performance counter for active particles
  37167. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37168. */
  37169. get activeParticlesPerfCounter(): PerfCounter;
  37170. /**
  37171. * Gets the total number of active bones rendered per frame
  37172. * @returns the total number of active bones rendered per frame
  37173. */
  37174. getActiveBones(): number;
  37175. /**
  37176. * Gets the performance counter for active bones
  37177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37178. */
  37179. get activeBonesPerfCounter(): PerfCounter;
  37180. /**
  37181. * Gets the array of active meshes
  37182. * @returns an array of AbstractMesh
  37183. */
  37184. getActiveMeshes(): SmartArray<AbstractMesh>;
  37185. /**
  37186. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37187. * @returns a number
  37188. */
  37189. getAnimationRatio(): number;
  37190. /**
  37191. * Gets an unique Id for the current render phase
  37192. * @returns a number
  37193. */
  37194. getRenderId(): number;
  37195. /**
  37196. * Gets an unique Id for the current frame
  37197. * @returns a number
  37198. */
  37199. getFrameId(): number;
  37200. /** Call this function if you want to manually increment the render Id*/
  37201. incrementRenderId(): void;
  37202. private _createUbo;
  37203. /**
  37204. * Use this method to simulate a pointer move on a mesh
  37205. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37206. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37207. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37208. * @returns the current scene
  37209. */
  37210. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37211. /**
  37212. * Use this method to simulate a pointer down on a mesh
  37213. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37214. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37215. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37216. * @returns the current scene
  37217. */
  37218. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37219. /**
  37220. * Use this method to simulate a pointer up on a mesh
  37221. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37222. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37223. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37224. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37225. * @returns the current scene
  37226. */
  37227. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37228. /**
  37229. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37230. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37231. * @returns true if the pointer was captured
  37232. */
  37233. isPointerCaptured(pointerId?: number): boolean;
  37234. /**
  37235. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37236. * @param attachUp defines if you want to attach events to pointerup
  37237. * @param attachDown defines if you want to attach events to pointerdown
  37238. * @param attachMove defines if you want to attach events to pointermove
  37239. */
  37240. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37241. /** Detaches all event handlers*/
  37242. detachControl(): void;
  37243. /**
  37244. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37245. * Delay loaded resources are not taking in account
  37246. * @return true if all required resources are ready
  37247. */
  37248. isReady(): boolean;
  37249. /** Resets all cached information relative to material (including effect and visibility) */
  37250. resetCachedMaterial(): void;
  37251. /**
  37252. * Registers a function to be called before every frame render
  37253. * @param func defines the function to register
  37254. */
  37255. registerBeforeRender(func: () => void): void;
  37256. /**
  37257. * Unregisters a function called before every frame render
  37258. * @param func defines the function to unregister
  37259. */
  37260. unregisterBeforeRender(func: () => void): void;
  37261. /**
  37262. * Registers a function to be called after every frame render
  37263. * @param func defines the function to register
  37264. */
  37265. registerAfterRender(func: () => void): void;
  37266. /**
  37267. * Unregisters a function called after every frame render
  37268. * @param func defines the function to unregister
  37269. */
  37270. unregisterAfterRender(func: () => void): void;
  37271. private _executeOnceBeforeRender;
  37272. /**
  37273. * The provided function will run before render once and will be disposed afterwards.
  37274. * A timeout delay can be provided so that the function will be executed in N ms.
  37275. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37276. * @param func The function to be executed.
  37277. * @param timeout optional delay in ms
  37278. */
  37279. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37280. /** @hidden */
  37281. _addPendingData(data: any): void;
  37282. /** @hidden */
  37283. _removePendingData(data: any): void;
  37284. /**
  37285. * Returns the number of items waiting to be loaded
  37286. * @returns the number of items waiting to be loaded
  37287. */
  37288. getWaitingItemsCount(): number;
  37289. /**
  37290. * Returns a boolean indicating if the scene is still loading data
  37291. */
  37292. get isLoading(): boolean;
  37293. /**
  37294. * Registers a function to be executed when the scene is ready
  37295. * @param {Function} func - the function to be executed
  37296. */
  37297. executeWhenReady(func: () => void): void;
  37298. /**
  37299. * Returns a promise that resolves when the scene is ready
  37300. * @returns A promise that resolves when the scene is ready
  37301. */
  37302. whenReadyAsync(): Promise<void>;
  37303. /** @hidden */
  37304. _checkIsReady(): void;
  37305. /**
  37306. * Gets all animatable attached to the scene
  37307. */
  37308. get animatables(): Animatable[];
  37309. /**
  37310. * Resets the last animation time frame.
  37311. * Useful to override when animations start running when loading a scene for the first time.
  37312. */
  37313. resetLastAnimationTimeFrame(): void;
  37314. /**
  37315. * Gets the current view matrix
  37316. * @returns a Matrix
  37317. */
  37318. getViewMatrix(): Matrix;
  37319. /**
  37320. * Gets the current projection matrix
  37321. * @returns a Matrix
  37322. */
  37323. getProjectionMatrix(): Matrix;
  37324. /**
  37325. * Gets the current transform matrix
  37326. * @returns a Matrix made of View * Projection
  37327. */
  37328. getTransformMatrix(): Matrix;
  37329. /**
  37330. * Sets the current transform matrix
  37331. * @param viewL defines the View matrix to use
  37332. * @param projectionL defines the Projection matrix to use
  37333. * @param viewR defines the right View matrix to use (if provided)
  37334. * @param projectionR defines the right Projection matrix to use (if provided)
  37335. */
  37336. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37337. /**
  37338. * Gets the uniform buffer used to store scene data
  37339. * @returns a UniformBuffer
  37340. */
  37341. getSceneUniformBuffer(): UniformBuffer;
  37342. /**
  37343. * Gets an unique (relatively to the current scene) Id
  37344. * @returns an unique number for the scene
  37345. */
  37346. getUniqueId(): number;
  37347. /**
  37348. * Add a mesh to the list of scene's meshes
  37349. * @param newMesh defines the mesh to add
  37350. * @param recursive if all child meshes should also be added to the scene
  37351. */
  37352. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37353. /**
  37354. * Remove a mesh for the list of scene's meshes
  37355. * @param toRemove defines the mesh to remove
  37356. * @param recursive if all child meshes should also be removed from the scene
  37357. * @returns the index where the mesh was in the mesh list
  37358. */
  37359. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37360. /**
  37361. * Add a transform node to the list of scene's transform nodes
  37362. * @param newTransformNode defines the transform node to add
  37363. */
  37364. addTransformNode(newTransformNode: TransformNode): void;
  37365. /**
  37366. * Remove a transform node for the list of scene's transform nodes
  37367. * @param toRemove defines the transform node to remove
  37368. * @returns the index where the transform node was in the transform node list
  37369. */
  37370. removeTransformNode(toRemove: TransformNode): number;
  37371. /**
  37372. * Remove a skeleton for the list of scene's skeletons
  37373. * @param toRemove defines the skeleton to remove
  37374. * @returns the index where the skeleton was in the skeleton list
  37375. */
  37376. removeSkeleton(toRemove: Skeleton): number;
  37377. /**
  37378. * Remove a morph target for the list of scene's morph targets
  37379. * @param toRemove defines the morph target to remove
  37380. * @returns the index where the morph target was in the morph target list
  37381. */
  37382. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37383. /**
  37384. * Remove a light for the list of scene's lights
  37385. * @param toRemove defines the light to remove
  37386. * @returns the index where the light was in the light list
  37387. */
  37388. removeLight(toRemove: Light): number;
  37389. /**
  37390. * Remove a camera for the list of scene's cameras
  37391. * @param toRemove defines the camera to remove
  37392. * @returns the index where the camera was in the camera list
  37393. */
  37394. removeCamera(toRemove: Camera): number;
  37395. /**
  37396. * Remove a particle system for the list of scene's particle systems
  37397. * @param toRemove defines the particle system to remove
  37398. * @returns the index where the particle system was in the particle system list
  37399. */
  37400. removeParticleSystem(toRemove: IParticleSystem): number;
  37401. /**
  37402. * Remove a animation for the list of scene's animations
  37403. * @param toRemove defines the animation to remove
  37404. * @returns the index where the animation was in the animation list
  37405. */
  37406. removeAnimation(toRemove: Animation): number;
  37407. /**
  37408. * Will stop the animation of the given target
  37409. * @param target - the target
  37410. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37411. * @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)
  37412. */
  37413. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37414. /**
  37415. * Removes the given animation group from this scene.
  37416. * @param toRemove The animation group to remove
  37417. * @returns The index of the removed animation group
  37418. */
  37419. removeAnimationGroup(toRemove: AnimationGroup): number;
  37420. /**
  37421. * Removes the given multi-material from this scene.
  37422. * @param toRemove The multi-material to remove
  37423. * @returns The index of the removed multi-material
  37424. */
  37425. removeMultiMaterial(toRemove: MultiMaterial): number;
  37426. /**
  37427. * Removes the given material from this scene.
  37428. * @param toRemove The material to remove
  37429. * @returns The index of the removed material
  37430. */
  37431. removeMaterial(toRemove: Material): number;
  37432. /**
  37433. * Removes the given action manager from this scene.
  37434. * @param toRemove The action manager to remove
  37435. * @returns The index of the removed action manager
  37436. */
  37437. removeActionManager(toRemove: AbstractActionManager): number;
  37438. /**
  37439. * Removes the given texture from this scene.
  37440. * @param toRemove The texture to remove
  37441. * @returns The index of the removed texture
  37442. */
  37443. removeTexture(toRemove: BaseTexture): number;
  37444. /**
  37445. * Adds the given light to this scene
  37446. * @param newLight The light to add
  37447. */
  37448. addLight(newLight: Light): void;
  37449. /**
  37450. * Sorts the list list based on light priorities
  37451. */
  37452. sortLightsByPriority(): void;
  37453. /**
  37454. * Adds the given camera to this scene
  37455. * @param newCamera The camera to add
  37456. */
  37457. addCamera(newCamera: Camera): void;
  37458. /**
  37459. * Adds the given skeleton to this scene
  37460. * @param newSkeleton The skeleton to add
  37461. */
  37462. addSkeleton(newSkeleton: Skeleton): void;
  37463. /**
  37464. * Adds the given particle system to this scene
  37465. * @param newParticleSystem The particle system to add
  37466. */
  37467. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37468. /**
  37469. * Adds the given animation to this scene
  37470. * @param newAnimation The animation to add
  37471. */
  37472. addAnimation(newAnimation: Animation): void;
  37473. /**
  37474. * Adds the given animation group to this scene.
  37475. * @param newAnimationGroup The animation group to add
  37476. */
  37477. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37478. /**
  37479. * Adds the given multi-material to this scene
  37480. * @param newMultiMaterial The multi-material to add
  37481. */
  37482. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37483. /**
  37484. * Adds the given material to this scene
  37485. * @param newMaterial The material to add
  37486. */
  37487. addMaterial(newMaterial: Material): void;
  37488. /**
  37489. * Adds the given morph target to this scene
  37490. * @param newMorphTargetManager The morph target to add
  37491. */
  37492. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37493. /**
  37494. * Adds the given geometry to this scene
  37495. * @param newGeometry The geometry to add
  37496. */
  37497. addGeometry(newGeometry: Geometry): void;
  37498. /**
  37499. * Adds the given action manager to this scene
  37500. * @param newActionManager The action manager to add
  37501. */
  37502. addActionManager(newActionManager: AbstractActionManager): void;
  37503. /**
  37504. * Adds the given texture to this scene.
  37505. * @param newTexture The texture to add
  37506. */
  37507. addTexture(newTexture: BaseTexture): void;
  37508. /**
  37509. * Switch active camera
  37510. * @param newCamera defines the new active camera
  37511. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37512. */
  37513. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37514. /**
  37515. * sets the active camera of the scene using its ID
  37516. * @param id defines the camera's ID
  37517. * @return the new active camera or null if none found.
  37518. */
  37519. setActiveCameraByID(id: string): Nullable<Camera>;
  37520. /**
  37521. * sets the active camera of the scene using its name
  37522. * @param name defines the camera's name
  37523. * @returns the new active camera or null if none found.
  37524. */
  37525. setActiveCameraByName(name: string): Nullable<Camera>;
  37526. /**
  37527. * get an animation group using its name
  37528. * @param name defines the material's name
  37529. * @return the animation group or null if none found.
  37530. */
  37531. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37532. /**
  37533. * Get a material using its unique id
  37534. * @param uniqueId defines the material's unique id
  37535. * @return the material or null if none found.
  37536. */
  37537. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37538. /**
  37539. * get a material using its id
  37540. * @param id defines the material's ID
  37541. * @return the material or null if none found.
  37542. */
  37543. getMaterialByID(id: string): Nullable<Material>;
  37544. /**
  37545. * Gets a the last added material using a given id
  37546. * @param id defines the material's ID
  37547. * @return the last material with the given id or null if none found.
  37548. */
  37549. getLastMaterialByID(id: string): Nullable<Material>;
  37550. /**
  37551. * Gets a material using its name
  37552. * @param name defines the material's name
  37553. * @return the material or null if none found.
  37554. */
  37555. getMaterialByName(name: string): Nullable<Material>;
  37556. /**
  37557. * Get a texture using its unique id
  37558. * @param uniqueId defines the texture's unique id
  37559. * @return the texture or null if none found.
  37560. */
  37561. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37562. /**
  37563. * Gets a camera using its id
  37564. * @param id defines the id to look for
  37565. * @returns the camera or null if not found
  37566. */
  37567. getCameraByID(id: string): Nullable<Camera>;
  37568. /**
  37569. * Gets a camera using its unique id
  37570. * @param uniqueId defines the unique id to look for
  37571. * @returns the camera or null if not found
  37572. */
  37573. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37574. /**
  37575. * Gets a camera using its name
  37576. * @param name defines the camera's name
  37577. * @return the camera or null if none found.
  37578. */
  37579. getCameraByName(name: string): Nullable<Camera>;
  37580. /**
  37581. * Gets a bone using its id
  37582. * @param id defines the bone's id
  37583. * @return the bone or null if not found
  37584. */
  37585. getBoneByID(id: string): Nullable<Bone>;
  37586. /**
  37587. * Gets a bone using its id
  37588. * @param name defines the bone's name
  37589. * @return the bone or null if not found
  37590. */
  37591. getBoneByName(name: string): Nullable<Bone>;
  37592. /**
  37593. * Gets a light node using its name
  37594. * @param name defines the the light's name
  37595. * @return the light or null if none found.
  37596. */
  37597. getLightByName(name: string): Nullable<Light>;
  37598. /**
  37599. * Gets a light node using its id
  37600. * @param id defines the light's id
  37601. * @return the light or null if none found.
  37602. */
  37603. getLightByID(id: string): Nullable<Light>;
  37604. /**
  37605. * Gets a light node using its scene-generated unique ID
  37606. * @param uniqueId defines the light's unique id
  37607. * @return the light or null if none found.
  37608. */
  37609. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37610. /**
  37611. * Gets a particle system by id
  37612. * @param id defines the particle system id
  37613. * @return the corresponding system or null if none found
  37614. */
  37615. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37616. /**
  37617. * Gets a geometry using its ID
  37618. * @param id defines the geometry's id
  37619. * @return the geometry or null if none found.
  37620. */
  37621. getGeometryByID(id: string): Nullable<Geometry>;
  37622. private _getGeometryByUniqueID;
  37623. /**
  37624. * Add a new geometry to this scene
  37625. * @param geometry defines the geometry to be added to the scene.
  37626. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37627. * @return a boolean defining if the geometry was added or not
  37628. */
  37629. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37630. /**
  37631. * Removes an existing geometry
  37632. * @param geometry defines the geometry to be removed from the scene
  37633. * @return a boolean defining if the geometry was removed or not
  37634. */
  37635. removeGeometry(geometry: Geometry): boolean;
  37636. /**
  37637. * Gets the list of geometries attached to the scene
  37638. * @returns an array of Geometry
  37639. */
  37640. getGeometries(): Geometry[];
  37641. /**
  37642. * Gets the first added mesh found of a given ID
  37643. * @param id defines the id to search for
  37644. * @return the mesh found or null if not found at all
  37645. */
  37646. getMeshByID(id: string): Nullable<AbstractMesh>;
  37647. /**
  37648. * Gets a list of meshes using their id
  37649. * @param id defines the id to search for
  37650. * @returns a list of meshes
  37651. */
  37652. getMeshesByID(id: string): Array<AbstractMesh>;
  37653. /**
  37654. * Gets the first added transform node found of a given ID
  37655. * @param id defines the id to search for
  37656. * @return the found transform node or null if not found at all.
  37657. */
  37658. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37659. /**
  37660. * Gets a transform node with its auto-generated unique id
  37661. * @param uniqueId efines the unique id to search for
  37662. * @return the found transform node or null if not found at all.
  37663. */
  37664. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37665. /**
  37666. * Gets a list of transform nodes using their id
  37667. * @param id defines the id to search for
  37668. * @returns a list of transform nodes
  37669. */
  37670. getTransformNodesByID(id: string): Array<TransformNode>;
  37671. /**
  37672. * Gets a mesh with its auto-generated unique id
  37673. * @param uniqueId defines the unique id to search for
  37674. * @return the found mesh or null if not found at all.
  37675. */
  37676. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37677. /**
  37678. * Gets a the last added mesh using a given id
  37679. * @param id defines the id to search for
  37680. * @return the found mesh or null if not found at all.
  37681. */
  37682. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37683. /**
  37684. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37685. * @param id defines the id to search for
  37686. * @return the found node or null if not found at all
  37687. */
  37688. getLastEntryByID(id: string): Nullable<Node>;
  37689. /**
  37690. * Gets a node (Mesh, Camera, Light) using a given id
  37691. * @param id defines the id to search for
  37692. * @return the found node or null if not found at all
  37693. */
  37694. getNodeByID(id: string): Nullable<Node>;
  37695. /**
  37696. * Gets a node (Mesh, Camera, Light) using a given name
  37697. * @param name defines the name to search for
  37698. * @return the found node or null if not found at all.
  37699. */
  37700. getNodeByName(name: string): Nullable<Node>;
  37701. /**
  37702. * Gets a mesh using a given name
  37703. * @param name defines the name to search for
  37704. * @return the found mesh or null if not found at all.
  37705. */
  37706. getMeshByName(name: string): Nullable<AbstractMesh>;
  37707. /**
  37708. * Gets a transform node using a given name
  37709. * @param name defines the name to search for
  37710. * @return the found transform node or null if not found at all.
  37711. */
  37712. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37713. /**
  37714. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37715. * @param id defines the id to search for
  37716. * @return the found skeleton or null if not found at all.
  37717. */
  37718. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37719. /**
  37720. * Gets a skeleton using a given auto generated unique id
  37721. * @param uniqueId defines the unique id to search for
  37722. * @return the found skeleton or null if not found at all.
  37723. */
  37724. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37725. /**
  37726. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37727. * @param id defines the id to search for
  37728. * @return the found skeleton or null if not found at all.
  37729. */
  37730. getSkeletonById(id: string): Nullable<Skeleton>;
  37731. /**
  37732. * Gets a skeleton using a given name
  37733. * @param name defines the name to search for
  37734. * @return the found skeleton or null if not found at all.
  37735. */
  37736. getSkeletonByName(name: string): Nullable<Skeleton>;
  37737. /**
  37738. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37739. * @param id defines the id to search for
  37740. * @return the found morph target manager or null if not found at all.
  37741. */
  37742. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37743. /**
  37744. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37745. * @param id defines the id to search for
  37746. * @return the found morph target or null if not found at all.
  37747. */
  37748. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37749. /**
  37750. * Gets a boolean indicating if the given mesh is active
  37751. * @param mesh defines the mesh to look for
  37752. * @returns true if the mesh is in the active list
  37753. */
  37754. isActiveMesh(mesh: AbstractMesh): boolean;
  37755. /**
  37756. * Return a unique id as a string which can serve as an identifier for the scene
  37757. */
  37758. get uid(): string;
  37759. /**
  37760. * Add an externaly attached data from its key.
  37761. * This method call will fail and return false, if such key already exists.
  37762. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37763. * @param key the unique key that identifies the data
  37764. * @param data the data object to associate to the key for this Engine instance
  37765. * @return true if no such key were already present and the data was added successfully, false otherwise
  37766. */
  37767. addExternalData<T>(key: string, data: T): boolean;
  37768. /**
  37769. * Get an externaly attached data from its key
  37770. * @param key the unique key that identifies the data
  37771. * @return the associated data, if present (can be null), or undefined if not present
  37772. */
  37773. getExternalData<T>(key: string): Nullable<T>;
  37774. /**
  37775. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37776. * @param key the unique key that identifies the data
  37777. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37778. * @return the associated data, can be null if the factory returned null.
  37779. */
  37780. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37781. /**
  37782. * Remove an externaly attached data from the Engine instance
  37783. * @param key the unique key that identifies the data
  37784. * @return true if the data was successfully removed, false if it doesn't exist
  37785. */
  37786. removeExternalData(key: string): boolean;
  37787. private _evaluateSubMesh;
  37788. /**
  37789. * Clear the processed materials smart array preventing retention point in material dispose.
  37790. */
  37791. freeProcessedMaterials(): void;
  37792. private _preventFreeActiveMeshesAndRenderingGroups;
  37793. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37794. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37795. * when disposing several meshes in a row or a hierarchy of meshes.
  37796. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37797. */
  37798. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37799. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37800. /**
  37801. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37802. */
  37803. freeActiveMeshes(): void;
  37804. /**
  37805. * Clear the info related to rendering groups preventing retention points during dispose.
  37806. */
  37807. freeRenderingGroups(): void;
  37808. /** @hidden */
  37809. _isInIntermediateRendering(): boolean;
  37810. /**
  37811. * Lambda returning the list of potentially active meshes.
  37812. */
  37813. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37814. /**
  37815. * Lambda returning the list of potentially active sub meshes.
  37816. */
  37817. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37818. /**
  37819. * Lambda returning the list of potentially intersecting sub meshes.
  37820. */
  37821. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37822. /**
  37823. * Lambda returning the list of potentially colliding sub meshes.
  37824. */
  37825. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37826. private _activeMeshesFrozen;
  37827. private _skipEvaluateActiveMeshesCompletely;
  37828. /**
  37829. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37830. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37831. * @returns the current scene
  37832. */
  37833. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37834. /**
  37835. * Use this function to restart evaluating active meshes on every frame
  37836. * @returns the current scene
  37837. */
  37838. unfreezeActiveMeshes(): Scene;
  37839. private _evaluateActiveMeshes;
  37840. private _activeMesh;
  37841. /**
  37842. * Update the transform matrix to update from the current active camera
  37843. * @param force defines a boolean used to force the update even if cache is up to date
  37844. */
  37845. updateTransformMatrix(force?: boolean): void;
  37846. private _bindFrameBuffer;
  37847. /** @hidden */
  37848. _allowPostProcessClearColor: boolean;
  37849. /** @hidden */
  37850. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37851. private _processSubCameras;
  37852. private _checkIntersections;
  37853. /** @hidden */
  37854. _advancePhysicsEngineStep(step: number): void;
  37855. /**
  37856. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37857. */
  37858. getDeterministicFrameTime: () => number;
  37859. /** @hidden */
  37860. _animate(): void;
  37861. /** Execute all animations (for a frame) */
  37862. animate(): void;
  37863. /**
  37864. * Render the scene
  37865. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37866. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37867. */
  37868. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37869. /**
  37870. * Freeze all materials
  37871. * A frozen material will not be updatable but should be faster to render
  37872. */
  37873. freezeMaterials(): void;
  37874. /**
  37875. * Unfreeze all materials
  37876. * A frozen material will not be updatable but should be faster to render
  37877. */
  37878. unfreezeMaterials(): void;
  37879. /**
  37880. * Releases all held ressources
  37881. */
  37882. dispose(): void;
  37883. /**
  37884. * Gets if the scene is already disposed
  37885. */
  37886. get isDisposed(): boolean;
  37887. /**
  37888. * Call this function to reduce memory footprint of the scene.
  37889. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37890. */
  37891. clearCachedVertexData(): void;
  37892. /**
  37893. * This function will remove the local cached buffer data from texture.
  37894. * It will save memory but will prevent the texture from being rebuilt
  37895. */
  37896. cleanCachedTextureBuffer(): void;
  37897. /**
  37898. * Get the world extend vectors with an optional filter
  37899. *
  37900. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37901. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37902. */
  37903. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37904. min: Vector3;
  37905. max: Vector3;
  37906. };
  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 world defines the world matrix to use if you want to pick in object space (instead of world space)
  37912. * @param camera defines the camera to use for the picking
  37913. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37914. * @returns a Ray
  37915. */
  37916. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37917. /**
  37918. * Creates a ray that can be used to pick in the scene
  37919. * @param x defines the x coordinate of the origin (on-screen)
  37920. * @param y defines the y coordinate of the origin (on-screen)
  37921. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37922. * @param result defines the ray where to store the picking ray
  37923. * @param camera defines the camera to use for the picking
  37924. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37925. * @returns the current scene
  37926. */
  37927. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37928. /**
  37929. * Creates a ray that can be used to pick in the scene
  37930. * @param x defines the x coordinate of the origin (on-screen)
  37931. * @param y defines the y coordinate of the origin (on-screen)
  37932. * @param camera defines the camera to use for the picking
  37933. * @returns a Ray
  37934. */
  37935. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37936. /**
  37937. * Creates a ray that can be used to pick in the scene
  37938. * @param x defines the x coordinate of the origin (on-screen)
  37939. * @param y defines the y coordinate of the origin (on-screen)
  37940. * @param result defines the ray where to store the picking ray
  37941. * @param camera defines the camera to use for the picking
  37942. * @returns the current scene
  37943. */
  37944. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37945. /** Launch a ray to try to pick a mesh in the scene
  37946. * @param x position on screen
  37947. * @param y position on screen
  37948. * @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
  37949. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37950. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37951. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37952. * @returns a PickingInfo
  37953. */
  37954. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37955. /** Use the given ray to pick a mesh in the scene
  37956. * @param ray The ray to use to pick meshes
  37957. * @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
  37958. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37959. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37960. * @returns a PickingInfo
  37961. */
  37962. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37963. /**
  37964. * Launch a ray to try to pick a mesh in the scene
  37965. * @param x X position on screen
  37966. * @param y Y position on screen
  37967. * @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
  37968. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37969. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37970. * @returns an array of PickingInfo
  37971. */
  37972. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37973. /**
  37974. * Launch a ray to try to pick a mesh in the scene
  37975. * @param ray Ray to use
  37976. * @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
  37977. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37978. * @returns an array of PickingInfo
  37979. */
  37980. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37981. /**
  37982. * Force the value of meshUnderPointer
  37983. * @param mesh defines the mesh to use
  37984. */
  37985. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37986. /**
  37987. * Gets the mesh under the pointer
  37988. * @returns a Mesh or null if no mesh is under the pointer
  37989. */
  37990. getPointerOverMesh(): Nullable<AbstractMesh>;
  37991. /** @hidden */
  37992. _rebuildGeometries(): void;
  37993. /** @hidden */
  37994. _rebuildTextures(): void;
  37995. private _getByTags;
  37996. /**
  37997. * Get a list of meshes by tags
  37998. * @param tagsQuery defines the tags query to use
  37999. * @param forEach defines a predicate used to filter results
  38000. * @returns an array of Mesh
  38001. */
  38002. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38003. /**
  38004. * Get a list of cameras by tags
  38005. * @param tagsQuery defines the tags query to use
  38006. * @param forEach defines a predicate used to filter results
  38007. * @returns an array of Camera
  38008. */
  38009. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38010. /**
  38011. * Get a list of lights by tags
  38012. * @param tagsQuery defines the tags query to use
  38013. * @param forEach defines a predicate used to filter results
  38014. * @returns an array of Light
  38015. */
  38016. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38017. /**
  38018. * Get a list of materials by tags
  38019. * @param tagsQuery defines the tags query to use
  38020. * @param forEach defines a predicate used to filter results
  38021. * @returns an array of Material
  38022. */
  38023. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38024. /**
  38025. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38026. * This allowed control for front to back rendering or reversly depending of the special needs.
  38027. *
  38028. * @param renderingGroupId The rendering group id corresponding to its index
  38029. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38030. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38031. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38032. */
  38033. 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;
  38034. /**
  38035. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38036. *
  38037. * @param renderingGroupId The rendering group id corresponding to its index
  38038. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38039. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38040. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38041. */
  38042. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38043. /**
  38044. * Gets the current auto clear configuration for one rendering group of the rendering
  38045. * manager.
  38046. * @param index the rendering group index to get the information for
  38047. * @returns The auto clear setup for the requested rendering group
  38048. */
  38049. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38050. private _blockMaterialDirtyMechanism;
  38051. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38052. get blockMaterialDirtyMechanism(): boolean;
  38053. set blockMaterialDirtyMechanism(value: boolean);
  38054. /**
  38055. * Will flag all materials as dirty to trigger new shader compilation
  38056. * @param flag defines the flag used to specify which material part must be marked as dirty
  38057. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38058. */
  38059. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38060. /** @hidden */
  38061. _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;
  38062. /** @hidden */
  38063. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38064. /** @hidden */
  38065. _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;
  38066. /** @hidden */
  38067. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38068. /** @hidden */
  38069. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38070. /** @hidden */
  38071. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38072. }
  38073. }
  38074. declare module "babylonjs/assetContainer" {
  38075. import { AbstractScene } from "babylonjs/abstractScene";
  38076. import { Scene } from "babylonjs/scene";
  38077. import { Mesh } from "babylonjs/Meshes/mesh";
  38078. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38079. import { Skeleton } from "babylonjs/Bones/skeleton";
  38080. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38081. import { Animatable } from "babylonjs/Animations/animatable";
  38082. import { Nullable } from "babylonjs/types";
  38083. import { Node } from "babylonjs/node";
  38084. /**
  38085. * Set of assets to keep when moving a scene into an asset container.
  38086. */
  38087. export class KeepAssets extends AbstractScene {
  38088. }
  38089. /**
  38090. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38091. */
  38092. export class InstantiatedEntries {
  38093. /**
  38094. * List of new root nodes (eg. nodes with no parent)
  38095. */
  38096. rootNodes: TransformNode[];
  38097. /**
  38098. * List of new skeletons
  38099. */
  38100. skeletons: Skeleton[];
  38101. /**
  38102. * List of new animation groups
  38103. */
  38104. animationGroups: AnimationGroup[];
  38105. }
  38106. /**
  38107. * Container with a set of assets that can be added or removed from a scene.
  38108. */
  38109. export class AssetContainer extends AbstractScene {
  38110. private _wasAddedToScene;
  38111. /**
  38112. * The scene the AssetContainer belongs to.
  38113. */
  38114. scene: Scene;
  38115. /**
  38116. * Instantiates an AssetContainer.
  38117. * @param scene The scene the AssetContainer belongs to.
  38118. */
  38119. constructor(scene: Scene);
  38120. /**
  38121. * Instantiate or clone all meshes and add the new ones to the scene.
  38122. * Skeletons and animation groups will all be cloned
  38123. * @param nameFunction defines an optional function used to get new names for clones
  38124. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38125. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38126. */
  38127. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38128. /**
  38129. * Adds all the assets from the container to the scene.
  38130. */
  38131. addAllToScene(): void;
  38132. /**
  38133. * Removes all the assets in the container from the scene
  38134. */
  38135. removeAllFromScene(): void;
  38136. /**
  38137. * Disposes all the assets in the container
  38138. */
  38139. dispose(): void;
  38140. private _moveAssets;
  38141. /**
  38142. * Removes all the assets contained in the scene and adds them to the container.
  38143. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38144. */
  38145. moveAllFromScene(keepAssets?: KeepAssets): void;
  38146. /**
  38147. * 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.
  38148. * @returns the root mesh
  38149. */
  38150. createRootMesh(): Mesh;
  38151. /**
  38152. * Merge animations from this asset container into a scene
  38153. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38154. * @param animatables set of animatables to retarget to a node from the scene
  38155. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38156. */
  38157. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38158. }
  38159. }
  38160. declare module "babylonjs/abstractScene" {
  38161. import { Scene } from "babylonjs/scene";
  38162. import { Nullable } from "babylonjs/types";
  38163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38165. import { Geometry } from "babylonjs/Meshes/geometry";
  38166. import { Skeleton } from "babylonjs/Bones/skeleton";
  38167. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38168. import { AssetContainer } from "babylonjs/assetContainer";
  38169. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38170. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38172. import { Material } from "babylonjs/Materials/material";
  38173. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38175. import { Camera } from "babylonjs/Cameras/camera";
  38176. import { Light } from "babylonjs/Lights/light";
  38177. import { Node } from "babylonjs/node";
  38178. import { Animation } from "babylonjs/Animations/animation";
  38179. /**
  38180. * Defines how the parser contract is defined.
  38181. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38182. */
  38183. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38184. /**
  38185. * Defines how the individual parser contract is defined.
  38186. * These parser can parse an individual asset
  38187. */
  38188. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38189. /**
  38190. * Base class of the scene acting as a container for the different elements composing a scene.
  38191. * This class is dynamically extended by the different components of the scene increasing
  38192. * flexibility and reducing coupling
  38193. */
  38194. export abstract class AbstractScene {
  38195. /**
  38196. * Stores the list of available parsers in the application.
  38197. */
  38198. private static _BabylonFileParsers;
  38199. /**
  38200. * Stores the list of available individual parsers in the application.
  38201. */
  38202. private static _IndividualBabylonFileParsers;
  38203. /**
  38204. * Adds a parser in the list of available ones
  38205. * @param name Defines the name of the parser
  38206. * @param parser Defines the parser to add
  38207. */
  38208. static AddParser(name: string, parser: BabylonFileParser): void;
  38209. /**
  38210. * Gets a general parser from the list of avaialble ones
  38211. * @param name Defines the name of the parser
  38212. * @returns the requested parser or null
  38213. */
  38214. static GetParser(name: string): Nullable<BabylonFileParser>;
  38215. /**
  38216. * Adds n individual parser in the list of available ones
  38217. * @param name Defines the name of the parser
  38218. * @param parser Defines the parser to add
  38219. */
  38220. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38221. /**
  38222. * Gets an individual parser from the list of avaialble ones
  38223. * @param name Defines the name of the parser
  38224. * @returns the requested parser or null
  38225. */
  38226. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38227. /**
  38228. * Parser json data and populate both a scene and its associated container object
  38229. * @param jsonData Defines the data to parse
  38230. * @param scene Defines the scene to parse the data for
  38231. * @param container Defines the container attached to the parsing sequence
  38232. * @param rootUrl Defines the root url of the data
  38233. */
  38234. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38235. /**
  38236. * Gets the list of root nodes (ie. nodes with no parent)
  38237. */
  38238. rootNodes: Node[];
  38239. /** All of the cameras added to this scene
  38240. * @see http://doc.babylonjs.com/babylon101/cameras
  38241. */
  38242. cameras: Camera[];
  38243. /**
  38244. * All of the lights added to this scene
  38245. * @see http://doc.babylonjs.com/babylon101/lights
  38246. */
  38247. lights: Light[];
  38248. /**
  38249. * All of the (abstract) meshes added to this scene
  38250. */
  38251. meshes: AbstractMesh[];
  38252. /**
  38253. * The list of skeletons added to the scene
  38254. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38255. */
  38256. skeletons: Skeleton[];
  38257. /**
  38258. * All of the particle systems added to this scene
  38259. * @see http://doc.babylonjs.com/babylon101/particles
  38260. */
  38261. particleSystems: IParticleSystem[];
  38262. /**
  38263. * Gets a list of Animations associated with the scene
  38264. */
  38265. animations: Animation[];
  38266. /**
  38267. * All of the animation groups added to this scene
  38268. * @see http://doc.babylonjs.com/how_to/group
  38269. */
  38270. animationGroups: AnimationGroup[];
  38271. /**
  38272. * All of the multi-materials added to this scene
  38273. * @see http://doc.babylonjs.com/how_to/multi_materials
  38274. */
  38275. multiMaterials: MultiMaterial[];
  38276. /**
  38277. * All of the materials added to this scene
  38278. * In the context of a Scene, it is not supposed to be modified manually.
  38279. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38280. * Note also that the order of the Material within the array is not significant and might change.
  38281. * @see http://doc.babylonjs.com/babylon101/materials
  38282. */
  38283. materials: Material[];
  38284. /**
  38285. * The list of morph target managers added to the scene
  38286. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38287. */
  38288. morphTargetManagers: MorphTargetManager[];
  38289. /**
  38290. * The list of geometries used in the scene.
  38291. */
  38292. geometries: Geometry[];
  38293. /**
  38294. * All of the tranform nodes added to this scene
  38295. * In the context of a Scene, it is not supposed to be modified manually.
  38296. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38297. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38298. * @see http://doc.babylonjs.com/how_to/transformnode
  38299. */
  38300. transformNodes: TransformNode[];
  38301. /**
  38302. * ActionManagers available on the scene.
  38303. */
  38304. actionManagers: AbstractActionManager[];
  38305. /**
  38306. * Textures to keep.
  38307. */
  38308. textures: BaseTexture[];
  38309. /**
  38310. * Environment texture for the scene
  38311. */
  38312. environmentTexture: Nullable<BaseTexture>;
  38313. /**
  38314. * @returns all meshes, lights, cameras, transformNodes and bones
  38315. */
  38316. getNodes(): Array<Node>;
  38317. }
  38318. }
  38319. declare module "babylonjs/Audio/sound" {
  38320. import { Observable } from "babylonjs/Misc/observable";
  38321. import { Vector3 } from "babylonjs/Maths/math.vector";
  38322. import { Nullable } from "babylonjs/types";
  38323. import { Scene } from "babylonjs/scene";
  38324. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38325. /**
  38326. * Interface used to define options for Sound class
  38327. */
  38328. export interface ISoundOptions {
  38329. /**
  38330. * Does the sound autoplay once loaded.
  38331. */
  38332. autoplay?: boolean;
  38333. /**
  38334. * Does the sound loop after it finishes playing once.
  38335. */
  38336. loop?: boolean;
  38337. /**
  38338. * Sound's volume
  38339. */
  38340. volume?: number;
  38341. /**
  38342. * Is it a spatial sound?
  38343. */
  38344. spatialSound?: boolean;
  38345. /**
  38346. * Maximum distance to hear that sound
  38347. */
  38348. maxDistance?: number;
  38349. /**
  38350. * Uses user defined attenuation function
  38351. */
  38352. useCustomAttenuation?: boolean;
  38353. /**
  38354. * Define the roll off factor of spatial sounds.
  38355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38356. */
  38357. rolloffFactor?: number;
  38358. /**
  38359. * Define the reference distance the sound should be heard perfectly.
  38360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38361. */
  38362. refDistance?: number;
  38363. /**
  38364. * Define the distance attenuation model the sound will follow.
  38365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38366. */
  38367. distanceModel?: string;
  38368. /**
  38369. * Defines the playback speed (1 by default)
  38370. */
  38371. playbackRate?: number;
  38372. /**
  38373. * Defines if the sound is from a streaming source
  38374. */
  38375. streaming?: boolean;
  38376. /**
  38377. * Defines an optional length (in seconds) inside the sound file
  38378. */
  38379. length?: number;
  38380. /**
  38381. * Defines an optional offset (in seconds) inside the sound file
  38382. */
  38383. offset?: number;
  38384. /**
  38385. * If true, URLs will not be required to state the audio file codec to use.
  38386. */
  38387. skipCodecCheck?: boolean;
  38388. }
  38389. /**
  38390. * Defines a sound that can be played in the application.
  38391. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38393. */
  38394. export class Sound {
  38395. /**
  38396. * The name of the sound in the scene.
  38397. */
  38398. name: string;
  38399. /**
  38400. * Does the sound autoplay once loaded.
  38401. */
  38402. autoplay: boolean;
  38403. /**
  38404. * Does the sound loop after it finishes playing once.
  38405. */
  38406. loop: boolean;
  38407. /**
  38408. * Does the sound use a custom attenuation curve to simulate the falloff
  38409. * happening when the source gets further away from the camera.
  38410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38411. */
  38412. useCustomAttenuation: boolean;
  38413. /**
  38414. * The sound track id this sound belongs to.
  38415. */
  38416. soundTrackId: number;
  38417. /**
  38418. * Is this sound currently played.
  38419. */
  38420. isPlaying: boolean;
  38421. /**
  38422. * Is this sound currently paused.
  38423. */
  38424. isPaused: boolean;
  38425. /**
  38426. * Does this sound enables spatial sound.
  38427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38428. */
  38429. spatialSound: boolean;
  38430. /**
  38431. * Define the reference distance the sound should be heard perfectly.
  38432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38433. */
  38434. refDistance: number;
  38435. /**
  38436. * Define the roll off factor of spatial sounds.
  38437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38438. */
  38439. rolloffFactor: number;
  38440. /**
  38441. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38443. */
  38444. maxDistance: number;
  38445. /**
  38446. * Define the distance attenuation model the sound will follow.
  38447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38448. */
  38449. distanceModel: string;
  38450. /**
  38451. * @hidden
  38452. * Back Compat
  38453. **/
  38454. onended: () => any;
  38455. /**
  38456. * Observable event when the current playing sound finishes.
  38457. */
  38458. onEndedObservable: Observable<Sound>;
  38459. private _panningModel;
  38460. private _playbackRate;
  38461. private _streaming;
  38462. private _startTime;
  38463. private _startOffset;
  38464. private _position;
  38465. /** @hidden */
  38466. _positionInEmitterSpace: boolean;
  38467. private _localDirection;
  38468. private _volume;
  38469. private _isReadyToPlay;
  38470. private _isDirectional;
  38471. private _readyToPlayCallback;
  38472. private _audioBuffer;
  38473. private _soundSource;
  38474. private _streamingSource;
  38475. private _soundPanner;
  38476. private _soundGain;
  38477. private _inputAudioNode;
  38478. private _outputAudioNode;
  38479. private _coneInnerAngle;
  38480. private _coneOuterAngle;
  38481. private _coneOuterGain;
  38482. private _scene;
  38483. private _connectedTransformNode;
  38484. private _customAttenuationFunction;
  38485. private _registerFunc;
  38486. private _isOutputConnected;
  38487. private _htmlAudioElement;
  38488. private _urlType;
  38489. private _length?;
  38490. private _offset?;
  38491. /** @hidden */
  38492. static _SceneComponentInitialization: (scene: Scene) => void;
  38493. /**
  38494. * Create a sound and attach it to a scene
  38495. * @param name Name of your sound
  38496. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38497. * @param scene defines the scene the sound belongs to
  38498. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38499. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38500. */
  38501. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38502. /**
  38503. * Release the sound and its associated resources
  38504. */
  38505. dispose(): void;
  38506. /**
  38507. * Gets if the sounds is ready to be played or not.
  38508. * @returns true if ready, otherwise false
  38509. */
  38510. isReady(): boolean;
  38511. private _soundLoaded;
  38512. /**
  38513. * Sets the data of the sound from an audiobuffer
  38514. * @param audioBuffer The audioBuffer containing the data
  38515. */
  38516. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38517. /**
  38518. * Updates the current sounds options such as maxdistance, loop...
  38519. * @param options A JSON object containing values named as the object properties
  38520. */
  38521. updateOptions(options: ISoundOptions): void;
  38522. private _createSpatialParameters;
  38523. private _updateSpatialParameters;
  38524. /**
  38525. * Switch the panning model to HRTF:
  38526. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38528. */
  38529. switchPanningModelToHRTF(): void;
  38530. /**
  38531. * Switch the panning model to Equal Power:
  38532. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38534. */
  38535. switchPanningModelToEqualPower(): void;
  38536. private _switchPanningModel;
  38537. /**
  38538. * Connect this sound to a sound track audio node like gain...
  38539. * @param soundTrackAudioNode the sound track audio node to connect to
  38540. */
  38541. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38542. /**
  38543. * Transform this sound into a directional source
  38544. * @param coneInnerAngle Size of the inner cone in degree
  38545. * @param coneOuterAngle Size of the outer cone in degree
  38546. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38547. */
  38548. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38549. /**
  38550. * Gets or sets the inner angle for the directional cone.
  38551. */
  38552. get directionalConeInnerAngle(): number;
  38553. /**
  38554. * Gets or sets the inner angle for the directional cone.
  38555. */
  38556. set directionalConeInnerAngle(value: number);
  38557. /**
  38558. * Gets or sets the outer angle for the directional cone.
  38559. */
  38560. get directionalConeOuterAngle(): number;
  38561. /**
  38562. * Gets or sets the outer angle for the directional cone.
  38563. */
  38564. set directionalConeOuterAngle(value: number);
  38565. /**
  38566. * Sets the position of the emitter if spatial sound is enabled
  38567. * @param newPosition Defines the new posisiton
  38568. */
  38569. setPosition(newPosition: Vector3): void;
  38570. /**
  38571. * Sets the local direction of the emitter if spatial sound is enabled
  38572. * @param newLocalDirection Defines the new local direction
  38573. */
  38574. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38575. private _updateDirection;
  38576. /** @hidden */
  38577. updateDistanceFromListener(): void;
  38578. /**
  38579. * Sets a new custom attenuation function for the sound.
  38580. * @param callback Defines the function used for the attenuation
  38581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38582. */
  38583. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38584. /**
  38585. * Play the sound
  38586. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38587. * @param offset (optional) Start the sound at a specific time in seconds
  38588. * @param length (optional) Sound duration (in seconds)
  38589. */
  38590. play(time?: number, offset?: number, length?: number): void;
  38591. private _onended;
  38592. /**
  38593. * Stop the sound
  38594. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38595. */
  38596. stop(time?: number): void;
  38597. /**
  38598. * Put the sound in pause
  38599. */
  38600. pause(): void;
  38601. /**
  38602. * Sets a dedicated volume for this sounds
  38603. * @param newVolume Define the new volume of the sound
  38604. * @param time Define time for gradual change to new volume
  38605. */
  38606. setVolume(newVolume: number, time?: number): void;
  38607. /**
  38608. * Set the sound play back rate
  38609. * @param newPlaybackRate Define the playback rate the sound should be played at
  38610. */
  38611. setPlaybackRate(newPlaybackRate: number): void;
  38612. /**
  38613. * Gets the volume of the sound.
  38614. * @returns the volume of the sound
  38615. */
  38616. getVolume(): number;
  38617. /**
  38618. * Attach the sound to a dedicated mesh
  38619. * @param transformNode The transform node to connect the sound with
  38620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38621. */
  38622. attachToMesh(transformNode: TransformNode): void;
  38623. /**
  38624. * Detach the sound from the previously attached mesh
  38625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38626. */
  38627. detachFromMesh(): void;
  38628. private _onRegisterAfterWorldMatrixUpdate;
  38629. /**
  38630. * Clone the current sound in the scene.
  38631. * @returns the new sound clone
  38632. */
  38633. clone(): Nullable<Sound>;
  38634. /**
  38635. * Gets the current underlying audio buffer containing the data
  38636. * @returns the audio buffer
  38637. */
  38638. getAudioBuffer(): Nullable<AudioBuffer>;
  38639. /**
  38640. * Serializes the Sound in a JSON representation
  38641. * @returns the JSON representation of the sound
  38642. */
  38643. serialize(): any;
  38644. /**
  38645. * Parse a JSON representation of a sound to innstantiate in a given scene
  38646. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38647. * @param scene Define the scene the new parsed sound should be created in
  38648. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38649. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38650. * @returns the newly parsed sound
  38651. */
  38652. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38653. }
  38654. }
  38655. declare module "babylonjs/Actions/directAudioActions" {
  38656. import { Action } from "babylonjs/Actions/action";
  38657. import { Condition } from "babylonjs/Actions/condition";
  38658. import { Sound } from "babylonjs/Audio/sound";
  38659. /**
  38660. * This defines an action helpful to play a defined sound on a triggered action.
  38661. */
  38662. export class PlaySoundAction extends Action {
  38663. private _sound;
  38664. /**
  38665. * Instantiate the action
  38666. * @param triggerOptions defines the trigger options
  38667. * @param sound defines the sound to play
  38668. * @param condition defines the trigger related conditions
  38669. */
  38670. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38671. /** @hidden */
  38672. _prepare(): void;
  38673. /**
  38674. * Execute the action and play the sound.
  38675. */
  38676. execute(): void;
  38677. /**
  38678. * Serializes the actions and its related information.
  38679. * @param parent defines the object to serialize in
  38680. * @returns the serialized object
  38681. */
  38682. serialize(parent: any): any;
  38683. }
  38684. /**
  38685. * This defines an action helpful to stop a defined sound on a triggered action.
  38686. */
  38687. export class StopSoundAction extends Action {
  38688. private _sound;
  38689. /**
  38690. * Instantiate the action
  38691. * @param triggerOptions defines the trigger options
  38692. * @param sound defines the sound to stop
  38693. * @param condition defines the trigger related conditions
  38694. */
  38695. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38696. /** @hidden */
  38697. _prepare(): void;
  38698. /**
  38699. * Execute the action and stop the sound.
  38700. */
  38701. execute(): void;
  38702. /**
  38703. * Serializes the actions and its related information.
  38704. * @param parent defines the object to serialize in
  38705. * @returns the serialized object
  38706. */
  38707. serialize(parent: any): any;
  38708. }
  38709. }
  38710. declare module "babylonjs/Actions/interpolateValueAction" {
  38711. import { Action } from "babylonjs/Actions/action";
  38712. import { Condition } from "babylonjs/Actions/condition";
  38713. import { Observable } from "babylonjs/Misc/observable";
  38714. /**
  38715. * This defines an action responsible to change the value of a property
  38716. * by interpolating between its current value and the newly set one once triggered.
  38717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38718. */
  38719. export class InterpolateValueAction extends Action {
  38720. /**
  38721. * Defines the path of the property where the value should be interpolated
  38722. */
  38723. propertyPath: string;
  38724. /**
  38725. * Defines the target value at the end of the interpolation.
  38726. */
  38727. value: any;
  38728. /**
  38729. * Defines the time it will take for the property to interpolate to the value.
  38730. */
  38731. duration: number;
  38732. /**
  38733. * Defines if the other scene animations should be stopped when the action has been triggered
  38734. */
  38735. stopOtherAnimations?: boolean;
  38736. /**
  38737. * Defines a callback raised once the interpolation animation has been done.
  38738. */
  38739. onInterpolationDone?: () => void;
  38740. /**
  38741. * Observable triggered once the interpolation animation has been done.
  38742. */
  38743. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38744. private _target;
  38745. private _effectiveTarget;
  38746. private _property;
  38747. /**
  38748. * Instantiate the action
  38749. * @param triggerOptions defines the trigger options
  38750. * @param target defines the object containing the value to interpolate
  38751. * @param propertyPath defines the path to the property in the target object
  38752. * @param value defines the target value at the end of the interpolation
  38753. * @param duration deines the time it will take for the property to interpolate to the value.
  38754. * @param condition defines the trigger related conditions
  38755. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38756. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38757. */
  38758. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38759. /** @hidden */
  38760. _prepare(): void;
  38761. /**
  38762. * Execute the action starts the value interpolation.
  38763. */
  38764. execute(): void;
  38765. /**
  38766. * Serializes the actions and its related information.
  38767. * @param parent defines the object to serialize in
  38768. * @returns the serialized object
  38769. */
  38770. serialize(parent: any): any;
  38771. }
  38772. }
  38773. declare module "babylonjs/Actions/index" {
  38774. export * from "babylonjs/Actions/abstractActionManager";
  38775. export * from "babylonjs/Actions/action";
  38776. export * from "babylonjs/Actions/actionEvent";
  38777. export * from "babylonjs/Actions/actionManager";
  38778. export * from "babylonjs/Actions/condition";
  38779. export * from "babylonjs/Actions/directActions";
  38780. export * from "babylonjs/Actions/directAudioActions";
  38781. export * from "babylonjs/Actions/interpolateValueAction";
  38782. }
  38783. declare module "babylonjs/Animations/index" {
  38784. export * from "babylonjs/Animations/animatable";
  38785. export * from "babylonjs/Animations/animation";
  38786. export * from "babylonjs/Animations/animationGroup";
  38787. export * from "babylonjs/Animations/animationPropertiesOverride";
  38788. export * from "babylonjs/Animations/easing";
  38789. export * from "babylonjs/Animations/runtimeAnimation";
  38790. export * from "babylonjs/Animations/animationEvent";
  38791. export * from "babylonjs/Animations/animationGroup";
  38792. export * from "babylonjs/Animations/animationKey";
  38793. export * from "babylonjs/Animations/animationRange";
  38794. export * from "babylonjs/Animations/animatable.interface";
  38795. }
  38796. declare module "babylonjs/Audio/soundTrack" {
  38797. import { Sound } from "babylonjs/Audio/sound";
  38798. import { Analyser } from "babylonjs/Audio/analyser";
  38799. import { Scene } from "babylonjs/scene";
  38800. /**
  38801. * Options allowed during the creation of a sound track.
  38802. */
  38803. export interface ISoundTrackOptions {
  38804. /**
  38805. * The volume the sound track should take during creation
  38806. */
  38807. volume?: number;
  38808. /**
  38809. * Define if the sound track is the main sound track of the scene
  38810. */
  38811. mainTrack?: boolean;
  38812. }
  38813. /**
  38814. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38815. * It will be also used in a future release to apply effects on a specific track.
  38816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38817. */
  38818. export class SoundTrack {
  38819. /**
  38820. * The unique identifier of the sound track in the scene.
  38821. */
  38822. id: number;
  38823. /**
  38824. * The list of sounds included in the sound track.
  38825. */
  38826. soundCollection: Array<Sound>;
  38827. private _outputAudioNode;
  38828. private _scene;
  38829. private _connectedAnalyser;
  38830. private _options;
  38831. private _isInitialized;
  38832. /**
  38833. * Creates a new sound track.
  38834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38835. * @param scene Define the scene the sound track belongs to
  38836. * @param options
  38837. */
  38838. constructor(scene: Scene, options?: ISoundTrackOptions);
  38839. private _initializeSoundTrackAudioGraph;
  38840. /**
  38841. * Release the sound track and its associated resources
  38842. */
  38843. dispose(): void;
  38844. /**
  38845. * Adds a sound to this sound track
  38846. * @param sound define the cound to add
  38847. * @ignoreNaming
  38848. */
  38849. AddSound(sound: Sound): void;
  38850. /**
  38851. * Removes a sound to this sound track
  38852. * @param sound define the cound to remove
  38853. * @ignoreNaming
  38854. */
  38855. RemoveSound(sound: Sound): void;
  38856. /**
  38857. * Set a global volume for the full sound track.
  38858. * @param newVolume Define the new volume of the sound track
  38859. */
  38860. setVolume(newVolume: number): void;
  38861. /**
  38862. * Switch the panning model to HRTF:
  38863. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38865. */
  38866. switchPanningModelToHRTF(): void;
  38867. /**
  38868. * Switch the panning model to Equal Power:
  38869. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38871. */
  38872. switchPanningModelToEqualPower(): void;
  38873. /**
  38874. * Connect the sound track to an audio analyser allowing some amazing
  38875. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38877. * @param analyser The analyser to connect to the engine
  38878. */
  38879. connectToAnalyser(analyser: Analyser): void;
  38880. }
  38881. }
  38882. declare module "babylonjs/Audio/audioSceneComponent" {
  38883. import { Sound } from "babylonjs/Audio/sound";
  38884. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38885. import { Nullable } from "babylonjs/types";
  38886. import { Vector3 } from "babylonjs/Maths/math.vector";
  38887. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38888. import { Scene } from "babylonjs/scene";
  38889. import { AbstractScene } from "babylonjs/abstractScene";
  38890. import "babylonjs/Audio/audioEngine";
  38891. module "babylonjs/abstractScene" {
  38892. interface AbstractScene {
  38893. /**
  38894. * The list of sounds used in the scene.
  38895. */
  38896. sounds: Nullable<Array<Sound>>;
  38897. }
  38898. }
  38899. module "babylonjs/scene" {
  38900. interface Scene {
  38901. /**
  38902. * @hidden
  38903. * Backing field
  38904. */
  38905. _mainSoundTrack: SoundTrack;
  38906. /**
  38907. * The main sound track played by the scene.
  38908. * It cotains your primary collection of sounds.
  38909. */
  38910. mainSoundTrack: SoundTrack;
  38911. /**
  38912. * The list of sound tracks added to the scene
  38913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38914. */
  38915. soundTracks: Nullable<Array<SoundTrack>>;
  38916. /**
  38917. * Gets a sound using a given name
  38918. * @param name defines the name to search for
  38919. * @return the found sound or null if not found at all.
  38920. */
  38921. getSoundByName(name: string): Nullable<Sound>;
  38922. /**
  38923. * Gets or sets if audio support is enabled
  38924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38925. */
  38926. audioEnabled: boolean;
  38927. /**
  38928. * Gets or sets if audio will be output to headphones
  38929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38930. */
  38931. headphone: boolean;
  38932. /**
  38933. * Gets or sets custom audio listener position provider
  38934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38935. */
  38936. audioListenerPositionProvider: Nullable<() => Vector3>;
  38937. /**
  38938. * Gets or sets a refresh rate when using 3D audio positioning
  38939. */
  38940. audioPositioningRefreshRate: number;
  38941. }
  38942. }
  38943. /**
  38944. * Defines the sound scene component responsible to manage any sounds
  38945. * in a given scene.
  38946. */
  38947. export class AudioSceneComponent implements ISceneSerializableComponent {
  38948. /**
  38949. * The component name helpfull to identify the component in the list of scene components.
  38950. */
  38951. readonly name: string;
  38952. /**
  38953. * The scene the component belongs to.
  38954. */
  38955. scene: Scene;
  38956. private _audioEnabled;
  38957. /**
  38958. * Gets whether audio is enabled or not.
  38959. * Please use related enable/disable method to switch state.
  38960. */
  38961. get audioEnabled(): boolean;
  38962. private _headphone;
  38963. /**
  38964. * Gets whether audio is outputing to headphone or not.
  38965. * Please use the according Switch methods to change output.
  38966. */
  38967. get headphone(): boolean;
  38968. /**
  38969. * Gets or sets a refresh rate when using 3D audio positioning
  38970. */
  38971. audioPositioningRefreshRate: number;
  38972. private _audioListenerPositionProvider;
  38973. /**
  38974. * Gets the current audio listener position provider
  38975. */
  38976. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38977. /**
  38978. * Sets a custom listener position for all sounds in the scene
  38979. * By default, this is the position of the first active camera
  38980. */
  38981. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38982. /**
  38983. * Creates a new instance of the component for the given scene
  38984. * @param scene Defines the scene to register the component in
  38985. */
  38986. constructor(scene: Scene);
  38987. /**
  38988. * Registers the component in a given scene
  38989. */
  38990. register(): void;
  38991. /**
  38992. * Rebuilds the elements related to this component in case of
  38993. * context lost for instance.
  38994. */
  38995. rebuild(): void;
  38996. /**
  38997. * Serializes the component data to the specified json object
  38998. * @param serializationObject The object to serialize to
  38999. */
  39000. serialize(serializationObject: any): void;
  39001. /**
  39002. * Adds all the elements from the container to the scene
  39003. * @param container the container holding the elements
  39004. */
  39005. addFromContainer(container: AbstractScene): void;
  39006. /**
  39007. * Removes all the elements in the container from the scene
  39008. * @param container contains the elements to remove
  39009. * @param dispose if the removed element should be disposed (default: false)
  39010. */
  39011. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39012. /**
  39013. * Disposes the component and the associated ressources.
  39014. */
  39015. dispose(): void;
  39016. /**
  39017. * Disables audio in the associated scene.
  39018. */
  39019. disableAudio(): void;
  39020. /**
  39021. * Enables audio in the associated scene.
  39022. */
  39023. enableAudio(): void;
  39024. /**
  39025. * Switch audio to headphone output.
  39026. */
  39027. switchAudioModeForHeadphones(): void;
  39028. /**
  39029. * Switch audio to normal speakers.
  39030. */
  39031. switchAudioModeForNormalSpeakers(): void;
  39032. private _cachedCameraDirection;
  39033. private _cachedCameraPosition;
  39034. private _lastCheck;
  39035. private _afterRender;
  39036. }
  39037. }
  39038. declare module "babylonjs/Audio/weightedsound" {
  39039. import { Sound } from "babylonjs/Audio/sound";
  39040. /**
  39041. * Wraps one or more Sound objects and selects one with random weight for playback.
  39042. */
  39043. export class WeightedSound {
  39044. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39045. loop: boolean;
  39046. private _coneInnerAngle;
  39047. private _coneOuterAngle;
  39048. private _volume;
  39049. /** A Sound is currently playing. */
  39050. isPlaying: boolean;
  39051. /** A Sound is currently paused. */
  39052. isPaused: boolean;
  39053. private _sounds;
  39054. private _weights;
  39055. private _currentIndex?;
  39056. /**
  39057. * Creates a new WeightedSound from the list of sounds given.
  39058. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39059. * @param sounds Array of Sounds that will be selected from.
  39060. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39061. */
  39062. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39063. /**
  39064. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39065. */
  39066. get directionalConeInnerAngle(): number;
  39067. /**
  39068. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39069. */
  39070. set directionalConeInnerAngle(value: number);
  39071. /**
  39072. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39073. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39074. */
  39075. get directionalConeOuterAngle(): number;
  39076. /**
  39077. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39078. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39079. */
  39080. set directionalConeOuterAngle(value: number);
  39081. /**
  39082. * Playback volume.
  39083. */
  39084. get volume(): number;
  39085. /**
  39086. * Playback volume.
  39087. */
  39088. set volume(value: number);
  39089. private _onended;
  39090. /**
  39091. * Suspend playback
  39092. */
  39093. pause(): void;
  39094. /**
  39095. * Stop playback
  39096. */
  39097. stop(): void;
  39098. /**
  39099. * Start playback.
  39100. * @param startOffset Position the clip head at a specific time in seconds.
  39101. */
  39102. play(startOffset?: number): void;
  39103. }
  39104. }
  39105. declare module "babylonjs/Audio/index" {
  39106. export * from "babylonjs/Audio/analyser";
  39107. export * from "babylonjs/Audio/audioEngine";
  39108. export * from "babylonjs/Audio/audioSceneComponent";
  39109. export * from "babylonjs/Audio/sound";
  39110. export * from "babylonjs/Audio/soundTrack";
  39111. export * from "babylonjs/Audio/weightedsound";
  39112. }
  39113. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39114. import { Behavior } from "babylonjs/Behaviors/behavior";
  39115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39116. import { BackEase } from "babylonjs/Animations/easing";
  39117. /**
  39118. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39120. */
  39121. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39122. /**
  39123. * Gets the name of the behavior.
  39124. */
  39125. get name(): string;
  39126. /**
  39127. * The easing function used by animations
  39128. */
  39129. static EasingFunction: BackEase;
  39130. /**
  39131. * The easing mode used by animations
  39132. */
  39133. static EasingMode: number;
  39134. /**
  39135. * The duration of the animation, in milliseconds
  39136. */
  39137. transitionDuration: number;
  39138. /**
  39139. * Length of the distance animated by the transition when lower radius is reached
  39140. */
  39141. lowerRadiusTransitionRange: number;
  39142. /**
  39143. * Length of the distance animated by the transition when upper radius is reached
  39144. */
  39145. upperRadiusTransitionRange: number;
  39146. private _autoTransitionRange;
  39147. /**
  39148. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39149. */
  39150. get autoTransitionRange(): boolean;
  39151. /**
  39152. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39153. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39154. */
  39155. set autoTransitionRange(value: boolean);
  39156. private _attachedCamera;
  39157. private _onAfterCheckInputsObserver;
  39158. private _onMeshTargetChangedObserver;
  39159. /**
  39160. * Initializes the behavior.
  39161. */
  39162. init(): void;
  39163. /**
  39164. * Attaches the behavior to its arc rotate camera.
  39165. * @param camera Defines the camera to attach the behavior to
  39166. */
  39167. attach(camera: ArcRotateCamera): void;
  39168. /**
  39169. * Detaches the behavior from its current arc rotate camera.
  39170. */
  39171. detach(): void;
  39172. private _radiusIsAnimating;
  39173. private _radiusBounceTransition;
  39174. private _animatables;
  39175. private _cachedWheelPrecision;
  39176. /**
  39177. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39178. * @param radiusLimit The limit to check against.
  39179. * @return Bool to indicate if at limit.
  39180. */
  39181. private _isRadiusAtLimit;
  39182. /**
  39183. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39184. * @param radiusDelta The delta by which to animate to. Can be negative.
  39185. */
  39186. private _applyBoundRadiusAnimation;
  39187. /**
  39188. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39189. */
  39190. protected _clearAnimationLocks(): void;
  39191. /**
  39192. * Stops and removes all animations that have been applied to the camera
  39193. */
  39194. stopAllAnimations(): void;
  39195. }
  39196. }
  39197. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39198. import { Behavior } from "babylonjs/Behaviors/behavior";
  39199. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39200. import { ExponentialEase } from "babylonjs/Animations/easing";
  39201. import { Nullable } from "babylonjs/types";
  39202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39203. import { Vector3 } from "babylonjs/Maths/math.vector";
  39204. /**
  39205. * 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.
  39206. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39207. */
  39208. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39209. /**
  39210. * Gets the name of the behavior.
  39211. */
  39212. get name(): string;
  39213. private _mode;
  39214. private _radiusScale;
  39215. private _positionScale;
  39216. private _defaultElevation;
  39217. private _elevationReturnTime;
  39218. private _elevationReturnWaitTime;
  39219. private _zoomStopsAnimation;
  39220. private _framingTime;
  39221. /**
  39222. * The easing function used by animations
  39223. */
  39224. static EasingFunction: ExponentialEase;
  39225. /**
  39226. * The easing mode used by animations
  39227. */
  39228. static EasingMode: number;
  39229. /**
  39230. * Sets the current mode used by the behavior
  39231. */
  39232. set mode(mode: number);
  39233. /**
  39234. * Gets current mode used by the behavior.
  39235. */
  39236. get mode(): number;
  39237. /**
  39238. * Sets the scale applied to the radius (1 by default)
  39239. */
  39240. set radiusScale(radius: number);
  39241. /**
  39242. * Gets the scale applied to the radius
  39243. */
  39244. get radiusScale(): number;
  39245. /**
  39246. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39247. */
  39248. set positionScale(scale: number);
  39249. /**
  39250. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39251. */
  39252. get positionScale(): number;
  39253. /**
  39254. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39255. * behaviour is triggered, in radians.
  39256. */
  39257. set defaultElevation(elevation: number);
  39258. /**
  39259. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39260. * behaviour is triggered, in radians.
  39261. */
  39262. get defaultElevation(): number;
  39263. /**
  39264. * Sets the time (in milliseconds) taken to return to the default beta position.
  39265. * Negative value indicates camera should not return to default.
  39266. */
  39267. set elevationReturnTime(speed: number);
  39268. /**
  39269. * Gets the time (in milliseconds) taken to return to the default beta position.
  39270. * Negative value indicates camera should not return to default.
  39271. */
  39272. get elevationReturnTime(): number;
  39273. /**
  39274. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39275. */
  39276. set elevationReturnWaitTime(time: number);
  39277. /**
  39278. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39279. */
  39280. get elevationReturnWaitTime(): number;
  39281. /**
  39282. * Sets the flag that indicates if user zooming should stop animation.
  39283. */
  39284. set zoomStopsAnimation(flag: boolean);
  39285. /**
  39286. * Gets the flag that indicates if user zooming should stop animation.
  39287. */
  39288. get zoomStopsAnimation(): boolean;
  39289. /**
  39290. * Sets the transition time when framing the mesh, in milliseconds
  39291. */
  39292. set framingTime(time: number);
  39293. /**
  39294. * Gets the transition time when framing the mesh, in milliseconds
  39295. */
  39296. get framingTime(): number;
  39297. /**
  39298. * Define if the behavior should automatically change the configured
  39299. * camera limits and sensibilities.
  39300. */
  39301. autoCorrectCameraLimitsAndSensibility: boolean;
  39302. private _onPrePointerObservableObserver;
  39303. private _onAfterCheckInputsObserver;
  39304. private _onMeshTargetChangedObserver;
  39305. private _attachedCamera;
  39306. private _isPointerDown;
  39307. private _lastInteractionTime;
  39308. /**
  39309. * Initializes the behavior.
  39310. */
  39311. init(): void;
  39312. /**
  39313. * Attaches the behavior to its arc rotate camera.
  39314. * @param camera Defines the camera to attach the behavior to
  39315. */
  39316. attach(camera: ArcRotateCamera): void;
  39317. /**
  39318. * Detaches the behavior from its current arc rotate camera.
  39319. */
  39320. detach(): void;
  39321. private _animatables;
  39322. private _betaIsAnimating;
  39323. private _betaTransition;
  39324. private _radiusTransition;
  39325. private _vectorTransition;
  39326. /**
  39327. * Targets the given mesh and updates zoom level accordingly.
  39328. * @param mesh The mesh to target.
  39329. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39330. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39331. */
  39332. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39333. /**
  39334. * Targets the given mesh with its children and updates zoom level accordingly.
  39335. * @param mesh The mesh to target.
  39336. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39337. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39338. */
  39339. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39340. /**
  39341. * Targets the given meshes with their children and updates zoom level accordingly.
  39342. * @param meshes The mesh to target.
  39343. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39344. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39345. */
  39346. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39347. /**
  39348. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39349. * @param minimumWorld Determines the smaller position of the bounding box extend
  39350. * @param maximumWorld Determines the bigger position of the bounding box extend
  39351. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39352. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39353. */
  39354. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39355. /**
  39356. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39357. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39358. * frustum width.
  39359. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39360. * to fully enclose the mesh in the viewing frustum.
  39361. */
  39362. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39363. /**
  39364. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39365. * is automatically returned to its default position (expected to be above ground plane).
  39366. */
  39367. private _maintainCameraAboveGround;
  39368. /**
  39369. * Returns the frustum slope based on the canvas ratio and camera FOV
  39370. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39371. */
  39372. private _getFrustumSlope;
  39373. /**
  39374. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39375. */
  39376. private _clearAnimationLocks;
  39377. /**
  39378. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39379. */
  39380. private _applyUserInteraction;
  39381. /**
  39382. * Stops and removes all animations that have been applied to the camera
  39383. */
  39384. stopAllAnimations(): void;
  39385. /**
  39386. * Gets a value indicating if the user is moving the camera
  39387. */
  39388. get isUserIsMoving(): boolean;
  39389. /**
  39390. * The camera can move all the way towards the mesh.
  39391. */
  39392. static IgnoreBoundsSizeMode: number;
  39393. /**
  39394. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39395. */
  39396. static FitFrustumSidesMode: number;
  39397. }
  39398. }
  39399. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39400. import { Nullable } from "babylonjs/types";
  39401. import { Camera } from "babylonjs/Cameras/camera";
  39402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39403. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39404. /**
  39405. * Base class for Camera Pointer Inputs.
  39406. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39407. * for example usage.
  39408. */
  39409. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39410. /**
  39411. * Defines the camera the input is attached to.
  39412. */
  39413. abstract camera: Camera;
  39414. /**
  39415. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39416. */
  39417. protected _altKey: boolean;
  39418. protected _ctrlKey: boolean;
  39419. protected _metaKey: boolean;
  39420. protected _shiftKey: boolean;
  39421. /**
  39422. * Which mouse buttons were pressed at time of last mouse event.
  39423. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39424. */
  39425. protected _buttonsPressed: number;
  39426. /**
  39427. * Defines the buttons associated with the input to handle camera move.
  39428. */
  39429. buttons: number[];
  39430. /**
  39431. * Attach the input controls to a specific dom element to get the input from.
  39432. * @param element Defines the element the controls should be listened from
  39433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39434. */
  39435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39436. /**
  39437. * Detach the current controls from the specified dom element.
  39438. * @param element Defines the element to stop listening the inputs from
  39439. */
  39440. detachControl(element: Nullable<HTMLElement>): void;
  39441. /**
  39442. * Gets the class name of the current input.
  39443. * @returns the class name
  39444. */
  39445. getClassName(): string;
  39446. /**
  39447. * Get the friendly name associated with the input class.
  39448. * @returns the input friendly name
  39449. */
  39450. getSimpleName(): string;
  39451. /**
  39452. * Called on pointer POINTERDOUBLETAP event.
  39453. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39454. */
  39455. protected onDoubleTap(type: string): void;
  39456. /**
  39457. * Called on pointer POINTERMOVE event if only a single touch is active.
  39458. * Override this method to provide functionality.
  39459. */
  39460. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39461. /**
  39462. * Called on pointer POINTERMOVE event if multiple touches are active.
  39463. * Override this method to provide functionality.
  39464. */
  39465. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39466. /**
  39467. * Called on JS contextmenu event.
  39468. * Override this method to provide functionality.
  39469. */
  39470. protected onContextMenu(evt: PointerEvent): void;
  39471. /**
  39472. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39473. * press.
  39474. * Override this method to provide functionality.
  39475. */
  39476. protected onButtonDown(evt: PointerEvent): void;
  39477. /**
  39478. * Called each time a new POINTERUP event occurs. Ie, for each button
  39479. * release.
  39480. * Override this method to provide functionality.
  39481. */
  39482. protected onButtonUp(evt: PointerEvent): void;
  39483. /**
  39484. * Called when window becomes inactive.
  39485. * Override this method to provide functionality.
  39486. */
  39487. protected onLostFocus(): void;
  39488. private _pointerInput;
  39489. private _observer;
  39490. private _onLostFocus;
  39491. private pointA;
  39492. private pointB;
  39493. }
  39494. }
  39495. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39496. import { Nullable } from "babylonjs/types";
  39497. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39498. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39499. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39500. /**
  39501. * Manage the pointers inputs to control an arc rotate camera.
  39502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39503. */
  39504. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39505. /**
  39506. * Defines the camera the input is attached to.
  39507. */
  39508. camera: ArcRotateCamera;
  39509. /**
  39510. * Gets the class name of the current input.
  39511. * @returns the class name
  39512. */
  39513. getClassName(): string;
  39514. /**
  39515. * Defines the buttons associated with the input to handle camera move.
  39516. */
  39517. buttons: number[];
  39518. /**
  39519. * Defines the pointer angular sensibility along the X axis or how fast is
  39520. * the camera rotating.
  39521. */
  39522. angularSensibilityX: number;
  39523. /**
  39524. * Defines the pointer angular sensibility along the Y axis or how fast is
  39525. * the camera rotating.
  39526. */
  39527. angularSensibilityY: number;
  39528. /**
  39529. * Defines the pointer pinch precision or how fast is the camera zooming.
  39530. */
  39531. pinchPrecision: number;
  39532. /**
  39533. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39534. * from 0.
  39535. * It defines the percentage of current camera.radius to use as delta when
  39536. * pinch zoom is used.
  39537. */
  39538. pinchDeltaPercentage: number;
  39539. /**
  39540. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39541. * that any object in the plane at the camera's target point will scale
  39542. * perfectly with finger motion.
  39543. * Overrides pinchDeltaPercentage and pinchPrecision.
  39544. */
  39545. useNaturalPinchZoom: boolean;
  39546. /**
  39547. * Defines the pointer panning sensibility or how fast is the camera moving.
  39548. */
  39549. panningSensibility: number;
  39550. /**
  39551. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39552. */
  39553. multiTouchPanning: boolean;
  39554. /**
  39555. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39556. * zoom (pinch) through multitouch.
  39557. */
  39558. multiTouchPanAndZoom: boolean;
  39559. /**
  39560. * Revers pinch action direction.
  39561. */
  39562. pinchInwards: boolean;
  39563. private _isPanClick;
  39564. private _twoFingerActivityCount;
  39565. private _isPinching;
  39566. /**
  39567. * Called on pointer POINTERMOVE event if only a single touch is active.
  39568. */
  39569. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39570. /**
  39571. * Called on pointer POINTERDOUBLETAP event.
  39572. */
  39573. protected onDoubleTap(type: string): void;
  39574. /**
  39575. * Called on pointer POINTERMOVE event if multiple touches are active.
  39576. */
  39577. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39578. /**
  39579. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39580. * press.
  39581. */
  39582. protected onButtonDown(evt: PointerEvent): void;
  39583. /**
  39584. * Called each time a new POINTERUP event occurs. Ie, for each button
  39585. * release.
  39586. */
  39587. protected onButtonUp(evt: PointerEvent): void;
  39588. /**
  39589. * Called when window becomes inactive.
  39590. */
  39591. protected onLostFocus(): void;
  39592. }
  39593. }
  39594. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39595. import { Nullable } from "babylonjs/types";
  39596. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39597. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39598. /**
  39599. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39601. */
  39602. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39603. /**
  39604. * Defines the camera the input is attached to.
  39605. */
  39606. camera: ArcRotateCamera;
  39607. /**
  39608. * Defines the list of key codes associated with the up action (increase alpha)
  39609. */
  39610. keysUp: number[];
  39611. /**
  39612. * Defines the list of key codes associated with the down action (decrease alpha)
  39613. */
  39614. keysDown: number[];
  39615. /**
  39616. * Defines the list of key codes associated with the left action (increase beta)
  39617. */
  39618. keysLeft: number[];
  39619. /**
  39620. * Defines the list of key codes associated with the right action (decrease beta)
  39621. */
  39622. keysRight: number[];
  39623. /**
  39624. * Defines the list of key codes associated with the reset action.
  39625. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39626. */
  39627. keysReset: number[];
  39628. /**
  39629. * Defines the panning sensibility of the inputs.
  39630. * (How fast is the camera panning)
  39631. */
  39632. panningSensibility: number;
  39633. /**
  39634. * Defines the zooming sensibility of the inputs.
  39635. * (How fast is the camera zooming)
  39636. */
  39637. zoomingSensibility: number;
  39638. /**
  39639. * Defines whether maintaining the alt key down switch the movement mode from
  39640. * orientation to zoom.
  39641. */
  39642. useAltToZoom: boolean;
  39643. /**
  39644. * Rotation speed of the camera
  39645. */
  39646. angularSpeed: number;
  39647. private _keys;
  39648. private _ctrlPressed;
  39649. private _altPressed;
  39650. private _onCanvasBlurObserver;
  39651. private _onKeyboardObserver;
  39652. private _engine;
  39653. private _scene;
  39654. /**
  39655. * Attach the input controls to a specific dom element to get the input from.
  39656. * @param element Defines the element the controls should be listened from
  39657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39658. */
  39659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39660. /**
  39661. * Detach the current controls from the specified dom element.
  39662. * @param element Defines the element to stop listening the inputs from
  39663. */
  39664. detachControl(element: Nullable<HTMLElement>): void;
  39665. /**
  39666. * Update the current camera state depending on the inputs that have been used this frame.
  39667. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39668. */
  39669. checkInputs(): void;
  39670. /**
  39671. * Gets the class name of the current intput.
  39672. * @returns the class name
  39673. */
  39674. getClassName(): string;
  39675. /**
  39676. * Get the friendly name associated with the input class.
  39677. * @returns the input friendly name
  39678. */
  39679. getSimpleName(): string;
  39680. }
  39681. }
  39682. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39683. import { Nullable } from "babylonjs/types";
  39684. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39685. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39686. /**
  39687. * Manage the mouse wheel inputs to control an arc rotate camera.
  39688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39689. */
  39690. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39691. /**
  39692. * Defines the camera the input is attached to.
  39693. */
  39694. camera: ArcRotateCamera;
  39695. /**
  39696. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39697. */
  39698. wheelPrecision: number;
  39699. /**
  39700. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39701. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39702. */
  39703. wheelDeltaPercentage: number;
  39704. private _wheel;
  39705. private _observer;
  39706. private computeDeltaFromMouseWheelLegacyEvent;
  39707. /**
  39708. * Attach the input controls to a specific dom element to get the input from.
  39709. * @param element Defines the element the controls should be listened from
  39710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39711. */
  39712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39713. /**
  39714. * Detach the current controls from the specified dom element.
  39715. * @param element Defines the element to stop listening the inputs from
  39716. */
  39717. detachControl(element: Nullable<HTMLElement>): void;
  39718. /**
  39719. * Gets the class name of the current intput.
  39720. * @returns the class name
  39721. */
  39722. getClassName(): string;
  39723. /**
  39724. * Get the friendly name associated with the input class.
  39725. * @returns the input friendly name
  39726. */
  39727. getSimpleName(): string;
  39728. }
  39729. }
  39730. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39732. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39733. /**
  39734. * Default Inputs manager for the ArcRotateCamera.
  39735. * It groups all the default supported inputs for ease of use.
  39736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39737. */
  39738. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39739. /**
  39740. * Instantiates a new ArcRotateCameraInputsManager.
  39741. * @param camera Defines the camera the inputs belong to
  39742. */
  39743. constructor(camera: ArcRotateCamera);
  39744. /**
  39745. * Add mouse wheel input support to the input manager.
  39746. * @returns the current input manager
  39747. */
  39748. addMouseWheel(): ArcRotateCameraInputsManager;
  39749. /**
  39750. * Add pointers input support to the input manager.
  39751. * @returns the current input manager
  39752. */
  39753. addPointers(): ArcRotateCameraInputsManager;
  39754. /**
  39755. * Add keyboard input support to the input manager.
  39756. * @returns the current input manager
  39757. */
  39758. addKeyboard(): ArcRotateCameraInputsManager;
  39759. }
  39760. }
  39761. declare module "babylonjs/Cameras/arcRotateCamera" {
  39762. import { Observable } from "babylonjs/Misc/observable";
  39763. import { Nullable } from "babylonjs/types";
  39764. import { Scene } from "babylonjs/scene";
  39765. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39767. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39768. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39769. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39770. import { Camera } from "babylonjs/Cameras/camera";
  39771. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39772. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39773. import { Collider } from "babylonjs/Collisions/collider";
  39774. /**
  39775. * This represents an orbital type of camera.
  39776. *
  39777. * 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.
  39778. * 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.
  39779. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39780. */
  39781. export class ArcRotateCamera extends TargetCamera {
  39782. /**
  39783. * Defines the rotation angle of the camera along the longitudinal axis.
  39784. */
  39785. alpha: number;
  39786. /**
  39787. * Defines the rotation angle of the camera along the latitudinal axis.
  39788. */
  39789. beta: number;
  39790. /**
  39791. * Defines the radius of the camera from it s target point.
  39792. */
  39793. radius: number;
  39794. protected _target: Vector3;
  39795. protected _targetHost: Nullable<AbstractMesh>;
  39796. /**
  39797. * Defines the target point of the camera.
  39798. * The camera looks towards it form the radius distance.
  39799. */
  39800. get target(): Vector3;
  39801. set target(value: Vector3);
  39802. /**
  39803. * Define the current local position of the camera in the scene
  39804. */
  39805. get position(): Vector3;
  39806. set position(newPosition: Vector3);
  39807. protected _upVector: Vector3;
  39808. protected _upToYMatrix: Matrix;
  39809. protected _YToUpMatrix: Matrix;
  39810. /**
  39811. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39812. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39813. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39814. */
  39815. set upVector(vec: Vector3);
  39816. get upVector(): Vector3;
  39817. /**
  39818. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39819. */
  39820. setMatUp(): void;
  39821. /**
  39822. * Current inertia value on the longitudinal axis.
  39823. * The bigger this number the longer it will take for the camera to stop.
  39824. */
  39825. inertialAlphaOffset: number;
  39826. /**
  39827. * Current inertia value on the latitudinal axis.
  39828. * The bigger this number the longer it will take for the camera to stop.
  39829. */
  39830. inertialBetaOffset: number;
  39831. /**
  39832. * Current inertia value on the radius axis.
  39833. * The bigger this number the longer it will take for the camera to stop.
  39834. */
  39835. inertialRadiusOffset: number;
  39836. /**
  39837. * Minimum allowed angle on the longitudinal axis.
  39838. * This can help limiting how the Camera is able to move in the scene.
  39839. */
  39840. lowerAlphaLimit: Nullable<number>;
  39841. /**
  39842. * Maximum allowed angle on the longitudinal axis.
  39843. * This can help limiting how the Camera is able to move in the scene.
  39844. */
  39845. upperAlphaLimit: Nullable<number>;
  39846. /**
  39847. * Minimum allowed angle on the latitudinal axis.
  39848. * This can help limiting how the Camera is able to move in the scene.
  39849. */
  39850. lowerBetaLimit: number;
  39851. /**
  39852. * Maximum allowed angle on the latitudinal axis.
  39853. * This can help limiting how the Camera is able to move in the scene.
  39854. */
  39855. upperBetaLimit: number;
  39856. /**
  39857. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39858. * This can help limiting how the Camera is able to move in the scene.
  39859. */
  39860. lowerRadiusLimit: Nullable<number>;
  39861. /**
  39862. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39863. * This can help limiting how the Camera is able to move in the scene.
  39864. */
  39865. upperRadiusLimit: Nullable<number>;
  39866. /**
  39867. * Defines the current inertia value used during panning of the camera along the X axis.
  39868. */
  39869. inertialPanningX: number;
  39870. /**
  39871. * Defines the current inertia value used during panning of the camera along the Y axis.
  39872. */
  39873. inertialPanningY: number;
  39874. /**
  39875. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39876. * Basically if your fingers moves away from more than this distance you will be considered
  39877. * in pinch mode.
  39878. */
  39879. pinchToPanMaxDistance: number;
  39880. /**
  39881. * Defines the maximum distance the camera can pan.
  39882. * This could help keeping the cammera always in your scene.
  39883. */
  39884. panningDistanceLimit: Nullable<number>;
  39885. /**
  39886. * Defines the target of the camera before paning.
  39887. */
  39888. panningOriginTarget: Vector3;
  39889. /**
  39890. * Defines the value of the inertia used during panning.
  39891. * 0 would mean stop inertia and one would mean no decelleration at all.
  39892. */
  39893. panningInertia: number;
  39894. /**
  39895. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39896. */
  39897. get angularSensibilityX(): number;
  39898. set angularSensibilityX(value: number);
  39899. /**
  39900. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39901. */
  39902. get angularSensibilityY(): number;
  39903. set angularSensibilityY(value: number);
  39904. /**
  39905. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39906. */
  39907. get pinchPrecision(): number;
  39908. set pinchPrecision(value: number);
  39909. /**
  39910. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39911. * It will be used instead of pinchDeltaPrecision if different from 0.
  39912. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39913. */
  39914. get pinchDeltaPercentage(): number;
  39915. set pinchDeltaPercentage(value: number);
  39916. /**
  39917. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39918. * and pinch delta percentage.
  39919. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39920. * that any object in the plane at the camera's target point will scale
  39921. * perfectly with finger motion.
  39922. */
  39923. get useNaturalPinchZoom(): boolean;
  39924. set useNaturalPinchZoom(value: boolean);
  39925. /**
  39926. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39927. */
  39928. get panningSensibility(): number;
  39929. set panningSensibility(value: number);
  39930. /**
  39931. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39932. */
  39933. get keysUp(): number[];
  39934. set keysUp(value: number[]);
  39935. /**
  39936. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39937. */
  39938. get keysDown(): number[];
  39939. set keysDown(value: number[]);
  39940. /**
  39941. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39942. */
  39943. get keysLeft(): number[];
  39944. set keysLeft(value: number[]);
  39945. /**
  39946. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39947. */
  39948. get keysRight(): number[];
  39949. set keysRight(value: number[]);
  39950. /**
  39951. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39952. */
  39953. get wheelPrecision(): number;
  39954. set wheelPrecision(value: number);
  39955. /**
  39956. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39957. * It will be used instead of pinchDeltaPrecision if different from 0.
  39958. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39959. */
  39960. get wheelDeltaPercentage(): number;
  39961. set wheelDeltaPercentage(value: number);
  39962. /**
  39963. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39964. */
  39965. zoomOnFactor: number;
  39966. /**
  39967. * Defines a screen offset for the camera position.
  39968. */
  39969. targetScreenOffset: Vector2;
  39970. /**
  39971. * Allows the camera to be completely reversed.
  39972. * If false the camera can not arrive upside down.
  39973. */
  39974. allowUpsideDown: boolean;
  39975. /**
  39976. * Define if double tap/click is used to restore the previously saved state of the camera.
  39977. */
  39978. useInputToRestoreState: boolean;
  39979. /** @hidden */
  39980. _viewMatrix: Matrix;
  39981. /** @hidden */
  39982. _useCtrlForPanning: boolean;
  39983. /** @hidden */
  39984. _panningMouseButton: number;
  39985. /**
  39986. * Defines the input associated to the camera.
  39987. */
  39988. inputs: ArcRotateCameraInputsManager;
  39989. /** @hidden */
  39990. _reset: () => void;
  39991. /**
  39992. * Defines the allowed panning axis.
  39993. */
  39994. panningAxis: Vector3;
  39995. protected _localDirection: Vector3;
  39996. protected _transformedDirection: Vector3;
  39997. private _bouncingBehavior;
  39998. /**
  39999. * Gets the bouncing behavior of the camera if it has been enabled.
  40000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40001. */
  40002. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40003. /**
  40004. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40005. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40006. */
  40007. get useBouncingBehavior(): boolean;
  40008. set useBouncingBehavior(value: boolean);
  40009. private _framingBehavior;
  40010. /**
  40011. * Gets the framing behavior of the camera if it has been enabled.
  40012. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40013. */
  40014. get framingBehavior(): Nullable<FramingBehavior>;
  40015. /**
  40016. * Defines if the framing behavior of the camera is enabled on the camera.
  40017. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40018. */
  40019. get useFramingBehavior(): boolean;
  40020. set useFramingBehavior(value: boolean);
  40021. private _autoRotationBehavior;
  40022. /**
  40023. * Gets the auto rotation behavior of the camera if it has been enabled.
  40024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40025. */
  40026. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40027. /**
  40028. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40030. */
  40031. get useAutoRotationBehavior(): boolean;
  40032. set useAutoRotationBehavior(value: boolean);
  40033. /**
  40034. * Observable triggered when the mesh target has been changed on the camera.
  40035. */
  40036. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40037. /**
  40038. * Event raised when the camera is colliding with a mesh.
  40039. */
  40040. onCollide: (collidedMesh: AbstractMesh) => void;
  40041. /**
  40042. * Defines whether the camera should check collision with the objects oh the scene.
  40043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40044. */
  40045. checkCollisions: boolean;
  40046. /**
  40047. * Defines the collision radius of the camera.
  40048. * This simulates a sphere around the camera.
  40049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40050. */
  40051. collisionRadius: Vector3;
  40052. protected _collider: Collider;
  40053. protected _previousPosition: Vector3;
  40054. protected _collisionVelocity: Vector3;
  40055. protected _newPosition: Vector3;
  40056. protected _previousAlpha: number;
  40057. protected _previousBeta: number;
  40058. protected _previousRadius: number;
  40059. protected _collisionTriggered: boolean;
  40060. protected _targetBoundingCenter: Nullable<Vector3>;
  40061. private _computationVector;
  40062. /**
  40063. * Instantiates a new ArcRotateCamera in a given scene
  40064. * @param name Defines the name of the camera
  40065. * @param alpha Defines the camera rotation along the logitudinal axis
  40066. * @param beta Defines the camera rotation along the latitudinal axis
  40067. * @param radius Defines the camera distance from its target
  40068. * @param target Defines the camera target
  40069. * @param scene Defines the scene the camera belongs to
  40070. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40071. */
  40072. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40073. /** @hidden */
  40074. _initCache(): void;
  40075. /** @hidden */
  40076. _updateCache(ignoreParentClass?: boolean): void;
  40077. protected _getTargetPosition(): Vector3;
  40078. private _storedAlpha;
  40079. private _storedBeta;
  40080. private _storedRadius;
  40081. private _storedTarget;
  40082. private _storedTargetScreenOffset;
  40083. /**
  40084. * Stores the current state of the camera (alpha, beta, radius and target)
  40085. * @returns the camera itself
  40086. */
  40087. storeState(): Camera;
  40088. /**
  40089. * @hidden
  40090. * Restored camera state. You must call storeState() first
  40091. */
  40092. _restoreStateValues(): boolean;
  40093. /** @hidden */
  40094. _isSynchronizedViewMatrix(): boolean;
  40095. /**
  40096. * Attached controls to the current camera.
  40097. * @param element Defines the element the controls should be listened from
  40098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40099. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40100. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40101. */
  40102. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40103. /**
  40104. * Detach the current controls from the camera.
  40105. * The camera will stop reacting to inputs.
  40106. * @param element Defines the element to stop listening the inputs from
  40107. */
  40108. detachControl(element: HTMLElement): void;
  40109. /** @hidden */
  40110. _checkInputs(): void;
  40111. protected _checkLimits(): void;
  40112. /**
  40113. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40114. */
  40115. rebuildAnglesAndRadius(): void;
  40116. /**
  40117. * Use a position to define the current camera related information like alpha, beta and radius
  40118. * @param position Defines the position to set the camera at
  40119. */
  40120. setPosition(position: Vector3): void;
  40121. /**
  40122. * Defines the target the camera should look at.
  40123. * This will automatically adapt alpha beta and radius to fit within the new target.
  40124. * @param target Defines the new target as a Vector or a mesh
  40125. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40126. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40127. */
  40128. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40129. /** @hidden */
  40130. _getViewMatrix(): Matrix;
  40131. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40132. /**
  40133. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40134. * @param meshes Defines the mesh to zoom on
  40135. * @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)
  40136. */
  40137. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40138. /**
  40139. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40140. * The target will be changed but the radius
  40141. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40142. * @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)
  40143. */
  40144. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40145. min: Vector3;
  40146. max: Vector3;
  40147. distance: number;
  40148. }, doNotUpdateMaxZ?: boolean): void;
  40149. /**
  40150. * @override
  40151. * Override Camera.createRigCamera
  40152. */
  40153. createRigCamera(name: string, cameraIndex: number): Camera;
  40154. /**
  40155. * @hidden
  40156. * @override
  40157. * Override Camera._updateRigCameras
  40158. */
  40159. _updateRigCameras(): void;
  40160. /**
  40161. * Destroy the camera and release the current resources hold by it.
  40162. */
  40163. dispose(): void;
  40164. /**
  40165. * Gets the current object class name.
  40166. * @return the class name
  40167. */
  40168. getClassName(): string;
  40169. }
  40170. }
  40171. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40172. import { Behavior } from "babylonjs/Behaviors/behavior";
  40173. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40174. /**
  40175. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40176. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40177. */
  40178. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40179. /**
  40180. * Gets the name of the behavior.
  40181. */
  40182. get name(): string;
  40183. private _zoomStopsAnimation;
  40184. private _idleRotationSpeed;
  40185. private _idleRotationWaitTime;
  40186. private _idleRotationSpinupTime;
  40187. /**
  40188. * Sets the flag that indicates if user zooming should stop animation.
  40189. */
  40190. set zoomStopsAnimation(flag: boolean);
  40191. /**
  40192. * Gets the flag that indicates if user zooming should stop animation.
  40193. */
  40194. get zoomStopsAnimation(): boolean;
  40195. /**
  40196. * Sets the default speed at which the camera rotates around the model.
  40197. */
  40198. set idleRotationSpeed(speed: number);
  40199. /**
  40200. * Gets the default speed at which the camera rotates around the model.
  40201. */
  40202. get idleRotationSpeed(): number;
  40203. /**
  40204. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40205. */
  40206. set idleRotationWaitTime(time: number);
  40207. /**
  40208. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40209. */
  40210. get idleRotationWaitTime(): number;
  40211. /**
  40212. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40213. */
  40214. set idleRotationSpinupTime(time: number);
  40215. /**
  40216. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40217. */
  40218. get idleRotationSpinupTime(): number;
  40219. /**
  40220. * Gets a value indicating if the camera is currently rotating because of this behavior
  40221. */
  40222. get rotationInProgress(): boolean;
  40223. private _onPrePointerObservableObserver;
  40224. private _onAfterCheckInputsObserver;
  40225. private _attachedCamera;
  40226. private _isPointerDown;
  40227. private _lastFrameTime;
  40228. private _lastInteractionTime;
  40229. private _cameraRotationSpeed;
  40230. /**
  40231. * Initializes the behavior.
  40232. */
  40233. init(): void;
  40234. /**
  40235. * Attaches the behavior to its arc rotate camera.
  40236. * @param camera Defines the camera to attach the behavior to
  40237. */
  40238. attach(camera: ArcRotateCamera): void;
  40239. /**
  40240. * Detaches the behavior from its current arc rotate camera.
  40241. */
  40242. detach(): void;
  40243. /**
  40244. * Returns true if user is scrolling.
  40245. * @return true if user is scrolling.
  40246. */
  40247. private _userIsZooming;
  40248. private _lastFrameRadius;
  40249. private _shouldAnimationStopForInteraction;
  40250. /**
  40251. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40252. */
  40253. private _applyUserInteraction;
  40254. private _userIsMoving;
  40255. }
  40256. }
  40257. declare module "babylonjs/Behaviors/Cameras/index" {
  40258. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40259. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40260. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40261. }
  40262. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40263. import { Mesh } from "babylonjs/Meshes/mesh";
  40264. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40265. import { Behavior } from "babylonjs/Behaviors/behavior";
  40266. /**
  40267. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40268. */
  40269. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40270. private ui;
  40271. /**
  40272. * The name of the behavior
  40273. */
  40274. name: string;
  40275. /**
  40276. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40277. */
  40278. distanceAwayFromFace: number;
  40279. /**
  40280. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40281. */
  40282. distanceAwayFromBottomOfFace: number;
  40283. private _faceVectors;
  40284. private _target;
  40285. private _scene;
  40286. private _onRenderObserver;
  40287. private _tmpMatrix;
  40288. private _tmpVector;
  40289. /**
  40290. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40291. * @param ui The transform node that should be attched to the mesh
  40292. */
  40293. constructor(ui: TransformNode);
  40294. /**
  40295. * Initializes the behavior
  40296. */
  40297. init(): void;
  40298. private _closestFace;
  40299. private _zeroVector;
  40300. private _lookAtTmpMatrix;
  40301. private _lookAtToRef;
  40302. /**
  40303. * Attaches the AttachToBoxBehavior to the passed in mesh
  40304. * @param target The mesh that the specified node will be attached to
  40305. */
  40306. attach(target: Mesh): void;
  40307. /**
  40308. * Detaches the behavior from the mesh
  40309. */
  40310. detach(): void;
  40311. }
  40312. }
  40313. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40314. import { Behavior } from "babylonjs/Behaviors/behavior";
  40315. import { Mesh } from "babylonjs/Meshes/mesh";
  40316. /**
  40317. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40318. */
  40319. export class FadeInOutBehavior implements Behavior<Mesh> {
  40320. /**
  40321. * Time in milliseconds to delay before fading in (Default: 0)
  40322. */
  40323. delay: number;
  40324. /**
  40325. * Time in milliseconds for the mesh to fade in (Default: 300)
  40326. */
  40327. fadeInTime: number;
  40328. private _millisecondsPerFrame;
  40329. private _hovered;
  40330. private _hoverValue;
  40331. private _ownerNode;
  40332. /**
  40333. * Instatiates the FadeInOutBehavior
  40334. */
  40335. constructor();
  40336. /**
  40337. * The name of the behavior
  40338. */
  40339. get name(): string;
  40340. /**
  40341. * Initializes the behavior
  40342. */
  40343. init(): void;
  40344. /**
  40345. * Attaches the fade behavior on the passed in mesh
  40346. * @param ownerNode The mesh that will be faded in/out once attached
  40347. */
  40348. attach(ownerNode: Mesh): void;
  40349. /**
  40350. * Detaches the behavior from the mesh
  40351. */
  40352. detach(): void;
  40353. /**
  40354. * Triggers the mesh to begin fading in or out
  40355. * @param value if the object should fade in or out (true to fade in)
  40356. */
  40357. fadeIn(value: boolean): void;
  40358. private _update;
  40359. private _setAllVisibility;
  40360. }
  40361. }
  40362. declare module "babylonjs/Misc/pivotTools" {
  40363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40364. /**
  40365. * Class containing a set of static utilities functions for managing Pivots
  40366. * @hidden
  40367. */
  40368. export class PivotTools {
  40369. private static _PivotCached;
  40370. private static _OldPivotPoint;
  40371. private static _PivotTranslation;
  40372. private static _PivotTmpVector;
  40373. /** @hidden */
  40374. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40375. /** @hidden */
  40376. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40377. }
  40378. }
  40379. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40380. import { Scene } from "babylonjs/scene";
  40381. import { Vector4 } from "babylonjs/Maths/math.vector";
  40382. import { Mesh } from "babylonjs/Meshes/mesh";
  40383. import { Nullable } from "babylonjs/types";
  40384. import { Plane } from "babylonjs/Maths/math.plane";
  40385. /**
  40386. * Class containing static functions to help procedurally build meshes
  40387. */
  40388. export class PlaneBuilder {
  40389. /**
  40390. * Creates a plane mesh
  40391. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40392. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40393. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40397. * @param name defines the name of the mesh
  40398. * @param options defines the options used to create the mesh
  40399. * @param scene defines the hosting scene
  40400. * @returns the plane mesh
  40401. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40402. */
  40403. static CreatePlane(name: string, options: {
  40404. size?: number;
  40405. width?: number;
  40406. height?: number;
  40407. sideOrientation?: number;
  40408. frontUVs?: Vector4;
  40409. backUVs?: Vector4;
  40410. updatable?: boolean;
  40411. sourcePlane?: Plane;
  40412. }, scene?: Nullable<Scene>): Mesh;
  40413. }
  40414. }
  40415. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40416. import { Behavior } from "babylonjs/Behaviors/behavior";
  40417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40418. import { Observable } from "babylonjs/Misc/observable";
  40419. import { Vector3 } from "babylonjs/Maths/math.vector";
  40420. import { Ray } from "babylonjs/Culling/ray";
  40421. import "babylonjs/Meshes/Builders/planeBuilder";
  40422. /**
  40423. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40424. */
  40425. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40426. private static _AnyMouseID;
  40427. /**
  40428. * Abstract mesh the behavior is set on
  40429. */
  40430. attachedNode: AbstractMesh;
  40431. private _dragPlane;
  40432. private _scene;
  40433. private _pointerObserver;
  40434. private _beforeRenderObserver;
  40435. private static _planeScene;
  40436. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40437. /**
  40438. * 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)
  40439. */
  40440. maxDragAngle: number;
  40441. /**
  40442. * @hidden
  40443. */
  40444. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40445. /**
  40446. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40447. */
  40448. currentDraggingPointerID: number;
  40449. /**
  40450. * The last position where the pointer hit the drag plane in world space
  40451. */
  40452. lastDragPosition: Vector3;
  40453. /**
  40454. * If the behavior is currently in a dragging state
  40455. */
  40456. dragging: boolean;
  40457. /**
  40458. * 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)
  40459. */
  40460. dragDeltaRatio: number;
  40461. /**
  40462. * If the drag plane orientation should be updated during the dragging (Default: true)
  40463. */
  40464. updateDragPlane: boolean;
  40465. private _debugMode;
  40466. private _moving;
  40467. /**
  40468. * Fires each time the attached mesh is dragged with the pointer
  40469. * * delta between last drag position and current drag position in world space
  40470. * * dragDistance along the drag axis
  40471. * * dragPlaneNormal normal of the current drag plane used during the drag
  40472. * * dragPlanePoint in world space where the drag intersects the drag plane
  40473. */
  40474. onDragObservable: Observable<{
  40475. delta: Vector3;
  40476. dragPlanePoint: Vector3;
  40477. dragPlaneNormal: Vector3;
  40478. dragDistance: number;
  40479. pointerId: number;
  40480. }>;
  40481. /**
  40482. * Fires each time a drag begins (eg. mouse down on mesh)
  40483. */
  40484. onDragStartObservable: Observable<{
  40485. dragPlanePoint: Vector3;
  40486. pointerId: number;
  40487. }>;
  40488. /**
  40489. * Fires each time a drag ends (eg. mouse release after drag)
  40490. */
  40491. onDragEndObservable: Observable<{
  40492. dragPlanePoint: Vector3;
  40493. pointerId: number;
  40494. }>;
  40495. /**
  40496. * If the attached mesh should be moved when dragged
  40497. */
  40498. moveAttached: boolean;
  40499. /**
  40500. * If the drag behavior will react to drag events (Default: true)
  40501. */
  40502. enabled: boolean;
  40503. /**
  40504. * If pointer events should start and release the drag (Default: true)
  40505. */
  40506. startAndReleaseDragOnPointerEvents: boolean;
  40507. /**
  40508. * If camera controls should be detached during the drag
  40509. */
  40510. detachCameraControls: boolean;
  40511. /**
  40512. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40513. */
  40514. useObjectOrientationForDragging: boolean;
  40515. private _options;
  40516. /**
  40517. * Gets the options used by the behavior
  40518. */
  40519. get options(): {
  40520. dragAxis?: Vector3;
  40521. dragPlaneNormal?: Vector3;
  40522. };
  40523. /**
  40524. * Sets the options used by the behavior
  40525. */
  40526. set options(options: {
  40527. dragAxis?: Vector3;
  40528. dragPlaneNormal?: Vector3;
  40529. });
  40530. /**
  40531. * Creates a pointer drag behavior that can be attached to a mesh
  40532. * @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)
  40533. */
  40534. constructor(options?: {
  40535. dragAxis?: Vector3;
  40536. dragPlaneNormal?: Vector3;
  40537. });
  40538. /**
  40539. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40540. */
  40541. validateDrag: (targetPosition: Vector3) => boolean;
  40542. /**
  40543. * The name of the behavior
  40544. */
  40545. get name(): string;
  40546. /**
  40547. * Initializes the behavior
  40548. */
  40549. init(): void;
  40550. private _tmpVector;
  40551. private _alternatePickedPoint;
  40552. private _worldDragAxis;
  40553. private _targetPosition;
  40554. private _attachedElement;
  40555. /**
  40556. * Attaches the drag behavior the passed in mesh
  40557. * @param ownerNode The mesh that will be dragged around once attached
  40558. * @param predicate Predicate to use for pick filtering
  40559. */
  40560. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40561. /**
  40562. * Force relase the drag action by code.
  40563. */
  40564. releaseDrag(): void;
  40565. private _startDragRay;
  40566. private _lastPointerRay;
  40567. /**
  40568. * Simulates the start of a pointer drag event on the behavior
  40569. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40570. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40571. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40572. */
  40573. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40574. private _startDrag;
  40575. private _dragDelta;
  40576. private _moveDrag;
  40577. private _pickWithRayOnDragPlane;
  40578. private _pointA;
  40579. private _pointB;
  40580. private _pointC;
  40581. private _lineA;
  40582. private _lineB;
  40583. private _localAxis;
  40584. private _lookAt;
  40585. private _updateDragPlanePosition;
  40586. /**
  40587. * Detaches the behavior from the mesh
  40588. */
  40589. detach(): void;
  40590. }
  40591. }
  40592. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40593. import { Mesh } from "babylonjs/Meshes/mesh";
  40594. import { Behavior } from "babylonjs/Behaviors/behavior";
  40595. /**
  40596. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40597. */
  40598. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40599. private _dragBehaviorA;
  40600. private _dragBehaviorB;
  40601. private _startDistance;
  40602. private _initialScale;
  40603. private _targetScale;
  40604. private _ownerNode;
  40605. private _sceneRenderObserver;
  40606. /**
  40607. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40608. */
  40609. constructor();
  40610. /**
  40611. * The name of the behavior
  40612. */
  40613. get name(): string;
  40614. /**
  40615. * Initializes the behavior
  40616. */
  40617. init(): void;
  40618. private _getCurrentDistance;
  40619. /**
  40620. * Attaches the scale behavior the passed in mesh
  40621. * @param ownerNode The mesh that will be scaled around once attached
  40622. */
  40623. attach(ownerNode: Mesh): void;
  40624. /**
  40625. * Detaches the behavior from the mesh
  40626. */
  40627. detach(): void;
  40628. }
  40629. }
  40630. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40631. import { Behavior } from "babylonjs/Behaviors/behavior";
  40632. import { Mesh } from "babylonjs/Meshes/mesh";
  40633. import { Observable } from "babylonjs/Misc/observable";
  40634. /**
  40635. * 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
  40636. */
  40637. export class SixDofDragBehavior implements Behavior<Mesh> {
  40638. private static _virtualScene;
  40639. private _ownerNode;
  40640. private _sceneRenderObserver;
  40641. private _scene;
  40642. private _targetPosition;
  40643. private _virtualOriginMesh;
  40644. private _virtualDragMesh;
  40645. private _pointerObserver;
  40646. private _moving;
  40647. private _startingOrientation;
  40648. /**
  40649. * 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)
  40650. */
  40651. private zDragFactor;
  40652. /**
  40653. * If the object should rotate to face the drag origin
  40654. */
  40655. rotateDraggedObject: boolean;
  40656. /**
  40657. * If the behavior is currently in a dragging state
  40658. */
  40659. dragging: boolean;
  40660. /**
  40661. * 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)
  40662. */
  40663. dragDeltaRatio: number;
  40664. /**
  40665. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40666. */
  40667. currentDraggingPointerID: number;
  40668. /**
  40669. * If camera controls should be detached during the drag
  40670. */
  40671. detachCameraControls: boolean;
  40672. /**
  40673. * Fires each time a drag starts
  40674. */
  40675. onDragStartObservable: Observable<{}>;
  40676. /**
  40677. * Fires each time a drag ends (eg. mouse release after drag)
  40678. */
  40679. onDragEndObservable: Observable<{}>;
  40680. /**
  40681. * 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
  40682. */
  40683. constructor();
  40684. /**
  40685. * The name of the behavior
  40686. */
  40687. get name(): string;
  40688. /**
  40689. * Initializes the behavior
  40690. */
  40691. init(): void;
  40692. /**
  40693. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40694. */
  40695. private get _pointerCamera();
  40696. /**
  40697. * Attaches the scale behavior the passed in mesh
  40698. * @param ownerNode The mesh that will be scaled around once attached
  40699. */
  40700. attach(ownerNode: Mesh): void;
  40701. /**
  40702. * Detaches the behavior from the mesh
  40703. */
  40704. detach(): void;
  40705. }
  40706. }
  40707. declare module "babylonjs/Behaviors/Meshes/index" {
  40708. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40709. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40710. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40711. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40712. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40713. }
  40714. declare module "babylonjs/Behaviors/index" {
  40715. export * from "babylonjs/Behaviors/behavior";
  40716. export * from "babylonjs/Behaviors/Cameras/index";
  40717. export * from "babylonjs/Behaviors/Meshes/index";
  40718. }
  40719. declare module "babylonjs/Bones/boneIKController" {
  40720. import { Bone } from "babylonjs/Bones/bone";
  40721. import { Vector3 } from "babylonjs/Maths/math.vector";
  40722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40723. import { Nullable } from "babylonjs/types";
  40724. /**
  40725. * Class used to apply inverse kinematics to bones
  40726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40727. */
  40728. export class BoneIKController {
  40729. private static _tmpVecs;
  40730. private static _tmpQuat;
  40731. private static _tmpMats;
  40732. /**
  40733. * Gets or sets the target mesh
  40734. */
  40735. targetMesh: AbstractMesh;
  40736. /** Gets or sets the mesh used as pole */
  40737. poleTargetMesh: AbstractMesh;
  40738. /**
  40739. * Gets or sets the bone used as pole
  40740. */
  40741. poleTargetBone: Nullable<Bone>;
  40742. /**
  40743. * Gets or sets the target position
  40744. */
  40745. targetPosition: Vector3;
  40746. /**
  40747. * Gets or sets the pole target position
  40748. */
  40749. poleTargetPosition: Vector3;
  40750. /**
  40751. * Gets or sets the pole target local offset
  40752. */
  40753. poleTargetLocalOffset: Vector3;
  40754. /**
  40755. * Gets or sets the pole angle
  40756. */
  40757. poleAngle: number;
  40758. /**
  40759. * Gets or sets the mesh associated with the controller
  40760. */
  40761. mesh: AbstractMesh;
  40762. /**
  40763. * 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)
  40764. */
  40765. slerpAmount: number;
  40766. private _bone1Quat;
  40767. private _bone1Mat;
  40768. private _bone2Ang;
  40769. private _bone1;
  40770. private _bone2;
  40771. private _bone1Length;
  40772. private _bone2Length;
  40773. private _maxAngle;
  40774. private _maxReach;
  40775. private _rightHandedSystem;
  40776. private _bendAxis;
  40777. private _slerping;
  40778. private _adjustRoll;
  40779. /**
  40780. * Gets or sets maximum allowed angle
  40781. */
  40782. get maxAngle(): number;
  40783. set maxAngle(value: number);
  40784. /**
  40785. * Creates a new BoneIKController
  40786. * @param mesh defines the mesh to control
  40787. * @param bone defines the bone to control
  40788. * @param options defines options to set up the controller
  40789. */
  40790. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40791. targetMesh?: AbstractMesh;
  40792. poleTargetMesh?: AbstractMesh;
  40793. poleTargetBone?: Bone;
  40794. poleTargetLocalOffset?: Vector3;
  40795. poleAngle?: number;
  40796. bendAxis?: Vector3;
  40797. maxAngle?: number;
  40798. slerpAmount?: number;
  40799. });
  40800. private _setMaxAngle;
  40801. /**
  40802. * Force the controller to update the bones
  40803. */
  40804. update(): void;
  40805. }
  40806. }
  40807. declare module "babylonjs/Bones/boneLookController" {
  40808. import { Vector3 } from "babylonjs/Maths/math.vector";
  40809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40810. import { Bone } from "babylonjs/Bones/bone";
  40811. import { Space } from "babylonjs/Maths/math.axis";
  40812. /**
  40813. * Class used to make a bone look toward a point in space
  40814. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40815. */
  40816. export class BoneLookController {
  40817. private static _tmpVecs;
  40818. private static _tmpQuat;
  40819. private static _tmpMats;
  40820. /**
  40821. * The target Vector3 that the bone will look at
  40822. */
  40823. target: Vector3;
  40824. /**
  40825. * The mesh that the bone is attached to
  40826. */
  40827. mesh: AbstractMesh;
  40828. /**
  40829. * The bone that will be looking to the target
  40830. */
  40831. bone: Bone;
  40832. /**
  40833. * The up axis of the coordinate system that is used when the bone is rotated
  40834. */
  40835. upAxis: Vector3;
  40836. /**
  40837. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40838. */
  40839. upAxisSpace: Space;
  40840. /**
  40841. * Used to make an adjustment to the yaw of the bone
  40842. */
  40843. adjustYaw: number;
  40844. /**
  40845. * Used to make an adjustment to the pitch of the bone
  40846. */
  40847. adjustPitch: number;
  40848. /**
  40849. * Used to make an adjustment to the roll of the bone
  40850. */
  40851. adjustRoll: number;
  40852. /**
  40853. * 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)
  40854. */
  40855. slerpAmount: number;
  40856. private _minYaw;
  40857. private _maxYaw;
  40858. private _minPitch;
  40859. private _maxPitch;
  40860. private _minYawSin;
  40861. private _minYawCos;
  40862. private _maxYawSin;
  40863. private _maxYawCos;
  40864. private _midYawConstraint;
  40865. private _minPitchTan;
  40866. private _maxPitchTan;
  40867. private _boneQuat;
  40868. private _slerping;
  40869. private _transformYawPitch;
  40870. private _transformYawPitchInv;
  40871. private _firstFrameSkipped;
  40872. private _yawRange;
  40873. private _fowardAxis;
  40874. /**
  40875. * Gets or sets the minimum yaw angle that the bone can look to
  40876. */
  40877. get minYaw(): number;
  40878. set minYaw(value: number);
  40879. /**
  40880. * Gets or sets the maximum yaw angle that the bone can look to
  40881. */
  40882. get maxYaw(): number;
  40883. set maxYaw(value: number);
  40884. /**
  40885. * Gets or sets the minimum pitch angle that the bone can look to
  40886. */
  40887. get minPitch(): number;
  40888. set minPitch(value: number);
  40889. /**
  40890. * Gets or sets the maximum pitch angle that the bone can look to
  40891. */
  40892. get maxPitch(): number;
  40893. set maxPitch(value: number);
  40894. /**
  40895. * Create a BoneLookController
  40896. * @param mesh the mesh that the bone belongs to
  40897. * @param bone the bone that will be looking to the target
  40898. * @param target the target Vector3 to look at
  40899. * @param options optional settings:
  40900. * * maxYaw: the maximum angle the bone will yaw to
  40901. * * minYaw: the minimum angle the bone will yaw to
  40902. * * maxPitch: the maximum angle the bone will pitch to
  40903. * * minPitch: the minimum angle the bone will yaw to
  40904. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40905. * * upAxis: the up axis of the coordinate system
  40906. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40907. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40908. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40909. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40910. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40911. * * adjustRoll: used to make an adjustment to the roll of the bone
  40912. **/
  40913. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40914. maxYaw?: number;
  40915. minYaw?: number;
  40916. maxPitch?: number;
  40917. minPitch?: number;
  40918. slerpAmount?: number;
  40919. upAxis?: Vector3;
  40920. upAxisSpace?: Space;
  40921. yawAxis?: Vector3;
  40922. pitchAxis?: Vector3;
  40923. adjustYaw?: number;
  40924. adjustPitch?: number;
  40925. adjustRoll?: number;
  40926. });
  40927. /**
  40928. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40929. */
  40930. update(): void;
  40931. private _getAngleDiff;
  40932. private _getAngleBetween;
  40933. private _isAngleBetween;
  40934. }
  40935. }
  40936. declare module "babylonjs/Bones/index" {
  40937. export * from "babylonjs/Bones/bone";
  40938. export * from "babylonjs/Bones/boneIKController";
  40939. export * from "babylonjs/Bones/boneLookController";
  40940. export * from "babylonjs/Bones/skeleton";
  40941. }
  40942. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40943. import { Nullable } from "babylonjs/types";
  40944. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40945. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40946. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40947. /**
  40948. * Manage the gamepad inputs to control an arc rotate camera.
  40949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40950. */
  40951. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40952. /**
  40953. * Defines the camera the input is attached to.
  40954. */
  40955. camera: ArcRotateCamera;
  40956. /**
  40957. * Defines the gamepad the input is gathering event from.
  40958. */
  40959. gamepad: Nullable<Gamepad>;
  40960. /**
  40961. * Defines the gamepad rotation sensiblity.
  40962. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40963. */
  40964. gamepadRotationSensibility: number;
  40965. /**
  40966. * Defines the gamepad move sensiblity.
  40967. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40968. */
  40969. gamepadMoveSensibility: number;
  40970. private _yAxisScale;
  40971. /**
  40972. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40973. */
  40974. get invertYAxis(): boolean;
  40975. set invertYAxis(value: boolean);
  40976. private _onGamepadConnectedObserver;
  40977. private _onGamepadDisconnectedObserver;
  40978. /**
  40979. * Attach the input controls to a specific dom element to get the input from.
  40980. * @param element Defines the element the controls should be listened from
  40981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40982. */
  40983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40984. /**
  40985. * Detach the current controls from the specified dom element.
  40986. * @param element Defines the element to stop listening the inputs from
  40987. */
  40988. detachControl(element: Nullable<HTMLElement>): void;
  40989. /**
  40990. * Update the current camera state depending on the inputs that have been used this frame.
  40991. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40992. */
  40993. checkInputs(): void;
  40994. /**
  40995. * Gets the class name of the current intput.
  40996. * @returns the class name
  40997. */
  40998. getClassName(): string;
  40999. /**
  41000. * Get the friendly name associated with the input class.
  41001. * @returns the input friendly name
  41002. */
  41003. getSimpleName(): string;
  41004. }
  41005. }
  41006. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41007. import { Nullable } from "babylonjs/types";
  41008. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41009. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41010. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41011. interface ArcRotateCameraInputsManager {
  41012. /**
  41013. * Add orientation input support to the input manager.
  41014. * @returns the current input manager
  41015. */
  41016. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41017. }
  41018. }
  41019. /**
  41020. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41022. */
  41023. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41024. /**
  41025. * Defines the camera the input is attached to.
  41026. */
  41027. camera: ArcRotateCamera;
  41028. /**
  41029. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41030. */
  41031. alphaCorrection: number;
  41032. /**
  41033. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41034. */
  41035. gammaCorrection: number;
  41036. private _alpha;
  41037. private _gamma;
  41038. private _dirty;
  41039. private _deviceOrientationHandler;
  41040. /**
  41041. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41042. */
  41043. constructor();
  41044. /**
  41045. * Attach the input controls to a specific dom element to get the input from.
  41046. * @param element Defines the element the controls should be listened from
  41047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41048. */
  41049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41050. /** @hidden */
  41051. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41052. /**
  41053. * Update the current camera state depending on the inputs that have been used this frame.
  41054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41055. */
  41056. checkInputs(): void;
  41057. /**
  41058. * Detach the current controls from the specified dom element.
  41059. * @param element Defines the element to stop listening the inputs from
  41060. */
  41061. detachControl(element: Nullable<HTMLElement>): void;
  41062. /**
  41063. * Gets the class name of the current intput.
  41064. * @returns the class name
  41065. */
  41066. getClassName(): string;
  41067. /**
  41068. * Get the friendly name associated with the input class.
  41069. * @returns the input friendly name
  41070. */
  41071. getSimpleName(): string;
  41072. }
  41073. }
  41074. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41075. import { Nullable } from "babylonjs/types";
  41076. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41077. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41078. /**
  41079. * Listen to mouse events to control the camera.
  41080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41081. */
  41082. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41083. /**
  41084. * Defines the camera the input is attached to.
  41085. */
  41086. camera: FlyCamera;
  41087. /**
  41088. * Defines if touch is enabled. (Default is true.)
  41089. */
  41090. touchEnabled: boolean;
  41091. /**
  41092. * Defines the buttons associated with the input to handle camera rotation.
  41093. */
  41094. buttons: number[];
  41095. /**
  41096. * Assign buttons for Yaw control.
  41097. */
  41098. buttonsYaw: number[];
  41099. /**
  41100. * Assign buttons for Pitch control.
  41101. */
  41102. buttonsPitch: number[];
  41103. /**
  41104. * Assign buttons for Roll control.
  41105. */
  41106. buttonsRoll: number[];
  41107. /**
  41108. * Detect if any button is being pressed while mouse is moved.
  41109. * -1 = Mouse locked.
  41110. * 0 = Left button.
  41111. * 1 = Middle Button.
  41112. * 2 = Right Button.
  41113. */
  41114. activeButton: number;
  41115. /**
  41116. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41117. * Higher values reduce its sensitivity.
  41118. */
  41119. angularSensibility: number;
  41120. private _mousemoveCallback;
  41121. private _observer;
  41122. private _rollObserver;
  41123. private previousPosition;
  41124. private noPreventDefault;
  41125. private element;
  41126. /**
  41127. * Listen to mouse events to control the camera.
  41128. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41130. */
  41131. constructor(touchEnabled?: boolean);
  41132. /**
  41133. * Attach the mouse control to the HTML DOM element.
  41134. * @param element Defines the element that listens to the input events.
  41135. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41136. */
  41137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41138. /**
  41139. * Detach the current controls from the specified dom element.
  41140. * @param element Defines the element to stop listening the inputs from
  41141. */
  41142. detachControl(element: Nullable<HTMLElement>): void;
  41143. /**
  41144. * Gets the class name of the current input.
  41145. * @returns the class name.
  41146. */
  41147. getClassName(): string;
  41148. /**
  41149. * Get the friendly name associated with the input class.
  41150. * @returns the input's friendly name.
  41151. */
  41152. getSimpleName(): string;
  41153. private _pointerInput;
  41154. private _onMouseMove;
  41155. /**
  41156. * Rotate camera by mouse offset.
  41157. */
  41158. private rotateCamera;
  41159. }
  41160. }
  41161. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41162. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41163. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41164. /**
  41165. * Default Inputs manager for the FlyCamera.
  41166. * It groups all the default supported inputs for ease of use.
  41167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41168. */
  41169. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41170. /**
  41171. * Instantiates a new FlyCameraInputsManager.
  41172. * @param camera Defines the camera the inputs belong to.
  41173. */
  41174. constructor(camera: FlyCamera);
  41175. /**
  41176. * Add keyboard input support to the input manager.
  41177. * @returns the new FlyCameraKeyboardMoveInput().
  41178. */
  41179. addKeyboard(): FlyCameraInputsManager;
  41180. /**
  41181. * Add mouse input support to the input manager.
  41182. * @param touchEnabled Enable touch screen support.
  41183. * @returns the new FlyCameraMouseInput().
  41184. */
  41185. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41186. }
  41187. }
  41188. declare module "babylonjs/Cameras/flyCamera" {
  41189. import { Scene } from "babylonjs/scene";
  41190. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41192. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41193. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41194. /**
  41195. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41196. * such as in a 3D Space Shooter or a Flight Simulator.
  41197. */
  41198. export class FlyCamera extends TargetCamera {
  41199. /**
  41200. * Define the collision ellipsoid of the camera.
  41201. * This is helpful for simulating a camera body, like a player's body.
  41202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41203. */
  41204. ellipsoid: Vector3;
  41205. /**
  41206. * Define an offset for the position of the ellipsoid around the camera.
  41207. * This can be helpful if the camera is attached away from the player's body center,
  41208. * such as at its head.
  41209. */
  41210. ellipsoidOffset: Vector3;
  41211. /**
  41212. * Enable or disable collisions of the camera with the rest of the scene objects.
  41213. */
  41214. checkCollisions: boolean;
  41215. /**
  41216. * Enable or disable gravity on the camera.
  41217. */
  41218. applyGravity: boolean;
  41219. /**
  41220. * Define the current direction the camera is moving to.
  41221. */
  41222. cameraDirection: Vector3;
  41223. /**
  41224. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41225. * This overrides and empties cameraRotation.
  41226. */
  41227. rotationQuaternion: Quaternion;
  41228. /**
  41229. * Track Roll to maintain the wanted Rolling when looking around.
  41230. */
  41231. _trackRoll: number;
  41232. /**
  41233. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41234. */
  41235. rollCorrect: number;
  41236. /**
  41237. * Mimic a banked turn, Rolling the camera when Yawing.
  41238. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41239. */
  41240. bankedTurn: boolean;
  41241. /**
  41242. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41243. */
  41244. bankedTurnLimit: number;
  41245. /**
  41246. * Value of 0 disables the banked Roll.
  41247. * Value of 1 is equal to the Yaw angle in radians.
  41248. */
  41249. bankedTurnMultiplier: number;
  41250. /**
  41251. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41252. */
  41253. inputs: FlyCameraInputsManager;
  41254. /**
  41255. * Gets the input sensibility for mouse input.
  41256. * Higher values reduce sensitivity.
  41257. */
  41258. get angularSensibility(): number;
  41259. /**
  41260. * Sets the input sensibility for a mouse input.
  41261. * Higher values reduce sensitivity.
  41262. */
  41263. set angularSensibility(value: number);
  41264. /**
  41265. * Get the keys for camera movement forward.
  41266. */
  41267. get keysForward(): number[];
  41268. /**
  41269. * Set the keys for camera movement forward.
  41270. */
  41271. set keysForward(value: number[]);
  41272. /**
  41273. * Get the keys for camera movement backward.
  41274. */
  41275. get keysBackward(): number[];
  41276. set keysBackward(value: number[]);
  41277. /**
  41278. * Get the keys for camera movement up.
  41279. */
  41280. get keysUp(): number[];
  41281. /**
  41282. * Set the keys for camera movement up.
  41283. */
  41284. set keysUp(value: number[]);
  41285. /**
  41286. * Get the keys for camera movement down.
  41287. */
  41288. get keysDown(): number[];
  41289. /**
  41290. * Set the keys for camera movement down.
  41291. */
  41292. set keysDown(value: number[]);
  41293. /**
  41294. * Get the keys for camera movement left.
  41295. */
  41296. get keysLeft(): number[];
  41297. /**
  41298. * Set the keys for camera movement left.
  41299. */
  41300. set keysLeft(value: number[]);
  41301. /**
  41302. * Set the keys for camera movement right.
  41303. */
  41304. get keysRight(): number[];
  41305. /**
  41306. * Set the keys for camera movement right.
  41307. */
  41308. set keysRight(value: number[]);
  41309. /**
  41310. * Event raised when the camera collides with a mesh in the scene.
  41311. */
  41312. onCollide: (collidedMesh: AbstractMesh) => void;
  41313. private _collider;
  41314. private _needMoveForGravity;
  41315. private _oldPosition;
  41316. private _diffPosition;
  41317. private _newPosition;
  41318. /** @hidden */
  41319. _localDirection: Vector3;
  41320. /** @hidden */
  41321. _transformedDirection: Vector3;
  41322. /**
  41323. * Instantiates a FlyCamera.
  41324. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41325. * such as in a 3D Space Shooter or a Flight Simulator.
  41326. * @param name Define the name of the camera in the scene.
  41327. * @param position Define the starting position of the camera in the scene.
  41328. * @param scene Define the scene the camera belongs to.
  41329. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41330. */
  41331. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41332. /**
  41333. * Attach a control to the HTML DOM element.
  41334. * @param element Defines the element that listens to the input events.
  41335. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41336. */
  41337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41338. /**
  41339. * Detach a control from the HTML DOM element.
  41340. * The camera will stop reacting to that input.
  41341. * @param element Defines the element that listens to the input events.
  41342. */
  41343. detachControl(element: HTMLElement): void;
  41344. private _collisionMask;
  41345. /**
  41346. * Get the mask that the camera ignores in collision events.
  41347. */
  41348. get collisionMask(): number;
  41349. /**
  41350. * Set the mask that the camera ignores in collision events.
  41351. */
  41352. set collisionMask(mask: number);
  41353. /** @hidden */
  41354. _collideWithWorld(displacement: Vector3): void;
  41355. /** @hidden */
  41356. private _onCollisionPositionChange;
  41357. /** @hidden */
  41358. _checkInputs(): void;
  41359. /** @hidden */
  41360. _decideIfNeedsToMove(): boolean;
  41361. /** @hidden */
  41362. _updatePosition(): void;
  41363. /**
  41364. * Restore the Roll to its target value at the rate specified.
  41365. * @param rate - Higher means slower restoring.
  41366. * @hidden
  41367. */
  41368. restoreRoll(rate: number): void;
  41369. /**
  41370. * Destroy the camera and release the current resources held by it.
  41371. */
  41372. dispose(): void;
  41373. /**
  41374. * Get the current object class name.
  41375. * @returns the class name.
  41376. */
  41377. getClassName(): string;
  41378. }
  41379. }
  41380. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41381. import { Nullable } from "babylonjs/types";
  41382. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41383. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41384. /**
  41385. * Listen to keyboard events to control the camera.
  41386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41387. */
  41388. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41389. /**
  41390. * Defines the camera the input is attached to.
  41391. */
  41392. camera: FlyCamera;
  41393. /**
  41394. * The list of keyboard keys used to control the forward move of the camera.
  41395. */
  41396. keysForward: number[];
  41397. /**
  41398. * The list of keyboard keys used to control the backward move of the camera.
  41399. */
  41400. keysBackward: number[];
  41401. /**
  41402. * The list of keyboard keys used to control the forward move of the camera.
  41403. */
  41404. keysUp: number[];
  41405. /**
  41406. * The list of keyboard keys used to control the backward move of the camera.
  41407. */
  41408. keysDown: number[];
  41409. /**
  41410. * The list of keyboard keys used to control the right strafe move of the camera.
  41411. */
  41412. keysRight: number[];
  41413. /**
  41414. * The list of keyboard keys used to control the left strafe move of the camera.
  41415. */
  41416. keysLeft: number[];
  41417. private _keys;
  41418. private _onCanvasBlurObserver;
  41419. private _onKeyboardObserver;
  41420. private _engine;
  41421. private _scene;
  41422. /**
  41423. * Attach the input controls to a specific dom element to get the input from.
  41424. * @param element Defines the element the controls should be listened from
  41425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41426. */
  41427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41428. /**
  41429. * Detach the current controls from the specified dom element.
  41430. * @param element Defines the element to stop listening the inputs from
  41431. */
  41432. detachControl(element: Nullable<HTMLElement>): void;
  41433. /**
  41434. * Gets the class name of the current intput.
  41435. * @returns the class name
  41436. */
  41437. getClassName(): string;
  41438. /** @hidden */
  41439. _onLostFocus(e: FocusEvent): void;
  41440. /**
  41441. * Get the friendly name associated with the input class.
  41442. * @returns the input friendly name
  41443. */
  41444. getSimpleName(): string;
  41445. /**
  41446. * Update the current camera state depending on the inputs that have been used this frame.
  41447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41448. */
  41449. checkInputs(): void;
  41450. }
  41451. }
  41452. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41453. import { Nullable } from "babylonjs/types";
  41454. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41455. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41456. /**
  41457. * Manage the mouse wheel inputs to control a follow camera.
  41458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41459. */
  41460. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41461. /**
  41462. * Defines the camera the input is attached to.
  41463. */
  41464. camera: FollowCamera;
  41465. /**
  41466. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41467. */
  41468. axisControlRadius: boolean;
  41469. /**
  41470. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41471. */
  41472. axisControlHeight: boolean;
  41473. /**
  41474. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41475. */
  41476. axisControlRotation: boolean;
  41477. /**
  41478. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41479. * relation to mouseWheel events.
  41480. */
  41481. wheelPrecision: number;
  41482. /**
  41483. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41484. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41485. */
  41486. wheelDeltaPercentage: number;
  41487. private _wheel;
  41488. private _observer;
  41489. /**
  41490. * Attach the input controls to a specific dom element to get the input from.
  41491. * @param element Defines the element the controls should be listened from
  41492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41493. */
  41494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41495. /**
  41496. * Detach the current controls from the specified dom element.
  41497. * @param element Defines the element to stop listening the inputs from
  41498. */
  41499. detachControl(element: Nullable<HTMLElement>): void;
  41500. /**
  41501. * Gets the class name of the current intput.
  41502. * @returns the class name
  41503. */
  41504. getClassName(): string;
  41505. /**
  41506. * Get the friendly name associated with the input class.
  41507. * @returns the input friendly name
  41508. */
  41509. getSimpleName(): string;
  41510. }
  41511. }
  41512. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41513. import { Nullable } from "babylonjs/types";
  41514. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41515. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41516. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41517. /**
  41518. * Manage the pointers inputs to control an follow camera.
  41519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41520. */
  41521. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41522. /**
  41523. * Defines the camera the input is attached to.
  41524. */
  41525. camera: FollowCamera;
  41526. /**
  41527. * Gets the class name of the current input.
  41528. * @returns the class name
  41529. */
  41530. getClassName(): string;
  41531. /**
  41532. * Defines the pointer angular sensibility along the X axis or how fast is
  41533. * the camera rotating.
  41534. * A negative number will reverse the axis direction.
  41535. */
  41536. angularSensibilityX: number;
  41537. /**
  41538. * Defines the pointer angular sensibility along the Y axis or how fast is
  41539. * the camera rotating.
  41540. * A negative number will reverse the axis direction.
  41541. */
  41542. angularSensibilityY: number;
  41543. /**
  41544. * Defines the pointer pinch precision or how fast is the camera zooming.
  41545. * A negative number will reverse the axis direction.
  41546. */
  41547. pinchPrecision: number;
  41548. /**
  41549. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41550. * from 0.
  41551. * It defines the percentage of current camera.radius to use as delta when
  41552. * pinch zoom is used.
  41553. */
  41554. pinchDeltaPercentage: number;
  41555. /**
  41556. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41557. */
  41558. axisXControlRadius: boolean;
  41559. /**
  41560. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41561. */
  41562. axisXControlHeight: boolean;
  41563. /**
  41564. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41565. */
  41566. axisXControlRotation: boolean;
  41567. /**
  41568. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41569. */
  41570. axisYControlRadius: boolean;
  41571. /**
  41572. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41573. */
  41574. axisYControlHeight: boolean;
  41575. /**
  41576. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41577. */
  41578. axisYControlRotation: boolean;
  41579. /**
  41580. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41581. */
  41582. axisPinchControlRadius: boolean;
  41583. /**
  41584. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41585. */
  41586. axisPinchControlHeight: boolean;
  41587. /**
  41588. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41589. */
  41590. axisPinchControlRotation: boolean;
  41591. /**
  41592. * Log error messages if basic misconfiguration has occurred.
  41593. */
  41594. warningEnable: boolean;
  41595. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41596. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41597. private _warningCounter;
  41598. private _warning;
  41599. }
  41600. }
  41601. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41602. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41603. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41604. /**
  41605. * Default Inputs manager for the FollowCamera.
  41606. * It groups all the default supported inputs for ease of use.
  41607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41608. */
  41609. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41610. /**
  41611. * Instantiates a new FollowCameraInputsManager.
  41612. * @param camera Defines the camera the inputs belong to
  41613. */
  41614. constructor(camera: FollowCamera);
  41615. /**
  41616. * Add keyboard input support to the input manager.
  41617. * @returns the current input manager
  41618. */
  41619. addKeyboard(): FollowCameraInputsManager;
  41620. /**
  41621. * Add mouse wheel input support to the input manager.
  41622. * @returns the current input manager
  41623. */
  41624. addMouseWheel(): FollowCameraInputsManager;
  41625. /**
  41626. * Add pointers input support to the input manager.
  41627. * @returns the current input manager
  41628. */
  41629. addPointers(): FollowCameraInputsManager;
  41630. /**
  41631. * Add orientation input support to the input manager.
  41632. * @returns the current input manager
  41633. */
  41634. addVRDeviceOrientation(): FollowCameraInputsManager;
  41635. }
  41636. }
  41637. declare module "babylonjs/Cameras/followCamera" {
  41638. import { Nullable } from "babylonjs/types";
  41639. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41640. import { Scene } from "babylonjs/scene";
  41641. import { Vector3 } from "babylonjs/Maths/math.vector";
  41642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41643. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41644. /**
  41645. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41646. * an arc rotate version arcFollowCamera are available.
  41647. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41648. */
  41649. export class FollowCamera extends TargetCamera {
  41650. /**
  41651. * Distance the follow camera should follow an object at
  41652. */
  41653. radius: number;
  41654. /**
  41655. * Minimum allowed distance of the camera to the axis of rotation
  41656. * (The camera can not get closer).
  41657. * This can help limiting how the Camera is able to move in the scene.
  41658. */
  41659. lowerRadiusLimit: Nullable<number>;
  41660. /**
  41661. * Maximum allowed distance of the camera to the axis of rotation
  41662. * (The camera can not get further).
  41663. * This can help limiting how the Camera is able to move in the scene.
  41664. */
  41665. upperRadiusLimit: Nullable<number>;
  41666. /**
  41667. * Define a rotation offset between the camera and the object it follows
  41668. */
  41669. rotationOffset: number;
  41670. /**
  41671. * Minimum allowed angle to camera position relative to target object.
  41672. * This can help limiting how the Camera is able to move in the scene.
  41673. */
  41674. lowerRotationOffsetLimit: Nullable<number>;
  41675. /**
  41676. * Maximum allowed angle to camera position relative to target object.
  41677. * This can help limiting how the Camera is able to move in the scene.
  41678. */
  41679. upperRotationOffsetLimit: Nullable<number>;
  41680. /**
  41681. * Define a height offset between the camera and the object it follows.
  41682. * It can help following an object from the top (like a car chaing a plane)
  41683. */
  41684. heightOffset: number;
  41685. /**
  41686. * Minimum allowed height of camera position relative to target object.
  41687. * This can help limiting how the Camera is able to move in the scene.
  41688. */
  41689. lowerHeightOffsetLimit: Nullable<number>;
  41690. /**
  41691. * Maximum allowed height of camera position relative to target object.
  41692. * This can help limiting how the Camera is able to move in the scene.
  41693. */
  41694. upperHeightOffsetLimit: Nullable<number>;
  41695. /**
  41696. * Define how fast the camera can accelerate to follow it s target.
  41697. */
  41698. cameraAcceleration: number;
  41699. /**
  41700. * Define the speed limit of the camera following an object.
  41701. */
  41702. maxCameraSpeed: number;
  41703. /**
  41704. * Define the target of the camera.
  41705. */
  41706. lockedTarget: Nullable<AbstractMesh>;
  41707. /**
  41708. * Defines the input associated with the camera.
  41709. */
  41710. inputs: FollowCameraInputsManager;
  41711. /**
  41712. * Instantiates the follow camera.
  41713. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41714. * @param name Define the name of the camera in the scene
  41715. * @param position Define the position of the camera
  41716. * @param scene Define the scene the camera belong to
  41717. * @param lockedTarget Define the target of the camera
  41718. */
  41719. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41720. private _follow;
  41721. /**
  41722. * Attached controls to the current camera.
  41723. * @param element Defines the element the controls should be listened from
  41724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41725. */
  41726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41727. /**
  41728. * Detach the current controls from the camera.
  41729. * The camera will stop reacting to inputs.
  41730. * @param element Defines the element to stop listening the inputs from
  41731. */
  41732. detachControl(element: HTMLElement): void;
  41733. /** @hidden */
  41734. _checkInputs(): void;
  41735. private _checkLimits;
  41736. /**
  41737. * Gets the camera class name.
  41738. * @returns the class name
  41739. */
  41740. getClassName(): string;
  41741. }
  41742. /**
  41743. * Arc Rotate version of the follow camera.
  41744. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41745. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41746. */
  41747. export class ArcFollowCamera extends TargetCamera {
  41748. /** The longitudinal angle of the camera */
  41749. alpha: number;
  41750. /** The latitudinal angle of the camera */
  41751. beta: number;
  41752. /** The radius of the camera from its target */
  41753. radius: number;
  41754. /** Define the camera target (the messh it should follow) */
  41755. target: Nullable<AbstractMesh>;
  41756. private _cartesianCoordinates;
  41757. /**
  41758. * Instantiates a new ArcFollowCamera
  41759. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41760. * @param name Define the name of the camera
  41761. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41762. * @param beta Define the rotation angle of the camera around the elevation axis
  41763. * @param radius Define the radius of the camera from its target point
  41764. * @param target Define the target of the camera
  41765. * @param scene Define the scene the camera belongs to
  41766. */
  41767. constructor(name: string,
  41768. /** The longitudinal angle of the camera */
  41769. alpha: number,
  41770. /** The latitudinal angle of the camera */
  41771. beta: number,
  41772. /** The radius of the camera from its target */
  41773. radius: number,
  41774. /** Define the camera target (the messh it should follow) */
  41775. target: Nullable<AbstractMesh>, scene: Scene);
  41776. private _follow;
  41777. /** @hidden */
  41778. _checkInputs(): void;
  41779. /**
  41780. * Returns the class name of the object.
  41781. * It is mostly used internally for serialization purposes.
  41782. */
  41783. getClassName(): string;
  41784. }
  41785. }
  41786. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41787. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41788. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41789. import { Nullable } from "babylonjs/types";
  41790. /**
  41791. * Manage the keyboard inputs to control the movement of a follow camera.
  41792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41793. */
  41794. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41795. /**
  41796. * Defines the camera the input is attached to.
  41797. */
  41798. camera: FollowCamera;
  41799. /**
  41800. * Defines the list of key codes associated with the up action (increase heightOffset)
  41801. */
  41802. keysHeightOffsetIncr: number[];
  41803. /**
  41804. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41805. */
  41806. keysHeightOffsetDecr: number[];
  41807. /**
  41808. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41809. */
  41810. keysHeightOffsetModifierAlt: boolean;
  41811. /**
  41812. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41813. */
  41814. keysHeightOffsetModifierCtrl: boolean;
  41815. /**
  41816. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41817. */
  41818. keysHeightOffsetModifierShift: boolean;
  41819. /**
  41820. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41821. */
  41822. keysRotationOffsetIncr: number[];
  41823. /**
  41824. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41825. */
  41826. keysRotationOffsetDecr: number[];
  41827. /**
  41828. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41829. */
  41830. keysRotationOffsetModifierAlt: boolean;
  41831. /**
  41832. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41833. */
  41834. keysRotationOffsetModifierCtrl: boolean;
  41835. /**
  41836. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41837. */
  41838. keysRotationOffsetModifierShift: boolean;
  41839. /**
  41840. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41841. */
  41842. keysRadiusIncr: number[];
  41843. /**
  41844. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41845. */
  41846. keysRadiusDecr: number[];
  41847. /**
  41848. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41849. */
  41850. keysRadiusModifierAlt: boolean;
  41851. /**
  41852. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41853. */
  41854. keysRadiusModifierCtrl: boolean;
  41855. /**
  41856. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41857. */
  41858. keysRadiusModifierShift: boolean;
  41859. /**
  41860. * Defines the rate of change of heightOffset.
  41861. */
  41862. heightSensibility: number;
  41863. /**
  41864. * Defines the rate of change of rotationOffset.
  41865. */
  41866. rotationSensibility: number;
  41867. /**
  41868. * Defines the rate of change of radius.
  41869. */
  41870. radiusSensibility: number;
  41871. private _keys;
  41872. private _ctrlPressed;
  41873. private _altPressed;
  41874. private _shiftPressed;
  41875. private _onCanvasBlurObserver;
  41876. private _onKeyboardObserver;
  41877. private _engine;
  41878. private _scene;
  41879. /**
  41880. * Attach the input controls to a specific dom element to get the input from.
  41881. * @param element Defines the element the controls should be listened from
  41882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41883. */
  41884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41885. /**
  41886. * Detach the current controls from the specified dom element.
  41887. * @param element Defines the element to stop listening the inputs from
  41888. */
  41889. detachControl(element: Nullable<HTMLElement>): void;
  41890. /**
  41891. * Update the current camera state depending on the inputs that have been used this frame.
  41892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41893. */
  41894. checkInputs(): void;
  41895. /**
  41896. * Gets the class name of the current input.
  41897. * @returns the class name
  41898. */
  41899. getClassName(): string;
  41900. /**
  41901. * Get the friendly name associated with the input class.
  41902. * @returns the input friendly name
  41903. */
  41904. getSimpleName(): string;
  41905. /**
  41906. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41907. * allow modification of the heightOffset value.
  41908. */
  41909. private _modifierHeightOffset;
  41910. /**
  41911. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41912. * allow modification of the rotationOffset value.
  41913. */
  41914. private _modifierRotationOffset;
  41915. /**
  41916. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41917. * allow modification of the radius value.
  41918. */
  41919. private _modifierRadius;
  41920. }
  41921. }
  41922. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41923. import { Nullable } from "babylonjs/types";
  41924. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41925. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41926. import { Observable } from "babylonjs/Misc/observable";
  41927. module "babylonjs/Cameras/freeCameraInputsManager" {
  41928. interface FreeCameraInputsManager {
  41929. /**
  41930. * @hidden
  41931. */
  41932. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41933. /**
  41934. * Add orientation input support to the input manager.
  41935. * @returns the current input manager
  41936. */
  41937. addDeviceOrientation(): FreeCameraInputsManager;
  41938. }
  41939. }
  41940. /**
  41941. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41942. * Screen rotation is taken into account.
  41943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41944. */
  41945. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41946. private _camera;
  41947. private _screenOrientationAngle;
  41948. private _constantTranform;
  41949. private _screenQuaternion;
  41950. private _alpha;
  41951. private _beta;
  41952. private _gamma;
  41953. /**
  41954. * Can be used to detect if a device orientation sensor is available on a device
  41955. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41956. * @returns a promise that will resolve on orientation change
  41957. */
  41958. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41959. /**
  41960. * @hidden
  41961. */
  41962. _onDeviceOrientationChangedObservable: Observable<void>;
  41963. /**
  41964. * Instantiates a new input
  41965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41966. */
  41967. constructor();
  41968. /**
  41969. * Define the camera controlled by the input.
  41970. */
  41971. get camera(): FreeCamera;
  41972. set camera(camera: FreeCamera);
  41973. /**
  41974. * Attach the input controls to a specific dom element to get the input from.
  41975. * @param element Defines the element the controls should be listened from
  41976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41977. */
  41978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41979. private _orientationChanged;
  41980. private _deviceOrientation;
  41981. /**
  41982. * Detach the current controls from the specified dom element.
  41983. * @param element Defines the element to stop listening the inputs from
  41984. */
  41985. detachControl(element: Nullable<HTMLElement>): void;
  41986. /**
  41987. * Update the current camera state depending on the inputs that have been used this frame.
  41988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41989. */
  41990. checkInputs(): void;
  41991. /**
  41992. * Gets the class name of the current intput.
  41993. * @returns the class name
  41994. */
  41995. getClassName(): string;
  41996. /**
  41997. * Get the friendly name associated with the input class.
  41998. * @returns the input friendly name
  41999. */
  42000. getSimpleName(): string;
  42001. }
  42002. }
  42003. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42004. import { Nullable } from "babylonjs/types";
  42005. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42006. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42007. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42008. /**
  42009. * Manage the gamepad inputs to control a free camera.
  42010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42011. */
  42012. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42013. /**
  42014. * Define the camera the input is attached to.
  42015. */
  42016. camera: FreeCamera;
  42017. /**
  42018. * Define the Gamepad controlling the input
  42019. */
  42020. gamepad: Nullable<Gamepad>;
  42021. /**
  42022. * Defines the gamepad rotation sensiblity.
  42023. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42024. */
  42025. gamepadAngularSensibility: number;
  42026. /**
  42027. * Defines the gamepad move sensiblity.
  42028. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42029. */
  42030. gamepadMoveSensibility: number;
  42031. private _yAxisScale;
  42032. /**
  42033. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42034. */
  42035. get invertYAxis(): boolean;
  42036. set invertYAxis(value: boolean);
  42037. private _onGamepadConnectedObserver;
  42038. private _onGamepadDisconnectedObserver;
  42039. private _cameraTransform;
  42040. private _deltaTransform;
  42041. private _vector3;
  42042. private _vector2;
  42043. /**
  42044. * Attach the input controls to a specific dom element to get the input from.
  42045. * @param element Defines the element the controls should be listened from
  42046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42047. */
  42048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42049. /**
  42050. * Detach the current controls from the specified dom element.
  42051. * @param element Defines the element to stop listening the inputs from
  42052. */
  42053. detachControl(element: Nullable<HTMLElement>): void;
  42054. /**
  42055. * Update the current camera state depending on the inputs that have been used this frame.
  42056. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42057. */
  42058. checkInputs(): void;
  42059. /**
  42060. * Gets the class name of the current intput.
  42061. * @returns the class name
  42062. */
  42063. getClassName(): string;
  42064. /**
  42065. * Get the friendly name associated with the input class.
  42066. * @returns the input friendly name
  42067. */
  42068. getSimpleName(): string;
  42069. }
  42070. }
  42071. declare module "babylonjs/Misc/virtualJoystick" {
  42072. import { Nullable } from "babylonjs/types";
  42073. import { Vector3 } from "babylonjs/Maths/math.vector";
  42074. /**
  42075. * Defines the potential axis of a Joystick
  42076. */
  42077. export enum JoystickAxis {
  42078. /** X axis */
  42079. X = 0,
  42080. /** Y axis */
  42081. Y = 1,
  42082. /** Z axis */
  42083. Z = 2
  42084. }
  42085. /**
  42086. * Class used to define virtual joystick (used in touch mode)
  42087. */
  42088. export class VirtualJoystick {
  42089. /**
  42090. * Gets or sets a boolean indicating that left and right values must be inverted
  42091. */
  42092. reverseLeftRight: boolean;
  42093. /**
  42094. * Gets or sets a boolean indicating that up and down values must be inverted
  42095. */
  42096. reverseUpDown: boolean;
  42097. /**
  42098. * Gets the offset value for the position (ie. the change of the position value)
  42099. */
  42100. deltaPosition: Vector3;
  42101. /**
  42102. * Gets a boolean indicating if the virtual joystick was pressed
  42103. */
  42104. pressed: boolean;
  42105. /**
  42106. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42107. */
  42108. static Canvas: Nullable<HTMLCanvasElement>;
  42109. private static _globalJoystickIndex;
  42110. private static vjCanvasContext;
  42111. private static vjCanvasWidth;
  42112. private static vjCanvasHeight;
  42113. private static halfWidth;
  42114. private _action;
  42115. private _axisTargetedByLeftAndRight;
  42116. private _axisTargetedByUpAndDown;
  42117. private _joystickSensibility;
  42118. private _inversedSensibility;
  42119. private _joystickPointerID;
  42120. private _joystickColor;
  42121. private _joystickPointerPos;
  42122. private _joystickPreviousPointerPos;
  42123. private _joystickPointerStartPos;
  42124. private _deltaJoystickVector;
  42125. private _leftJoystick;
  42126. private _touches;
  42127. private _onPointerDownHandlerRef;
  42128. private _onPointerMoveHandlerRef;
  42129. private _onPointerUpHandlerRef;
  42130. private _onResize;
  42131. /**
  42132. * Creates a new virtual joystick
  42133. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42134. */
  42135. constructor(leftJoystick?: boolean);
  42136. /**
  42137. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42138. * @param newJoystickSensibility defines the new sensibility
  42139. */
  42140. setJoystickSensibility(newJoystickSensibility: number): void;
  42141. private _onPointerDown;
  42142. private _onPointerMove;
  42143. private _onPointerUp;
  42144. /**
  42145. * Change the color of the virtual joystick
  42146. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42147. */
  42148. setJoystickColor(newColor: string): void;
  42149. /**
  42150. * Defines a callback to call when the joystick is touched
  42151. * @param action defines the callback
  42152. */
  42153. setActionOnTouch(action: () => any): void;
  42154. /**
  42155. * Defines which axis you'd like to control for left & right
  42156. * @param axis defines the axis to use
  42157. */
  42158. setAxisForLeftRight(axis: JoystickAxis): void;
  42159. /**
  42160. * Defines which axis you'd like to control for up & down
  42161. * @param axis defines the axis to use
  42162. */
  42163. setAxisForUpDown(axis: JoystickAxis): void;
  42164. private _drawVirtualJoystick;
  42165. /**
  42166. * Release internal HTML canvas
  42167. */
  42168. releaseCanvas(): void;
  42169. }
  42170. }
  42171. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42172. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42173. import { Nullable } from "babylonjs/types";
  42174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42175. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42176. module "babylonjs/Cameras/freeCameraInputsManager" {
  42177. interface FreeCameraInputsManager {
  42178. /**
  42179. * Add virtual joystick input support to the input manager.
  42180. * @returns the current input manager
  42181. */
  42182. addVirtualJoystick(): FreeCameraInputsManager;
  42183. }
  42184. }
  42185. /**
  42186. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42188. */
  42189. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42190. /**
  42191. * Defines the camera the input is attached to.
  42192. */
  42193. camera: FreeCamera;
  42194. private _leftjoystick;
  42195. private _rightjoystick;
  42196. /**
  42197. * Gets the left stick of the virtual joystick.
  42198. * @returns The virtual Joystick
  42199. */
  42200. getLeftJoystick(): VirtualJoystick;
  42201. /**
  42202. * Gets the right stick of the virtual joystick.
  42203. * @returns The virtual Joystick
  42204. */
  42205. getRightJoystick(): VirtualJoystick;
  42206. /**
  42207. * Update the current camera state depending on the inputs that have been used this frame.
  42208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42209. */
  42210. checkInputs(): void;
  42211. /**
  42212. * Attach the input controls to a specific dom element to get the input from.
  42213. * @param element Defines the element the controls should be listened from
  42214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42215. */
  42216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42217. /**
  42218. * Detach the current controls from the specified dom element.
  42219. * @param element Defines the element to stop listening the inputs from
  42220. */
  42221. detachControl(element: Nullable<HTMLElement>): void;
  42222. /**
  42223. * Gets the class name of the current intput.
  42224. * @returns the class name
  42225. */
  42226. getClassName(): string;
  42227. /**
  42228. * Get the friendly name associated with the input class.
  42229. * @returns the input friendly name
  42230. */
  42231. getSimpleName(): string;
  42232. }
  42233. }
  42234. declare module "babylonjs/Cameras/Inputs/index" {
  42235. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42236. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42237. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42238. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42239. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42240. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42241. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42242. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42243. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42244. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42245. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42246. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42247. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42248. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42249. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42250. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42251. }
  42252. declare module "babylonjs/Cameras/touchCamera" {
  42253. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42254. import { Scene } from "babylonjs/scene";
  42255. import { Vector3 } from "babylonjs/Maths/math.vector";
  42256. /**
  42257. * This represents a FPS type of camera controlled by touch.
  42258. * This is like a universal camera minus the Gamepad controls.
  42259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42260. */
  42261. export class TouchCamera extends FreeCamera {
  42262. /**
  42263. * Defines the touch sensibility for rotation.
  42264. * The higher the faster.
  42265. */
  42266. get touchAngularSensibility(): number;
  42267. set touchAngularSensibility(value: number);
  42268. /**
  42269. * Defines the touch sensibility for move.
  42270. * The higher the faster.
  42271. */
  42272. get touchMoveSensibility(): number;
  42273. set touchMoveSensibility(value: number);
  42274. /**
  42275. * Instantiates a new touch camera.
  42276. * This represents a FPS type of camera controlled by touch.
  42277. * This is like a universal camera minus the Gamepad controls.
  42278. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42279. * @param name Define the name of the camera in the scene
  42280. * @param position Define the start position of the camera in the scene
  42281. * @param scene Define the scene the camera belongs to
  42282. */
  42283. constructor(name: string, position: Vector3, scene: Scene);
  42284. /**
  42285. * Gets the current object class name.
  42286. * @return the class name
  42287. */
  42288. getClassName(): string;
  42289. /** @hidden */
  42290. _setupInputs(): void;
  42291. }
  42292. }
  42293. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42294. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42295. import { Scene } from "babylonjs/scene";
  42296. import { Vector3 } from "babylonjs/Maths/math.vector";
  42297. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42298. import { Axis } from "babylonjs/Maths/math.axis";
  42299. /**
  42300. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42301. * being tilted forward or back and left or right.
  42302. */
  42303. export class DeviceOrientationCamera extends FreeCamera {
  42304. private _initialQuaternion;
  42305. private _quaternionCache;
  42306. private _tmpDragQuaternion;
  42307. private _disablePointerInputWhenUsingDeviceOrientation;
  42308. /**
  42309. * Creates a new device orientation camera
  42310. * @param name The name of the camera
  42311. * @param position The start position camera
  42312. * @param scene The scene the camera belongs to
  42313. */
  42314. constructor(name: string, position: Vector3, scene: Scene);
  42315. /**
  42316. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42317. */
  42318. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42319. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42320. private _dragFactor;
  42321. /**
  42322. * Enabled turning on the y axis when the orientation sensor is active
  42323. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42324. */
  42325. enableHorizontalDragging(dragFactor?: number): void;
  42326. /**
  42327. * Gets the current instance class name ("DeviceOrientationCamera").
  42328. * This helps avoiding instanceof at run time.
  42329. * @returns the class name
  42330. */
  42331. getClassName(): string;
  42332. /**
  42333. * @hidden
  42334. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42335. */
  42336. _checkInputs(): void;
  42337. /**
  42338. * Reset the camera to its default orientation on the specified axis only.
  42339. * @param axis The axis to reset
  42340. */
  42341. resetToCurrentRotation(axis?: Axis): void;
  42342. }
  42343. }
  42344. declare module "babylonjs/Gamepads/xboxGamepad" {
  42345. import { Observable } from "babylonjs/Misc/observable";
  42346. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42347. /**
  42348. * Defines supported buttons for XBox360 compatible gamepads
  42349. */
  42350. export enum Xbox360Button {
  42351. /** A */
  42352. A = 0,
  42353. /** B */
  42354. B = 1,
  42355. /** X */
  42356. X = 2,
  42357. /** Y */
  42358. Y = 3,
  42359. /** Left button */
  42360. LB = 4,
  42361. /** Right button */
  42362. RB = 5,
  42363. /** Back */
  42364. Back = 8,
  42365. /** Start */
  42366. Start = 9,
  42367. /** Left stick */
  42368. LeftStick = 10,
  42369. /** Right stick */
  42370. RightStick = 11
  42371. }
  42372. /** Defines values for XBox360 DPad */
  42373. export enum Xbox360Dpad {
  42374. /** Up */
  42375. Up = 12,
  42376. /** Down */
  42377. Down = 13,
  42378. /** Left */
  42379. Left = 14,
  42380. /** Right */
  42381. Right = 15
  42382. }
  42383. /**
  42384. * Defines a XBox360 gamepad
  42385. */
  42386. export class Xbox360Pad extends Gamepad {
  42387. private _leftTrigger;
  42388. private _rightTrigger;
  42389. private _onlefttriggerchanged;
  42390. private _onrighttriggerchanged;
  42391. private _onbuttondown;
  42392. private _onbuttonup;
  42393. private _ondpaddown;
  42394. private _ondpadup;
  42395. /** Observable raised when a button is pressed */
  42396. onButtonDownObservable: Observable<Xbox360Button>;
  42397. /** Observable raised when a button is released */
  42398. onButtonUpObservable: Observable<Xbox360Button>;
  42399. /** Observable raised when a pad is pressed */
  42400. onPadDownObservable: Observable<Xbox360Dpad>;
  42401. /** Observable raised when a pad is released */
  42402. onPadUpObservable: Observable<Xbox360Dpad>;
  42403. private _buttonA;
  42404. private _buttonB;
  42405. private _buttonX;
  42406. private _buttonY;
  42407. private _buttonBack;
  42408. private _buttonStart;
  42409. private _buttonLB;
  42410. private _buttonRB;
  42411. private _buttonLeftStick;
  42412. private _buttonRightStick;
  42413. private _dPadUp;
  42414. private _dPadDown;
  42415. private _dPadLeft;
  42416. private _dPadRight;
  42417. private _isXboxOnePad;
  42418. /**
  42419. * Creates a new XBox360 gamepad object
  42420. * @param id defines the id of this gamepad
  42421. * @param index defines its index
  42422. * @param gamepad defines the internal HTML gamepad object
  42423. * @param xboxOne defines if it is a XBox One gamepad
  42424. */
  42425. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42426. /**
  42427. * Defines the callback to call when left trigger is pressed
  42428. * @param callback defines the callback to use
  42429. */
  42430. onlefttriggerchanged(callback: (value: number) => void): void;
  42431. /**
  42432. * Defines the callback to call when right trigger is pressed
  42433. * @param callback defines the callback to use
  42434. */
  42435. onrighttriggerchanged(callback: (value: number) => void): void;
  42436. /**
  42437. * Gets the left trigger value
  42438. */
  42439. get leftTrigger(): number;
  42440. /**
  42441. * Sets the left trigger value
  42442. */
  42443. set leftTrigger(newValue: number);
  42444. /**
  42445. * Gets the right trigger value
  42446. */
  42447. get rightTrigger(): number;
  42448. /**
  42449. * Sets the right trigger value
  42450. */
  42451. set rightTrigger(newValue: number);
  42452. /**
  42453. * Defines the callback to call when a button is pressed
  42454. * @param callback defines the callback to use
  42455. */
  42456. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42457. /**
  42458. * Defines the callback to call when a button is released
  42459. * @param callback defines the callback to use
  42460. */
  42461. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42462. /**
  42463. * Defines the callback to call when a pad is pressed
  42464. * @param callback defines the callback to use
  42465. */
  42466. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42467. /**
  42468. * Defines the callback to call when a pad is released
  42469. * @param callback defines the callback to use
  42470. */
  42471. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42472. private _setButtonValue;
  42473. private _setDPadValue;
  42474. /**
  42475. * Gets the value of the `A` button
  42476. */
  42477. get buttonA(): number;
  42478. /**
  42479. * Sets the value of the `A` button
  42480. */
  42481. set buttonA(value: number);
  42482. /**
  42483. * Gets the value of the `B` button
  42484. */
  42485. get buttonB(): number;
  42486. /**
  42487. * Sets the value of the `B` button
  42488. */
  42489. set buttonB(value: number);
  42490. /**
  42491. * Gets the value of the `X` button
  42492. */
  42493. get buttonX(): number;
  42494. /**
  42495. * Sets the value of the `X` button
  42496. */
  42497. set buttonX(value: number);
  42498. /**
  42499. * Gets the value of the `Y` button
  42500. */
  42501. get buttonY(): number;
  42502. /**
  42503. * Sets the value of the `Y` button
  42504. */
  42505. set buttonY(value: number);
  42506. /**
  42507. * Gets the value of the `Start` button
  42508. */
  42509. get buttonStart(): number;
  42510. /**
  42511. * Sets the value of the `Start` button
  42512. */
  42513. set buttonStart(value: number);
  42514. /**
  42515. * Gets the value of the `Back` button
  42516. */
  42517. get buttonBack(): number;
  42518. /**
  42519. * Sets the value of the `Back` button
  42520. */
  42521. set buttonBack(value: number);
  42522. /**
  42523. * Gets the value of the `Left` button
  42524. */
  42525. get buttonLB(): number;
  42526. /**
  42527. * Sets the value of the `Left` button
  42528. */
  42529. set buttonLB(value: number);
  42530. /**
  42531. * Gets the value of the `Right` button
  42532. */
  42533. get buttonRB(): number;
  42534. /**
  42535. * Sets the value of the `Right` button
  42536. */
  42537. set buttonRB(value: number);
  42538. /**
  42539. * Gets the value of the Left joystick
  42540. */
  42541. get buttonLeftStick(): number;
  42542. /**
  42543. * Sets the value of the Left joystick
  42544. */
  42545. set buttonLeftStick(value: number);
  42546. /**
  42547. * Gets the value of the Right joystick
  42548. */
  42549. get buttonRightStick(): number;
  42550. /**
  42551. * Sets the value of the Right joystick
  42552. */
  42553. set buttonRightStick(value: number);
  42554. /**
  42555. * Gets the value of D-pad up
  42556. */
  42557. get dPadUp(): number;
  42558. /**
  42559. * Sets the value of D-pad up
  42560. */
  42561. set dPadUp(value: number);
  42562. /**
  42563. * Gets the value of D-pad down
  42564. */
  42565. get dPadDown(): number;
  42566. /**
  42567. * Sets the value of D-pad down
  42568. */
  42569. set dPadDown(value: number);
  42570. /**
  42571. * Gets the value of D-pad left
  42572. */
  42573. get dPadLeft(): number;
  42574. /**
  42575. * Sets the value of D-pad left
  42576. */
  42577. set dPadLeft(value: number);
  42578. /**
  42579. * Gets the value of D-pad right
  42580. */
  42581. get dPadRight(): number;
  42582. /**
  42583. * Sets the value of D-pad right
  42584. */
  42585. set dPadRight(value: number);
  42586. /**
  42587. * Force the gamepad to synchronize with device values
  42588. */
  42589. update(): void;
  42590. /**
  42591. * Disposes the gamepad
  42592. */
  42593. dispose(): void;
  42594. }
  42595. }
  42596. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42597. import { Observable } from "babylonjs/Misc/observable";
  42598. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42599. /**
  42600. * Defines supported buttons for DualShock compatible gamepads
  42601. */
  42602. export enum DualShockButton {
  42603. /** Cross */
  42604. Cross = 0,
  42605. /** Circle */
  42606. Circle = 1,
  42607. /** Square */
  42608. Square = 2,
  42609. /** Triangle */
  42610. Triangle = 3,
  42611. /** L1 */
  42612. L1 = 4,
  42613. /** R1 */
  42614. R1 = 5,
  42615. /** Share */
  42616. Share = 8,
  42617. /** Options */
  42618. Options = 9,
  42619. /** Left stick */
  42620. LeftStick = 10,
  42621. /** Right stick */
  42622. RightStick = 11
  42623. }
  42624. /** Defines values for DualShock DPad */
  42625. export enum DualShockDpad {
  42626. /** Up */
  42627. Up = 12,
  42628. /** Down */
  42629. Down = 13,
  42630. /** Left */
  42631. Left = 14,
  42632. /** Right */
  42633. Right = 15
  42634. }
  42635. /**
  42636. * Defines a DualShock gamepad
  42637. */
  42638. export class DualShockPad extends Gamepad {
  42639. private _leftTrigger;
  42640. private _rightTrigger;
  42641. private _onlefttriggerchanged;
  42642. private _onrighttriggerchanged;
  42643. private _onbuttondown;
  42644. private _onbuttonup;
  42645. private _ondpaddown;
  42646. private _ondpadup;
  42647. /** Observable raised when a button is pressed */
  42648. onButtonDownObservable: Observable<DualShockButton>;
  42649. /** Observable raised when a button is released */
  42650. onButtonUpObservable: Observable<DualShockButton>;
  42651. /** Observable raised when a pad is pressed */
  42652. onPadDownObservable: Observable<DualShockDpad>;
  42653. /** Observable raised when a pad is released */
  42654. onPadUpObservable: Observable<DualShockDpad>;
  42655. private _buttonCross;
  42656. private _buttonCircle;
  42657. private _buttonSquare;
  42658. private _buttonTriangle;
  42659. private _buttonShare;
  42660. private _buttonOptions;
  42661. private _buttonL1;
  42662. private _buttonR1;
  42663. private _buttonLeftStick;
  42664. private _buttonRightStick;
  42665. private _dPadUp;
  42666. private _dPadDown;
  42667. private _dPadLeft;
  42668. private _dPadRight;
  42669. /**
  42670. * Creates a new DualShock gamepad object
  42671. * @param id defines the id of this gamepad
  42672. * @param index defines its index
  42673. * @param gamepad defines the internal HTML gamepad object
  42674. */
  42675. constructor(id: string, index: number, gamepad: any);
  42676. /**
  42677. * Defines the callback to call when left trigger is pressed
  42678. * @param callback defines the callback to use
  42679. */
  42680. onlefttriggerchanged(callback: (value: number) => void): void;
  42681. /**
  42682. * Defines the callback to call when right trigger is pressed
  42683. * @param callback defines the callback to use
  42684. */
  42685. onrighttriggerchanged(callback: (value: number) => void): void;
  42686. /**
  42687. * Gets the left trigger value
  42688. */
  42689. get leftTrigger(): number;
  42690. /**
  42691. * Sets the left trigger value
  42692. */
  42693. set leftTrigger(newValue: number);
  42694. /**
  42695. * Gets the right trigger value
  42696. */
  42697. get rightTrigger(): number;
  42698. /**
  42699. * Sets the right trigger value
  42700. */
  42701. set rightTrigger(newValue: number);
  42702. /**
  42703. * Defines the callback to call when a button is pressed
  42704. * @param callback defines the callback to use
  42705. */
  42706. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42707. /**
  42708. * Defines the callback to call when a button is released
  42709. * @param callback defines the callback to use
  42710. */
  42711. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42712. /**
  42713. * Defines the callback to call when a pad is pressed
  42714. * @param callback defines the callback to use
  42715. */
  42716. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42717. /**
  42718. * Defines the callback to call when a pad is released
  42719. * @param callback defines the callback to use
  42720. */
  42721. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42722. private _setButtonValue;
  42723. private _setDPadValue;
  42724. /**
  42725. * Gets the value of the `Cross` button
  42726. */
  42727. get buttonCross(): number;
  42728. /**
  42729. * Sets the value of the `Cross` button
  42730. */
  42731. set buttonCross(value: number);
  42732. /**
  42733. * Gets the value of the `Circle` button
  42734. */
  42735. get buttonCircle(): number;
  42736. /**
  42737. * Sets the value of the `Circle` button
  42738. */
  42739. set buttonCircle(value: number);
  42740. /**
  42741. * Gets the value of the `Square` button
  42742. */
  42743. get buttonSquare(): number;
  42744. /**
  42745. * Sets the value of the `Square` button
  42746. */
  42747. set buttonSquare(value: number);
  42748. /**
  42749. * Gets the value of the `Triangle` button
  42750. */
  42751. get buttonTriangle(): number;
  42752. /**
  42753. * Sets the value of the `Triangle` button
  42754. */
  42755. set buttonTriangle(value: number);
  42756. /**
  42757. * Gets the value of the `Options` button
  42758. */
  42759. get buttonOptions(): number;
  42760. /**
  42761. * Sets the value of the `Options` button
  42762. */
  42763. set buttonOptions(value: number);
  42764. /**
  42765. * Gets the value of the `Share` button
  42766. */
  42767. get buttonShare(): number;
  42768. /**
  42769. * Sets the value of the `Share` button
  42770. */
  42771. set buttonShare(value: number);
  42772. /**
  42773. * Gets the value of the `L1` button
  42774. */
  42775. get buttonL1(): number;
  42776. /**
  42777. * Sets the value of the `L1` button
  42778. */
  42779. set buttonL1(value: number);
  42780. /**
  42781. * Gets the value of the `R1` button
  42782. */
  42783. get buttonR1(): number;
  42784. /**
  42785. * Sets the value of the `R1` button
  42786. */
  42787. set buttonR1(value: number);
  42788. /**
  42789. * Gets the value of the Left joystick
  42790. */
  42791. get buttonLeftStick(): number;
  42792. /**
  42793. * Sets the value of the Left joystick
  42794. */
  42795. set buttonLeftStick(value: number);
  42796. /**
  42797. * Gets the value of the Right joystick
  42798. */
  42799. get buttonRightStick(): number;
  42800. /**
  42801. * Sets the value of the Right joystick
  42802. */
  42803. set buttonRightStick(value: number);
  42804. /**
  42805. * Gets the value of D-pad up
  42806. */
  42807. get dPadUp(): number;
  42808. /**
  42809. * Sets the value of D-pad up
  42810. */
  42811. set dPadUp(value: number);
  42812. /**
  42813. * Gets the value of D-pad down
  42814. */
  42815. get dPadDown(): number;
  42816. /**
  42817. * Sets the value of D-pad down
  42818. */
  42819. set dPadDown(value: number);
  42820. /**
  42821. * Gets the value of D-pad left
  42822. */
  42823. get dPadLeft(): number;
  42824. /**
  42825. * Sets the value of D-pad left
  42826. */
  42827. set dPadLeft(value: number);
  42828. /**
  42829. * Gets the value of D-pad right
  42830. */
  42831. get dPadRight(): number;
  42832. /**
  42833. * Sets the value of D-pad right
  42834. */
  42835. set dPadRight(value: number);
  42836. /**
  42837. * Force the gamepad to synchronize with device values
  42838. */
  42839. update(): void;
  42840. /**
  42841. * Disposes the gamepad
  42842. */
  42843. dispose(): void;
  42844. }
  42845. }
  42846. declare module "babylonjs/Gamepads/gamepadManager" {
  42847. import { Observable } from "babylonjs/Misc/observable";
  42848. import { Nullable } from "babylonjs/types";
  42849. import { Scene } from "babylonjs/scene";
  42850. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42851. /**
  42852. * Manager for handling gamepads
  42853. */
  42854. export class GamepadManager {
  42855. private _scene?;
  42856. private _babylonGamepads;
  42857. private _oneGamepadConnected;
  42858. /** @hidden */
  42859. _isMonitoring: boolean;
  42860. private _gamepadEventSupported;
  42861. private _gamepadSupport?;
  42862. /**
  42863. * observable to be triggered when the gamepad controller has been connected
  42864. */
  42865. onGamepadConnectedObservable: Observable<Gamepad>;
  42866. /**
  42867. * observable to be triggered when the gamepad controller has been disconnected
  42868. */
  42869. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42870. private _onGamepadConnectedEvent;
  42871. private _onGamepadDisconnectedEvent;
  42872. /**
  42873. * Initializes the gamepad manager
  42874. * @param _scene BabylonJS scene
  42875. */
  42876. constructor(_scene?: Scene | undefined);
  42877. /**
  42878. * The gamepads in the game pad manager
  42879. */
  42880. get gamepads(): Gamepad[];
  42881. /**
  42882. * Get the gamepad controllers based on type
  42883. * @param type The type of gamepad controller
  42884. * @returns Nullable gamepad
  42885. */
  42886. getGamepadByType(type?: number): Nullable<Gamepad>;
  42887. /**
  42888. * Disposes the gamepad manager
  42889. */
  42890. dispose(): void;
  42891. private _addNewGamepad;
  42892. private _startMonitoringGamepads;
  42893. private _stopMonitoringGamepads;
  42894. /** @hidden */
  42895. _checkGamepadsStatus(): void;
  42896. private _updateGamepadObjects;
  42897. }
  42898. }
  42899. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42900. import { Nullable } from "babylonjs/types";
  42901. import { Scene } from "babylonjs/scene";
  42902. import { ISceneComponent } from "babylonjs/sceneComponent";
  42903. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42904. module "babylonjs/scene" {
  42905. interface Scene {
  42906. /** @hidden */
  42907. _gamepadManager: Nullable<GamepadManager>;
  42908. /**
  42909. * Gets the gamepad manager associated with the scene
  42910. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42911. */
  42912. gamepadManager: GamepadManager;
  42913. }
  42914. }
  42915. module "babylonjs/Cameras/freeCameraInputsManager" {
  42916. /**
  42917. * Interface representing a free camera inputs manager
  42918. */
  42919. interface FreeCameraInputsManager {
  42920. /**
  42921. * Adds gamepad input support to the FreeCameraInputsManager.
  42922. * @returns the FreeCameraInputsManager
  42923. */
  42924. addGamepad(): FreeCameraInputsManager;
  42925. }
  42926. }
  42927. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42928. /**
  42929. * Interface representing an arc rotate camera inputs manager
  42930. */
  42931. interface ArcRotateCameraInputsManager {
  42932. /**
  42933. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42934. * @returns the camera inputs manager
  42935. */
  42936. addGamepad(): ArcRotateCameraInputsManager;
  42937. }
  42938. }
  42939. /**
  42940. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42941. */
  42942. export class GamepadSystemSceneComponent implements ISceneComponent {
  42943. /**
  42944. * The component name helpfull to identify the component in the list of scene components.
  42945. */
  42946. readonly name: string;
  42947. /**
  42948. * The scene the component belongs to.
  42949. */
  42950. scene: Scene;
  42951. /**
  42952. * Creates a new instance of the component for the given scene
  42953. * @param scene Defines the scene to register the component in
  42954. */
  42955. constructor(scene: Scene);
  42956. /**
  42957. * Registers the component in a given scene
  42958. */
  42959. register(): void;
  42960. /**
  42961. * Rebuilds the elements related to this component in case of
  42962. * context lost for instance.
  42963. */
  42964. rebuild(): void;
  42965. /**
  42966. * Disposes the component and the associated ressources
  42967. */
  42968. dispose(): void;
  42969. private _beforeCameraUpdate;
  42970. }
  42971. }
  42972. declare module "babylonjs/Cameras/universalCamera" {
  42973. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42974. import { Scene } from "babylonjs/scene";
  42975. import { Vector3 } from "babylonjs/Maths/math.vector";
  42976. import "babylonjs/Gamepads/gamepadSceneComponent";
  42977. /**
  42978. * 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,
  42979. * which still works and will still be found in many Playgrounds.
  42980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42981. */
  42982. export class UniversalCamera extends TouchCamera {
  42983. /**
  42984. * Defines the gamepad rotation sensiblity.
  42985. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42986. */
  42987. get gamepadAngularSensibility(): number;
  42988. set gamepadAngularSensibility(value: number);
  42989. /**
  42990. * Defines the gamepad move sensiblity.
  42991. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42992. */
  42993. get gamepadMoveSensibility(): number;
  42994. set gamepadMoveSensibility(value: number);
  42995. /**
  42996. * 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,
  42997. * which still works and will still be found in many Playgrounds.
  42998. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42999. * @param name Define the name of the camera in the scene
  43000. * @param position Define the start position of the camera in the scene
  43001. * @param scene Define the scene the camera belongs to
  43002. */
  43003. constructor(name: string, position: Vector3, scene: Scene);
  43004. /**
  43005. * Gets the current object class name.
  43006. * @return the class name
  43007. */
  43008. getClassName(): string;
  43009. }
  43010. }
  43011. declare module "babylonjs/Cameras/gamepadCamera" {
  43012. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43013. import { Scene } from "babylonjs/scene";
  43014. import { Vector3 } from "babylonjs/Maths/math.vector";
  43015. /**
  43016. * This represents a FPS type of camera. This is only here for back compat purpose.
  43017. * Please use the UniversalCamera instead as both are identical.
  43018. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43019. */
  43020. export class GamepadCamera extends UniversalCamera {
  43021. /**
  43022. * Instantiates a new Gamepad Camera
  43023. * This represents a FPS type of camera. This is only here for back compat purpose.
  43024. * Please use the UniversalCamera instead as both are identical.
  43025. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43026. * @param name Define the name of the camera in the scene
  43027. * @param position Define the start position of the camera in the scene
  43028. * @param scene Define the scene the camera belongs to
  43029. */
  43030. constructor(name: string, position: Vector3, scene: Scene);
  43031. /**
  43032. * Gets the current object class name.
  43033. * @return the class name
  43034. */
  43035. getClassName(): string;
  43036. }
  43037. }
  43038. declare module "babylonjs/Shaders/pass.fragment" {
  43039. /** @hidden */
  43040. export var passPixelShader: {
  43041. name: string;
  43042. shader: string;
  43043. };
  43044. }
  43045. declare module "babylonjs/Shaders/passCube.fragment" {
  43046. /** @hidden */
  43047. export var passCubePixelShader: {
  43048. name: string;
  43049. shader: string;
  43050. };
  43051. }
  43052. declare module "babylonjs/PostProcesses/passPostProcess" {
  43053. import { Nullable } from "babylonjs/types";
  43054. import { Camera } from "babylonjs/Cameras/camera";
  43055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43056. import { Engine } from "babylonjs/Engines/engine";
  43057. import "babylonjs/Shaders/pass.fragment";
  43058. import "babylonjs/Shaders/passCube.fragment";
  43059. /**
  43060. * PassPostProcess which produces an output the same as it's input
  43061. */
  43062. export class PassPostProcess extends PostProcess {
  43063. /**
  43064. * Creates the PassPostProcess
  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. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43078. */
  43079. export class PassCubePostProcess extends PostProcess {
  43080. private _face;
  43081. /**
  43082. * Gets or sets the cube face to display.
  43083. * * 0 is +X
  43084. * * 1 is -X
  43085. * * 2 is +Y
  43086. * * 3 is -Y
  43087. * * 4 is +Z
  43088. * * 5 is -Z
  43089. */
  43090. get face(): number;
  43091. set face(value: number);
  43092. /**
  43093. * Creates the PassCubePostProcess
  43094. * @param name The name of the effect.
  43095. * @param options The required width/height ratio to downsize to before computing the render pass.
  43096. * @param camera The camera to apply the render pass to.
  43097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43098. * @param engine The engine which the post process will be applied. (default: current engine)
  43099. * @param reusable If the post process can be reused on the same frame. (default: false)
  43100. * @param textureType The type of texture to be used when performing the post processing.
  43101. * @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)
  43102. */
  43103. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43104. }
  43105. }
  43106. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43107. /** @hidden */
  43108. export var anaglyphPixelShader: {
  43109. name: string;
  43110. shader: string;
  43111. };
  43112. }
  43113. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43114. import { Engine } from "babylonjs/Engines/engine";
  43115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43116. import { Camera } from "babylonjs/Cameras/camera";
  43117. import "babylonjs/Shaders/anaglyph.fragment";
  43118. /**
  43119. * Postprocess used to generate anaglyphic rendering
  43120. */
  43121. export class AnaglyphPostProcess extends PostProcess {
  43122. private _passedProcess;
  43123. /**
  43124. * Creates a new AnaglyphPostProcess
  43125. * @param name defines postprocess name
  43126. * @param options defines creation options or target ratio scale
  43127. * @param rigCameras defines cameras using this postprocess
  43128. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43129. * @param engine defines hosting engine
  43130. * @param reusable defines if the postprocess will be reused multiple times per frame
  43131. */
  43132. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43133. }
  43134. }
  43135. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43136. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43138. import { Scene } from "babylonjs/scene";
  43139. import { Vector3 } from "babylonjs/Maths/math.vector";
  43140. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43141. /**
  43142. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43143. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43144. */
  43145. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43146. /**
  43147. * Creates a new AnaglyphArcRotateCamera
  43148. * @param name defines camera name
  43149. * @param alpha defines alpha angle (in radians)
  43150. * @param beta defines beta angle (in radians)
  43151. * @param radius defines radius
  43152. * @param target defines camera target
  43153. * @param interaxialDistance defines distance between each color axis
  43154. * @param scene defines the hosting scene
  43155. */
  43156. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43157. /**
  43158. * Gets camera class name
  43159. * @returns AnaglyphArcRotateCamera
  43160. */
  43161. getClassName(): string;
  43162. }
  43163. }
  43164. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43165. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43166. import { Scene } from "babylonjs/scene";
  43167. import { Vector3 } from "babylonjs/Maths/math.vector";
  43168. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43169. /**
  43170. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43171. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43172. */
  43173. export class AnaglyphFreeCamera extends FreeCamera {
  43174. /**
  43175. * Creates a new AnaglyphFreeCamera
  43176. * @param name defines camera name
  43177. * @param position defines initial position
  43178. * @param interaxialDistance defines distance between each color axis
  43179. * @param scene defines the hosting scene
  43180. */
  43181. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43182. /**
  43183. * Gets camera class name
  43184. * @returns AnaglyphFreeCamera
  43185. */
  43186. getClassName(): string;
  43187. }
  43188. }
  43189. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43190. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43191. import { Scene } from "babylonjs/scene";
  43192. import { Vector3 } from "babylonjs/Maths/math.vector";
  43193. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43194. /**
  43195. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43196. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43197. */
  43198. export class AnaglyphGamepadCamera extends GamepadCamera {
  43199. /**
  43200. * Creates a new AnaglyphGamepadCamera
  43201. * @param name defines camera name
  43202. * @param position defines initial position
  43203. * @param interaxialDistance defines distance between each color axis
  43204. * @param scene defines the hosting scene
  43205. */
  43206. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43207. /**
  43208. * Gets camera class name
  43209. * @returns AnaglyphGamepadCamera
  43210. */
  43211. getClassName(): string;
  43212. }
  43213. }
  43214. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43215. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43216. import { Scene } from "babylonjs/scene";
  43217. import { Vector3 } from "babylonjs/Maths/math.vector";
  43218. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43219. /**
  43220. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43221. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43222. */
  43223. export class AnaglyphUniversalCamera extends UniversalCamera {
  43224. /**
  43225. * Creates a new AnaglyphUniversalCamera
  43226. * @param name defines camera name
  43227. * @param position defines initial position
  43228. * @param interaxialDistance defines distance between each color axis
  43229. * @param scene defines the hosting scene
  43230. */
  43231. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43232. /**
  43233. * Gets camera class name
  43234. * @returns AnaglyphUniversalCamera
  43235. */
  43236. getClassName(): string;
  43237. }
  43238. }
  43239. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43240. /** @hidden */
  43241. export var stereoscopicInterlacePixelShader: {
  43242. name: string;
  43243. shader: string;
  43244. };
  43245. }
  43246. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43247. import { Camera } from "babylonjs/Cameras/camera";
  43248. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43249. import { Engine } from "babylonjs/Engines/engine";
  43250. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43251. /**
  43252. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43253. */
  43254. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43255. private _stepSize;
  43256. private _passedProcess;
  43257. /**
  43258. * Initializes a StereoscopicInterlacePostProcessI
  43259. * @param name The name of the effect.
  43260. * @param rigCameras The rig cameras to be appled to the post process
  43261. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43262. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43264. * @param engine The engine which the post process will be applied. (default: current engine)
  43265. * @param reusable If the post process can be reused on the same frame. (default: false)
  43266. */
  43267. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43268. }
  43269. /**
  43270. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43271. */
  43272. export class StereoscopicInterlacePostProcess extends PostProcess {
  43273. private _stepSize;
  43274. private _passedProcess;
  43275. /**
  43276. * Initializes a StereoscopicInterlacePostProcess
  43277. * @param name The name of the effect.
  43278. * @param rigCameras The rig cameras to be appled to the post process
  43279. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43281. * @param engine The engine which the post process will be applied. (default: current engine)
  43282. * @param reusable If the post process can be reused on the same frame. (default: false)
  43283. */
  43284. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43285. }
  43286. }
  43287. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43288. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43289. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  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 ArcRotateCamera)
  43295. * @see http://doc.babylonjs.com/features/cameras
  43296. */
  43297. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43298. /**
  43299. * Creates a new StereoscopicArcRotateCamera
  43300. * @param name defines camera name
  43301. * @param alpha defines alpha angle (in radians)
  43302. * @param beta defines beta angle (in radians)
  43303. * @param radius defines radius
  43304. * @param target defines camera target
  43305. * @param interaxialDistance defines distance between each color axis
  43306. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43307. * @param scene defines the hosting scene
  43308. */
  43309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43310. /**
  43311. * Gets camera class name
  43312. * @returns StereoscopicArcRotateCamera
  43313. */
  43314. getClassName(): string;
  43315. }
  43316. }
  43317. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43318. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43319. import { Scene } from "babylonjs/scene";
  43320. import { Vector3 } from "babylonjs/Maths/math.vector";
  43321. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43322. /**
  43323. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43324. * @see http://doc.babylonjs.com/features/cameras
  43325. */
  43326. export class StereoscopicFreeCamera extends FreeCamera {
  43327. /**
  43328. * Creates a new StereoscopicFreeCamera
  43329. * @param name defines camera name
  43330. * @param position defines initial position
  43331. * @param interaxialDistance defines distance between each color axis
  43332. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43333. * @param scene defines the hosting scene
  43334. */
  43335. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43336. /**
  43337. * Gets camera class name
  43338. * @returns StereoscopicFreeCamera
  43339. */
  43340. getClassName(): string;
  43341. }
  43342. }
  43343. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43344. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43345. import { Scene } from "babylonjs/scene";
  43346. import { Vector3 } from "babylonjs/Maths/math.vector";
  43347. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43348. /**
  43349. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43350. * @see http://doc.babylonjs.com/features/cameras
  43351. */
  43352. export class StereoscopicGamepadCamera extends GamepadCamera {
  43353. /**
  43354. * Creates a new StereoscopicGamepadCamera
  43355. * @param name defines camera name
  43356. * @param position defines initial position
  43357. * @param interaxialDistance defines distance between each color axis
  43358. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43359. * @param scene defines the hosting scene
  43360. */
  43361. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43362. /**
  43363. * Gets camera class name
  43364. * @returns StereoscopicGamepadCamera
  43365. */
  43366. getClassName(): string;
  43367. }
  43368. }
  43369. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43370. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43371. import { Scene } from "babylonjs/scene";
  43372. import { Vector3 } from "babylonjs/Maths/math.vector";
  43373. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43374. /**
  43375. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43376. * @see http://doc.babylonjs.com/features/cameras
  43377. */
  43378. export class StereoscopicUniversalCamera extends UniversalCamera {
  43379. /**
  43380. * Creates a new StereoscopicUniversalCamera
  43381. * @param name defines camera name
  43382. * @param position defines initial position
  43383. * @param interaxialDistance defines distance between each color axis
  43384. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43385. * @param scene defines the hosting scene
  43386. */
  43387. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43388. /**
  43389. * Gets camera class name
  43390. * @returns StereoscopicUniversalCamera
  43391. */
  43392. getClassName(): string;
  43393. }
  43394. }
  43395. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43396. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43397. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43398. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43399. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43400. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43401. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43402. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43403. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43404. }
  43405. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43406. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43407. import { Scene } from "babylonjs/scene";
  43408. import { Vector3 } from "babylonjs/Maths/math.vector";
  43409. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43410. /**
  43411. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43412. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43413. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43414. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43415. */
  43416. export class VirtualJoysticksCamera extends FreeCamera {
  43417. /**
  43418. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43419. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43420. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43421. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43422. * @param name Define the name of the camera in the scene
  43423. * @param position Define the start position of the camera in the scene
  43424. * @param scene Define the scene the camera belongs to
  43425. */
  43426. constructor(name: string, position: Vector3, scene: Scene);
  43427. /**
  43428. * Gets the current object class name.
  43429. * @return the class name
  43430. */
  43431. getClassName(): string;
  43432. }
  43433. }
  43434. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43435. import { Matrix } from "babylonjs/Maths/math.vector";
  43436. /**
  43437. * This represents all the required metrics to create a VR camera.
  43438. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43439. */
  43440. export class VRCameraMetrics {
  43441. /**
  43442. * Define the horizontal resolution off the screen.
  43443. */
  43444. hResolution: number;
  43445. /**
  43446. * Define the vertical resolution off the screen.
  43447. */
  43448. vResolution: number;
  43449. /**
  43450. * Define the horizontal screen size.
  43451. */
  43452. hScreenSize: number;
  43453. /**
  43454. * Define the vertical screen size.
  43455. */
  43456. vScreenSize: number;
  43457. /**
  43458. * Define the vertical screen center position.
  43459. */
  43460. vScreenCenter: number;
  43461. /**
  43462. * Define the distance of the eyes to the screen.
  43463. */
  43464. eyeToScreenDistance: number;
  43465. /**
  43466. * Define the distance between both lenses
  43467. */
  43468. lensSeparationDistance: number;
  43469. /**
  43470. * Define the distance between both viewer's eyes.
  43471. */
  43472. interpupillaryDistance: number;
  43473. /**
  43474. * Define the distortion factor of the VR postprocess.
  43475. * Please, touch with care.
  43476. */
  43477. distortionK: number[];
  43478. /**
  43479. * Define the chromatic aberration correction factors for the VR post process.
  43480. */
  43481. chromaAbCorrection: number[];
  43482. /**
  43483. * Define the scale factor of the post process.
  43484. * The smaller the better but the slower.
  43485. */
  43486. postProcessScaleFactor: number;
  43487. /**
  43488. * Define an offset for the lens center.
  43489. */
  43490. lensCenterOffset: number;
  43491. /**
  43492. * Define if the current vr camera should compensate the distortion of the lense or not.
  43493. */
  43494. compensateDistortion: boolean;
  43495. /**
  43496. * Defines if multiview should be enabled when rendering (Default: false)
  43497. */
  43498. multiviewEnabled: boolean;
  43499. /**
  43500. * Gets the rendering aspect ratio based on the provided resolutions.
  43501. */
  43502. get aspectRatio(): number;
  43503. /**
  43504. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43505. */
  43506. get aspectRatioFov(): number;
  43507. /**
  43508. * @hidden
  43509. */
  43510. get leftHMatrix(): Matrix;
  43511. /**
  43512. * @hidden
  43513. */
  43514. get rightHMatrix(): Matrix;
  43515. /**
  43516. * @hidden
  43517. */
  43518. get leftPreViewMatrix(): Matrix;
  43519. /**
  43520. * @hidden
  43521. */
  43522. get rightPreViewMatrix(): Matrix;
  43523. /**
  43524. * Get the default VRMetrics based on the most generic setup.
  43525. * @returns the default vr metrics
  43526. */
  43527. static GetDefault(): VRCameraMetrics;
  43528. }
  43529. }
  43530. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43531. /** @hidden */
  43532. export var vrDistortionCorrectionPixelShader: {
  43533. name: string;
  43534. shader: string;
  43535. };
  43536. }
  43537. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43538. import { Camera } from "babylonjs/Cameras/camera";
  43539. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43540. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43541. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43542. /**
  43543. * VRDistortionCorrectionPostProcess used for mobile VR
  43544. */
  43545. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43546. private _isRightEye;
  43547. private _distortionFactors;
  43548. private _postProcessScaleFactor;
  43549. private _lensCenterOffset;
  43550. private _scaleIn;
  43551. private _scaleFactor;
  43552. private _lensCenter;
  43553. /**
  43554. * Initializes the VRDistortionCorrectionPostProcess
  43555. * @param name The name of the effect.
  43556. * @param camera The camera to apply the render pass to.
  43557. * @param isRightEye If this is for the right eye distortion
  43558. * @param vrMetrics All the required metrics for the VR camera
  43559. */
  43560. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43561. }
  43562. }
  43563. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43564. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43565. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43566. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43567. import { Scene } from "babylonjs/scene";
  43568. import { Vector3 } from "babylonjs/Maths/math.vector";
  43569. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43570. import "babylonjs/Cameras/RigModes/vrRigMode";
  43571. /**
  43572. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43573. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43574. */
  43575. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43576. /**
  43577. * Creates a new VRDeviceOrientationArcRotateCamera
  43578. * @param name defines camera name
  43579. * @param alpha defines the camera rotation along the logitudinal axis
  43580. * @param beta defines the camera rotation along the latitudinal axis
  43581. * @param radius defines the camera distance from its target
  43582. * @param target defines the camera target
  43583. * @param scene defines the scene the camera belongs to
  43584. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43585. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43586. */
  43587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43588. /**
  43589. * Gets camera class name
  43590. * @returns VRDeviceOrientationArcRotateCamera
  43591. */
  43592. getClassName(): string;
  43593. }
  43594. }
  43595. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43596. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43597. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43598. import { Scene } from "babylonjs/scene";
  43599. import { Vector3 } from "babylonjs/Maths/math.vector";
  43600. import "babylonjs/Cameras/RigModes/vrRigMode";
  43601. /**
  43602. * Camera used to simulate VR rendering (based on FreeCamera)
  43603. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43604. */
  43605. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43606. /**
  43607. * Creates a new VRDeviceOrientationFreeCamera
  43608. * @param name defines camera name
  43609. * @param position defines the start position of the camera
  43610. * @param scene defines the scene the camera belongs to
  43611. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43612. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43613. */
  43614. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43615. /**
  43616. * Gets camera class name
  43617. * @returns VRDeviceOrientationFreeCamera
  43618. */
  43619. getClassName(): string;
  43620. }
  43621. }
  43622. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43623. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43624. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43625. import { Scene } from "babylonjs/scene";
  43626. import { Vector3 } from "babylonjs/Maths/math.vector";
  43627. import "babylonjs/Gamepads/gamepadSceneComponent";
  43628. /**
  43629. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43630. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43631. */
  43632. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43633. /**
  43634. * Creates a new VRDeviceOrientationGamepadCamera
  43635. * @param name defines camera name
  43636. * @param position defines the start position of the camera
  43637. * @param scene defines the scene the camera belongs to
  43638. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43639. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43640. */
  43641. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43642. /**
  43643. * Gets camera class name
  43644. * @returns VRDeviceOrientationGamepadCamera
  43645. */
  43646. getClassName(): string;
  43647. }
  43648. }
  43649. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43650. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43651. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43652. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43653. /** @hidden */
  43654. export var imageProcessingPixelShader: {
  43655. name: string;
  43656. shader: string;
  43657. };
  43658. }
  43659. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43660. import { Nullable } from "babylonjs/types";
  43661. import { Color4 } from "babylonjs/Maths/math.color";
  43662. import { Camera } from "babylonjs/Cameras/camera";
  43663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43664. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43665. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43667. import { Engine } from "babylonjs/Engines/engine";
  43668. import "babylonjs/Shaders/imageProcessing.fragment";
  43669. import "babylonjs/Shaders/postprocess.vertex";
  43670. /**
  43671. * ImageProcessingPostProcess
  43672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43673. */
  43674. export class ImageProcessingPostProcess extends PostProcess {
  43675. /**
  43676. * Default configuration related to image processing available in the PBR Material.
  43677. */
  43678. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43679. /**
  43680. * Gets the image processing configuration used either in this material.
  43681. */
  43682. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43683. /**
  43684. * Sets the Default image processing configuration used either in the this material.
  43685. *
  43686. * If sets to null, the scene one is in use.
  43687. */
  43688. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43689. /**
  43690. * Keep track of the image processing observer to allow dispose and replace.
  43691. */
  43692. private _imageProcessingObserver;
  43693. /**
  43694. * Attaches a new image processing configuration to the PBR Material.
  43695. * @param configuration
  43696. */
  43697. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43698. /**
  43699. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43700. */
  43701. get colorCurves(): Nullable<ColorCurves>;
  43702. /**
  43703. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43704. */
  43705. set colorCurves(value: Nullable<ColorCurves>);
  43706. /**
  43707. * Gets wether the color curves effect is enabled.
  43708. */
  43709. get colorCurvesEnabled(): boolean;
  43710. /**
  43711. * Sets wether the color curves effect is enabled.
  43712. */
  43713. set colorCurvesEnabled(value: boolean);
  43714. /**
  43715. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43716. */
  43717. get colorGradingTexture(): Nullable<BaseTexture>;
  43718. /**
  43719. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43720. */
  43721. set colorGradingTexture(value: Nullable<BaseTexture>);
  43722. /**
  43723. * Gets wether the color grading effect is enabled.
  43724. */
  43725. get colorGradingEnabled(): boolean;
  43726. /**
  43727. * Gets wether the color grading effect is enabled.
  43728. */
  43729. set colorGradingEnabled(value: boolean);
  43730. /**
  43731. * Gets exposure used in the effect.
  43732. */
  43733. get exposure(): number;
  43734. /**
  43735. * Sets exposure used in the effect.
  43736. */
  43737. set exposure(value: number);
  43738. /**
  43739. * Gets wether tonemapping is enabled or not.
  43740. */
  43741. get toneMappingEnabled(): boolean;
  43742. /**
  43743. * Sets wether tonemapping is enabled or not
  43744. */
  43745. set toneMappingEnabled(value: boolean);
  43746. /**
  43747. * Gets the type of tone mapping effect.
  43748. */
  43749. get toneMappingType(): number;
  43750. /**
  43751. * Sets the type of tone mapping effect.
  43752. */
  43753. set toneMappingType(value: number);
  43754. /**
  43755. * Gets contrast used in the effect.
  43756. */
  43757. get contrast(): number;
  43758. /**
  43759. * Sets contrast used in the effect.
  43760. */
  43761. set contrast(value: number);
  43762. /**
  43763. * Gets Vignette stretch size.
  43764. */
  43765. get vignetteStretch(): number;
  43766. /**
  43767. * Sets Vignette stretch size.
  43768. */
  43769. set vignetteStretch(value: number);
  43770. /**
  43771. * Gets Vignette centre X Offset.
  43772. */
  43773. get vignetteCentreX(): number;
  43774. /**
  43775. * Sets Vignette centre X Offset.
  43776. */
  43777. set vignetteCentreX(value: number);
  43778. /**
  43779. * Gets Vignette centre Y Offset.
  43780. */
  43781. get vignetteCentreY(): number;
  43782. /**
  43783. * Sets Vignette centre Y Offset.
  43784. */
  43785. set vignetteCentreY(value: number);
  43786. /**
  43787. * Gets Vignette weight or intensity of the vignette effect.
  43788. */
  43789. get vignetteWeight(): number;
  43790. /**
  43791. * Sets Vignette weight or intensity of the vignette effect.
  43792. */
  43793. set vignetteWeight(value: number);
  43794. /**
  43795. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43796. * if vignetteEnabled is set to true.
  43797. */
  43798. get vignetteColor(): Color4;
  43799. /**
  43800. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43801. * if vignetteEnabled is set to true.
  43802. */
  43803. set vignetteColor(value: Color4);
  43804. /**
  43805. * Gets Camera field of view used by the Vignette effect.
  43806. */
  43807. get vignetteCameraFov(): number;
  43808. /**
  43809. * Sets Camera field of view used by the Vignette effect.
  43810. */
  43811. set vignetteCameraFov(value: number);
  43812. /**
  43813. * Gets the vignette blend mode allowing different kind of effect.
  43814. */
  43815. get vignetteBlendMode(): number;
  43816. /**
  43817. * Sets the vignette blend mode allowing different kind of effect.
  43818. */
  43819. set vignetteBlendMode(value: number);
  43820. /**
  43821. * Gets wether the vignette effect is enabled.
  43822. */
  43823. get vignetteEnabled(): boolean;
  43824. /**
  43825. * Sets wether the vignette effect is enabled.
  43826. */
  43827. set vignetteEnabled(value: boolean);
  43828. private _fromLinearSpace;
  43829. /**
  43830. * Gets wether the input of the processing is in Gamma or Linear Space.
  43831. */
  43832. get fromLinearSpace(): boolean;
  43833. /**
  43834. * Sets wether the input of the processing is in Gamma or Linear Space.
  43835. */
  43836. set fromLinearSpace(value: boolean);
  43837. /**
  43838. * Defines cache preventing GC.
  43839. */
  43840. private _defines;
  43841. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43842. /**
  43843. * "ImageProcessingPostProcess"
  43844. * @returns "ImageProcessingPostProcess"
  43845. */
  43846. getClassName(): string;
  43847. protected _updateParameters(): void;
  43848. dispose(camera?: Camera): void;
  43849. }
  43850. }
  43851. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43852. import { Scene } from "babylonjs/scene";
  43853. import { Color3 } from "babylonjs/Maths/math.color";
  43854. import { Mesh } from "babylonjs/Meshes/mesh";
  43855. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43856. import { Nullable } from "babylonjs/types";
  43857. /**
  43858. * Class containing static functions to help procedurally build meshes
  43859. */
  43860. export class GroundBuilder {
  43861. /**
  43862. * Creates a ground mesh
  43863. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43864. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43866. * @param name defines the name of the mesh
  43867. * @param options defines the options used to create the mesh
  43868. * @param scene defines the hosting scene
  43869. * @returns the ground mesh
  43870. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43871. */
  43872. static CreateGround(name: string, options: {
  43873. width?: number;
  43874. height?: number;
  43875. subdivisions?: number;
  43876. subdivisionsX?: number;
  43877. subdivisionsY?: number;
  43878. updatable?: boolean;
  43879. }, scene: any): Mesh;
  43880. /**
  43881. * Creates a tiled ground mesh
  43882. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43883. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43884. * * 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
  43885. * * 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
  43886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43887. * @param name defines the name of the mesh
  43888. * @param options defines the options used to create the mesh
  43889. * @param scene defines the hosting scene
  43890. * @returns the tiled ground mesh
  43891. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43892. */
  43893. static CreateTiledGround(name: string, options: {
  43894. xmin: number;
  43895. zmin: number;
  43896. xmax: number;
  43897. zmax: number;
  43898. subdivisions?: {
  43899. w: number;
  43900. h: number;
  43901. };
  43902. precision?: {
  43903. w: number;
  43904. h: number;
  43905. };
  43906. updatable?: boolean;
  43907. }, scene?: Nullable<Scene>): Mesh;
  43908. /**
  43909. * Creates a ground mesh from a height map
  43910. * * The parameter `url` sets the URL of the height map image resource.
  43911. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43912. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43913. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43914. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43915. * * 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.
  43916. * * 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).
  43917. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43919. * @param name defines the name of the mesh
  43920. * @param url defines the url to the height map
  43921. * @param options defines the options used to create the mesh
  43922. * @param scene defines the hosting scene
  43923. * @returns the ground mesh
  43924. * @see https://doc.babylonjs.com/babylon101/height_map
  43925. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43926. */
  43927. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43928. width?: number;
  43929. height?: number;
  43930. subdivisions?: number;
  43931. minHeight?: number;
  43932. maxHeight?: number;
  43933. colorFilter?: Color3;
  43934. alphaFilter?: number;
  43935. updatable?: boolean;
  43936. onReady?: (mesh: GroundMesh) => void;
  43937. }, scene?: Nullable<Scene>): GroundMesh;
  43938. }
  43939. }
  43940. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43941. import { Vector4 } from "babylonjs/Maths/math.vector";
  43942. import { Mesh } from "babylonjs/Meshes/mesh";
  43943. /**
  43944. * Class containing static functions to help procedurally build meshes
  43945. */
  43946. export class TorusBuilder {
  43947. /**
  43948. * Creates a torus mesh
  43949. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43950. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43951. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43955. * @param name defines the name of the mesh
  43956. * @param options defines the options used to create the mesh
  43957. * @param scene defines the hosting scene
  43958. * @returns the torus mesh
  43959. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43960. */
  43961. static CreateTorus(name: string, options: {
  43962. diameter?: number;
  43963. thickness?: number;
  43964. tessellation?: number;
  43965. updatable?: boolean;
  43966. sideOrientation?: number;
  43967. frontUVs?: Vector4;
  43968. backUVs?: Vector4;
  43969. }, scene: any): Mesh;
  43970. }
  43971. }
  43972. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43973. import { Vector4 } from "babylonjs/Maths/math.vector";
  43974. import { Color4 } from "babylonjs/Maths/math.color";
  43975. import { Mesh } from "babylonjs/Meshes/mesh";
  43976. /**
  43977. * Class containing static functions to help procedurally build meshes
  43978. */
  43979. export class CylinderBuilder {
  43980. /**
  43981. * Creates a cylinder or a cone mesh
  43982. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43983. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43984. * * 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.
  43985. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43986. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43987. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43988. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43989. * * 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).
  43990. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43991. * * 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).
  43992. * * 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
  43993. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43994. * * 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
  43995. * * 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.
  43996. * * If `enclose` is false, a ring surface is one element.
  43997. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43998. * * 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
  43999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44002. * @param name defines the name of the mesh
  44003. * @param options defines the options used to create the mesh
  44004. * @param scene defines the hosting scene
  44005. * @returns the cylinder mesh
  44006. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44007. */
  44008. static CreateCylinder(name: string, options: {
  44009. height?: number;
  44010. diameterTop?: number;
  44011. diameterBottom?: number;
  44012. diameter?: number;
  44013. tessellation?: number;
  44014. subdivisions?: number;
  44015. arc?: number;
  44016. faceColors?: Color4[];
  44017. faceUV?: Vector4[];
  44018. updatable?: boolean;
  44019. hasRings?: boolean;
  44020. enclose?: boolean;
  44021. cap?: number;
  44022. sideOrientation?: number;
  44023. frontUVs?: Vector4;
  44024. backUVs?: Vector4;
  44025. }, scene: any): Mesh;
  44026. }
  44027. }
  44028. declare module "babylonjs/XR/webXRTypes" {
  44029. import { Nullable } from "babylonjs/types";
  44030. import { IDisposable } from "babylonjs/scene";
  44031. /**
  44032. * States of the webXR experience
  44033. */
  44034. export enum WebXRState {
  44035. /**
  44036. * Transitioning to being in XR mode
  44037. */
  44038. ENTERING_XR = 0,
  44039. /**
  44040. * Transitioning to non XR mode
  44041. */
  44042. EXITING_XR = 1,
  44043. /**
  44044. * In XR mode and presenting
  44045. */
  44046. IN_XR = 2,
  44047. /**
  44048. * Not entered XR mode
  44049. */
  44050. NOT_IN_XR = 3
  44051. }
  44052. /**
  44053. * Abstraction of the XR render target
  44054. */
  44055. export interface WebXRRenderTarget extends IDisposable {
  44056. /**
  44057. * xrpresent context of the canvas which can be used to display/mirror xr content
  44058. */
  44059. canvasContext: WebGLRenderingContext;
  44060. /**
  44061. * xr layer for the canvas
  44062. */
  44063. xrLayer: Nullable<XRWebGLLayer>;
  44064. /**
  44065. * Initializes the xr layer for the session
  44066. * @param xrSession xr session
  44067. * @returns a promise that will resolve once the XR Layer has been created
  44068. */
  44069. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44070. }
  44071. }
  44072. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44073. import { Nullable } from "babylonjs/types";
  44074. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44075. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44076. /**
  44077. * COnfiguration object for WebXR output canvas
  44078. */
  44079. export class WebXRManagedOutputCanvasOptions {
  44080. /**
  44081. * An optional canvas in case you wish to create it yourself and provide it here.
  44082. * If not provided, a new canvas will be created
  44083. */
  44084. canvasElement?: HTMLCanvasElement;
  44085. /**
  44086. * Options for this XR Layer output
  44087. */
  44088. canvasOptions?: XRWebGLLayerOptions;
  44089. /**
  44090. * CSS styling for a newly created canvas (if not provided)
  44091. */
  44092. newCanvasCssStyle?: string;
  44093. /**
  44094. * Get the default values of the configuration object
  44095. * @returns default values of this configuration object
  44096. */
  44097. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44098. }
  44099. /**
  44100. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44101. */
  44102. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44103. private _options;
  44104. private _canvas;
  44105. private _engine;
  44106. /**
  44107. * Rendering context of the canvas which can be used to display/mirror xr content
  44108. */
  44109. canvasContext: WebGLRenderingContext;
  44110. /**
  44111. * xr layer for the canvas
  44112. */
  44113. xrLayer: Nullable<XRWebGLLayer>;
  44114. /**
  44115. * Initializes the canvas to be added/removed upon entering/exiting xr
  44116. * @param _xrSessionManager The XR Session manager
  44117. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44118. */
  44119. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44120. /**
  44121. * Disposes of the object
  44122. */
  44123. dispose(): void;
  44124. /**
  44125. * Initializes the xr layer for the session
  44126. * @param xrSession xr session
  44127. * @returns a promise that will resolve once the XR Layer has been created
  44128. */
  44129. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44130. private _addCanvas;
  44131. private _removeCanvas;
  44132. private _setManagedOutputCanvas;
  44133. }
  44134. }
  44135. declare module "babylonjs/XR/webXRSessionManager" {
  44136. import { Observable } from "babylonjs/Misc/observable";
  44137. import { Nullable } from "babylonjs/types";
  44138. import { IDisposable, Scene } from "babylonjs/scene";
  44139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44140. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44141. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44142. /**
  44143. * Manages an XRSession to work with Babylon's engine
  44144. * @see https://doc.babylonjs.com/how_to/webxr
  44145. */
  44146. export class WebXRSessionManager implements IDisposable {
  44147. /** The scene which the session should be created for */
  44148. scene: Scene;
  44149. private _referenceSpace;
  44150. private _rttProvider;
  44151. private _sessionEnded;
  44152. private _xrNavigator;
  44153. private baseLayer;
  44154. /**
  44155. * The base reference space from which the session started. good if you want to reset your
  44156. * reference space
  44157. */
  44158. baseReferenceSpace: XRReferenceSpace;
  44159. /**
  44160. * Current XR frame
  44161. */
  44162. currentFrame: Nullable<XRFrame>;
  44163. /** WebXR timestamp updated every frame */
  44164. currentTimestamp: number;
  44165. /**
  44166. * Used just in case of a failure to initialize an immersive session.
  44167. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44168. */
  44169. defaultHeightCompensation: number;
  44170. /**
  44171. * Fires every time a new xrFrame arrives which can be used to update the camera
  44172. */
  44173. onXRFrameObservable: Observable<XRFrame>;
  44174. /**
  44175. * Fires when the reference space changed
  44176. */
  44177. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44178. /**
  44179. * Fires when the xr session is ended either by the device or manually done
  44180. */
  44181. onXRSessionEnded: Observable<any>;
  44182. /**
  44183. * Fires when the xr session is ended either by the device or manually done
  44184. */
  44185. onXRSessionInit: Observable<XRSession>;
  44186. /**
  44187. * Underlying xr session
  44188. */
  44189. session: XRSession;
  44190. /**
  44191. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44192. * or get the offset the player is currently at.
  44193. */
  44194. viewerReferenceSpace: XRReferenceSpace;
  44195. /**
  44196. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44197. * @param scene The scene which the session should be created for
  44198. */
  44199. constructor(
  44200. /** The scene which the session should be created for */
  44201. scene: Scene);
  44202. /**
  44203. * The current reference space used in this session. This reference space can constantly change!
  44204. * It is mainly used to offset the camera's position.
  44205. */
  44206. get referenceSpace(): XRReferenceSpace;
  44207. /**
  44208. * Set a new reference space and triggers the observable
  44209. */
  44210. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44211. /**
  44212. * Disposes of the session manager
  44213. */
  44214. dispose(): void;
  44215. /**
  44216. * Stops the xrSession and restores the render loop
  44217. * @returns Promise which resolves after it exits XR
  44218. */
  44219. exitXRAsync(): Promise<void>;
  44220. /**
  44221. * Gets the correct render target texture to be rendered this frame for this eye
  44222. * @param eye the eye for which to get the render target
  44223. * @returns the render target for the specified eye
  44224. */
  44225. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44226. /**
  44227. * Creates a WebXRRenderTarget object for the XR session
  44228. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44229. * @param options optional options to provide when creating a new render target
  44230. * @returns a WebXR render target to which the session can render
  44231. */
  44232. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44233. /**
  44234. * Initializes the manager
  44235. * After initialization enterXR can be called to start an XR session
  44236. * @returns Promise which resolves after it is initialized
  44237. */
  44238. initializeAsync(): Promise<void>;
  44239. /**
  44240. * Initializes an xr session
  44241. * @param xrSessionMode mode to initialize
  44242. * @param xrSessionInit defines optional and required values to pass to the session builder
  44243. * @returns a promise which will resolve once the session has been initialized
  44244. */
  44245. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44246. /**
  44247. * Checks if a session would be supported for the creation options specified
  44248. * @param sessionMode session mode to check if supported eg. immersive-vr
  44249. * @returns A Promise that resolves to true if supported and false if not
  44250. */
  44251. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44252. /**
  44253. * Resets the reference space to the one started the session
  44254. */
  44255. resetReferenceSpace(): void;
  44256. /**
  44257. * Starts rendering to the xr layer
  44258. */
  44259. runXRRenderLoop(): void;
  44260. /**
  44261. * Sets the reference space on the xr session
  44262. * @param referenceSpaceType space to set
  44263. * @returns a promise that will resolve once the reference space has been set
  44264. */
  44265. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44266. /**
  44267. * Updates the render state of the session
  44268. * @param state state to set
  44269. * @returns a promise that resolves once the render state has been updated
  44270. */
  44271. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44272. /**
  44273. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44274. * @param sessionMode defines the session to test
  44275. * @returns a promise with boolean as final value
  44276. */
  44277. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44278. private _createRenderTargetTexture;
  44279. }
  44280. }
  44281. declare module "babylonjs/XR/webXRCamera" {
  44282. import { Scene } from "babylonjs/scene";
  44283. import { Camera } from "babylonjs/Cameras/camera";
  44284. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44285. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44286. /**
  44287. * WebXR Camera which holds the views for the xrSession
  44288. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44289. */
  44290. export class WebXRCamera extends FreeCamera {
  44291. private _xrSessionManager;
  44292. private _firstFrame;
  44293. private _referenceQuaternion;
  44294. private _referencedPosition;
  44295. private _xrInvPositionCache;
  44296. private _xrInvQuaternionCache;
  44297. /**
  44298. * Should position compensation execute on first frame.
  44299. * This is used when copying the position from a native (non XR) camera
  44300. */
  44301. compensateOnFirstFrame: boolean;
  44302. /**
  44303. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44304. * @param name the name of the camera
  44305. * @param scene the scene to add the camera to
  44306. * @param _xrSessionManager a constructed xr session manager
  44307. */
  44308. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44309. /**
  44310. * Return the user's height, unrelated to the current ground.
  44311. * This will be the y position of this camera, when ground level is 0.
  44312. */
  44313. get realWorldHeight(): number;
  44314. /** @hidden */
  44315. _updateForDualEyeDebugging(): void;
  44316. /**
  44317. * Sets this camera's transformation based on a non-vr camera
  44318. * @param otherCamera the non-vr camera to copy the transformation from
  44319. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44320. */
  44321. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44322. /**
  44323. * Gets the current instance class name ("WebXRCamera").
  44324. * @returns the class name
  44325. */
  44326. getClassName(): string;
  44327. private _updateFromXRSession;
  44328. private _updateNumberOfRigCameras;
  44329. private _updateReferenceSpace;
  44330. private _updateReferenceSpaceOffset;
  44331. }
  44332. }
  44333. declare module "babylonjs/XR/webXRFeaturesManager" {
  44334. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44335. import { IDisposable } from "babylonjs/scene";
  44336. /**
  44337. * Defining the interface required for a (webxr) feature
  44338. */
  44339. export interface IWebXRFeature extends IDisposable {
  44340. /**
  44341. * Is this feature attached
  44342. */
  44343. attached: boolean;
  44344. /**
  44345. * Should auto-attach be disabled?
  44346. */
  44347. disableAutoAttach: boolean;
  44348. /**
  44349. * Attach the feature to the session
  44350. * Will usually be called by the features manager
  44351. *
  44352. * @param force should attachment be forced (even when already attached)
  44353. * @returns true if successful.
  44354. */
  44355. attach(force?: boolean): boolean;
  44356. /**
  44357. * Detach the feature from the session
  44358. * Will usually be called by the features manager
  44359. *
  44360. * @returns true if successful.
  44361. */
  44362. detach(): boolean;
  44363. }
  44364. /**
  44365. * A list of the currently available features without referencing them
  44366. */
  44367. export class WebXRFeatureName {
  44368. /**
  44369. * The name of the anchor system feature
  44370. */
  44371. static ANCHOR_SYSTEM: string;
  44372. /**
  44373. * The name of the background remover feature
  44374. */
  44375. static BACKGROUND_REMOVER: string;
  44376. /**
  44377. * The name of the hit test feature
  44378. */
  44379. static HIT_TEST: string;
  44380. /**
  44381. * physics impostors for xr controllers feature
  44382. */
  44383. static PHYSICS_CONTROLLERS: string;
  44384. /**
  44385. * The name of the plane detection feature
  44386. */
  44387. static PLANE_DETECTION: string;
  44388. /**
  44389. * The name of the pointer selection feature
  44390. */
  44391. static POINTER_SELECTION: string;
  44392. /**
  44393. * The name of the teleportation feature
  44394. */
  44395. static TELEPORTATION: string;
  44396. }
  44397. /**
  44398. * Defining the constructor of a feature. Used to register the modules.
  44399. */
  44400. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44401. /**
  44402. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44403. * It is mainly used in AR sessions.
  44404. *
  44405. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44406. */
  44407. export class WebXRFeaturesManager implements IDisposable {
  44408. private _xrSessionManager;
  44409. private static readonly _AvailableFeatures;
  44410. private _features;
  44411. /**
  44412. * constructs a new features manages.
  44413. *
  44414. * @param _xrSessionManager an instance of WebXRSessionManager
  44415. */
  44416. constructor(_xrSessionManager: WebXRSessionManager);
  44417. /**
  44418. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44419. * Mainly used internally.
  44420. *
  44421. * @param featureName the name of the feature to register
  44422. * @param constructorFunction the function used to construct the module
  44423. * @param version the (babylon) version of the module
  44424. * @param stable is that a stable version of this module
  44425. */
  44426. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44427. /**
  44428. * Returns a constructor of a specific feature.
  44429. *
  44430. * @param featureName the name of the feature to construct
  44431. * @param version the version of the feature to load
  44432. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44433. * @param options optional options provided to the module.
  44434. * @returns a function that, when called, will return a new instance of this feature
  44435. */
  44436. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44437. /**
  44438. * Can be used to return the list of features currently registered
  44439. *
  44440. * @returns an Array of available features
  44441. */
  44442. static GetAvailableFeatures(): string[];
  44443. /**
  44444. * Gets the versions available for a specific feature
  44445. * @param featureName the name of the feature
  44446. * @returns an array with the available versions
  44447. */
  44448. static GetAvailableVersions(featureName: string): string[];
  44449. /**
  44450. * Return the latest unstable version of this feature
  44451. * @param featureName the name of the feature to search
  44452. * @returns the version number. if not found will return -1
  44453. */
  44454. static GetLatestVersionOfFeature(featureName: string): number;
  44455. /**
  44456. * Return the latest stable version of this feature
  44457. * @param featureName the name of the feature to search
  44458. * @returns the version number. if not found will return -1
  44459. */
  44460. static GetStableVersionOfFeature(featureName: string): number;
  44461. /**
  44462. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44463. * Can be used during a session to start a feature
  44464. * @param featureName the name of feature to attach
  44465. */
  44466. attachFeature(featureName: string): void;
  44467. /**
  44468. * Can be used inside a session or when the session ends to detach a specific feature
  44469. * @param featureName the name of the feature to detach
  44470. */
  44471. detachFeature(featureName: string): void;
  44472. /**
  44473. * Used to disable an already-enabled feature
  44474. * The feature will be disposed and will be recreated once enabled.
  44475. * @param featureName the feature to disable
  44476. * @returns true if disable was successful
  44477. */
  44478. disableFeature(featureName: string | {
  44479. Name: string;
  44480. }): boolean;
  44481. /**
  44482. * dispose this features manager
  44483. */
  44484. dispose(): void;
  44485. /**
  44486. * 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.
  44487. * 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.
  44488. *
  44489. * @param featureName the name of the feature to load or the class of the feature
  44490. * @param version optional version to load. if not provided the latest version will be enabled
  44491. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44492. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44493. * @returns a new constructed feature or throws an error if feature not found.
  44494. */
  44495. enableFeature(featureName: string | {
  44496. Name: string;
  44497. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44498. /**
  44499. * get the implementation of an enabled feature.
  44500. * @param featureName the name of the feature to load
  44501. * @returns the feature class, if found
  44502. */
  44503. getEnabledFeature(featureName: string): IWebXRFeature;
  44504. /**
  44505. * Get the list of enabled features
  44506. * @returns an array of enabled features
  44507. */
  44508. getEnabledFeatures(): string[];
  44509. }
  44510. }
  44511. declare module "babylonjs/XR/webXRExperienceHelper" {
  44512. import { Observable } from "babylonjs/Misc/observable";
  44513. import { IDisposable, Scene } from "babylonjs/scene";
  44514. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44515. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44516. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44517. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44518. /**
  44519. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44520. * @see https://doc.babylonjs.com/how_to/webxr
  44521. */
  44522. export class WebXRExperienceHelper implements IDisposable {
  44523. private scene;
  44524. private _nonVRCamera;
  44525. private _originalSceneAutoClear;
  44526. private _supported;
  44527. /**
  44528. * Camera used to render xr content
  44529. */
  44530. camera: WebXRCamera;
  44531. /** A features manager for this xr session */
  44532. featuresManager: WebXRFeaturesManager;
  44533. /**
  44534. * Observers registered here will be triggered after the camera's initial transformation is set
  44535. * This can be used to set a different ground level or an extra rotation.
  44536. *
  44537. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44538. * to the position set after this observable is done executing.
  44539. */
  44540. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44541. /**
  44542. * Fires when the state of the experience helper has changed
  44543. */
  44544. onStateChangedObservable: Observable<WebXRState>;
  44545. /** Session manager used to keep track of xr session */
  44546. sessionManager: WebXRSessionManager;
  44547. /**
  44548. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44549. */
  44550. state: WebXRState;
  44551. /**
  44552. * Creates a WebXRExperienceHelper
  44553. * @param scene The scene the helper should be created in
  44554. */
  44555. private constructor();
  44556. /**
  44557. * Creates the experience helper
  44558. * @param scene the scene to attach the experience helper to
  44559. * @returns a promise for the experience helper
  44560. */
  44561. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44562. /**
  44563. * Disposes of the experience helper
  44564. */
  44565. dispose(): void;
  44566. /**
  44567. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44568. * @param sessionMode options for the XR session
  44569. * @param referenceSpaceType frame of reference of the XR session
  44570. * @param renderTarget the output canvas that will be used to enter XR mode
  44571. * @returns promise that resolves after xr mode has entered
  44572. */
  44573. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44574. /**
  44575. * Exits XR mode and returns the scene to its original state
  44576. * @returns promise that resolves after xr mode has exited
  44577. */
  44578. exitXRAsync(): Promise<void>;
  44579. private _nonXRToXRCamera;
  44580. private _setState;
  44581. }
  44582. }
  44583. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44584. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44585. import { Observable } from "babylonjs/Misc/observable";
  44586. import { IDisposable } from "babylonjs/scene";
  44587. /**
  44588. * X-Y values for axes in WebXR
  44589. */
  44590. export interface IWebXRMotionControllerAxesValue {
  44591. /**
  44592. * The value of the x axis
  44593. */
  44594. x: number;
  44595. /**
  44596. * The value of the y-axis
  44597. */
  44598. y: number;
  44599. }
  44600. /**
  44601. * changed / previous values for the values of this component
  44602. */
  44603. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44604. /**
  44605. * current (this frame) value
  44606. */
  44607. current: T;
  44608. /**
  44609. * previous (last change) value
  44610. */
  44611. previous: T;
  44612. }
  44613. /**
  44614. * Represents changes in the component between current frame and last values recorded
  44615. */
  44616. export interface IWebXRMotionControllerComponentChanges {
  44617. /**
  44618. * will be populated with previous and current values if axes changed
  44619. */
  44620. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44621. /**
  44622. * will be populated with previous and current values if pressed changed
  44623. */
  44624. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44625. /**
  44626. * will be populated with previous and current values if touched changed
  44627. */
  44628. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44629. /**
  44630. * will be populated with previous and current values if value changed
  44631. */
  44632. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44633. }
  44634. /**
  44635. * This class represents a single component (for example button or thumbstick) of a motion controller
  44636. */
  44637. export class WebXRControllerComponent implements IDisposable {
  44638. /**
  44639. * the id of this component
  44640. */
  44641. id: string;
  44642. /**
  44643. * the type of the component
  44644. */
  44645. type: MotionControllerComponentType;
  44646. private _buttonIndex;
  44647. private _axesIndices;
  44648. private _axes;
  44649. private _changes;
  44650. private _currentValue;
  44651. private _hasChanges;
  44652. private _pressed;
  44653. private _touched;
  44654. /**
  44655. * button component type
  44656. */
  44657. static BUTTON_TYPE: MotionControllerComponentType;
  44658. /**
  44659. * squeeze component type
  44660. */
  44661. static SQUEEZE_TYPE: MotionControllerComponentType;
  44662. /**
  44663. * Thumbstick component type
  44664. */
  44665. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44666. /**
  44667. * Touchpad component type
  44668. */
  44669. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44670. /**
  44671. * trigger component type
  44672. */
  44673. static TRIGGER_TYPE: MotionControllerComponentType;
  44674. /**
  44675. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44676. * the axes data changes
  44677. */
  44678. onAxisValueChangedObservable: Observable<{
  44679. x: number;
  44680. y: number;
  44681. }>;
  44682. /**
  44683. * Observers registered here will be triggered when the state of a button changes
  44684. * State change is either pressed / touched / value
  44685. */
  44686. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44687. /**
  44688. * Creates a new component for a motion controller.
  44689. * It is created by the motion controller itself
  44690. *
  44691. * @param id the id of this component
  44692. * @param type the type of the component
  44693. * @param _buttonIndex index in the buttons array of the gamepad
  44694. * @param _axesIndices indices of the values in the axes array of the gamepad
  44695. */
  44696. constructor(
  44697. /**
  44698. * the id of this component
  44699. */
  44700. id: string,
  44701. /**
  44702. * the type of the component
  44703. */
  44704. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44705. /**
  44706. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44707. */
  44708. get axes(): IWebXRMotionControllerAxesValue;
  44709. /**
  44710. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44711. */
  44712. get changes(): IWebXRMotionControllerComponentChanges;
  44713. /**
  44714. * Return whether or not the component changed the last frame
  44715. */
  44716. get hasChanges(): boolean;
  44717. /**
  44718. * is the button currently pressed
  44719. */
  44720. get pressed(): boolean;
  44721. /**
  44722. * is the button currently touched
  44723. */
  44724. get touched(): boolean;
  44725. /**
  44726. * Get the current value of this component
  44727. */
  44728. get value(): number;
  44729. /**
  44730. * Dispose this component
  44731. */
  44732. dispose(): void;
  44733. /**
  44734. * Are there axes correlating to this component
  44735. * @return true is axes data is available
  44736. */
  44737. isAxes(): boolean;
  44738. /**
  44739. * Is this component a button (hence - pressable)
  44740. * @returns true if can be pressed
  44741. */
  44742. isButton(): boolean;
  44743. /**
  44744. * update this component using the gamepad object it is in. Called on every frame
  44745. * @param nativeController the native gamepad controller object
  44746. */
  44747. update(nativeController: IMinimalMotionControllerObject): void;
  44748. }
  44749. }
  44750. declare module "babylonjs/Loading/sceneLoader" {
  44751. import { Observable } from "babylonjs/Misc/observable";
  44752. import { Nullable } from "babylonjs/types";
  44753. import { Scene } from "babylonjs/scene";
  44754. import { Engine } from "babylonjs/Engines/engine";
  44755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44756. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44757. import { AssetContainer } from "babylonjs/assetContainer";
  44758. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44759. import { Skeleton } from "babylonjs/Bones/skeleton";
  44760. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44761. import { WebRequest } from "babylonjs/Misc/webRequest";
  44762. /**
  44763. * Class used to represent data loading progression
  44764. */
  44765. export class SceneLoaderProgressEvent {
  44766. /** defines if data length to load can be evaluated */
  44767. readonly lengthComputable: boolean;
  44768. /** defines the loaded data length */
  44769. readonly loaded: number;
  44770. /** defines the data length to load */
  44771. readonly total: number;
  44772. /**
  44773. * Create a new progress event
  44774. * @param lengthComputable defines if data length to load can be evaluated
  44775. * @param loaded defines the loaded data length
  44776. * @param total defines the data length to load
  44777. */
  44778. constructor(
  44779. /** defines if data length to load can be evaluated */
  44780. lengthComputable: boolean,
  44781. /** defines the loaded data length */
  44782. loaded: number,
  44783. /** defines the data length to load */
  44784. total: number);
  44785. /**
  44786. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44787. * @param event defines the source event
  44788. * @returns a new SceneLoaderProgressEvent
  44789. */
  44790. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44791. }
  44792. /**
  44793. * Interface used by SceneLoader plugins to define supported file extensions
  44794. */
  44795. export interface ISceneLoaderPluginExtensions {
  44796. /**
  44797. * Defines the list of supported extensions
  44798. */
  44799. [extension: string]: {
  44800. isBinary: boolean;
  44801. };
  44802. }
  44803. /**
  44804. * Interface used by SceneLoader plugin factory
  44805. */
  44806. export interface ISceneLoaderPluginFactory {
  44807. /**
  44808. * Defines the name of the factory
  44809. */
  44810. name: string;
  44811. /**
  44812. * Function called to create a new plugin
  44813. * @return the new plugin
  44814. */
  44815. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44816. /**
  44817. * The callback that returns true if the data can be directly loaded.
  44818. * @param data string containing the file data
  44819. * @returns if the data can be loaded directly
  44820. */
  44821. canDirectLoad?(data: string): boolean;
  44822. }
  44823. /**
  44824. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44825. */
  44826. export interface ISceneLoaderPluginBase {
  44827. /**
  44828. * The friendly name of this plugin.
  44829. */
  44830. name: string;
  44831. /**
  44832. * The file extensions supported by this plugin.
  44833. */
  44834. extensions: string | ISceneLoaderPluginExtensions;
  44835. /**
  44836. * The callback called when loading from a url.
  44837. * @param scene scene loading this url
  44838. * @param url url to load
  44839. * @param onSuccess callback called when the file successfully loads
  44840. * @param onProgress callback called while file is loading (if the server supports this mode)
  44841. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44842. * @param onError callback called when the file fails to load
  44843. * @returns a file request object
  44844. */
  44845. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44846. /**
  44847. * The callback called when loading from a file object.
  44848. * @param scene scene loading this file
  44849. * @param file defines the file to load
  44850. * @param onSuccess defines the callback to call when data is loaded
  44851. * @param onProgress defines the callback to call during loading process
  44852. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44853. * @param onError defines the callback to call when an error occurs
  44854. * @returns a file request object
  44855. */
  44856. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44857. /**
  44858. * The callback that returns true if the data can be directly loaded.
  44859. * @param data string containing the file data
  44860. * @returns if the data can be loaded directly
  44861. */
  44862. canDirectLoad?(data: string): boolean;
  44863. /**
  44864. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44865. * @param scene scene loading this data
  44866. * @param data string containing the data
  44867. * @returns data to pass to the plugin
  44868. */
  44869. directLoad?(scene: Scene, data: string): any;
  44870. /**
  44871. * The callback that allows custom handling of the root url based on the response url.
  44872. * @param rootUrl the original root url
  44873. * @param responseURL the response url if available
  44874. * @returns the new root url
  44875. */
  44876. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44877. }
  44878. /**
  44879. * Interface used to define a SceneLoader plugin
  44880. */
  44881. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44882. /**
  44883. * Import meshes into a scene.
  44884. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44885. * @param scene The scene to import into
  44886. * @param data The data to import
  44887. * @param rootUrl The root url for scene and resources
  44888. * @param meshes The meshes array to import into
  44889. * @param particleSystems The particle systems array to import into
  44890. * @param skeletons The skeletons array to import into
  44891. * @param onError The callback when import fails
  44892. * @returns True if successful or false otherwise
  44893. */
  44894. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44895. /**
  44896. * Load into a scene.
  44897. * @param scene The scene to load into
  44898. * @param data The data to import
  44899. * @param rootUrl The root url for scene and resources
  44900. * @param onError The callback when import fails
  44901. * @returns True if successful or false otherwise
  44902. */
  44903. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44904. /**
  44905. * Load into an asset container.
  44906. * @param scene The scene to load into
  44907. * @param data The data to import
  44908. * @param rootUrl The root url for scene and resources
  44909. * @param onError The callback when import fails
  44910. * @returns The loaded asset container
  44911. */
  44912. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44913. }
  44914. /**
  44915. * Interface used to define an async SceneLoader plugin
  44916. */
  44917. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44918. /**
  44919. * Import meshes into a scene.
  44920. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44921. * @param scene The scene to import into
  44922. * @param data The data to import
  44923. * @param rootUrl The root url for scene and resources
  44924. * @param onProgress The callback when the load progresses
  44925. * @param fileName Defines the name of the file to load
  44926. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44927. */
  44928. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44929. meshes: AbstractMesh[];
  44930. particleSystems: IParticleSystem[];
  44931. skeletons: Skeleton[];
  44932. animationGroups: AnimationGroup[];
  44933. }>;
  44934. /**
  44935. * Load into a scene.
  44936. * @param scene The scene to load into
  44937. * @param data The data to import
  44938. * @param rootUrl The root url for scene and resources
  44939. * @param onProgress The callback when the load progresses
  44940. * @param fileName Defines the name of the file to load
  44941. * @returns Nothing
  44942. */
  44943. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44944. /**
  44945. * Load into an asset container.
  44946. * @param scene The scene to load into
  44947. * @param data The data to import
  44948. * @param rootUrl The root url for scene and resources
  44949. * @param onProgress The callback when the load progresses
  44950. * @param fileName Defines the name of the file to load
  44951. * @returns The loaded asset container
  44952. */
  44953. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44954. }
  44955. /**
  44956. * Mode that determines how to handle old animation groups before loading new ones.
  44957. */
  44958. export enum SceneLoaderAnimationGroupLoadingMode {
  44959. /**
  44960. * Reset all old animations to initial state then dispose them.
  44961. */
  44962. Clean = 0,
  44963. /**
  44964. * Stop all old animations.
  44965. */
  44966. Stop = 1,
  44967. /**
  44968. * Restart old animations from first frame.
  44969. */
  44970. Sync = 2,
  44971. /**
  44972. * Old animations remains untouched.
  44973. */
  44974. NoSync = 3
  44975. }
  44976. /**
  44977. * Class used to load scene from various file formats using registered plugins
  44978. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44979. */
  44980. export class SceneLoader {
  44981. /**
  44982. * No logging while loading
  44983. */
  44984. static readonly NO_LOGGING: number;
  44985. /**
  44986. * Minimal logging while loading
  44987. */
  44988. static readonly MINIMAL_LOGGING: number;
  44989. /**
  44990. * Summary logging while loading
  44991. */
  44992. static readonly SUMMARY_LOGGING: number;
  44993. /**
  44994. * Detailled logging while loading
  44995. */
  44996. static readonly DETAILED_LOGGING: number;
  44997. /**
  44998. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44999. */
  45000. static get ForceFullSceneLoadingForIncremental(): boolean;
  45001. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45002. /**
  45003. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45004. */
  45005. static get ShowLoadingScreen(): boolean;
  45006. static set ShowLoadingScreen(value: boolean);
  45007. /**
  45008. * Defines the current logging level (while loading the scene)
  45009. * @ignorenaming
  45010. */
  45011. static get loggingLevel(): number;
  45012. static set loggingLevel(value: number);
  45013. /**
  45014. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45015. */
  45016. static get CleanBoneMatrixWeights(): boolean;
  45017. static set CleanBoneMatrixWeights(value: boolean);
  45018. /**
  45019. * Event raised when a plugin is used to load a scene
  45020. */
  45021. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45022. private static _registeredPlugins;
  45023. private static _getDefaultPlugin;
  45024. private static _getPluginForExtension;
  45025. private static _getPluginForDirectLoad;
  45026. private static _getPluginForFilename;
  45027. private static _getDirectLoad;
  45028. private static _loadData;
  45029. private static _getFileInfo;
  45030. /**
  45031. * Gets a plugin that can load the given extension
  45032. * @param extension defines the extension to load
  45033. * @returns a plugin or null if none works
  45034. */
  45035. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45036. /**
  45037. * Gets a boolean indicating that the given extension can be loaded
  45038. * @param extension defines the extension to load
  45039. * @returns true if the extension is supported
  45040. */
  45041. static IsPluginForExtensionAvailable(extension: string): boolean;
  45042. /**
  45043. * Adds a new plugin to the list of registered plugins
  45044. * @param plugin defines the plugin to add
  45045. */
  45046. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45047. /**
  45048. * Import meshes into a scene
  45049. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45050. * @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)
  45051. * @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)
  45052. * @param scene the instance of BABYLON.Scene to append to
  45053. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45054. * @param onProgress a callback with a progress event for each file being loaded
  45055. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45056. * @param pluginExtension the extension used to determine the plugin
  45057. * @returns The loaded plugin
  45058. */
  45059. 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>;
  45060. /**
  45061. * Import meshes into a scene
  45062. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45063. * @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)
  45064. * @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)
  45065. * @param scene the instance of BABYLON.Scene to append to
  45066. * @param onProgress a callback with a progress event for each file being loaded
  45067. * @param pluginExtension the extension used to determine the plugin
  45068. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45069. */
  45070. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45071. meshes: AbstractMesh[];
  45072. particleSystems: IParticleSystem[];
  45073. skeletons: Skeleton[];
  45074. animationGroups: AnimationGroup[];
  45075. }>;
  45076. /**
  45077. * Load a scene
  45078. * @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)
  45079. * @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)
  45080. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45081. * @param onSuccess a callback with the scene when import succeeds
  45082. * @param onProgress a callback with a progress event for each file being loaded
  45083. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45084. * @param pluginExtension the extension used to determine the plugin
  45085. * @returns The loaded plugin
  45086. */
  45087. 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>;
  45088. /**
  45089. * Load a scene
  45090. * @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)
  45091. * @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)
  45092. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45093. * @param onProgress a callback with a progress event for each file being loaded
  45094. * @param pluginExtension the extension used to determine the plugin
  45095. * @returns The loaded scene
  45096. */
  45097. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45098. /**
  45099. * Append a scene
  45100. * @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)
  45101. * @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)
  45102. * @param scene is the instance of BABYLON.Scene to append to
  45103. * @param onSuccess a callback with the scene when import succeeds
  45104. * @param onProgress a callback with a progress event for each file being loaded
  45105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45106. * @param pluginExtension the extension used to determine the plugin
  45107. * @returns The loaded plugin
  45108. */
  45109. 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>;
  45110. /**
  45111. * Append a scene
  45112. * @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)
  45113. * @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)
  45114. * @param scene is the instance of BABYLON.Scene to append to
  45115. * @param onProgress a callback with a progress event for each file being loaded
  45116. * @param pluginExtension the extension used to determine the plugin
  45117. * @returns The given scene
  45118. */
  45119. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45120. /**
  45121. * Load a scene into an asset container
  45122. * @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)
  45123. * @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)
  45124. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45125. * @param onSuccess a callback with the scene when import succeeds
  45126. * @param onProgress a callback with a progress event for each file being loaded
  45127. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45128. * @param pluginExtension the extension used to determine the plugin
  45129. * @returns The loaded plugin
  45130. */
  45131. 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>;
  45132. /**
  45133. * Load a scene into an asset container
  45134. * @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)
  45135. * @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)
  45136. * @param scene is the instance of Scene to append to
  45137. * @param onProgress a callback with a progress event for each file being loaded
  45138. * @param pluginExtension the extension used to determine the plugin
  45139. * @returns The loaded asset container
  45140. */
  45141. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45142. /**
  45143. * Import animations from a file into a scene
  45144. * @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)
  45145. * @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)
  45146. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45147. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45148. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45149. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45150. * @param onSuccess a callback with the scene when import succeeds
  45151. * @param onProgress a callback with a progress event for each file being loaded
  45152. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45153. */
  45154. 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;
  45155. /**
  45156. * Import animations from a file into a scene
  45157. * @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)
  45158. * @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)
  45159. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45160. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45161. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45162. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45163. * @param onSuccess a callback with the scene when import succeeds
  45164. * @param onProgress a callback with a progress event for each file being loaded
  45165. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45166. * @returns the updated scene with imported animations
  45167. */
  45168. 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>;
  45169. }
  45170. }
  45171. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45172. import { IDisposable, Scene } from "babylonjs/scene";
  45173. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45174. import { Observable } from "babylonjs/Misc/observable";
  45175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45176. import { Nullable } from "babylonjs/types";
  45177. /**
  45178. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45179. */
  45180. export type MotionControllerHandness = "none" | "left" | "right";
  45181. /**
  45182. * The type of components available in motion controllers.
  45183. * This is not the name of the component.
  45184. */
  45185. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45186. /**
  45187. * The state of a controller component
  45188. */
  45189. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45190. /**
  45191. * The schema of motion controller layout.
  45192. * No object will be initialized using this interface
  45193. * This is used just to define the profile.
  45194. */
  45195. export interface IMotionControllerLayout {
  45196. /**
  45197. * Path to load the assets. Usually relative to the base path
  45198. */
  45199. assetPath: string;
  45200. /**
  45201. * Available components (unsorted)
  45202. */
  45203. components: {
  45204. /**
  45205. * A map of component Ids
  45206. */
  45207. [componentId: string]: {
  45208. /**
  45209. * The type of input the component outputs
  45210. */
  45211. type: MotionControllerComponentType;
  45212. /**
  45213. * The indices of this component in the gamepad object
  45214. */
  45215. gamepadIndices: {
  45216. /**
  45217. * Index of button
  45218. */
  45219. button?: number;
  45220. /**
  45221. * If available, index of x-axis
  45222. */
  45223. xAxis?: number;
  45224. /**
  45225. * If available, index of y-axis
  45226. */
  45227. yAxis?: number;
  45228. };
  45229. /**
  45230. * The mesh's root node name
  45231. */
  45232. rootNodeName: string;
  45233. /**
  45234. * Animation definitions for this model
  45235. */
  45236. visualResponses: {
  45237. [stateKey: string]: {
  45238. /**
  45239. * What property will be animated
  45240. */
  45241. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45242. /**
  45243. * What states influence this visual response
  45244. */
  45245. states: MotionControllerComponentStateType[];
  45246. /**
  45247. * Type of animation - movement or visibility
  45248. */
  45249. valueNodeProperty: "transform" | "visibility";
  45250. /**
  45251. * Base node name to move. Its position will be calculated according to the min and max nodes
  45252. */
  45253. valueNodeName?: string;
  45254. /**
  45255. * Minimum movement node
  45256. */
  45257. minNodeName?: string;
  45258. /**
  45259. * Max movement node
  45260. */
  45261. maxNodeName?: string;
  45262. };
  45263. };
  45264. /**
  45265. * If touch enabled, what is the name of node to display user feedback
  45266. */
  45267. touchPointNodeName?: string;
  45268. };
  45269. };
  45270. /**
  45271. * Is it xr standard mapping or not
  45272. */
  45273. gamepadMapping: "" | "xr-standard";
  45274. /**
  45275. * Base root node of this entire model
  45276. */
  45277. rootNodeName: string;
  45278. /**
  45279. * Defines the main button component id
  45280. */
  45281. selectComponentId: string;
  45282. }
  45283. /**
  45284. * A definition for the layout map in the input profile
  45285. */
  45286. export interface IMotionControllerLayoutMap {
  45287. /**
  45288. * Layouts with handness type as a key
  45289. */
  45290. [handness: string]: IMotionControllerLayout;
  45291. }
  45292. /**
  45293. * The XR Input profile schema
  45294. * Profiles can be found here:
  45295. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45296. */
  45297. export interface IMotionControllerProfile {
  45298. /**
  45299. * fallback profiles for this profileId
  45300. */
  45301. fallbackProfileIds: string[];
  45302. /**
  45303. * The layout map, with handness as key
  45304. */
  45305. layouts: IMotionControllerLayoutMap;
  45306. /**
  45307. * The id of this profile
  45308. * correlates to the profile(s) in the xrInput.profiles array
  45309. */
  45310. profileId: string;
  45311. }
  45312. /**
  45313. * A helper-interface for the 3 meshes needed for controller button animation
  45314. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45315. */
  45316. export interface IMotionControllerButtonMeshMap {
  45317. /**
  45318. * the mesh that defines the pressed value mesh position.
  45319. * This is used to find the max-position of this button
  45320. */
  45321. pressedMesh: AbstractMesh;
  45322. /**
  45323. * the mesh that defines the unpressed value mesh position.
  45324. * This is used to find the min (or initial) position of this button
  45325. */
  45326. unpressedMesh: AbstractMesh;
  45327. /**
  45328. * The mesh that will be changed when value changes
  45329. */
  45330. valueMesh: AbstractMesh;
  45331. }
  45332. /**
  45333. * A helper-interface for the 3 meshes needed for controller axis animation.
  45334. * This will be expanded when touchpad animations are fully supported
  45335. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45336. */
  45337. export interface IMotionControllerMeshMap {
  45338. /**
  45339. * the mesh that defines the maximum value mesh position.
  45340. */
  45341. maxMesh?: AbstractMesh;
  45342. /**
  45343. * the mesh that defines the minimum value mesh position.
  45344. */
  45345. minMesh?: AbstractMesh;
  45346. /**
  45347. * The mesh that will be changed when axis value changes
  45348. */
  45349. valueMesh: AbstractMesh;
  45350. }
  45351. /**
  45352. * The elements needed for change-detection of the gamepad objects in motion controllers
  45353. */
  45354. export interface IMinimalMotionControllerObject {
  45355. /**
  45356. * Available axes of this controller
  45357. */
  45358. axes: number[];
  45359. /**
  45360. * An array of available buttons
  45361. */
  45362. buttons: Array<{
  45363. /**
  45364. * Value of the button/trigger
  45365. */
  45366. value: number;
  45367. /**
  45368. * If the button/trigger is currently touched
  45369. */
  45370. touched: boolean;
  45371. /**
  45372. * If the button/trigger is currently pressed
  45373. */
  45374. pressed: boolean;
  45375. }>;
  45376. }
  45377. /**
  45378. * An Abstract Motion controller
  45379. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45380. * Each component has an observable to check for changes in value and state
  45381. */
  45382. export abstract class WebXRAbstractMotionController implements IDisposable {
  45383. protected scene: Scene;
  45384. protected layout: IMotionControllerLayout;
  45385. /**
  45386. * The gamepad object correlating to this controller
  45387. */
  45388. gamepadObject: IMinimalMotionControllerObject;
  45389. /**
  45390. * handness (left/right/none) of this controller
  45391. */
  45392. handness: MotionControllerHandness;
  45393. private _initComponent;
  45394. private _modelReady;
  45395. /**
  45396. * A map of components (WebXRControllerComponent) in this motion controller
  45397. * Components have a ComponentType and can also have both button and axis definitions
  45398. */
  45399. readonly components: {
  45400. [id: string]: WebXRControllerComponent;
  45401. };
  45402. /**
  45403. * Disable the model's animation. Can be set at any time.
  45404. */
  45405. disableAnimation: boolean;
  45406. /**
  45407. * Observers registered here will be triggered when the model of this controller is done loading
  45408. */
  45409. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45410. /**
  45411. * The profile id of this motion controller
  45412. */
  45413. abstract profileId: string;
  45414. /**
  45415. * The root mesh of the model. It is null if the model was not yet initialized
  45416. */
  45417. rootMesh: Nullable<AbstractMesh>;
  45418. /**
  45419. * constructs a new abstract motion controller
  45420. * @param scene the scene to which the model of the controller will be added
  45421. * @param layout The profile layout to load
  45422. * @param gamepadObject The gamepad object correlating to this controller
  45423. * @param handness handness (left/right/none) of this controller
  45424. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45425. */
  45426. constructor(scene: Scene, layout: IMotionControllerLayout,
  45427. /**
  45428. * The gamepad object correlating to this controller
  45429. */
  45430. gamepadObject: IMinimalMotionControllerObject,
  45431. /**
  45432. * handness (left/right/none) of this controller
  45433. */
  45434. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45435. /**
  45436. * Dispose this controller, the model mesh and all its components
  45437. */
  45438. dispose(): void;
  45439. /**
  45440. * Returns all components of specific type
  45441. * @param type the type to search for
  45442. * @return an array of components with this type
  45443. */
  45444. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45445. /**
  45446. * get a component based an its component id as defined in layout.components
  45447. * @param id the id of the component
  45448. * @returns the component correlates to the id or undefined if not found
  45449. */
  45450. getComponent(id: string): WebXRControllerComponent;
  45451. /**
  45452. * Get the list of components available in this motion controller
  45453. * @returns an array of strings correlating to available components
  45454. */
  45455. getComponentIds(): string[];
  45456. /**
  45457. * Get the first component of specific type
  45458. * @param type type of component to find
  45459. * @return a controller component or null if not found
  45460. */
  45461. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45462. /**
  45463. * Get the main (Select) component of this controller as defined in the layout
  45464. * @returns the main component of this controller
  45465. */
  45466. getMainComponent(): WebXRControllerComponent;
  45467. /**
  45468. * Loads the model correlating to this controller
  45469. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45470. * @returns A promise fulfilled with the result of the model loading
  45471. */
  45472. loadModel(): Promise<boolean>;
  45473. /**
  45474. * Update this model using the current XRFrame
  45475. * @param xrFrame the current xr frame to use and update the model
  45476. */
  45477. updateFromXRFrame(xrFrame: XRFrame): void;
  45478. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45479. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45480. /**
  45481. * Moves the axis on the controller mesh based on its current state
  45482. * @param axis the index of the axis
  45483. * @param axisValue the value of the axis which determines the meshes new position
  45484. * @hidden
  45485. */
  45486. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45487. /**
  45488. * Update the model itself with the current frame data
  45489. * @param xrFrame the frame to use for updating the model mesh
  45490. */
  45491. protected updateModel(xrFrame: XRFrame): void;
  45492. /**
  45493. * Get the filename and path for this controller's model
  45494. * @returns a map of filename and path
  45495. */
  45496. protected abstract _getFilenameAndPath(): {
  45497. filename: string;
  45498. path: string;
  45499. };
  45500. /**
  45501. * This function is called before the mesh is loaded. It checks for loading constraints.
  45502. * For example, this function can check if the GLB loader is available
  45503. * If this function returns false, the generic controller will be loaded instead
  45504. * @returns Is the client ready to load the mesh
  45505. */
  45506. protected abstract _getModelLoadingConstraints(): boolean;
  45507. /**
  45508. * This function will be called after the model was successfully loaded and can be used
  45509. * for mesh transformations before it is available for the user
  45510. * @param meshes the loaded meshes
  45511. */
  45512. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45513. /**
  45514. * Set the root mesh for this controller. Important for the WebXR controller class
  45515. * @param meshes the loaded meshes
  45516. */
  45517. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45518. /**
  45519. * A function executed each frame that updates the mesh (if needed)
  45520. * @param xrFrame the current xrFrame
  45521. */
  45522. protected abstract _updateModel(xrFrame: XRFrame): void;
  45523. private _getGenericFilenameAndPath;
  45524. private _getGenericParentMesh;
  45525. }
  45526. }
  45527. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45528. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45530. import { Scene } from "babylonjs/scene";
  45531. /**
  45532. * A generic trigger-only motion controller for WebXR
  45533. */
  45534. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45535. /**
  45536. * Static version of the profile id of this controller
  45537. */
  45538. static ProfileId: string;
  45539. profileId: string;
  45540. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45541. protected _getFilenameAndPath(): {
  45542. filename: string;
  45543. path: string;
  45544. };
  45545. protected _getModelLoadingConstraints(): boolean;
  45546. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45547. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45548. protected _updateModel(): void;
  45549. }
  45550. }
  45551. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45552. import { Vector4 } from "babylonjs/Maths/math.vector";
  45553. import { Mesh } from "babylonjs/Meshes/mesh";
  45554. import { Scene } from "babylonjs/scene";
  45555. import { Nullable } from "babylonjs/types";
  45556. /**
  45557. * Class containing static functions to help procedurally build meshes
  45558. */
  45559. export class SphereBuilder {
  45560. /**
  45561. * Creates a sphere mesh
  45562. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45563. * * 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`)
  45564. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45565. * * 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
  45566. * * 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)
  45567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45570. * @param name defines the name of the mesh
  45571. * @param options defines the options used to create the mesh
  45572. * @param scene defines the hosting scene
  45573. * @returns the sphere mesh
  45574. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45575. */
  45576. static CreateSphere(name: string, options: {
  45577. segments?: number;
  45578. diameter?: number;
  45579. diameterX?: number;
  45580. diameterY?: number;
  45581. diameterZ?: number;
  45582. arc?: number;
  45583. slice?: number;
  45584. sideOrientation?: number;
  45585. frontUVs?: Vector4;
  45586. backUVs?: Vector4;
  45587. updatable?: boolean;
  45588. }, scene?: Nullable<Scene>): Mesh;
  45589. }
  45590. }
  45591. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45593. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45594. import { Scene } from "babylonjs/scene";
  45595. /**
  45596. * A profiled motion controller has its profile loaded from an online repository.
  45597. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45598. */
  45599. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45600. private _repositoryUrl;
  45601. private _buttonMeshMapping;
  45602. private _touchDots;
  45603. /**
  45604. * The profile ID of this controller. Will be populated when the controller initializes.
  45605. */
  45606. profileId: string;
  45607. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45608. dispose(): void;
  45609. protected _getFilenameAndPath(): {
  45610. filename: string;
  45611. path: string;
  45612. };
  45613. protected _getModelLoadingConstraints(): boolean;
  45614. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45615. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45616. protected _updateModel(_xrFrame: XRFrame): void;
  45617. }
  45618. }
  45619. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45620. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45621. import { Scene } from "babylonjs/scene";
  45622. /**
  45623. * A construction function type to create a new controller based on an xrInput object
  45624. */
  45625. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45626. /**
  45627. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45628. *
  45629. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45630. * it should be replaced with auto-loaded controllers.
  45631. *
  45632. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45633. */
  45634. export class WebXRMotionControllerManager {
  45635. private static _AvailableControllers;
  45636. private static _Fallbacks;
  45637. private static _ProfileLoadingPromises;
  45638. private static _ProfilesList;
  45639. /**
  45640. * The base URL of the online controller repository. Can be changed at any time.
  45641. */
  45642. static BaseRepositoryUrl: string;
  45643. /**
  45644. * Which repository gets priority - local or online
  45645. */
  45646. static PrioritizeOnlineRepository: boolean;
  45647. /**
  45648. * Use the online repository, or use only locally-defined controllers
  45649. */
  45650. static UseOnlineRepository: boolean;
  45651. /**
  45652. * Clear the cache used for profile loading and reload when requested again
  45653. */
  45654. static ClearProfilesCache(): void;
  45655. /**
  45656. * Register the default fallbacks.
  45657. * This function is called automatically when this file is imported.
  45658. */
  45659. static DefaultFallbacks(): void;
  45660. /**
  45661. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45662. * @param profileId the profile to which a fallback needs to be found
  45663. * @return an array with corresponding fallback profiles
  45664. */
  45665. static FindFallbackWithProfileId(profileId: string): string[];
  45666. /**
  45667. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45668. * The order of search:
  45669. *
  45670. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45671. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45672. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45673. * 4) return the generic trigger controller if none were found
  45674. *
  45675. * @param xrInput the xrInput to which a new controller is initialized
  45676. * @param scene the scene to which the model will be added
  45677. * @param forceProfile force a certain profile for this controller
  45678. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45679. */
  45680. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45681. /**
  45682. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45683. *
  45684. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45685. *
  45686. * @param type the profile type to register
  45687. * @param constructFunction the function to be called when loading this profile
  45688. */
  45689. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45690. /**
  45691. * Register a fallback to a specific profile.
  45692. * @param profileId the profileId that will receive the fallbacks
  45693. * @param fallbacks A list of fallback profiles
  45694. */
  45695. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45696. /**
  45697. * Will update the list of profiles available in the repository
  45698. * @return a promise that resolves to a map of profiles available online
  45699. */
  45700. static UpdateProfilesList(): Promise<{
  45701. [profile: string]: string;
  45702. }>;
  45703. private static _LoadProfileFromRepository;
  45704. private static _LoadProfilesFromAvailableControllers;
  45705. }
  45706. }
  45707. declare module "babylonjs/XR/webXRInputSource" {
  45708. import { Observable } from "babylonjs/Misc/observable";
  45709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45710. import { Ray } from "babylonjs/Culling/ray";
  45711. import { Scene } from "babylonjs/scene";
  45712. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45713. /**
  45714. * Configuration options for the WebXR controller creation
  45715. */
  45716. export interface IWebXRControllerOptions {
  45717. /**
  45718. * Should the controller mesh be animated when a user interacts with it
  45719. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45720. */
  45721. disableMotionControllerAnimation?: boolean;
  45722. /**
  45723. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45724. */
  45725. doNotLoadControllerMesh?: boolean;
  45726. /**
  45727. * Force a specific controller type for this controller.
  45728. * This can be used when creating your own profile or when testing different controllers
  45729. */
  45730. forceControllerProfile?: string;
  45731. }
  45732. /**
  45733. * Represents an XR controller
  45734. */
  45735. export class WebXRInputSource {
  45736. private _scene;
  45737. /** The underlying input source for the controller */
  45738. inputSource: XRInputSource;
  45739. private _options;
  45740. private _tmpQuaternion;
  45741. private _tmpVector;
  45742. private _uniqueId;
  45743. /**
  45744. * 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
  45745. */
  45746. grip?: AbstractMesh;
  45747. /**
  45748. * If available, this is the gamepad object related to this controller.
  45749. * Using this object it is possible to get click events and trackpad changes of the
  45750. * webxr controller that is currently being used.
  45751. */
  45752. motionController?: WebXRAbstractMotionController;
  45753. /**
  45754. * Event that fires when the controller is removed/disposed.
  45755. * The object provided as event data is this controller, after associated assets were disposed.
  45756. * uniqueId is still available.
  45757. */
  45758. onDisposeObservable: Observable<WebXRInputSource>;
  45759. /**
  45760. * Will be triggered when the mesh associated with the motion controller is done loading.
  45761. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45762. * A shortened version of controller -> motion controller -> on mesh loaded.
  45763. */
  45764. onMeshLoadedObservable: Observable<AbstractMesh>;
  45765. /**
  45766. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45767. */
  45768. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45769. /**
  45770. * Pointer which can be used to select objects or attach a visible laser to
  45771. */
  45772. pointer: AbstractMesh;
  45773. /**
  45774. * Creates the controller
  45775. * @see https://doc.babylonjs.com/how_to/webxr
  45776. * @param _scene the scene which the controller should be associated to
  45777. * @param inputSource the underlying input source for the controller
  45778. * @param _options options for this controller creation
  45779. */
  45780. constructor(_scene: Scene,
  45781. /** The underlying input source for the controller */
  45782. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45783. /**
  45784. * Get this controllers unique id
  45785. */
  45786. get uniqueId(): string;
  45787. /**
  45788. * Disposes of the object
  45789. */
  45790. dispose(): void;
  45791. /**
  45792. * Gets a world space ray coming from the pointer or grip
  45793. * @param result the resulting ray
  45794. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45795. */
  45796. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45797. /**
  45798. * Updates the controller pose based on the given XRFrame
  45799. * @param xrFrame xr frame to update the pose with
  45800. * @param referenceSpace reference space to use
  45801. */
  45802. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45803. }
  45804. }
  45805. declare module "babylonjs/XR/webXRInput" {
  45806. import { Observable } from "babylonjs/Misc/observable";
  45807. import { IDisposable } from "babylonjs/scene";
  45808. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45809. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45810. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45811. /**
  45812. * The schema for initialization options of the XR Input class
  45813. */
  45814. export interface IWebXRInputOptions {
  45815. /**
  45816. * If set to true no model will be automatically loaded
  45817. */
  45818. doNotLoadControllerMeshes?: boolean;
  45819. /**
  45820. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45821. * If not found, the xr input profile data will be used.
  45822. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45823. */
  45824. forceInputProfile?: string;
  45825. /**
  45826. * Do not send a request to the controller repository to load the profile.
  45827. *
  45828. * Instead, use the controllers available in babylon itself.
  45829. */
  45830. disableOnlineControllerRepository?: boolean;
  45831. /**
  45832. * A custom URL for the controllers repository
  45833. */
  45834. customControllersRepositoryURL?: string;
  45835. /**
  45836. * Should the controller model's components not move according to the user input
  45837. */
  45838. disableControllerAnimation?: boolean;
  45839. }
  45840. /**
  45841. * XR input used to track XR inputs such as controllers/rays
  45842. */
  45843. export class WebXRInput implements IDisposable {
  45844. /**
  45845. * the xr session manager for this session
  45846. */
  45847. xrSessionManager: WebXRSessionManager;
  45848. /**
  45849. * the WebXR camera for this session. Mainly used for teleportation
  45850. */
  45851. xrCamera: WebXRCamera;
  45852. private readonly options;
  45853. /**
  45854. * XR controllers being tracked
  45855. */
  45856. controllers: Array<WebXRInputSource>;
  45857. private _frameObserver;
  45858. private _sessionEndedObserver;
  45859. private _sessionInitObserver;
  45860. /**
  45861. * Event when a controller has been connected/added
  45862. */
  45863. onControllerAddedObservable: Observable<WebXRInputSource>;
  45864. /**
  45865. * Event when a controller has been removed/disconnected
  45866. */
  45867. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45868. /**
  45869. * Initializes the WebXRInput
  45870. * @param xrSessionManager the xr session manager for this session
  45871. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45872. * @param options = initialization options for this xr input
  45873. */
  45874. constructor(
  45875. /**
  45876. * the xr session manager for this session
  45877. */
  45878. xrSessionManager: WebXRSessionManager,
  45879. /**
  45880. * the WebXR camera for this session. Mainly used for teleportation
  45881. */
  45882. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45883. private _onInputSourcesChange;
  45884. private _addAndRemoveControllers;
  45885. /**
  45886. * Disposes of the object
  45887. */
  45888. dispose(): void;
  45889. }
  45890. }
  45891. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45892. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45893. import { Observable, EventState } from "babylonjs/Misc/observable";
  45894. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45895. /**
  45896. * This is the base class for all WebXR features.
  45897. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45898. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45899. */
  45900. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45901. protected _xrSessionManager: WebXRSessionManager;
  45902. private _attached;
  45903. private _removeOnDetach;
  45904. /**
  45905. * Should auto-attach be disabled?
  45906. */
  45907. disableAutoAttach: boolean;
  45908. /**
  45909. * Construct a new (abstract) WebXR feature
  45910. * @param _xrSessionManager the xr session manager for this feature
  45911. */
  45912. constructor(_xrSessionManager: WebXRSessionManager);
  45913. /**
  45914. * Is this feature attached
  45915. */
  45916. get attached(): boolean;
  45917. /**
  45918. * attach this feature
  45919. *
  45920. * @param force should attachment be forced (even when already attached)
  45921. * @returns true if successful, false is failed or already attached
  45922. */
  45923. attach(force?: boolean): boolean;
  45924. /**
  45925. * detach this feature.
  45926. *
  45927. * @returns true if successful, false if failed or already detached
  45928. */
  45929. detach(): boolean;
  45930. /**
  45931. * Dispose this feature and all of the resources attached
  45932. */
  45933. dispose(): void;
  45934. /**
  45935. * This is used to register callbacks that will automatically be removed when detach is called.
  45936. * @param observable the observable to which the observer will be attached
  45937. * @param callback the callback to register
  45938. */
  45939. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45940. /**
  45941. * Code in this function will be executed on each xrFrame received from the browser.
  45942. * This function will not execute after the feature is detached.
  45943. * @param _xrFrame the current frame
  45944. */
  45945. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45946. }
  45947. }
  45948. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45949. import { IDisposable, Scene } from "babylonjs/scene";
  45950. import { Nullable } from "babylonjs/types";
  45951. import { Observable } from "babylonjs/Misc/observable";
  45952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45953. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45954. import { Camera } from "babylonjs/Cameras/camera";
  45955. /**
  45956. * Renders a layer on top of an existing scene
  45957. */
  45958. export class UtilityLayerRenderer implements IDisposable {
  45959. /** the original scene that will be rendered on top of */
  45960. originalScene: Scene;
  45961. private _pointerCaptures;
  45962. private _lastPointerEvents;
  45963. private static _DefaultUtilityLayer;
  45964. private static _DefaultKeepDepthUtilityLayer;
  45965. private _sharedGizmoLight;
  45966. private _renderCamera;
  45967. /**
  45968. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45969. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45970. * @returns the camera that is used when rendering the utility layer
  45971. */
  45972. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45973. /**
  45974. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45975. * @param cam the camera that should be used when rendering the utility layer
  45976. */
  45977. setRenderCamera(cam: Nullable<Camera>): void;
  45978. /**
  45979. * @hidden
  45980. * Light which used by gizmos to get light shading
  45981. */
  45982. _getSharedGizmoLight(): HemisphericLight;
  45983. /**
  45984. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45985. */
  45986. pickUtilitySceneFirst: boolean;
  45987. /**
  45988. * 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)
  45989. */
  45990. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45991. /**
  45992. * 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)
  45993. */
  45994. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45995. /**
  45996. * The scene that is rendered on top of the original scene
  45997. */
  45998. utilityLayerScene: Scene;
  45999. /**
  46000. * If the utility layer should automatically be rendered on top of existing scene
  46001. */
  46002. shouldRender: boolean;
  46003. /**
  46004. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46005. */
  46006. onlyCheckPointerDownEvents: boolean;
  46007. /**
  46008. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46009. */
  46010. processAllEvents: boolean;
  46011. /**
  46012. * Observable raised when the pointer move from the utility layer scene to the main scene
  46013. */
  46014. onPointerOutObservable: Observable<number>;
  46015. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46016. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46017. private _afterRenderObserver;
  46018. private _sceneDisposeObserver;
  46019. private _originalPointerObserver;
  46020. /**
  46021. * Instantiates a UtilityLayerRenderer
  46022. * @param originalScene the original scene that will be rendered on top of
  46023. * @param handleEvents boolean indicating if the utility layer should handle events
  46024. */
  46025. constructor(
  46026. /** the original scene that will be rendered on top of */
  46027. originalScene: Scene, handleEvents?: boolean);
  46028. private _notifyObservers;
  46029. /**
  46030. * Renders the utility layers scene on top of the original scene
  46031. */
  46032. render(): void;
  46033. /**
  46034. * Disposes of the renderer
  46035. */
  46036. dispose(): void;
  46037. private _updateCamera;
  46038. }
  46039. }
  46040. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46041. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46043. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46044. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46045. import { Scene } from "babylonjs/scene";
  46046. import { Nullable } from "babylonjs/types";
  46047. import { Color3 } from "babylonjs/Maths/math.color";
  46048. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46049. /**
  46050. * Options interface for the pointer selection module
  46051. */
  46052. export interface IWebXRControllerPointerSelectionOptions {
  46053. /**
  46054. * if provided, this scene will be used to render meshes.
  46055. */
  46056. customUtilityLayerScene?: Scene;
  46057. /**
  46058. * 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)
  46059. * If not disabled, the last picked point will be used to execute a pointer up event
  46060. * If disabled, pointer up event will be triggered right after the pointer down event.
  46061. * Used in screen and gaze target ray mode only
  46062. */
  46063. disablePointerUpOnTouchOut: boolean;
  46064. /**
  46065. * For gaze mode (time to select instead of press)
  46066. */
  46067. forceGazeMode: boolean;
  46068. /**
  46069. * 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
  46070. * to start a new countdown to the pointer down event.
  46071. * Defaults to 1.
  46072. */
  46073. gazeModePointerMovedFactor?: number;
  46074. /**
  46075. * Different button type to use instead of the main component
  46076. */
  46077. overrideButtonId?: string;
  46078. /**
  46079. * use this rendering group id for the meshes (optional)
  46080. */
  46081. renderingGroupId?: number;
  46082. /**
  46083. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46084. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46085. * 3000 means 3 seconds between pointing at something and selecting it
  46086. */
  46087. timeToSelect?: number;
  46088. /**
  46089. * Should meshes created here be added to a utility layer or the main scene
  46090. */
  46091. useUtilityLayer?: boolean;
  46092. /**
  46093. * the xr input to use with this pointer selection
  46094. */
  46095. xrInput: WebXRInput;
  46096. }
  46097. /**
  46098. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46099. */
  46100. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46101. private readonly _options;
  46102. private static _idCounter;
  46103. private _attachController;
  46104. private _controllers;
  46105. private _scene;
  46106. private _tmpVectorForPickCompare;
  46107. /**
  46108. * The module's name
  46109. */
  46110. static readonly Name: string;
  46111. /**
  46112. * The (Babylon) version of this module.
  46113. * This is an integer representing the implementation version.
  46114. * This number does not correspond to the WebXR specs version
  46115. */
  46116. static readonly Version: number;
  46117. /**
  46118. * Disable lighting on the laser pointer (so it will always be visible)
  46119. */
  46120. disablePointerLighting: boolean;
  46121. /**
  46122. * Disable lighting on the selection mesh (so it will always be visible)
  46123. */
  46124. disableSelectionMeshLighting: boolean;
  46125. /**
  46126. * Should the laser pointer be displayed
  46127. */
  46128. displayLaserPointer: boolean;
  46129. /**
  46130. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46131. */
  46132. displaySelectionMesh: boolean;
  46133. /**
  46134. * This color will be set to the laser pointer when selection is triggered
  46135. */
  46136. laserPointerPickedColor: Color3;
  46137. /**
  46138. * Default color of the laser pointer
  46139. */
  46140. lasterPointerDefaultColor: Color3;
  46141. /**
  46142. * default color of the selection ring
  46143. */
  46144. selectionMeshDefaultColor: Color3;
  46145. /**
  46146. * This color will be applied to the selection ring when selection is triggered
  46147. */
  46148. selectionMeshPickedColor: Color3;
  46149. /**
  46150. * constructs a new background remover module
  46151. * @param _xrSessionManager the session manager for this module
  46152. * @param _options read-only options to be used in this module
  46153. */
  46154. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46155. /**
  46156. * attach this feature
  46157. * Will usually be called by the features manager
  46158. *
  46159. * @returns true if successful.
  46160. */
  46161. attach(): boolean;
  46162. /**
  46163. * detach this feature.
  46164. * Will usually be called by the features manager
  46165. *
  46166. * @returns true if successful.
  46167. */
  46168. detach(): boolean;
  46169. /**
  46170. * Will get the mesh under a specific pointer.
  46171. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46172. * @param controllerId the controllerId to check
  46173. * @returns The mesh under pointer or null if no mesh is under the pointer
  46174. */
  46175. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46176. /**
  46177. * Get the xr controller that correlates to the pointer id in the pointer event
  46178. *
  46179. * @param id the pointer id to search for
  46180. * @returns the controller that correlates to this id or null if not found
  46181. */
  46182. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46183. protected _onXRFrame(_xrFrame: XRFrame): void;
  46184. private _attachGazeMode;
  46185. private _attachScreenRayMode;
  46186. private _attachTrackedPointerRayMode;
  46187. private _convertNormalToDirectionOfRay;
  46188. private _detachController;
  46189. private _generateNewMeshPair;
  46190. private _pickingMoved;
  46191. private _updatePointerDistance;
  46192. }
  46193. }
  46194. declare module "babylonjs/XR/webXREnterExitUI" {
  46195. import { Nullable } from "babylonjs/types";
  46196. import { Observable } from "babylonjs/Misc/observable";
  46197. import { IDisposable, Scene } from "babylonjs/scene";
  46198. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46199. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46200. /**
  46201. * Button which can be used to enter a different mode of XR
  46202. */
  46203. export class WebXREnterExitUIButton {
  46204. /** button element */
  46205. element: HTMLElement;
  46206. /** XR initialization options for the button */
  46207. sessionMode: XRSessionMode;
  46208. /** Reference space type */
  46209. referenceSpaceType: XRReferenceSpaceType;
  46210. /**
  46211. * Creates a WebXREnterExitUIButton
  46212. * @param element button element
  46213. * @param sessionMode XR initialization session mode
  46214. * @param referenceSpaceType the type of reference space to be used
  46215. */
  46216. constructor(
  46217. /** button element */
  46218. element: HTMLElement,
  46219. /** XR initialization options for the button */
  46220. sessionMode: XRSessionMode,
  46221. /** Reference space type */
  46222. referenceSpaceType: XRReferenceSpaceType);
  46223. /**
  46224. * Extendable function which can be used to update the button's visuals when the state changes
  46225. * @param activeButton the current active button in the UI
  46226. */
  46227. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46228. }
  46229. /**
  46230. * Options to create the webXR UI
  46231. */
  46232. export class WebXREnterExitUIOptions {
  46233. /**
  46234. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46235. */
  46236. customButtons?: Array<WebXREnterExitUIButton>;
  46237. /**
  46238. * A reference space type to use when creating the default button.
  46239. * Default is local-floor
  46240. */
  46241. referenceSpaceType?: XRReferenceSpaceType;
  46242. /**
  46243. * Context to enter xr with
  46244. */
  46245. renderTarget?: Nullable<WebXRRenderTarget>;
  46246. /**
  46247. * A session mode to use when creating the default button.
  46248. * Default is immersive-vr
  46249. */
  46250. sessionMode?: XRSessionMode;
  46251. }
  46252. /**
  46253. * UI to allow the user to enter/exit XR mode
  46254. */
  46255. export class WebXREnterExitUI implements IDisposable {
  46256. private scene;
  46257. /** version of the options passed to this UI */
  46258. options: WebXREnterExitUIOptions;
  46259. private _activeButton;
  46260. private _buttons;
  46261. private _overlay;
  46262. /**
  46263. * Fired every time the active button is changed.
  46264. *
  46265. * When xr is entered via a button that launches xr that button will be the callback parameter
  46266. *
  46267. * When exiting xr the callback parameter will be null)
  46268. */
  46269. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46270. /**
  46271. *
  46272. * @param scene babylon scene object to use
  46273. * @param options (read-only) version of the options passed to this UI
  46274. */
  46275. private constructor();
  46276. /**
  46277. * Creates UI to allow the user to enter/exit XR mode
  46278. * @param scene the scene to add the ui to
  46279. * @param helper the xr experience helper to enter/exit xr with
  46280. * @param options options to configure the UI
  46281. * @returns the created ui
  46282. */
  46283. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46284. /**
  46285. * Disposes of the XR UI component
  46286. */
  46287. dispose(): void;
  46288. private _updateButtons;
  46289. }
  46290. }
  46291. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46292. import { Vector3 } from "babylonjs/Maths/math.vector";
  46293. import { Color4 } from "babylonjs/Maths/math.color";
  46294. import { Nullable } from "babylonjs/types";
  46295. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46296. import { Scene } from "babylonjs/scene";
  46297. /**
  46298. * Class containing static functions to help procedurally build meshes
  46299. */
  46300. export class LinesBuilder {
  46301. /**
  46302. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46303. * * 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
  46304. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46305. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46306. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46307. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46308. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46309. * * 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
  46310. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46313. * @param name defines the name of the new line system
  46314. * @param options defines the options used to create the line system
  46315. * @param scene defines the hosting scene
  46316. * @returns a new line system mesh
  46317. */
  46318. static CreateLineSystem(name: string, options: {
  46319. lines: Vector3[][];
  46320. updatable?: boolean;
  46321. instance?: Nullable<LinesMesh>;
  46322. colors?: Nullable<Color4[][]>;
  46323. useVertexAlpha?: boolean;
  46324. }, scene: Nullable<Scene>): LinesMesh;
  46325. /**
  46326. * Creates a line mesh
  46327. * 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
  46328. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46329. * * The parameter `points` is an array successive Vector3
  46330. * * 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
  46331. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46332. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46333. * * When updating an instance, remember that only point positions can change, not the number of points
  46334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46336. * @param name defines the name of the new line system
  46337. * @param options defines the options used to create the line system
  46338. * @param scene defines the hosting scene
  46339. * @returns a new line mesh
  46340. */
  46341. static CreateLines(name: string, options: {
  46342. points: Vector3[];
  46343. updatable?: boolean;
  46344. instance?: Nullable<LinesMesh>;
  46345. colors?: Color4[];
  46346. useVertexAlpha?: boolean;
  46347. }, scene?: Nullable<Scene>): LinesMesh;
  46348. /**
  46349. * Creates a dashed line mesh
  46350. * * 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
  46351. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46352. * * The parameter `points` is an array successive Vector3
  46353. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46354. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46355. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46356. * * 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
  46357. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46358. * * When updating an instance, remember that only point positions can change, not the number of points
  46359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46360. * @param name defines the name of the mesh
  46361. * @param options defines the options used to create the mesh
  46362. * @param scene defines the hosting scene
  46363. * @returns the dashed line mesh
  46364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46365. */
  46366. static CreateDashedLines(name: string, options: {
  46367. points: Vector3[];
  46368. dashSize?: number;
  46369. gapSize?: number;
  46370. dashNb?: number;
  46371. updatable?: boolean;
  46372. instance?: LinesMesh;
  46373. useVertexAlpha?: boolean;
  46374. }, scene?: Nullable<Scene>): LinesMesh;
  46375. }
  46376. }
  46377. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46378. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46379. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46380. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46382. import { Vector3 } from "babylonjs/Maths/math.vector";
  46383. import { Material } from "babylonjs/Materials/material";
  46384. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46385. import { Scene } from "babylonjs/scene";
  46386. /**
  46387. * The options container for the teleportation module
  46388. */
  46389. export interface IWebXRTeleportationOptions {
  46390. /**
  46391. * if provided, this scene will be used to render meshes.
  46392. */
  46393. customUtilityLayerScene?: Scene;
  46394. /**
  46395. * Values to configure the default target mesh
  46396. */
  46397. defaultTargetMeshOptions?: {
  46398. /**
  46399. * Fill color of the teleportation area
  46400. */
  46401. teleportationFillColor?: string;
  46402. /**
  46403. * Border color for the teleportation area
  46404. */
  46405. teleportationBorderColor?: string;
  46406. /**
  46407. * Disable the mesh's animation sequence
  46408. */
  46409. disableAnimation?: boolean;
  46410. /**
  46411. * Disable lighting on the material or the ring and arrow
  46412. */
  46413. disableLighting?: boolean;
  46414. /**
  46415. * Override the default material of the torus and arrow
  46416. */
  46417. torusArrowMaterial?: Material;
  46418. };
  46419. /**
  46420. * A list of meshes to use as floor meshes.
  46421. * Meshes can be added and removed after initializing the feature using the
  46422. * addFloorMesh and removeFloorMesh functions
  46423. * If empty, rotation will still work
  46424. */
  46425. floorMeshes?: AbstractMesh[];
  46426. /**
  46427. * use this rendering group id for the meshes (optional)
  46428. */
  46429. renderingGroupId?: number;
  46430. /**
  46431. * Should teleportation move only to snap points
  46432. */
  46433. snapPointsOnly?: boolean;
  46434. /**
  46435. * An array of points to which the teleportation will snap to.
  46436. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46437. */
  46438. snapPositions?: Vector3[];
  46439. /**
  46440. * How close should the teleportation ray be in order to snap to position.
  46441. * Default to 0.8 units (meters)
  46442. */
  46443. snapToPositionRadius?: number;
  46444. /**
  46445. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46446. * If you want to support rotation, make sure your mesh has a direction indicator.
  46447. *
  46448. * When left untouched, the default mesh will be initialized.
  46449. */
  46450. teleportationTargetMesh?: AbstractMesh;
  46451. /**
  46452. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46453. */
  46454. timeToTeleport?: number;
  46455. /**
  46456. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46457. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46458. */
  46459. useMainComponentOnly?: boolean;
  46460. /**
  46461. * Should meshes created here be added to a utility layer or the main scene
  46462. */
  46463. useUtilityLayer?: boolean;
  46464. /**
  46465. * Babylon XR Input class for controller
  46466. */
  46467. xrInput: WebXRInput;
  46468. }
  46469. /**
  46470. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46471. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46472. * the input of the attached controllers.
  46473. */
  46474. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46475. private _options;
  46476. private _controllers;
  46477. private _currentTeleportationControllerId;
  46478. private _floorMeshes;
  46479. private _quadraticBezierCurve;
  46480. private _selectionFeature;
  46481. private _snapToPositions;
  46482. private _snappedToPoint;
  46483. private _teleportationRingMaterial?;
  46484. private _tmpRay;
  46485. private _tmpVector;
  46486. /**
  46487. * The module's name
  46488. */
  46489. static readonly Name: string;
  46490. /**
  46491. * The (Babylon) version of this module.
  46492. * This is an integer representing the implementation version.
  46493. * This number does not correspond to the webxr specs version
  46494. */
  46495. static readonly Version: number;
  46496. /**
  46497. * Is movement backwards enabled
  46498. */
  46499. backwardsMovementEnabled: boolean;
  46500. /**
  46501. * Distance to travel when moving backwards
  46502. */
  46503. backwardsTeleportationDistance: number;
  46504. /**
  46505. * The distance from the user to the inspection point in the direction of the controller
  46506. * A higher number will allow the user to move further
  46507. * defaults to 5 (meters, in xr units)
  46508. */
  46509. parabolicCheckRadius: number;
  46510. /**
  46511. * Should the module support parabolic ray on top of direct ray
  46512. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46513. * Very helpful when moving between floors / different heights
  46514. */
  46515. parabolicRayEnabled: boolean;
  46516. /**
  46517. * How much rotation should be applied when rotating right and left
  46518. */
  46519. rotationAngle: number;
  46520. /**
  46521. * Is rotation enabled when moving forward?
  46522. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46523. */
  46524. rotationEnabled: boolean;
  46525. /**
  46526. * constructs a new anchor system
  46527. * @param _xrSessionManager an instance of WebXRSessionManager
  46528. * @param _options configuration object for this feature
  46529. */
  46530. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46531. /**
  46532. * Get the snapPointsOnly flag
  46533. */
  46534. get snapPointsOnly(): boolean;
  46535. /**
  46536. * Sets the snapPointsOnly flag
  46537. * @param snapToPoints should teleportation be exclusively to snap points
  46538. */
  46539. set snapPointsOnly(snapToPoints: boolean);
  46540. /**
  46541. * Add a new mesh to the floor meshes array
  46542. * @param mesh the mesh to use as floor mesh
  46543. */
  46544. addFloorMesh(mesh: AbstractMesh): void;
  46545. /**
  46546. * Add a new snap-to point to fix teleportation to this position
  46547. * @param newSnapPoint The new Snap-To point
  46548. */
  46549. addSnapPoint(newSnapPoint: Vector3): void;
  46550. attach(): boolean;
  46551. detach(): boolean;
  46552. dispose(): void;
  46553. /**
  46554. * Remove a mesh from the floor meshes array
  46555. * @param mesh the mesh to remove
  46556. */
  46557. removeFloorMesh(mesh: AbstractMesh): void;
  46558. /**
  46559. * Remove a mesh from the floor meshes array using its name
  46560. * @param name the mesh name to remove
  46561. */
  46562. removeFloorMeshByName(name: string): void;
  46563. /**
  46564. * 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
  46565. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46566. * @returns was the point found and removed or not
  46567. */
  46568. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46569. /**
  46570. * This function sets a selection feature that will be disabled when
  46571. * the forward ray is shown and will be reattached when hidden.
  46572. * This is used to remove the selection rays when moving.
  46573. * @param selectionFeature the feature to disable when forward movement is enabled
  46574. */
  46575. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46576. protected _onXRFrame(_xrFrame: XRFrame): void;
  46577. private _attachController;
  46578. private _createDefaultTargetMesh;
  46579. private _detachController;
  46580. private _findClosestSnapPointWithRadius;
  46581. private _setTargetMeshPosition;
  46582. private _setTargetMeshVisibility;
  46583. private _showParabolicPath;
  46584. private _teleportForward;
  46585. }
  46586. }
  46587. declare module "babylonjs/XR/webXRDefaultExperience" {
  46588. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46589. import { Scene } from "babylonjs/scene";
  46590. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46591. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46592. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46593. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46595. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46596. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46597. /**
  46598. * Options for the default xr helper
  46599. */
  46600. export class WebXRDefaultExperienceOptions {
  46601. /**
  46602. * Enable or disable default UI to enter XR
  46603. */
  46604. disableDefaultUI?: boolean;
  46605. /**
  46606. * Should teleportation not initialize. defaults to false.
  46607. */
  46608. disableTeleportation?: boolean;
  46609. /**
  46610. * Floor meshes that will be used for teleport
  46611. */
  46612. floorMeshes?: Array<AbstractMesh>;
  46613. /**
  46614. * If set to true, the first frame will not be used to reset position
  46615. * The first frame is mainly used when copying transformation from the old camera
  46616. * Mainly used in AR
  46617. */
  46618. ignoreNativeCameraTransformation?: boolean;
  46619. /**
  46620. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46621. */
  46622. inputOptions?: IWebXRInputOptions;
  46623. /**
  46624. * optional configuration for the output canvas
  46625. */
  46626. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46627. /**
  46628. * optional UI options. This can be used among other to change session mode and reference space type
  46629. */
  46630. uiOptions?: WebXREnterExitUIOptions;
  46631. /**
  46632. * When loading teleportation and pointer select, use stable versions instead of latest.
  46633. */
  46634. useStablePlugins?: boolean;
  46635. }
  46636. /**
  46637. * Default experience which provides a similar setup to the previous webVRExperience
  46638. */
  46639. export class WebXRDefaultExperience {
  46640. /**
  46641. * Base experience
  46642. */
  46643. baseExperience: WebXRExperienceHelper;
  46644. /**
  46645. * Enables ui for entering/exiting xr
  46646. */
  46647. enterExitUI: WebXREnterExitUI;
  46648. /**
  46649. * Input experience extension
  46650. */
  46651. input: WebXRInput;
  46652. /**
  46653. * Enables laser pointer and selection
  46654. */
  46655. pointerSelection: WebXRControllerPointerSelection;
  46656. /**
  46657. * Default target xr should render to
  46658. */
  46659. renderTarget: WebXRRenderTarget;
  46660. /**
  46661. * Enables teleportation
  46662. */
  46663. teleportation: WebXRMotionControllerTeleportation;
  46664. private constructor();
  46665. /**
  46666. * Creates the default xr experience
  46667. * @param scene scene
  46668. * @param options options for basic configuration
  46669. * @returns resulting WebXRDefaultExperience
  46670. */
  46671. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46672. /**
  46673. * DIsposes of the experience helper
  46674. */
  46675. dispose(): void;
  46676. }
  46677. }
  46678. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46679. import { Observable } from "babylonjs/Misc/observable";
  46680. import { Nullable } from "babylonjs/types";
  46681. import { Camera } from "babylonjs/Cameras/camera";
  46682. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46683. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46684. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46685. import { Scene } from "babylonjs/scene";
  46686. import { Vector3 } from "babylonjs/Maths/math.vector";
  46687. import { Color3 } from "babylonjs/Maths/math.color";
  46688. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46690. import { Mesh } from "babylonjs/Meshes/mesh";
  46691. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46692. import { EasingFunction } from "babylonjs/Animations/easing";
  46693. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46694. import "babylonjs/Meshes/Builders/groundBuilder";
  46695. import "babylonjs/Meshes/Builders/torusBuilder";
  46696. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46697. import "babylonjs/Gamepads/gamepadSceneComponent";
  46698. import "babylonjs/Animations/animatable";
  46699. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46700. /**
  46701. * Options to modify the vr teleportation behavior.
  46702. */
  46703. export interface VRTeleportationOptions {
  46704. /**
  46705. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46706. */
  46707. floorMeshName?: string;
  46708. /**
  46709. * A list of meshes to be used as the teleportation floor. (default: empty)
  46710. */
  46711. floorMeshes?: Mesh[];
  46712. /**
  46713. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46714. */
  46715. teleportationMode?: number;
  46716. /**
  46717. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46718. */
  46719. teleportationTime?: number;
  46720. /**
  46721. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46722. */
  46723. teleportationSpeed?: number;
  46724. /**
  46725. * The easing function used in the animation or null for Linear. (default CircleEase)
  46726. */
  46727. easingFunction?: EasingFunction;
  46728. }
  46729. /**
  46730. * Options to modify the vr experience helper's behavior.
  46731. */
  46732. export interface VRExperienceHelperOptions extends WebVROptions {
  46733. /**
  46734. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46735. */
  46736. createDeviceOrientationCamera?: boolean;
  46737. /**
  46738. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46739. */
  46740. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46741. /**
  46742. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46743. */
  46744. laserToggle?: boolean;
  46745. /**
  46746. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46747. */
  46748. floorMeshes?: Mesh[];
  46749. /**
  46750. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46751. */
  46752. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46753. /**
  46754. * Defines if WebXR should be used instead of WebVR (if available)
  46755. */
  46756. useXR?: boolean;
  46757. }
  46758. /**
  46759. * Event containing information after VR has been entered
  46760. */
  46761. export class OnAfterEnteringVRObservableEvent {
  46762. /**
  46763. * If entering vr was successful
  46764. */
  46765. success: boolean;
  46766. }
  46767. /**
  46768. * Helps to quickly add VR support to an existing scene.
  46769. * See http://doc.babylonjs.com/how_to/webvr_helper
  46770. */
  46771. export class VRExperienceHelper {
  46772. /** Options to modify the vr experience helper's behavior. */
  46773. webVROptions: VRExperienceHelperOptions;
  46774. private _scene;
  46775. private _position;
  46776. private _btnVR;
  46777. private _btnVRDisplayed;
  46778. private _webVRsupported;
  46779. private _webVRready;
  46780. private _webVRrequesting;
  46781. private _webVRpresenting;
  46782. private _hasEnteredVR;
  46783. private _fullscreenVRpresenting;
  46784. private _inputElement;
  46785. private _webVRCamera;
  46786. private _vrDeviceOrientationCamera;
  46787. private _deviceOrientationCamera;
  46788. private _existingCamera;
  46789. private _onKeyDown;
  46790. private _onVrDisplayPresentChange;
  46791. private _onVRDisplayChanged;
  46792. private _onVRRequestPresentStart;
  46793. private _onVRRequestPresentComplete;
  46794. /**
  46795. * 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)
  46796. */
  46797. enableGazeEvenWhenNoPointerLock: boolean;
  46798. /**
  46799. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46800. */
  46801. exitVROnDoubleTap: boolean;
  46802. /**
  46803. * Observable raised right before entering VR.
  46804. */
  46805. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46806. /**
  46807. * Observable raised when entering VR has completed.
  46808. */
  46809. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46810. /**
  46811. * Observable raised when exiting VR.
  46812. */
  46813. onExitingVRObservable: Observable<VRExperienceHelper>;
  46814. /**
  46815. * Observable raised when controller mesh is loaded.
  46816. */
  46817. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46818. /** Return this.onEnteringVRObservable
  46819. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46820. */
  46821. get onEnteringVR(): Observable<VRExperienceHelper>;
  46822. /** Return this.onExitingVRObservable
  46823. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46824. */
  46825. get onExitingVR(): Observable<VRExperienceHelper>;
  46826. /** Return this.onControllerMeshLoadedObservable
  46827. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46828. */
  46829. get onControllerMeshLoaded(): Observable<WebVRController>;
  46830. private _rayLength;
  46831. private _useCustomVRButton;
  46832. private _teleportationRequested;
  46833. private _teleportActive;
  46834. private _floorMeshName;
  46835. private _floorMeshesCollection;
  46836. private _teleportationMode;
  46837. private _teleportationTime;
  46838. private _teleportationSpeed;
  46839. private _teleportationEasing;
  46840. private _rotationAllowed;
  46841. private _teleportBackwardsVector;
  46842. private _teleportationTarget;
  46843. private _isDefaultTeleportationTarget;
  46844. private _postProcessMove;
  46845. private _teleportationFillColor;
  46846. private _teleportationBorderColor;
  46847. private _rotationAngle;
  46848. private _haloCenter;
  46849. private _cameraGazer;
  46850. private _padSensibilityUp;
  46851. private _padSensibilityDown;
  46852. private _leftController;
  46853. private _rightController;
  46854. private _gazeColor;
  46855. private _laserColor;
  46856. private _pickedLaserColor;
  46857. private _pickedGazeColor;
  46858. /**
  46859. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46860. */
  46861. onNewMeshSelected: Observable<AbstractMesh>;
  46862. /**
  46863. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46864. * This observable will provide the mesh and the controller used to select the mesh
  46865. */
  46866. onMeshSelectedWithController: Observable<{
  46867. mesh: AbstractMesh;
  46868. controller: WebVRController;
  46869. }>;
  46870. /**
  46871. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46872. */
  46873. onNewMeshPicked: Observable<PickingInfo>;
  46874. private _circleEase;
  46875. /**
  46876. * Observable raised before camera teleportation
  46877. */
  46878. onBeforeCameraTeleport: Observable<Vector3>;
  46879. /**
  46880. * Observable raised after camera teleportation
  46881. */
  46882. onAfterCameraTeleport: Observable<Vector3>;
  46883. /**
  46884. * Observable raised when current selected mesh gets unselected
  46885. */
  46886. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46887. private _raySelectionPredicate;
  46888. /**
  46889. * To be optionaly changed by user to define custom ray selection
  46890. */
  46891. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46892. /**
  46893. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46894. */
  46895. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46896. /**
  46897. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46898. */
  46899. teleportationEnabled: boolean;
  46900. private _defaultHeight;
  46901. private _teleportationInitialized;
  46902. private _interactionsEnabled;
  46903. private _interactionsRequested;
  46904. private _displayGaze;
  46905. private _displayLaserPointer;
  46906. /**
  46907. * The mesh used to display where the user is going to teleport.
  46908. */
  46909. get teleportationTarget(): Mesh;
  46910. /**
  46911. * Sets the mesh to be used to display where the user is going to teleport.
  46912. */
  46913. set teleportationTarget(value: Mesh);
  46914. /**
  46915. * 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
  46916. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46917. * See http://doc.babylonjs.com/resources/baking_transformations
  46918. */
  46919. get gazeTrackerMesh(): Mesh;
  46920. set gazeTrackerMesh(value: Mesh);
  46921. /**
  46922. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46923. */
  46924. updateGazeTrackerScale: boolean;
  46925. /**
  46926. * If the gaze trackers color should be updated when selecting meshes
  46927. */
  46928. updateGazeTrackerColor: boolean;
  46929. /**
  46930. * If the controller laser color should be updated when selecting meshes
  46931. */
  46932. updateControllerLaserColor: boolean;
  46933. /**
  46934. * The gaze tracking mesh corresponding to the left controller
  46935. */
  46936. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46937. /**
  46938. * The gaze tracking mesh corresponding to the right controller
  46939. */
  46940. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46941. /**
  46942. * If the ray of the gaze should be displayed.
  46943. */
  46944. get displayGaze(): boolean;
  46945. /**
  46946. * Sets if the ray of the gaze should be displayed.
  46947. */
  46948. set displayGaze(value: boolean);
  46949. /**
  46950. * If the ray of the LaserPointer should be displayed.
  46951. */
  46952. get displayLaserPointer(): boolean;
  46953. /**
  46954. * Sets if the ray of the LaserPointer should be displayed.
  46955. */
  46956. set displayLaserPointer(value: boolean);
  46957. /**
  46958. * The deviceOrientationCamera used as the camera when not in VR.
  46959. */
  46960. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46961. /**
  46962. * Based on the current WebVR support, returns the current VR camera used.
  46963. */
  46964. get currentVRCamera(): Nullable<Camera>;
  46965. /**
  46966. * The webVRCamera which is used when in VR.
  46967. */
  46968. get webVRCamera(): WebVRFreeCamera;
  46969. /**
  46970. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46971. */
  46972. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46973. /**
  46974. * The html button that is used to trigger entering into VR.
  46975. */
  46976. get vrButton(): Nullable<HTMLButtonElement>;
  46977. private get _teleportationRequestInitiated();
  46978. /**
  46979. * Defines whether or not Pointer lock should be requested when switching to
  46980. * full screen.
  46981. */
  46982. requestPointerLockOnFullScreen: boolean;
  46983. /**
  46984. * If asking to force XR, this will be populated with the default xr experience
  46985. */
  46986. xr: WebXRDefaultExperience;
  46987. /**
  46988. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46989. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46990. */
  46991. xrTestDone: boolean;
  46992. /**
  46993. * Instantiates a VRExperienceHelper.
  46994. * Helps to quickly add VR support to an existing scene.
  46995. * @param scene The scene the VRExperienceHelper belongs to.
  46996. * @param webVROptions Options to modify the vr experience helper's behavior.
  46997. */
  46998. constructor(scene: Scene,
  46999. /** Options to modify the vr experience helper's behavior. */
  47000. webVROptions?: VRExperienceHelperOptions);
  47001. private completeVRInit;
  47002. private _onDefaultMeshLoaded;
  47003. private _onResize;
  47004. private _onFullscreenChange;
  47005. /**
  47006. * Gets a value indicating if we are currently in VR mode.
  47007. */
  47008. get isInVRMode(): boolean;
  47009. private onVrDisplayPresentChange;
  47010. private onVRDisplayChanged;
  47011. private moveButtonToBottomRight;
  47012. private displayVRButton;
  47013. private updateButtonVisibility;
  47014. private _cachedAngularSensibility;
  47015. /**
  47016. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47017. * Otherwise, will use the fullscreen API.
  47018. */
  47019. enterVR(): void;
  47020. /**
  47021. * Attempt to exit VR, or fullscreen.
  47022. */
  47023. exitVR(): void;
  47024. /**
  47025. * The position of the vr experience helper.
  47026. */
  47027. get position(): Vector3;
  47028. /**
  47029. * Sets the position of the vr experience helper.
  47030. */
  47031. set position(value: Vector3);
  47032. /**
  47033. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47034. */
  47035. enableInteractions(): void;
  47036. private get _noControllerIsActive();
  47037. private beforeRender;
  47038. private _isTeleportationFloor;
  47039. /**
  47040. * Adds a floor mesh to be used for teleportation.
  47041. * @param floorMesh the mesh to be used for teleportation.
  47042. */
  47043. addFloorMesh(floorMesh: Mesh): void;
  47044. /**
  47045. * Removes a floor mesh from being used for teleportation.
  47046. * @param floorMesh the mesh to be removed.
  47047. */
  47048. removeFloorMesh(floorMesh: Mesh): void;
  47049. /**
  47050. * Enables interactions and teleportation using the VR controllers and gaze.
  47051. * @param vrTeleportationOptions options to modify teleportation behavior.
  47052. */
  47053. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47054. private _onNewGamepadConnected;
  47055. private _tryEnableInteractionOnController;
  47056. private _onNewGamepadDisconnected;
  47057. private _enableInteractionOnController;
  47058. private _checkTeleportWithRay;
  47059. private _checkRotate;
  47060. private _checkTeleportBackwards;
  47061. private _enableTeleportationOnController;
  47062. private _createTeleportationCircles;
  47063. private _displayTeleportationTarget;
  47064. private _hideTeleportationTarget;
  47065. private _rotateCamera;
  47066. private _moveTeleportationSelectorTo;
  47067. private _workingVector;
  47068. private _workingQuaternion;
  47069. private _workingMatrix;
  47070. /**
  47071. * Time Constant Teleportation Mode
  47072. */
  47073. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47074. /**
  47075. * Speed Constant Teleportation Mode
  47076. */
  47077. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47078. /**
  47079. * Teleports the users feet to the desired location
  47080. * @param location The location where the user's feet should be placed
  47081. */
  47082. teleportCamera(location: Vector3): void;
  47083. private _convertNormalToDirectionOfRay;
  47084. private _castRayAndSelectObject;
  47085. private _notifySelectedMeshUnselected;
  47086. /**
  47087. * Permanently set new colors for the laser pointer
  47088. * @param color the new laser color
  47089. * @param pickedColor the new laser color when picked mesh detected
  47090. */
  47091. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47092. /**
  47093. * Set lighting enabled / disabled on the laser pointer of both controllers
  47094. * @param enabled should the lighting be enabled on the laser pointer
  47095. */
  47096. setLaserLightingState(enabled?: boolean): void;
  47097. /**
  47098. * Permanently set new colors for the gaze pointer
  47099. * @param color the new gaze color
  47100. * @param pickedColor the new gaze color when picked mesh detected
  47101. */
  47102. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47103. /**
  47104. * Sets the color of the laser ray from the vr controllers.
  47105. * @param color new color for the ray.
  47106. */
  47107. changeLaserColor(color: Color3): void;
  47108. /**
  47109. * Sets the color of the ray from the vr headsets gaze.
  47110. * @param color new color for the ray.
  47111. */
  47112. changeGazeColor(color: Color3): void;
  47113. /**
  47114. * Exits VR and disposes of the vr experience helper
  47115. */
  47116. dispose(): void;
  47117. /**
  47118. * Gets the name of the VRExperienceHelper class
  47119. * @returns "VRExperienceHelper"
  47120. */
  47121. getClassName(): string;
  47122. }
  47123. }
  47124. declare module "babylonjs/Cameras/VR/index" {
  47125. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47126. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47127. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47128. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47129. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47130. export * from "babylonjs/Cameras/VR/webVRCamera";
  47131. }
  47132. declare module "babylonjs/Cameras/RigModes/index" {
  47133. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47134. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47135. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47136. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47137. }
  47138. declare module "babylonjs/Cameras/index" {
  47139. export * from "babylonjs/Cameras/Inputs/index";
  47140. export * from "babylonjs/Cameras/cameraInputsManager";
  47141. export * from "babylonjs/Cameras/camera";
  47142. export * from "babylonjs/Cameras/targetCamera";
  47143. export * from "babylonjs/Cameras/freeCamera";
  47144. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47145. export * from "babylonjs/Cameras/touchCamera";
  47146. export * from "babylonjs/Cameras/arcRotateCamera";
  47147. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47148. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47149. export * from "babylonjs/Cameras/flyCamera";
  47150. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47151. export * from "babylonjs/Cameras/followCamera";
  47152. export * from "babylonjs/Cameras/followCameraInputsManager";
  47153. export * from "babylonjs/Cameras/gamepadCamera";
  47154. export * from "babylonjs/Cameras/Stereoscopic/index";
  47155. export * from "babylonjs/Cameras/universalCamera";
  47156. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47157. export * from "babylonjs/Cameras/VR/index";
  47158. export * from "babylonjs/Cameras/RigModes/index";
  47159. }
  47160. declare module "babylonjs/Collisions/index" {
  47161. export * from "babylonjs/Collisions/collider";
  47162. export * from "babylonjs/Collisions/collisionCoordinator";
  47163. export * from "babylonjs/Collisions/pickingInfo";
  47164. export * from "babylonjs/Collisions/intersectionInfo";
  47165. export * from "babylonjs/Collisions/meshCollisionData";
  47166. }
  47167. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47168. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47169. import { Vector3 } from "babylonjs/Maths/math.vector";
  47170. import { Ray } from "babylonjs/Culling/ray";
  47171. import { Plane } from "babylonjs/Maths/math.plane";
  47172. /**
  47173. * Contains an array of blocks representing the octree
  47174. */
  47175. export interface IOctreeContainer<T> {
  47176. /**
  47177. * Blocks within the octree
  47178. */
  47179. blocks: Array<OctreeBlock<T>>;
  47180. }
  47181. /**
  47182. * Class used to store a cell in an octree
  47183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47184. */
  47185. export class OctreeBlock<T> {
  47186. /**
  47187. * Gets the content of the current block
  47188. */
  47189. entries: T[];
  47190. /**
  47191. * Gets the list of block children
  47192. */
  47193. blocks: Array<OctreeBlock<T>>;
  47194. private _depth;
  47195. private _maxDepth;
  47196. private _capacity;
  47197. private _minPoint;
  47198. private _maxPoint;
  47199. private _boundingVectors;
  47200. private _creationFunc;
  47201. /**
  47202. * Creates a new block
  47203. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47204. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47205. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47206. * @param depth defines the current depth of this block in the octree
  47207. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47208. * @param creationFunc defines a callback to call when an element is added to the block
  47209. */
  47210. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47211. /**
  47212. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47213. */
  47214. get capacity(): number;
  47215. /**
  47216. * Gets the minimum vector (in world space) of the block's bounding box
  47217. */
  47218. get minPoint(): Vector3;
  47219. /**
  47220. * Gets the maximum vector (in world space) of the block's bounding box
  47221. */
  47222. get maxPoint(): Vector3;
  47223. /**
  47224. * Add a new element to this block
  47225. * @param entry defines the element to add
  47226. */
  47227. addEntry(entry: T): void;
  47228. /**
  47229. * Remove an element from this block
  47230. * @param entry defines the element to remove
  47231. */
  47232. removeEntry(entry: T): void;
  47233. /**
  47234. * Add an array of elements to this block
  47235. * @param entries defines the array of elements to add
  47236. */
  47237. addEntries(entries: T[]): void;
  47238. /**
  47239. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47240. * @param frustumPlanes defines the frustum planes to test
  47241. * @param selection defines the array to store current content if selection is positive
  47242. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47243. */
  47244. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47245. /**
  47246. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47247. * @param sphereCenter defines the bounding sphere center
  47248. * @param sphereRadius defines the bounding sphere radius
  47249. * @param selection defines the array to store current content if selection is positive
  47250. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47251. */
  47252. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47253. /**
  47254. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47255. * @param ray defines the ray to test with
  47256. * @param selection defines the array to store current content if selection is positive
  47257. */
  47258. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47259. /**
  47260. * Subdivide the content into child blocks (this block will then be empty)
  47261. */
  47262. createInnerBlocks(): void;
  47263. /**
  47264. * @hidden
  47265. */
  47266. 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;
  47267. }
  47268. }
  47269. declare module "babylonjs/Culling/Octrees/octree" {
  47270. import { SmartArray } from "babylonjs/Misc/smartArray";
  47271. import { Vector3 } from "babylonjs/Maths/math.vector";
  47272. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47274. import { Ray } from "babylonjs/Culling/ray";
  47275. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47276. import { Plane } from "babylonjs/Maths/math.plane";
  47277. /**
  47278. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47280. */
  47281. export class Octree<T> {
  47282. /** 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.) */
  47283. maxDepth: number;
  47284. /**
  47285. * Blocks within the octree containing objects
  47286. */
  47287. blocks: Array<OctreeBlock<T>>;
  47288. /**
  47289. * Content stored in the octree
  47290. */
  47291. dynamicContent: T[];
  47292. private _maxBlockCapacity;
  47293. private _selectionContent;
  47294. private _creationFunc;
  47295. /**
  47296. * Creates a octree
  47297. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47298. * @param creationFunc function to be used to instatiate the octree
  47299. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47300. * @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.)
  47301. */
  47302. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47303. /** 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.) */
  47304. maxDepth?: number);
  47305. /**
  47306. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47307. * @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);
  47308. * @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);
  47309. * @param entries meshes to be added to the octree blocks
  47310. */
  47311. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47312. /**
  47313. * Adds a mesh to the octree
  47314. * @param entry Mesh to add to the octree
  47315. */
  47316. addMesh(entry: T): void;
  47317. /**
  47318. * Remove an element from the octree
  47319. * @param entry defines the element to remove
  47320. */
  47321. removeMesh(entry: T): void;
  47322. /**
  47323. * Selects an array of meshes within the frustum
  47324. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47325. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47326. * @returns array of meshes within the frustum
  47327. */
  47328. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47329. /**
  47330. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47331. * @param sphereCenter defines the bounding sphere center
  47332. * @param sphereRadius defines the bounding sphere radius
  47333. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47334. * @returns an array of objects that intersect the sphere
  47335. */
  47336. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47337. /**
  47338. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47339. * @param ray defines the ray to test with
  47340. * @returns array of intersected objects
  47341. */
  47342. intersectsRay(ray: Ray): SmartArray<T>;
  47343. /**
  47344. * Adds a mesh into the octree block if it intersects the block
  47345. */
  47346. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47347. /**
  47348. * Adds a submesh into the octree block if it intersects the block
  47349. */
  47350. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47351. }
  47352. }
  47353. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47354. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47355. import { Scene } from "babylonjs/scene";
  47356. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47358. import { Ray } from "babylonjs/Culling/ray";
  47359. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47360. import { Collider } from "babylonjs/Collisions/collider";
  47361. module "babylonjs/scene" {
  47362. interface Scene {
  47363. /**
  47364. * @hidden
  47365. * Backing Filed
  47366. */
  47367. _selectionOctree: Octree<AbstractMesh>;
  47368. /**
  47369. * Gets the octree used to boost mesh selection (picking)
  47370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47371. */
  47372. selectionOctree: Octree<AbstractMesh>;
  47373. /**
  47374. * Creates or updates the octree used to boost selection (picking)
  47375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47376. * @param maxCapacity defines the maximum capacity per leaf
  47377. * @param maxDepth defines the maximum depth of the octree
  47378. * @returns an octree of AbstractMesh
  47379. */
  47380. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47381. }
  47382. }
  47383. module "babylonjs/Meshes/abstractMesh" {
  47384. interface AbstractMesh {
  47385. /**
  47386. * @hidden
  47387. * Backing Field
  47388. */
  47389. _submeshesOctree: Octree<SubMesh>;
  47390. /**
  47391. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47392. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47393. * @param maxCapacity defines the maximum size of each block (64 by default)
  47394. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47395. * @returns the new octree
  47396. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47398. */
  47399. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47400. }
  47401. }
  47402. /**
  47403. * Defines the octree scene component responsible to manage any octrees
  47404. * in a given scene.
  47405. */
  47406. export class OctreeSceneComponent {
  47407. /**
  47408. * The component name help to identify the component in the list of scene components.
  47409. */
  47410. readonly name: string;
  47411. /**
  47412. * The scene the component belongs to.
  47413. */
  47414. scene: Scene;
  47415. /**
  47416. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47417. */
  47418. readonly checksIsEnabled: boolean;
  47419. /**
  47420. * Creates a new instance of the component for the given scene
  47421. * @param scene Defines the scene to register the component in
  47422. */
  47423. constructor(scene: Scene);
  47424. /**
  47425. * Registers the component in a given scene
  47426. */
  47427. register(): void;
  47428. /**
  47429. * Return the list of active meshes
  47430. * @returns the list of active meshes
  47431. */
  47432. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47433. /**
  47434. * Return the list of active sub meshes
  47435. * @param mesh The mesh to get the candidates sub meshes from
  47436. * @returns the list of active sub meshes
  47437. */
  47438. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47439. private _tempRay;
  47440. /**
  47441. * Return the list of sub meshes intersecting with a given local ray
  47442. * @param mesh defines the mesh to find the submesh for
  47443. * @param localRay defines the ray in local space
  47444. * @returns the list of intersecting sub meshes
  47445. */
  47446. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47447. /**
  47448. * Return the list of sub meshes colliding with a collider
  47449. * @param mesh defines the mesh to find the submesh for
  47450. * @param collider defines the collider to evaluate the collision against
  47451. * @returns the list of colliding sub meshes
  47452. */
  47453. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47454. /**
  47455. * Rebuilds the elements related to this component in case of
  47456. * context lost for instance.
  47457. */
  47458. rebuild(): void;
  47459. /**
  47460. * Disposes the component and the associated ressources.
  47461. */
  47462. dispose(): void;
  47463. }
  47464. }
  47465. declare module "babylonjs/Culling/Octrees/index" {
  47466. export * from "babylonjs/Culling/Octrees/octree";
  47467. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47468. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47469. }
  47470. declare module "babylonjs/Culling/index" {
  47471. export * from "babylonjs/Culling/boundingBox";
  47472. export * from "babylonjs/Culling/boundingInfo";
  47473. export * from "babylonjs/Culling/boundingSphere";
  47474. export * from "babylonjs/Culling/Octrees/index";
  47475. export * from "babylonjs/Culling/ray";
  47476. }
  47477. declare module "babylonjs/Gizmos/gizmo" {
  47478. import { Nullable } from "babylonjs/types";
  47479. import { IDisposable } from "babylonjs/scene";
  47480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47481. import { Mesh } from "babylonjs/Meshes/mesh";
  47482. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47483. /**
  47484. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47485. */
  47486. export class Gizmo implements IDisposable {
  47487. /** The utility layer the gizmo will be added to */
  47488. gizmoLayer: UtilityLayerRenderer;
  47489. /**
  47490. * The root mesh of the gizmo
  47491. */
  47492. _rootMesh: Mesh;
  47493. private _attachedMesh;
  47494. /**
  47495. * Ratio for the scale of the gizmo (Default: 1)
  47496. */
  47497. scaleRatio: number;
  47498. /**
  47499. * If a custom mesh has been set (Default: false)
  47500. */
  47501. protected _customMeshSet: boolean;
  47502. /**
  47503. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47504. * * When set, interactions will be enabled
  47505. */
  47506. get attachedMesh(): Nullable<AbstractMesh>;
  47507. set attachedMesh(value: Nullable<AbstractMesh>);
  47508. /**
  47509. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47510. * @param mesh The mesh to replace the default mesh of the gizmo
  47511. */
  47512. setCustomMesh(mesh: Mesh): void;
  47513. /**
  47514. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47515. */
  47516. updateGizmoRotationToMatchAttachedMesh: boolean;
  47517. /**
  47518. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47519. */
  47520. updateGizmoPositionToMatchAttachedMesh: boolean;
  47521. /**
  47522. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47523. */
  47524. updateScale: boolean;
  47525. protected _interactionsEnabled: boolean;
  47526. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47527. private _beforeRenderObserver;
  47528. private _tempVector;
  47529. /**
  47530. * Creates a gizmo
  47531. * @param gizmoLayer The utility layer the gizmo will be added to
  47532. */
  47533. constructor(
  47534. /** The utility layer the gizmo will be added to */
  47535. gizmoLayer?: UtilityLayerRenderer);
  47536. /**
  47537. * Updates the gizmo to match the attached mesh's position/rotation
  47538. */
  47539. protected _update(): void;
  47540. /**
  47541. * Disposes of the gizmo
  47542. */
  47543. dispose(): void;
  47544. }
  47545. }
  47546. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47547. import { Observable } from "babylonjs/Misc/observable";
  47548. import { Nullable } from "babylonjs/types";
  47549. import { Vector3 } from "babylonjs/Maths/math.vector";
  47550. import { Color3 } from "babylonjs/Maths/math.color";
  47551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47553. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47554. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47555. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47556. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47557. import { Scene } from "babylonjs/scene";
  47558. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47559. /**
  47560. * Single plane drag gizmo
  47561. */
  47562. export class PlaneDragGizmo extends Gizmo {
  47563. /**
  47564. * Drag behavior responsible for the gizmos dragging interactions
  47565. */
  47566. dragBehavior: PointerDragBehavior;
  47567. private _pointerObserver;
  47568. /**
  47569. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47570. */
  47571. snapDistance: number;
  47572. /**
  47573. * Event that fires each time the gizmo snaps to a new location.
  47574. * * snapDistance is the the change in distance
  47575. */
  47576. onSnapObservable: Observable<{
  47577. snapDistance: number;
  47578. }>;
  47579. private _plane;
  47580. private _coloredMaterial;
  47581. private _hoverMaterial;
  47582. private _isEnabled;
  47583. private _parent;
  47584. /** @hidden */
  47585. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47586. /** @hidden */
  47587. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47588. /**
  47589. * Creates a PlaneDragGizmo
  47590. * @param gizmoLayer The utility layer the gizmo will be added to
  47591. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47592. * @param color The color of the gizmo
  47593. */
  47594. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47595. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47596. /**
  47597. * If the gizmo is enabled
  47598. */
  47599. set isEnabled(value: boolean);
  47600. get isEnabled(): boolean;
  47601. /**
  47602. * Disposes of the gizmo
  47603. */
  47604. dispose(): void;
  47605. }
  47606. }
  47607. declare module "babylonjs/Gizmos/positionGizmo" {
  47608. import { Observable } from "babylonjs/Misc/observable";
  47609. import { Nullable } from "babylonjs/types";
  47610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47611. import { Mesh } from "babylonjs/Meshes/mesh";
  47612. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47613. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47614. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47615. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47616. /**
  47617. * Gizmo that enables dragging a mesh along 3 axis
  47618. */
  47619. export class PositionGizmo extends Gizmo {
  47620. /**
  47621. * Internal gizmo used for interactions on the x axis
  47622. */
  47623. xGizmo: AxisDragGizmo;
  47624. /**
  47625. * Internal gizmo used for interactions on the y axis
  47626. */
  47627. yGizmo: AxisDragGizmo;
  47628. /**
  47629. * Internal gizmo used for interactions on the z axis
  47630. */
  47631. zGizmo: AxisDragGizmo;
  47632. /**
  47633. * Internal gizmo used for interactions on the yz plane
  47634. */
  47635. xPlaneGizmo: PlaneDragGizmo;
  47636. /**
  47637. * Internal gizmo used for interactions on the xz plane
  47638. */
  47639. yPlaneGizmo: PlaneDragGizmo;
  47640. /**
  47641. * Internal gizmo used for interactions on the xy plane
  47642. */
  47643. zPlaneGizmo: PlaneDragGizmo;
  47644. /**
  47645. * private variables
  47646. */
  47647. private _meshAttached;
  47648. private _updateGizmoRotationToMatchAttachedMesh;
  47649. private _snapDistance;
  47650. private _scaleRatio;
  47651. /** Fires an event when any of it's sub gizmos are dragged */
  47652. onDragStartObservable: Observable<unknown>;
  47653. /** Fires an event when any of it's sub gizmos are released from dragging */
  47654. onDragEndObservable: Observable<unknown>;
  47655. /**
  47656. * If set to true, planar drag is enabled
  47657. */
  47658. private _planarGizmoEnabled;
  47659. get attachedMesh(): Nullable<AbstractMesh>;
  47660. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47661. /**
  47662. * Creates a PositionGizmo
  47663. * @param gizmoLayer The utility layer the gizmo will be added to
  47664. */
  47665. constructor(gizmoLayer?: UtilityLayerRenderer);
  47666. /**
  47667. * If the planar drag gizmo is enabled
  47668. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47669. */
  47670. set planarGizmoEnabled(value: boolean);
  47671. get planarGizmoEnabled(): boolean;
  47672. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47673. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47674. /**
  47675. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47676. */
  47677. set snapDistance(value: number);
  47678. get snapDistance(): number;
  47679. /**
  47680. * Ratio for the scale of the gizmo (Default: 1)
  47681. */
  47682. set scaleRatio(value: number);
  47683. get scaleRatio(): number;
  47684. /**
  47685. * Disposes of the gizmo
  47686. */
  47687. dispose(): void;
  47688. /**
  47689. * CustomMeshes are not supported by this gizmo
  47690. * @param mesh The mesh to replace the default mesh of the gizmo
  47691. */
  47692. setCustomMesh(mesh: Mesh): void;
  47693. }
  47694. }
  47695. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47696. import { Observable } from "babylonjs/Misc/observable";
  47697. import { Nullable } from "babylonjs/types";
  47698. import { Vector3 } from "babylonjs/Maths/math.vector";
  47699. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47701. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47702. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47703. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47704. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47705. import { Scene } from "babylonjs/scene";
  47706. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47707. import { Color3 } from "babylonjs/Maths/math.color";
  47708. /**
  47709. * Single axis drag gizmo
  47710. */
  47711. export class AxisDragGizmo extends Gizmo {
  47712. /**
  47713. * Drag behavior responsible for the gizmos dragging interactions
  47714. */
  47715. dragBehavior: PointerDragBehavior;
  47716. private _pointerObserver;
  47717. /**
  47718. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47719. */
  47720. snapDistance: number;
  47721. /**
  47722. * Event that fires each time the gizmo snaps to a new location.
  47723. * * snapDistance is the the change in distance
  47724. */
  47725. onSnapObservable: Observable<{
  47726. snapDistance: number;
  47727. }>;
  47728. private _isEnabled;
  47729. private _parent;
  47730. private _arrow;
  47731. private _coloredMaterial;
  47732. private _hoverMaterial;
  47733. /** @hidden */
  47734. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47735. /** @hidden */
  47736. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47737. /**
  47738. * Creates an AxisDragGizmo
  47739. * @param gizmoLayer The utility layer the gizmo will be added to
  47740. * @param dragAxis The axis which the gizmo will be able to drag on
  47741. * @param color The color of the gizmo
  47742. */
  47743. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47744. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47745. /**
  47746. * If the gizmo is enabled
  47747. */
  47748. set isEnabled(value: boolean);
  47749. get isEnabled(): boolean;
  47750. /**
  47751. * Disposes of the gizmo
  47752. */
  47753. dispose(): void;
  47754. }
  47755. }
  47756. declare module "babylonjs/Debug/axesViewer" {
  47757. import { Vector3 } from "babylonjs/Maths/math.vector";
  47758. import { Nullable } from "babylonjs/types";
  47759. import { Scene } from "babylonjs/scene";
  47760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47761. /**
  47762. * The Axes viewer will show 3 axes in a specific point in space
  47763. */
  47764. export class AxesViewer {
  47765. private _xAxis;
  47766. private _yAxis;
  47767. private _zAxis;
  47768. private _scaleLinesFactor;
  47769. private _instanced;
  47770. /**
  47771. * Gets the hosting scene
  47772. */
  47773. scene: Scene;
  47774. /**
  47775. * Gets or sets a number used to scale line length
  47776. */
  47777. scaleLines: number;
  47778. /** Gets the node hierarchy used to render x-axis */
  47779. get xAxis(): TransformNode;
  47780. /** Gets the node hierarchy used to render y-axis */
  47781. get yAxis(): TransformNode;
  47782. /** Gets the node hierarchy used to render z-axis */
  47783. get zAxis(): TransformNode;
  47784. /**
  47785. * Creates a new AxesViewer
  47786. * @param scene defines the hosting scene
  47787. * @param scaleLines defines a number used to scale line length (1 by default)
  47788. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47789. * @param xAxis defines the node hierarchy used to render the x-axis
  47790. * @param yAxis defines the node hierarchy used to render the y-axis
  47791. * @param zAxis defines the node hierarchy used to render the z-axis
  47792. */
  47793. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47794. /**
  47795. * Force the viewer to update
  47796. * @param position defines the position of the viewer
  47797. * @param xaxis defines the x axis of the viewer
  47798. * @param yaxis defines the y axis of the viewer
  47799. * @param zaxis defines the z axis of the viewer
  47800. */
  47801. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47802. /**
  47803. * Creates an instance of this axes viewer.
  47804. * @returns a new axes viewer with instanced meshes
  47805. */
  47806. createInstance(): AxesViewer;
  47807. /** Releases resources */
  47808. dispose(): void;
  47809. private static _SetRenderingGroupId;
  47810. }
  47811. }
  47812. declare module "babylonjs/Debug/boneAxesViewer" {
  47813. import { Nullable } from "babylonjs/types";
  47814. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47815. import { Vector3 } from "babylonjs/Maths/math.vector";
  47816. import { Mesh } from "babylonjs/Meshes/mesh";
  47817. import { Bone } from "babylonjs/Bones/bone";
  47818. import { Scene } from "babylonjs/scene";
  47819. /**
  47820. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47821. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47822. */
  47823. export class BoneAxesViewer extends AxesViewer {
  47824. /**
  47825. * Gets or sets the target mesh where to display the axes viewer
  47826. */
  47827. mesh: Nullable<Mesh>;
  47828. /**
  47829. * Gets or sets the target bone where to display the axes viewer
  47830. */
  47831. bone: Nullable<Bone>;
  47832. /** Gets current position */
  47833. pos: Vector3;
  47834. /** Gets direction of X axis */
  47835. xaxis: Vector3;
  47836. /** Gets direction of Y axis */
  47837. yaxis: Vector3;
  47838. /** Gets direction of Z axis */
  47839. zaxis: Vector3;
  47840. /**
  47841. * Creates a new BoneAxesViewer
  47842. * @param scene defines the hosting scene
  47843. * @param bone defines the target bone
  47844. * @param mesh defines the target mesh
  47845. * @param scaleLines defines a scaling factor for line length (1 by default)
  47846. */
  47847. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47848. /**
  47849. * Force the viewer to update
  47850. */
  47851. update(): void;
  47852. /** Releases resources */
  47853. dispose(): void;
  47854. }
  47855. }
  47856. declare module "babylonjs/Debug/debugLayer" {
  47857. import { Scene } from "babylonjs/scene";
  47858. /**
  47859. * Interface used to define scene explorer extensibility option
  47860. */
  47861. export interface IExplorerExtensibilityOption {
  47862. /**
  47863. * Define the option label
  47864. */
  47865. label: string;
  47866. /**
  47867. * Defines the action to execute on click
  47868. */
  47869. action: (entity: any) => void;
  47870. }
  47871. /**
  47872. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47873. */
  47874. export interface IExplorerExtensibilityGroup {
  47875. /**
  47876. * Defines a predicate to test if a given type mut be extended
  47877. */
  47878. predicate: (entity: any) => boolean;
  47879. /**
  47880. * Gets the list of options added to a type
  47881. */
  47882. entries: IExplorerExtensibilityOption[];
  47883. }
  47884. /**
  47885. * Interface used to define the options to use to create the Inspector
  47886. */
  47887. export interface IInspectorOptions {
  47888. /**
  47889. * Display in overlay mode (default: false)
  47890. */
  47891. overlay?: boolean;
  47892. /**
  47893. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47894. */
  47895. globalRoot?: HTMLElement;
  47896. /**
  47897. * Display the Scene explorer
  47898. */
  47899. showExplorer?: boolean;
  47900. /**
  47901. * Display the property inspector
  47902. */
  47903. showInspector?: boolean;
  47904. /**
  47905. * Display in embed mode (both panes on the right)
  47906. */
  47907. embedMode?: boolean;
  47908. /**
  47909. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47910. */
  47911. handleResize?: boolean;
  47912. /**
  47913. * Allow the panes to popup (default: true)
  47914. */
  47915. enablePopup?: boolean;
  47916. /**
  47917. * Allow the panes to be closed by users (default: true)
  47918. */
  47919. enableClose?: boolean;
  47920. /**
  47921. * Optional list of extensibility entries
  47922. */
  47923. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47924. /**
  47925. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47926. */
  47927. inspectorURL?: string;
  47928. /**
  47929. * Optional initial tab (default to DebugLayerTab.Properties)
  47930. */
  47931. initialTab?: DebugLayerTab;
  47932. }
  47933. module "babylonjs/scene" {
  47934. interface Scene {
  47935. /**
  47936. * @hidden
  47937. * Backing field
  47938. */
  47939. _debugLayer: DebugLayer;
  47940. /**
  47941. * Gets the debug layer (aka Inspector) associated with the scene
  47942. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47943. */
  47944. debugLayer: DebugLayer;
  47945. }
  47946. }
  47947. /**
  47948. * Enum of inspector action tab
  47949. */
  47950. export enum DebugLayerTab {
  47951. /**
  47952. * Properties tag (default)
  47953. */
  47954. Properties = 0,
  47955. /**
  47956. * Debug tab
  47957. */
  47958. Debug = 1,
  47959. /**
  47960. * Statistics tab
  47961. */
  47962. Statistics = 2,
  47963. /**
  47964. * Tools tab
  47965. */
  47966. Tools = 3,
  47967. /**
  47968. * Settings tab
  47969. */
  47970. Settings = 4
  47971. }
  47972. /**
  47973. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47974. * what is happening in your scene
  47975. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47976. */
  47977. export class DebugLayer {
  47978. /**
  47979. * Define the url to get the inspector script from.
  47980. * By default it uses the babylonjs CDN.
  47981. * @ignoreNaming
  47982. */
  47983. static InspectorURL: string;
  47984. private _scene;
  47985. private BJSINSPECTOR;
  47986. private _onPropertyChangedObservable?;
  47987. /**
  47988. * Observable triggered when a property is changed through the inspector.
  47989. */
  47990. get onPropertyChangedObservable(): any;
  47991. /**
  47992. * Instantiates a new debug layer.
  47993. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47994. * what is happening in your scene
  47995. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47996. * @param scene Defines the scene to inspect
  47997. */
  47998. constructor(scene: Scene);
  47999. /** Creates the inspector window. */
  48000. private _createInspector;
  48001. /**
  48002. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48003. * @param entity defines the entity to select
  48004. * @param lineContainerTitle defines the specific block to highlight
  48005. */
  48006. select(entity: any, lineContainerTitle?: string): void;
  48007. /** Get the inspector from bundle or global */
  48008. private _getGlobalInspector;
  48009. /**
  48010. * Get if the inspector is visible or not.
  48011. * @returns true if visible otherwise, false
  48012. */
  48013. isVisible(): boolean;
  48014. /**
  48015. * Hide the inspector and close its window.
  48016. */
  48017. hide(): void;
  48018. /**
  48019. * Launch the debugLayer.
  48020. * @param config Define the configuration of the inspector
  48021. * @return a promise fulfilled when the debug layer is visible
  48022. */
  48023. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48024. }
  48025. }
  48026. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48027. import { Nullable } from "babylonjs/types";
  48028. import { Scene } from "babylonjs/scene";
  48029. import { Vector4 } from "babylonjs/Maths/math.vector";
  48030. import { Color4 } from "babylonjs/Maths/math.color";
  48031. import { Mesh } from "babylonjs/Meshes/mesh";
  48032. /**
  48033. * Class containing static functions to help procedurally build meshes
  48034. */
  48035. export class BoxBuilder {
  48036. /**
  48037. * Creates a box mesh
  48038. * * The parameter `size` sets the size (float) of each box side (default 1)
  48039. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48040. * * 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)
  48041. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48045. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48046. * @param name defines the name of the mesh
  48047. * @param options defines the options used to create the mesh
  48048. * @param scene defines the hosting scene
  48049. * @returns the box mesh
  48050. */
  48051. static CreateBox(name: string, options: {
  48052. size?: number;
  48053. width?: number;
  48054. height?: number;
  48055. depth?: number;
  48056. faceUV?: Vector4[];
  48057. faceColors?: Color4[];
  48058. sideOrientation?: number;
  48059. frontUVs?: Vector4;
  48060. backUVs?: Vector4;
  48061. wrap?: boolean;
  48062. topBaseAt?: number;
  48063. bottomBaseAt?: number;
  48064. updatable?: boolean;
  48065. }, scene?: Nullable<Scene>): Mesh;
  48066. }
  48067. }
  48068. declare module "babylonjs/Debug/physicsViewer" {
  48069. import { Nullable } from "babylonjs/types";
  48070. import { Scene } from "babylonjs/scene";
  48071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48072. import { Mesh } from "babylonjs/Meshes/mesh";
  48073. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48074. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48075. /**
  48076. * Used to show the physics impostor around the specific mesh
  48077. */
  48078. export class PhysicsViewer {
  48079. /** @hidden */
  48080. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48081. /** @hidden */
  48082. protected _meshes: Array<Nullable<AbstractMesh>>;
  48083. /** @hidden */
  48084. protected _scene: Nullable<Scene>;
  48085. /** @hidden */
  48086. protected _numMeshes: number;
  48087. /** @hidden */
  48088. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48089. private _renderFunction;
  48090. private _utilityLayer;
  48091. private _debugBoxMesh;
  48092. private _debugSphereMesh;
  48093. private _debugCylinderMesh;
  48094. private _debugMaterial;
  48095. private _debugMeshMeshes;
  48096. /**
  48097. * Creates a new PhysicsViewer
  48098. * @param scene defines the hosting scene
  48099. */
  48100. constructor(scene: Scene);
  48101. /** @hidden */
  48102. protected _updateDebugMeshes(): void;
  48103. /**
  48104. * Renders a specified physic impostor
  48105. * @param impostor defines the impostor to render
  48106. * @param targetMesh defines the mesh represented by the impostor
  48107. * @returns the new debug mesh used to render the impostor
  48108. */
  48109. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48110. /**
  48111. * Hides a specified physic impostor
  48112. * @param impostor defines the impostor to hide
  48113. */
  48114. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48115. private _getDebugMaterial;
  48116. private _getDebugBoxMesh;
  48117. private _getDebugSphereMesh;
  48118. private _getDebugCylinderMesh;
  48119. private _getDebugMeshMesh;
  48120. private _getDebugMesh;
  48121. /** Releases all resources */
  48122. dispose(): void;
  48123. }
  48124. }
  48125. declare module "babylonjs/Debug/rayHelper" {
  48126. import { Nullable } from "babylonjs/types";
  48127. import { Ray } from "babylonjs/Culling/ray";
  48128. import { Vector3 } from "babylonjs/Maths/math.vector";
  48129. import { Color3 } from "babylonjs/Maths/math.color";
  48130. import { Scene } from "babylonjs/scene";
  48131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48132. import "babylonjs/Meshes/Builders/linesBuilder";
  48133. /**
  48134. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48135. * in order to better appreciate the issue one might have.
  48136. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48137. */
  48138. export class RayHelper {
  48139. /**
  48140. * Defines the ray we are currently tryin to visualize.
  48141. */
  48142. ray: Nullable<Ray>;
  48143. private _renderPoints;
  48144. private _renderLine;
  48145. private _renderFunction;
  48146. private _scene;
  48147. private _updateToMeshFunction;
  48148. private _attachedToMesh;
  48149. private _meshSpaceDirection;
  48150. private _meshSpaceOrigin;
  48151. /**
  48152. * Helper function to create a colored helper in a scene in one line.
  48153. * @param ray Defines the ray we are currently tryin to visualize
  48154. * @param scene Defines the scene the ray is used in
  48155. * @param color Defines the color we want to see the ray in
  48156. * @returns The newly created ray helper.
  48157. */
  48158. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48159. /**
  48160. * Instantiate a new ray helper.
  48161. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48162. * in order to better appreciate the issue one might have.
  48163. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48164. * @param ray Defines the ray we are currently tryin to visualize
  48165. */
  48166. constructor(ray: Ray);
  48167. /**
  48168. * Shows the ray we are willing to debug.
  48169. * @param scene Defines the scene the ray needs to be rendered in
  48170. * @param color Defines the color the ray needs to be rendered in
  48171. */
  48172. show(scene: Scene, color?: Color3): void;
  48173. /**
  48174. * Hides the ray we are debugging.
  48175. */
  48176. hide(): void;
  48177. private _render;
  48178. /**
  48179. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48180. * @param mesh Defines the mesh we want the helper attached to
  48181. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48182. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48183. * @param length Defines the length of the ray
  48184. */
  48185. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48186. /**
  48187. * Detach the ray helper from the mesh it has previously been attached to.
  48188. */
  48189. detachFromMesh(): void;
  48190. private _updateToMesh;
  48191. /**
  48192. * Dispose the helper and release its associated resources.
  48193. */
  48194. dispose(): void;
  48195. }
  48196. }
  48197. declare module "babylonjs/Debug/skeletonViewer" {
  48198. import { Color3 } from "babylonjs/Maths/math.color";
  48199. import { Scene } from "babylonjs/scene";
  48200. import { Nullable } from "babylonjs/types";
  48201. import { Skeleton } from "babylonjs/Bones/skeleton";
  48202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48203. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48204. /**
  48205. * Class used to render a debug view of a given skeleton
  48206. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48207. */
  48208. export class SkeletonViewer {
  48209. /** defines the skeleton to render */
  48210. skeleton: Skeleton;
  48211. /** defines the mesh attached to the skeleton */
  48212. mesh: AbstractMesh;
  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 the color used to render the skeleton */
  48218. color: Color3;
  48219. private _scene;
  48220. private _debugLines;
  48221. private _debugMesh;
  48222. private _isEnabled;
  48223. private _renderFunction;
  48224. private _utilityLayer;
  48225. /**
  48226. * Returns the mesh used to render the bones
  48227. */
  48228. get debugMesh(): Nullable<LinesMesh>;
  48229. /**
  48230. * Creates a new SkeletonViewer
  48231. * @param skeleton defines the skeleton to render
  48232. * @param mesh defines the mesh attached to the skeleton
  48233. * @param scene defines the hosting scene
  48234. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48235. * @param renderingGroupId defines the rendering group id to use with the viewer
  48236. */
  48237. constructor(
  48238. /** defines the skeleton to render */
  48239. skeleton: Skeleton,
  48240. /** defines the mesh attached to the skeleton */
  48241. mesh: AbstractMesh, scene: Scene,
  48242. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48243. autoUpdateBonesMatrices?: boolean,
  48244. /** defines the rendering group id to use with the viewer */
  48245. renderingGroupId?: number);
  48246. /** Gets or sets a boolean indicating if the viewer is enabled */
  48247. set isEnabled(value: boolean);
  48248. get isEnabled(): boolean;
  48249. private _getBonePosition;
  48250. private _getLinesForBonesWithLength;
  48251. private _getLinesForBonesNoLength;
  48252. /** Update the viewer to sync with current skeleton state */
  48253. update(): void;
  48254. /** Release associated resources */
  48255. dispose(): void;
  48256. }
  48257. }
  48258. declare module "babylonjs/Debug/index" {
  48259. export * from "babylonjs/Debug/axesViewer";
  48260. export * from "babylonjs/Debug/boneAxesViewer";
  48261. export * from "babylonjs/Debug/debugLayer";
  48262. export * from "babylonjs/Debug/physicsViewer";
  48263. export * from "babylonjs/Debug/rayHelper";
  48264. export * from "babylonjs/Debug/skeletonViewer";
  48265. }
  48266. declare module "babylonjs/Engines/nullEngine" {
  48267. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48268. import { Engine } from "babylonjs/Engines/engine";
  48269. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48270. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48272. import { Effect } from "babylonjs/Materials/effect";
  48273. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48274. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48275. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48276. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48277. /**
  48278. * Options to create the null engine
  48279. */
  48280. export class NullEngineOptions {
  48281. /**
  48282. * Render width (Default: 512)
  48283. */
  48284. renderWidth: number;
  48285. /**
  48286. * Render height (Default: 256)
  48287. */
  48288. renderHeight: number;
  48289. /**
  48290. * Texture size (Default: 512)
  48291. */
  48292. textureSize: number;
  48293. /**
  48294. * If delta time between frames should be constant
  48295. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48296. */
  48297. deterministicLockstep: boolean;
  48298. /**
  48299. * Maximum about of steps between frames (Default: 4)
  48300. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48301. */
  48302. lockstepMaxSteps: number;
  48303. }
  48304. /**
  48305. * The null engine class provides support for headless version of babylon.js.
  48306. * This can be used in server side scenario or for testing purposes
  48307. */
  48308. export class NullEngine extends Engine {
  48309. private _options;
  48310. /**
  48311. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48313. * @returns true if engine is in deterministic lock step mode
  48314. */
  48315. isDeterministicLockStep(): boolean;
  48316. /**
  48317. * Gets the max steps when engine is running in deterministic lock step
  48318. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48319. * @returns the max steps
  48320. */
  48321. getLockstepMaxSteps(): number;
  48322. /**
  48323. * Gets the current hardware scaling level.
  48324. * By default the hardware scaling level is computed from the window device ratio.
  48325. * 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.
  48326. * @returns a number indicating the current hardware scaling level
  48327. */
  48328. getHardwareScalingLevel(): number;
  48329. constructor(options?: NullEngineOptions);
  48330. /**
  48331. * Creates a vertex buffer
  48332. * @param vertices the data for the vertex buffer
  48333. * @returns the new WebGL static buffer
  48334. */
  48335. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48336. /**
  48337. * Creates a new index buffer
  48338. * @param indices defines the content of the index buffer
  48339. * @param updatable defines if the index buffer must be updatable
  48340. * @returns a new webGL buffer
  48341. */
  48342. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48343. /**
  48344. * Clear the current render buffer or the current render target (if any is set up)
  48345. * @param color defines the color to use
  48346. * @param backBuffer defines if the back buffer must be cleared
  48347. * @param depth defines if the depth buffer must be cleared
  48348. * @param stencil defines if the stencil buffer must be cleared
  48349. */
  48350. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48351. /**
  48352. * Gets the current render width
  48353. * @param useScreen defines if screen size must be used (or the current render target if any)
  48354. * @returns a number defining the current render width
  48355. */
  48356. getRenderWidth(useScreen?: boolean): number;
  48357. /**
  48358. * Gets the current render height
  48359. * @param useScreen defines if screen size must be used (or the current render target if any)
  48360. * @returns a number defining the current render height
  48361. */
  48362. getRenderHeight(useScreen?: boolean): number;
  48363. /**
  48364. * Set the WebGL's viewport
  48365. * @param viewport defines the viewport element to be used
  48366. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48367. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48368. */
  48369. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48370. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48371. /**
  48372. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48373. * @param pipelineContext defines the pipeline context to use
  48374. * @param uniformsNames defines the list of uniform names
  48375. * @returns an array of webGL uniform locations
  48376. */
  48377. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48378. /**
  48379. * Gets the lsit of active attributes for a given webGL program
  48380. * @param pipelineContext defines the pipeline context to use
  48381. * @param attributesNames defines the list of attribute names to get
  48382. * @returns an array of indices indicating the offset of each attribute
  48383. */
  48384. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48385. /**
  48386. * Binds an effect to the webGL context
  48387. * @param effect defines the effect to bind
  48388. */
  48389. bindSamplers(effect: Effect): void;
  48390. /**
  48391. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48392. * @param effect defines the effect to activate
  48393. */
  48394. enableEffect(effect: Effect): void;
  48395. /**
  48396. * Set various states to the webGL context
  48397. * @param culling defines backface culling state
  48398. * @param zOffset defines the value to apply to zOffset (0 by default)
  48399. * @param force defines if states must be applied even if cache is up to date
  48400. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48401. */
  48402. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48403. /**
  48404. * Set the value of an uniform to an array of int32
  48405. * @param uniform defines the webGL uniform location where to store the value
  48406. * @param array defines the array of int32 to store
  48407. */
  48408. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48409. /**
  48410. * Set the value of an uniform to an array of int32 (stored as vec2)
  48411. * @param uniform defines the webGL uniform location where to store the value
  48412. * @param array defines the array of int32 to store
  48413. */
  48414. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48415. /**
  48416. * Set the value of an uniform to an array of int32 (stored as vec3)
  48417. * @param uniform defines the webGL uniform location where to store the value
  48418. * @param array defines the array of int32 to store
  48419. */
  48420. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48421. /**
  48422. * Set the value of an uniform to an array of int32 (stored as vec4)
  48423. * @param uniform defines the webGL uniform location where to store the value
  48424. * @param array defines the array of int32 to store
  48425. */
  48426. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48427. /**
  48428. * Set the value of an uniform to an array of float32
  48429. * @param uniform defines the webGL uniform location where to store the value
  48430. * @param array defines the array of float32 to store
  48431. */
  48432. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48433. /**
  48434. * Set the value of an uniform to an array of float32 (stored as vec2)
  48435. * @param uniform defines the webGL uniform location where to store the value
  48436. * @param array defines the array of float32 to store
  48437. */
  48438. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48439. /**
  48440. * Set the value of an uniform to an array of float32 (stored as vec3)
  48441. * @param uniform defines the webGL uniform location where to store the value
  48442. * @param array defines the array of float32 to store
  48443. */
  48444. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48445. /**
  48446. * Set the value of an uniform to an array of float32 (stored as vec4)
  48447. * @param uniform defines the webGL uniform location where to store the value
  48448. * @param array defines the array of float32 to store
  48449. */
  48450. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48451. /**
  48452. * Set the value of an uniform to an array of number
  48453. * @param uniform defines the webGL uniform location where to store the value
  48454. * @param array defines the array of number to store
  48455. */
  48456. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48457. /**
  48458. * Set the value of an uniform to an array of number (stored as vec2)
  48459. * @param uniform defines the webGL uniform location where to store the value
  48460. * @param array defines the array of number to store
  48461. */
  48462. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48463. /**
  48464. * Set the value of an uniform to an array of number (stored as vec3)
  48465. * @param uniform defines the webGL uniform location where to store the value
  48466. * @param array defines the array of number to store
  48467. */
  48468. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48469. /**
  48470. * Set the value of an uniform to an array of number (stored as vec4)
  48471. * @param uniform defines the webGL uniform location where to store the value
  48472. * @param array defines the array of number to store
  48473. */
  48474. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48475. /**
  48476. * Set the value of an uniform to an array of float32 (stored as matrices)
  48477. * @param uniform defines the webGL uniform location where to store the value
  48478. * @param matrices defines the array of float32 to store
  48479. */
  48480. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48481. /**
  48482. * Set the value of an uniform to a matrix (3x3)
  48483. * @param uniform defines the webGL uniform location where to store the value
  48484. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48485. */
  48486. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48487. /**
  48488. * Set the value of an uniform to a matrix (2x2)
  48489. * @param uniform defines the webGL uniform location where to store the value
  48490. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48491. */
  48492. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48493. /**
  48494. * Set the value of an uniform to a number (float)
  48495. * @param uniform defines the webGL uniform location where to store the value
  48496. * @param value defines the float number to store
  48497. */
  48498. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48499. /**
  48500. * Set the value of an uniform to a vec2
  48501. * @param uniform defines the webGL uniform location where to store the value
  48502. * @param x defines the 1st component of the value
  48503. * @param y defines the 2nd component of the value
  48504. */
  48505. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48506. /**
  48507. * Set the value of an uniform to a vec3
  48508. * @param uniform defines the webGL uniform location where to store the value
  48509. * @param x defines the 1st component of the value
  48510. * @param y defines the 2nd component of the value
  48511. * @param z defines the 3rd component of the value
  48512. */
  48513. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48514. /**
  48515. * Set the value of an uniform to a boolean
  48516. * @param uniform defines the webGL uniform location where to store the value
  48517. * @param bool defines the boolean to store
  48518. */
  48519. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48520. /**
  48521. * Set the value of an uniform to a vec4
  48522. * @param uniform defines the webGL uniform location where to store the value
  48523. * @param x defines the 1st component of the value
  48524. * @param y defines the 2nd component of the value
  48525. * @param z defines the 3rd component of the value
  48526. * @param w defines the 4th component of the value
  48527. */
  48528. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48529. /**
  48530. * Sets the current alpha mode
  48531. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48532. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48533. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48534. */
  48535. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48536. /**
  48537. * Bind webGl buffers directly to the webGL context
  48538. * @param vertexBuffers defines the vertex buffer to bind
  48539. * @param indexBuffer defines the index buffer to bind
  48540. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48541. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48542. * @param effect defines the effect associated with the vertex buffer
  48543. */
  48544. bindBuffers(vertexBuffers: {
  48545. [key: string]: VertexBuffer;
  48546. }, indexBuffer: DataBuffer, effect: Effect): void;
  48547. /**
  48548. * Force the entire cache to be cleared
  48549. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48550. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48551. */
  48552. wipeCaches(bruteForce?: boolean): void;
  48553. /**
  48554. * Send a draw order
  48555. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48556. * @param indexStart defines the starting index
  48557. * @param indexCount defines the number of index to draw
  48558. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48559. */
  48560. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48561. /**
  48562. * Draw a list of indexed primitives
  48563. * @param fillMode defines the primitive to use
  48564. * @param indexStart defines the starting index
  48565. * @param indexCount defines the number of index to draw
  48566. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48567. */
  48568. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48569. /**
  48570. * Draw a list of unindexed primitives
  48571. * @param fillMode defines the primitive to use
  48572. * @param verticesStart defines the index of first vertex to draw
  48573. * @param verticesCount defines the count of vertices to draw
  48574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48575. */
  48576. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48577. /** @hidden */
  48578. _createTexture(): WebGLTexture;
  48579. /** @hidden */
  48580. _releaseTexture(texture: InternalTexture): void;
  48581. /**
  48582. * Usually called from Texture.ts.
  48583. * Passed information to create a WebGLTexture
  48584. * @param urlArg defines a value which contains one of the following:
  48585. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48586. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48587. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48588. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48589. * @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)
  48590. * @param scene needed for loading to the correct scene
  48591. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48592. * @param onLoad optional callback to be called upon successful completion
  48593. * @param onError optional callback to be called upon failure
  48594. * @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
  48595. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48596. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48597. * @param forcedExtension defines the extension to use to pick the right loader
  48598. * @param mimeType defines an optional mime type
  48599. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48600. */
  48601. 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;
  48602. /**
  48603. * Creates a new render target texture
  48604. * @param size defines the size of the texture
  48605. * @param options defines the options used to create the texture
  48606. * @returns a new render target texture stored in an InternalTexture
  48607. */
  48608. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48609. /**
  48610. * Update the sampling mode of a given texture
  48611. * @param samplingMode defines the required sampling mode
  48612. * @param texture defines the texture to update
  48613. */
  48614. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48615. /**
  48616. * Binds the frame buffer to the specified texture.
  48617. * @param texture The texture to render to or null for the default canvas
  48618. * @param faceIndex The face of the texture to render to in case of cube texture
  48619. * @param requiredWidth The width of the target to render to
  48620. * @param requiredHeight The height of the target to render to
  48621. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48622. * @param lodLevel defines le lod level to bind to the frame buffer
  48623. */
  48624. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48625. /**
  48626. * Unbind the current render target texture from the webGL context
  48627. * @param texture defines the render target texture to unbind
  48628. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48629. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48630. */
  48631. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48632. /**
  48633. * Creates a dynamic vertex buffer
  48634. * @param vertices the data for the dynamic vertex buffer
  48635. * @returns the new WebGL dynamic buffer
  48636. */
  48637. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48638. /**
  48639. * Update the content of a dynamic texture
  48640. * @param texture defines the texture to update
  48641. * @param canvas defines the canvas containing the source
  48642. * @param invertY defines if data must be stored with Y axis inverted
  48643. * @param premulAlpha defines if alpha is stored as premultiplied
  48644. * @param format defines the format of the data
  48645. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48646. */
  48647. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48648. /**
  48649. * Gets a boolean indicating if all created effects are ready
  48650. * @returns true if all effects are ready
  48651. */
  48652. areAllEffectsReady(): boolean;
  48653. /**
  48654. * @hidden
  48655. * Get the current error code of the webGL context
  48656. * @returns the error code
  48657. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48658. */
  48659. getError(): number;
  48660. /** @hidden */
  48661. _getUnpackAlignement(): number;
  48662. /** @hidden */
  48663. _unpackFlipY(value: boolean): void;
  48664. /**
  48665. * Update a dynamic index buffer
  48666. * @param indexBuffer defines the target index buffer
  48667. * @param indices defines the data to update
  48668. * @param offset defines the offset in the target index buffer where update should start
  48669. */
  48670. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48671. /**
  48672. * Updates a dynamic vertex buffer.
  48673. * @param vertexBuffer the vertex buffer to update
  48674. * @param vertices the data used to update the vertex buffer
  48675. * @param byteOffset the byte offset of the data (optional)
  48676. * @param byteLength the byte length of the data (optional)
  48677. */
  48678. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48679. /** @hidden */
  48680. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48681. /** @hidden */
  48682. _bindTexture(channel: number, texture: InternalTexture): void;
  48683. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48684. /**
  48685. * 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
  48686. */
  48687. releaseEffects(): void;
  48688. displayLoadingUI(): void;
  48689. hideLoadingUI(): void;
  48690. /** @hidden */
  48691. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48692. /** @hidden */
  48693. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48694. /** @hidden */
  48695. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48696. /** @hidden */
  48697. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48698. }
  48699. }
  48700. declare module "babylonjs/Instrumentation/timeToken" {
  48701. import { Nullable } from "babylonjs/types";
  48702. /**
  48703. * @hidden
  48704. **/
  48705. export class _TimeToken {
  48706. _startTimeQuery: Nullable<WebGLQuery>;
  48707. _endTimeQuery: Nullable<WebGLQuery>;
  48708. _timeElapsedQuery: Nullable<WebGLQuery>;
  48709. _timeElapsedQueryEnded: boolean;
  48710. }
  48711. }
  48712. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48713. import { Nullable, int } from "babylonjs/types";
  48714. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48715. /** @hidden */
  48716. export class _OcclusionDataStorage {
  48717. /** @hidden */
  48718. occlusionInternalRetryCounter: number;
  48719. /** @hidden */
  48720. isOcclusionQueryInProgress: boolean;
  48721. /** @hidden */
  48722. isOccluded: boolean;
  48723. /** @hidden */
  48724. occlusionRetryCount: number;
  48725. /** @hidden */
  48726. occlusionType: number;
  48727. /** @hidden */
  48728. occlusionQueryAlgorithmType: number;
  48729. }
  48730. module "babylonjs/Engines/engine" {
  48731. interface Engine {
  48732. /**
  48733. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48734. * @return the new query
  48735. */
  48736. createQuery(): WebGLQuery;
  48737. /**
  48738. * Delete and release a webGL query
  48739. * @param query defines the query to delete
  48740. * @return the current engine
  48741. */
  48742. deleteQuery(query: WebGLQuery): Engine;
  48743. /**
  48744. * Check if a given query has resolved and got its value
  48745. * @param query defines the query to check
  48746. * @returns true if the query got its value
  48747. */
  48748. isQueryResultAvailable(query: WebGLQuery): boolean;
  48749. /**
  48750. * Gets the value of a given query
  48751. * @param query defines the query to check
  48752. * @returns the value of the query
  48753. */
  48754. getQueryResult(query: WebGLQuery): number;
  48755. /**
  48756. * Initiates an occlusion query
  48757. * @param algorithmType defines the algorithm to use
  48758. * @param query defines the query to use
  48759. * @returns the current engine
  48760. * @see http://doc.babylonjs.com/features/occlusionquery
  48761. */
  48762. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48763. /**
  48764. * Ends an occlusion query
  48765. * @see http://doc.babylonjs.com/features/occlusionquery
  48766. * @param algorithmType defines the algorithm to use
  48767. * @returns the current engine
  48768. */
  48769. endOcclusionQuery(algorithmType: number): Engine;
  48770. /**
  48771. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48772. * Please note that only one query can be issued at a time
  48773. * @returns a time token used to track the time span
  48774. */
  48775. startTimeQuery(): Nullable<_TimeToken>;
  48776. /**
  48777. * Ends a time query
  48778. * @param token defines the token used to measure the time span
  48779. * @returns the time spent (in ns)
  48780. */
  48781. endTimeQuery(token: _TimeToken): int;
  48782. /** @hidden */
  48783. _currentNonTimestampToken: Nullable<_TimeToken>;
  48784. /** @hidden */
  48785. _createTimeQuery(): WebGLQuery;
  48786. /** @hidden */
  48787. _deleteTimeQuery(query: WebGLQuery): void;
  48788. /** @hidden */
  48789. _getGlAlgorithmType(algorithmType: number): number;
  48790. /** @hidden */
  48791. _getTimeQueryResult(query: WebGLQuery): any;
  48792. /** @hidden */
  48793. _getTimeQueryAvailability(query: WebGLQuery): any;
  48794. }
  48795. }
  48796. module "babylonjs/Meshes/abstractMesh" {
  48797. interface AbstractMesh {
  48798. /**
  48799. * Backing filed
  48800. * @hidden
  48801. */
  48802. __occlusionDataStorage: _OcclusionDataStorage;
  48803. /**
  48804. * Access property
  48805. * @hidden
  48806. */
  48807. _occlusionDataStorage: _OcclusionDataStorage;
  48808. /**
  48809. * 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.
  48810. * The default value is -1 which means don't break the query and wait till the result
  48811. * @see http://doc.babylonjs.com/features/occlusionquery
  48812. */
  48813. occlusionRetryCount: number;
  48814. /**
  48815. * 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:
  48816. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48817. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48818. * * 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.
  48819. * @see http://doc.babylonjs.com/features/occlusionquery
  48820. */
  48821. occlusionType: number;
  48822. /**
  48823. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48824. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48825. * * 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.
  48826. * @see http://doc.babylonjs.com/features/occlusionquery
  48827. */
  48828. occlusionQueryAlgorithmType: number;
  48829. /**
  48830. * 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
  48831. * @see http://doc.babylonjs.com/features/occlusionquery
  48832. */
  48833. isOccluded: boolean;
  48834. /**
  48835. * Flag to check the progress status of the query
  48836. * @see http://doc.babylonjs.com/features/occlusionquery
  48837. */
  48838. isOcclusionQueryInProgress: boolean;
  48839. }
  48840. }
  48841. }
  48842. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48843. import { Nullable } from "babylonjs/types";
  48844. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48845. /** @hidden */
  48846. export var _forceTransformFeedbackToBundle: boolean;
  48847. module "babylonjs/Engines/engine" {
  48848. interface Engine {
  48849. /**
  48850. * Creates a webGL transform feedback object
  48851. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48852. * @returns the webGL transform feedback object
  48853. */
  48854. createTransformFeedback(): WebGLTransformFeedback;
  48855. /**
  48856. * Delete a webGL transform feedback object
  48857. * @param value defines the webGL transform feedback object to delete
  48858. */
  48859. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48860. /**
  48861. * Bind a webGL transform feedback object to the webgl context
  48862. * @param value defines the webGL transform feedback object to bind
  48863. */
  48864. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48865. /**
  48866. * Begins a transform feedback operation
  48867. * @param usePoints defines if points or triangles must be used
  48868. */
  48869. beginTransformFeedback(usePoints: boolean): void;
  48870. /**
  48871. * Ends a transform feedback operation
  48872. */
  48873. endTransformFeedback(): void;
  48874. /**
  48875. * Specify the varyings to use with transform feedback
  48876. * @param program defines the associated webGL program
  48877. * @param value defines the list of strings representing the varying names
  48878. */
  48879. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48880. /**
  48881. * Bind a webGL buffer for a transform feedback operation
  48882. * @param value defines the webGL buffer to bind
  48883. */
  48884. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48885. }
  48886. }
  48887. }
  48888. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48889. import { Scene } from "babylonjs/scene";
  48890. import { Engine } from "babylonjs/Engines/engine";
  48891. import { Texture } from "babylonjs/Materials/Textures/texture";
  48892. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48893. import "babylonjs/Engines/Extensions/engine.multiRender";
  48894. /**
  48895. * Creation options of the multi render target texture.
  48896. */
  48897. export interface IMultiRenderTargetOptions {
  48898. /**
  48899. * Define if the texture needs to create mip maps after render.
  48900. */
  48901. generateMipMaps?: boolean;
  48902. /**
  48903. * Define the types of all the draw buffers we want to create
  48904. */
  48905. types?: number[];
  48906. /**
  48907. * Define the sampling modes of all the draw buffers we want to create
  48908. */
  48909. samplingModes?: number[];
  48910. /**
  48911. * Define if a depth buffer is required
  48912. */
  48913. generateDepthBuffer?: boolean;
  48914. /**
  48915. * Define if a stencil buffer is required
  48916. */
  48917. generateStencilBuffer?: boolean;
  48918. /**
  48919. * Define if a depth texture is required instead of a depth buffer
  48920. */
  48921. generateDepthTexture?: boolean;
  48922. /**
  48923. * Define the number of desired draw buffers
  48924. */
  48925. textureCount?: number;
  48926. /**
  48927. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48928. */
  48929. doNotChangeAspectRatio?: boolean;
  48930. /**
  48931. * Define the default type of the buffers we are creating
  48932. */
  48933. defaultType?: number;
  48934. }
  48935. /**
  48936. * A multi render target, like a render target provides the ability to render to a texture.
  48937. * Unlike the render target, it can render to several draw buffers in one draw.
  48938. * This is specially interesting in deferred rendering or for any effects requiring more than
  48939. * just one color from a single pass.
  48940. */
  48941. export class MultiRenderTarget extends RenderTargetTexture {
  48942. private _internalTextures;
  48943. private _textures;
  48944. private _multiRenderTargetOptions;
  48945. /**
  48946. * Get if draw buffers are currently supported by the used hardware and browser.
  48947. */
  48948. get isSupported(): boolean;
  48949. /**
  48950. * Get the list of textures generated by the multi render target.
  48951. */
  48952. get textures(): Texture[];
  48953. /**
  48954. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48955. */
  48956. get depthTexture(): Texture;
  48957. /**
  48958. * Set the wrapping mode on U of all the textures we are rendering to.
  48959. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48960. */
  48961. set wrapU(wrap: number);
  48962. /**
  48963. * Set the wrapping mode on V of all the textures we are rendering to.
  48964. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48965. */
  48966. set wrapV(wrap: number);
  48967. /**
  48968. * Instantiate a new multi render target texture.
  48969. * A multi render target, like a render target provides the ability to render to a texture.
  48970. * Unlike the render target, it can render to several draw buffers in one draw.
  48971. * This is specially interesting in deferred rendering or for any effects requiring more than
  48972. * just one color from a single pass.
  48973. * @param name Define the name of the texture
  48974. * @param size Define the size of the buffers to render to
  48975. * @param count Define the number of target we are rendering into
  48976. * @param scene Define the scene the texture belongs to
  48977. * @param options Define the options used to create the multi render target
  48978. */
  48979. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48980. /** @hidden */
  48981. _rebuild(): void;
  48982. private _createInternalTextures;
  48983. private _createTextures;
  48984. /**
  48985. * Define the number of samples used if MSAA is enabled.
  48986. */
  48987. get samples(): number;
  48988. set samples(value: number);
  48989. /**
  48990. * Resize all the textures in the multi render target.
  48991. * Be carrefull as it will recreate all the data in the new texture.
  48992. * @param size Define the new size
  48993. */
  48994. resize(size: any): void;
  48995. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48996. /**
  48997. * Dispose the render targets and their associated resources
  48998. */
  48999. dispose(): void;
  49000. /**
  49001. * Release all the underlying texture used as draw buffers.
  49002. */
  49003. releaseInternalTextures(): void;
  49004. }
  49005. }
  49006. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49007. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49008. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49009. import { Nullable } from "babylonjs/types";
  49010. module "babylonjs/Engines/thinEngine" {
  49011. interface ThinEngine {
  49012. /**
  49013. * Unbind a list of render target textures from the webGL context
  49014. * This is used only when drawBuffer extension or webGL2 are active
  49015. * @param textures defines the render target textures to unbind
  49016. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49017. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49018. */
  49019. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49020. /**
  49021. * Create a multi render target texture
  49022. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49023. * @param size defines the size of the texture
  49024. * @param options defines the creation options
  49025. * @returns the cube texture as an InternalTexture
  49026. */
  49027. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49028. /**
  49029. * Update the sample count for a given multiple render target texture
  49030. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49031. * @param textures defines the textures to update
  49032. * @param samples defines the sample count to set
  49033. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49034. */
  49035. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49036. }
  49037. }
  49038. }
  49039. declare module "babylonjs/Engines/Extensions/engine.views" {
  49040. import { Camera } from "babylonjs/Cameras/camera";
  49041. import { Nullable } from "babylonjs/types";
  49042. /**
  49043. * Class used to define an additional view for the engine
  49044. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49045. */
  49046. export class EngineView {
  49047. /** Defines the canvas where to render the view */
  49048. target: HTMLCanvasElement;
  49049. /** Defines an optional camera used to render the view (will use active camera else) */
  49050. camera?: Camera;
  49051. }
  49052. module "babylonjs/Engines/engine" {
  49053. interface Engine {
  49054. /**
  49055. * Gets or sets the HTML element to use for attaching events
  49056. */
  49057. inputElement: Nullable<HTMLElement>;
  49058. /**
  49059. * Gets the current engine view
  49060. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49061. */
  49062. activeView: Nullable<EngineView>;
  49063. /** Gets or sets the list of views */
  49064. views: EngineView[];
  49065. /**
  49066. * Register a new child canvas
  49067. * @param canvas defines the canvas to register
  49068. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49069. * @returns the associated view
  49070. */
  49071. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49072. /**
  49073. * Remove a registered child canvas
  49074. * @param canvas defines the canvas to remove
  49075. * @returns the current engine
  49076. */
  49077. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49078. }
  49079. }
  49080. }
  49081. declare module "babylonjs/Engines/Extensions/index" {
  49082. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49083. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49084. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49085. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49086. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49087. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49088. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49089. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49090. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49091. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49092. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49093. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49094. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49095. export * from "babylonjs/Engines/Extensions/engine.views";
  49096. }
  49097. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49098. import { Nullable } from "babylonjs/types";
  49099. /**
  49100. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49101. */
  49102. export interface CubeMapInfo {
  49103. /**
  49104. * The pixel array for the front face.
  49105. * This is stored in format, left to right, up to down format.
  49106. */
  49107. front: Nullable<ArrayBufferView>;
  49108. /**
  49109. * The pixel array for the back face.
  49110. * This is stored in format, left to right, up to down format.
  49111. */
  49112. back: Nullable<ArrayBufferView>;
  49113. /**
  49114. * The pixel array for the left face.
  49115. * This is stored in format, left to right, up to down format.
  49116. */
  49117. left: Nullable<ArrayBufferView>;
  49118. /**
  49119. * The pixel array for the right face.
  49120. * This is stored in format, left to right, up to down format.
  49121. */
  49122. right: Nullable<ArrayBufferView>;
  49123. /**
  49124. * The pixel array for the up face.
  49125. * This is stored in format, left to right, up to down format.
  49126. */
  49127. up: Nullable<ArrayBufferView>;
  49128. /**
  49129. * The pixel array for the down face.
  49130. * This is stored in format, left to right, up to down format.
  49131. */
  49132. down: Nullable<ArrayBufferView>;
  49133. /**
  49134. * The size of the cubemap stored.
  49135. *
  49136. * Each faces will be size * size pixels.
  49137. */
  49138. size: number;
  49139. /**
  49140. * The format of the texture.
  49141. *
  49142. * RGBA, RGB.
  49143. */
  49144. format: number;
  49145. /**
  49146. * The type of the texture data.
  49147. *
  49148. * UNSIGNED_INT, FLOAT.
  49149. */
  49150. type: number;
  49151. /**
  49152. * Specifies whether the texture is in gamma space.
  49153. */
  49154. gammaSpace: boolean;
  49155. }
  49156. /**
  49157. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49158. */
  49159. export class PanoramaToCubeMapTools {
  49160. private static FACE_FRONT;
  49161. private static FACE_BACK;
  49162. private static FACE_RIGHT;
  49163. private static FACE_LEFT;
  49164. private static FACE_DOWN;
  49165. private static FACE_UP;
  49166. /**
  49167. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49168. *
  49169. * @param float32Array The source data.
  49170. * @param inputWidth The width of the input panorama.
  49171. * @param inputHeight The height of the input panorama.
  49172. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49173. * @return The cubemap data
  49174. */
  49175. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49176. private static CreateCubemapTexture;
  49177. private static CalcProjectionSpherical;
  49178. }
  49179. }
  49180. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49181. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49183. import { Nullable } from "babylonjs/types";
  49184. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49185. /**
  49186. * Helper class dealing with the extraction of spherical polynomial dataArray
  49187. * from a cube map.
  49188. */
  49189. export class CubeMapToSphericalPolynomialTools {
  49190. private static FileFaces;
  49191. /**
  49192. * Converts a texture to the according Spherical Polynomial data.
  49193. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49194. *
  49195. * @param texture The texture to extract the information from.
  49196. * @return The Spherical Polynomial data.
  49197. */
  49198. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49199. /**
  49200. * Converts a cubemap to the according Spherical Polynomial data.
  49201. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49202. *
  49203. * @param cubeInfo The Cube map to extract the information from.
  49204. * @return The Spherical Polynomial data.
  49205. */
  49206. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49207. }
  49208. }
  49209. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49210. import { Nullable } from "babylonjs/types";
  49211. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49212. module "babylonjs/Materials/Textures/baseTexture" {
  49213. interface BaseTexture {
  49214. /**
  49215. * Get the polynomial representation of the texture data.
  49216. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49217. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49218. */
  49219. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49220. }
  49221. }
  49222. }
  49223. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49224. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49225. /** @hidden */
  49226. export var rgbdEncodePixelShader: {
  49227. name: string;
  49228. shader: string;
  49229. };
  49230. }
  49231. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49232. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49233. /** @hidden */
  49234. export var rgbdDecodePixelShader: {
  49235. name: string;
  49236. shader: string;
  49237. };
  49238. }
  49239. declare module "babylonjs/Misc/environmentTextureTools" {
  49240. import { Nullable } from "babylonjs/types";
  49241. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49243. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49244. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49245. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49246. import "babylonjs/Shaders/rgbdEncode.fragment";
  49247. import "babylonjs/Shaders/rgbdDecode.fragment";
  49248. /**
  49249. * Raw texture data and descriptor sufficient for WebGL texture upload
  49250. */
  49251. export interface EnvironmentTextureInfo {
  49252. /**
  49253. * Version of the environment map
  49254. */
  49255. version: number;
  49256. /**
  49257. * Width of image
  49258. */
  49259. width: number;
  49260. /**
  49261. * Irradiance information stored in the file.
  49262. */
  49263. irradiance: any;
  49264. /**
  49265. * Specular information stored in the file.
  49266. */
  49267. specular: any;
  49268. }
  49269. /**
  49270. * Defines One Image in the file. It requires only the position in the file
  49271. * as well as the length.
  49272. */
  49273. interface BufferImageData {
  49274. /**
  49275. * Length of the image data.
  49276. */
  49277. length: number;
  49278. /**
  49279. * Position of the data from the null terminator delimiting the end of the JSON.
  49280. */
  49281. position: number;
  49282. }
  49283. /**
  49284. * Defines the specular data enclosed in the file.
  49285. * This corresponds to the version 1 of the data.
  49286. */
  49287. export interface EnvironmentTextureSpecularInfoV1 {
  49288. /**
  49289. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49290. */
  49291. specularDataPosition?: number;
  49292. /**
  49293. * This contains all the images data needed to reconstruct the cubemap.
  49294. */
  49295. mipmaps: Array<BufferImageData>;
  49296. /**
  49297. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49298. */
  49299. lodGenerationScale: number;
  49300. }
  49301. /**
  49302. * Sets of helpers addressing the serialization and deserialization of environment texture
  49303. * stored in a BabylonJS env file.
  49304. * Those files are usually stored as .env files.
  49305. */
  49306. export class EnvironmentTextureTools {
  49307. /**
  49308. * Magic number identifying the env file.
  49309. */
  49310. private static _MagicBytes;
  49311. /**
  49312. * Gets the environment info from an env file.
  49313. * @param data The array buffer containing the .env bytes.
  49314. * @returns the environment file info (the json header) if successfully parsed.
  49315. */
  49316. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49317. /**
  49318. * Creates an environment texture from a loaded cube texture.
  49319. * @param texture defines the cube texture to convert in env file
  49320. * @return a promise containing the environment data if succesfull.
  49321. */
  49322. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49323. /**
  49324. * Creates a JSON representation of the spherical data.
  49325. * @param texture defines the texture containing the polynomials
  49326. * @return the JSON representation of the spherical info
  49327. */
  49328. private static _CreateEnvTextureIrradiance;
  49329. /**
  49330. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49331. * @param data the image data
  49332. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49333. * @return the views described by info providing access to the underlying buffer
  49334. */
  49335. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49336. /**
  49337. * Uploads the texture info contained in the env file to the GPU.
  49338. * @param texture defines the internal texture to upload to
  49339. * @param data defines the data to load
  49340. * @param info defines the texture info retrieved through the GetEnvInfo method
  49341. * @returns a promise
  49342. */
  49343. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49344. private static _OnImageReadyAsync;
  49345. /**
  49346. * Uploads the levels of image data to the GPU.
  49347. * @param texture defines the internal texture to upload to
  49348. * @param imageData defines the array buffer views of image data [mipmap][face]
  49349. * @returns a promise
  49350. */
  49351. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49352. /**
  49353. * Uploads spherical polynomials information to the texture.
  49354. * @param texture defines the texture we are trying to upload the information to
  49355. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49356. */
  49357. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49358. /** @hidden */
  49359. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49360. }
  49361. }
  49362. declare module "babylonjs/Maths/math.vertexFormat" {
  49363. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49364. /**
  49365. * Contains position and normal vectors for a vertex
  49366. */
  49367. export class PositionNormalVertex {
  49368. /** the position of the vertex (defaut: 0,0,0) */
  49369. position: Vector3;
  49370. /** the normal of the vertex (defaut: 0,1,0) */
  49371. normal: Vector3;
  49372. /**
  49373. * Creates a PositionNormalVertex
  49374. * @param position the position of the vertex (defaut: 0,0,0)
  49375. * @param normal the normal of the vertex (defaut: 0,1,0)
  49376. */
  49377. constructor(
  49378. /** the position of the vertex (defaut: 0,0,0) */
  49379. position?: Vector3,
  49380. /** the normal of the vertex (defaut: 0,1,0) */
  49381. normal?: Vector3);
  49382. /**
  49383. * Clones the PositionNormalVertex
  49384. * @returns the cloned PositionNormalVertex
  49385. */
  49386. clone(): PositionNormalVertex;
  49387. }
  49388. /**
  49389. * Contains position, normal and uv vectors for a vertex
  49390. */
  49391. export class PositionNormalTextureVertex {
  49392. /** the position of the vertex (defaut: 0,0,0) */
  49393. position: Vector3;
  49394. /** the normal of the vertex (defaut: 0,1,0) */
  49395. normal: Vector3;
  49396. /** the uv of the vertex (default: 0,0) */
  49397. uv: Vector2;
  49398. /**
  49399. * Creates a PositionNormalTextureVertex
  49400. * @param position the position of the vertex (defaut: 0,0,0)
  49401. * @param normal the normal of the vertex (defaut: 0,1,0)
  49402. * @param uv the uv of the vertex (default: 0,0)
  49403. */
  49404. constructor(
  49405. /** the position of the vertex (defaut: 0,0,0) */
  49406. position?: Vector3,
  49407. /** the normal of the vertex (defaut: 0,1,0) */
  49408. normal?: Vector3,
  49409. /** the uv of the vertex (default: 0,0) */
  49410. uv?: Vector2);
  49411. /**
  49412. * Clones the PositionNormalTextureVertex
  49413. * @returns the cloned PositionNormalTextureVertex
  49414. */
  49415. clone(): PositionNormalTextureVertex;
  49416. }
  49417. }
  49418. declare module "babylonjs/Maths/math" {
  49419. export * from "babylonjs/Maths/math.axis";
  49420. export * from "babylonjs/Maths/math.color";
  49421. export * from "babylonjs/Maths/math.constants";
  49422. export * from "babylonjs/Maths/math.frustum";
  49423. export * from "babylonjs/Maths/math.path";
  49424. export * from "babylonjs/Maths/math.plane";
  49425. export * from "babylonjs/Maths/math.size";
  49426. export * from "babylonjs/Maths/math.vector";
  49427. export * from "babylonjs/Maths/math.vertexFormat";
  49428. export * from "babylonjs/Maths/math.viewport";
  49429. }
  49430. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49431. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49432. /** @hidden */
  49433. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49434. private _genericAttributeLocation;
  49435. private _varyingLocationCount;
  49436. private _varyingLocationMap;
  49437. private _replacements;
  49438. private _textureCount;
  49439. private _uniforms;
  49440. lineProcessor(line: string): string;
  49441. attributeProcessor(attribute: string): string;
  49442. varyingProcessor(varying: string, isFragment: boolean): string;
  49443. uniformProcessor(uniform: string): string;
  49444. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49445. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49446. }
  49447. }
  49448. declare module "babylonjs/Engines/nativeEngine" {
  49449. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49450. import { Engine } from "babylonjs/Engines/engine";
  49451. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49454. import { Effect } from "babylonjs/Materials/effect";
  49455. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49456. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49457. import { IColor4Like } from "babylonjs/Maths/math.like";
  49458. import { Scene } from "babylonjs/scene";
  49459. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49460. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49461. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49462. /**
  49463. * Container for accessors for natively-stored mesh data buffers.
  49464. */
  49465. class NativeDataBuffer extends DataBuffer {
  49466. /**
  49467. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49468. */
  49469. nativeIndexBuffer?: any;
  49470. /**
  49471. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49472. */
  49473. nativeVertexBuffer?: any;
  49474. }
  49475. /** @hidden */
  49476. class NativeTexture extends InternalTexture {
  49477. getInternalTexture(): InternalTexture;
  49478. getViewCount(): number;
  49479. }
  49480. /** @hidden */
  49481. export class NativeEngine extends Engine {
  49482. private readonly _native;
  49483. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49484. private readonly INVALID_HANDLE;
  49485. getHardwareScalingLevel(): number;
  49486. constructor();
  49487. /**
  49488. * Can be used to override the current requestAnimationFrame requester.
  49489. * @hidden
  49490. */
  49491. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49492. /**
  49493. * Override default engine behavior.
  49494. * @param color
  49495. * @param backBuffer
  49496. * @param depth
  49497. * @param stencil
  49498. */
  49499. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49500. /**
  49501. * Gets host document
  49502. * @returns the host document object
  49503. */
  49504. getHostDocument(): Nullable<Document>;
  49505. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49506. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49507. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49508. recordVertexArrayObject(vertexBuffers: {
  49509. [key: string]: VertexBuffer;
  49510. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49511. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49512. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49513. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49514. /**
  49515. * Draw a list of indexed primitives
  49516. * @param fillMode defines the primitive to use
  49517. * @param indexStart defines the starting index
  49518. * @param indexCount defines the number of index to draw
  49519. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49520. */
  49521. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49522. /**
  49523. * Draw a list of unindexed primitives
  49524. * @param fillMode defines the primitive to use
  49525. * @param verticesStart defines the index of first vertex to draw
  49526. * @param verticesCount defines the count of vertices to draw
  49527. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49528. */
  49529. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49530. createPipelineContext(): IPipelineContext;
  49531. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49532. /** @hidden */
  49533. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49534. /** @hidden */
  49535. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49536. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49537. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49538. protected _setProgram(program: WebGLProgram): void;
  49539. _releaseEffect(effect: Effect): void;
  49540. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49541. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49542. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49543. bindSamplers(effect: Effect): void;
  49544. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49545. getRenderWidth(useScreen?: boolean): number;
  49546. getRenderHeight(useScreen?: boolean): number;
  49547. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49548. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49549. /**
  49550. * Set the z offset to apply to current rendering
  49551. * @param value defines the offset to apply
  49552. */
  49553. setZOffset(value: number): void;
  49554. /**
  49555. * Gets the current value of the zOffset
  49556. * @returns the current zOffset state
  49557. */
  49558. getZOffset(): number;
  49559. /**
  49560. * Enable or disable depth buffering
  49561. * @param enable defines the state to set
  49562. */
  49563. setDepthBuffer(enable: boolean): void;
  49564. /**
  49565. * Gets a boolean indicating if depth writing is enabled
  49566. * @returns the current depth writing state
  49567. */
  49568. getDepthWrite(): boolean;
  49569. /**
  49570. * Enable or disable depth writing
  49571. * @param enable defines the state to set
  49572. */
  49573. setDepthWrite(enable: boolean): void;
  49574. /**
  49575. * Enable or disable color writing
  49576. * @param enable defines the state to set
  49577. */
  49578. setColorWrite(enable: boolean): void;
  49579. /**
  49580. * Gets a boolean indicating if color writing is enabled
  49581. * @returns the current color writing state
  49582. */
  49583. getColorWrite(): boolean;
  49584. /**
  49585. * Sets alpha constants used by some alpha blending modes
  49586. * @param r defines the red component
  49587. * @param g defines the green component
  49588. * @param b defines the blue component
  49589. * @param a defines the alpha component
  49590. */
  49591. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49592. /**
  49593. * Sets the current alpha mode
  49594. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49595. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49597. */
  49598. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49599. /**
  49600. * Gets the current alpha mode
  49601. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49602. * @returns the current alpha mode
  49603. */
  49604. getAlphaMode(): number;
  49605. setInt(uniform: WebGLUniformLocation, int: number): void;
  49606. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49607. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49608. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49609. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49610. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49611. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49612. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49613. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49614. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49615. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49616. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49617. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49618. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49619. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49620. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49621. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49622. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49623. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49624. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49625. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49626. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49627. wipeCaches(bruteForce?: boolean): void;
  49628. _createTexture(): WebGLTexture;
  49629. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49630. /**
  49631. * Usually called from Texture.ts.
  49632. * Passed information to create a WebGLTexture
  49633. * @param urlArg defines a value which contains one of the following:
  49634. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49635. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49636. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49637. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49638. * @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)
  49639. * @param scene needed for loading to the correct scene
  49640. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49641. * @param onLoad optional callback to be called upon successful completion
  49642. * @param onError optional callback to be called upon failure
  49643. * @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
  49644. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49645. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49646. * @param forcedExtension defines the extension to use to pick the right loader
  49647. * @param mimeType defines an optional mime type
  49648. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49649. */
  49650. 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;
  49651. /**
  49652. * Creates a cube texture
  49653. * @param rootUrl defines the url where the files to load is located
  49654. * @param scene defines the current scene
  49655. * @param files defines the list of files to load (1 per face)
  49656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49657. * @param onLoad defines an optional callback raised when the texture is loaded
  49658. * @param onError defines an optional callback raised if there is an issue to load the texture
  49659. * @param format defines the format of the data
  49660. * @param forcedExtension defines the extension to use to pick the right loader
  49661. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49662. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49663. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49664. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49665. * @returns the cube texture as an InternalTexture
  49666. */
  49667. 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;
  49668. private _getSamplingFilter;
  49669. private static _GetNativeTextureFormat;
  49670. createRenderTargetTexture(size: number | {
  49671. width: number;
  49672. height: number;
  49673. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49674. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49675. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49676. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49677. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49678. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49679. /**
  49680. * Updates a dynamic vertex buffer.
  49681. * @param vertexBuffer the vertex buffer to update
  49682. * @param data the data used to update the vertex buffer
  49683. * @param byteOffset the byte offset of the data (optional)
  49684. * @param byteLength the byte length of the data (optional)
  49685. */
  49686. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49687. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49688. private _updateAnisotropicLevel;
  49689. private _getAddressMode;
  49690. /** @hidden */
  49691. _bindTexture(channel: number, texture: InternalTexture): void;
  49692. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49693. releaseEffects(): void;
  49694. /** @hidden */
  49695. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49696. /** @hidden */
  49697. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49698. /** @hidden */
  49699. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49700. /** @hidden */
  49701. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49702. }
  49703. }
  49704. declare module "babylonjs/Engines/index" {
  49705. export * from "babylonjs/Engines/constants";
  49706. export * from "babylonjs/Engines/engineCapabilities";
  49707. export * from "babylonjs/Engines/instancingAttributeInfo";
  49708. export * from "babylonjs/Engines/thinEngine";
  49709. export * from "babylonjs/Engines/engine";
  49710. export * from "babylonjs/Engines/engineStore";
  49711. export * from "babylonjs/Engines/nullEngine";
  49712. export * from "babylonjs/Engines/Extensions/index";
  49713. export * from "babylonjs/Engines/IPipelineContext";
  49714. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49715. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49716. export * from "babylonjs/Engines/nativeEngine";
  49717. }
  49718. declare module "babylonjs/Events/clipboardEvents" {
  49719. /**
  49720. * Gather the list of clipboard event types as constants.
  49721. */
  49722. export class ClipboardEventTypes {
  49723. /**
  49724. * The clipboard event is fired when a copy command is active (pressed).
  49725. */
  49726. static readonly COPY: number;
  49727. /**
  49728. * The clipboard event is fired when a cut command is active (pressed).
  49729. */
  49730. static readonly CUT: number;
  49731. /**
  49732. * The clipboard event is fired when a paste command is active (pressed).
  49733. */
  49734. static readonly PASTE: number;
  49735. }
  49736. /**
  49737. * This class is used to store clipboard related info for the onClipboardObservable event.
  49738. */
  49739. export class ClipboardInfo {
  49740. /**
  49741. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49742. */
  49743. type: number;
  49744. /**
  49745. * Defines the related dom event
  49746. */
  49747. event: ClipboardEvent;
  49748. /**
  49749. *Creates an instance of ClipboardInfo.
  49750. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49751. * @param event Defines the related dom event
  49752. */
  49753. constructor(
  49754. /**
  49755. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49756. */
  49757. type: number,
  49758. /**
  49759. * Defines the related dom event
  49760. */
  49761. event: ClipboardEvent);
  49762. /**
  49763. * Get the clipboard event's type from the keycode.
  49764. * @param keyCode Defines the keyCode for the current keyboard event.
  49765. * @return {number}
  49766. */
  49767. static GetTypeFromCharacter(keyCode: number): number;
  49768. }
  49769. }
  49770. declare module "babylonjs/Events/index" {
  49771. export * from "babylonjs/Events/keyboardEvents";
  49772. export * from "babylonjs/Events/pointerEvents";
  49773. export * from "babylonjs/Events/clipboardEvents";
  49774. }
  49775. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49776. import { Scene } from "babylonjs/scene";
  49777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49778. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49779. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49780. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49781. /**
  49782. * Google Daydream controller
  49783. */
  49784. export class DaydreamController extends WebVRController {
  49785. /**
  49786. * Base Url for the controller model.
  49787. */
  49788. static MODEL_BASE_URL: string;
  49789. /**
  49790. * File name for the controller model.
  49791. */
  49792. static MODEL_FILENAME: string;
  49793. /**
  49794. * Gamepad Id prefix used to identify Daydream Controller.
  49795. */
  49796. static readonly GAMEPAD_ID_PREFIX: string;
  49797. /**
  49798. * Creates a new DaydreamController from a gamepad
  49799. * @param vrGamepad the gamepad that the controller should be created from
  49800. */
  49801. constructor(vrGamepad: any);
  49802. /**
  49803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49804. * @param scene scene in which to add meshes
  49805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49806. */
  49807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49808. /**
  49809. * Called once for each button that changed state since the last frame
  49810. * @param buttonIdx Which button index changed
  49811. * @param state New state of the button
  49812. * @param changes Which properties on the state changed since last frame
  49813. */
  49814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49815. }
  49816. }
  49817. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49818. import { Scene } from "babylonjs/scene";
  49819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49820. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49821. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49822. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49823. /**
  49824. * Gear VR Controller
  49825. */
  49826. export class GearVRController extends WebVRController {
  49827. /**
  49828. * Base Url for the controller model.
  49829. */
  49830. static MODEL_BASE_URL: string;
  49831. /**
  49832. * File name for the controller model.
  49833. */
  49834. static MODEL_FILENAME: string;
  49835. /**
  49836. * Gamepad Id prefix used to identify this controller.
  49837. */
  49838. static readonly GAMEPAD_ID_PREFIX: string;
  49839. private readonly _buttonIndexToObservableNameMap;
  49840. /**
  49841. * Creates a new GearVRController from a gamepad
  49842. * @param vrGamepad the gamepad that the controller should be created from
  49843. */
  49844. constructor(vrGamepad: any);
  49845. /**
  49846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49847. * @param scene scene in which to add meshes
  49848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49849. */
  49850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49851. /**
  49852. * Called once for each button that changed state since the last frame
  49853. * @param buttonIdx Which button index changed
  49854. * @param state New state of the button
  49855. * @param changes Which properties on the state changed since last frame
  49856. */
  49857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49858. }
  49859. }
  49860. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49861. import { Scene } from "babylonjs/scene";
  49862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49863. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49864. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49865. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49866. /**
  49867. * Generic Controller
  49868. */
  49869. export class GenericController extends WebVRController {
  49870. /**
  49871. * Base Url for the controller model.
  49872. */
  49873. static readonly MODEL_BASE_URL: string;
  49874. /**
  49875. * File name for the controller model.
  49876. */
  49877. static readonly MODEL_FILENAME: string;
  49878. /**
  49879. * Creates a new GenericController from a gamepad
  49880. * @param vrGamepad the gamepad that the controller should be created from
  49881. */
  49882. constructor(vrGamepad: any);
  49883. /**
  49884. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49885. * @param scene scene in which to add meshes
  49886. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49887. */
  49888. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49889. /**
  49890. * Called once for each button that changed state since the last frame
  49891. * @param buttonIdx Which button index changed
  49892. * @param state New state of the button
  49893. * @param changes Which properties on the state changed since last frame
  49894. */
  49895. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49896. }
  49897. }
  49898. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49899. import { Observable } from "babylonjs/Misc/observable";
  49900. import { Scene } from "babylonjs/scene";
  49901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49902. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49903. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49904. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49905. /**
  49906. * Oculus Touch Controller
  49907. */
  49908. export class OculusTouchController extends WebVRController {
  49909. /**
  49910. * Base Url for the controller model.
  49911. */
  49912. static MODEL_BASE_URL: string;
  49913. /**
  49914. * File name for the left controller model.
  49915. */
  49916. static MODEL_LEFT_FILENAME: string;
  49917. /**
  49918. * File name for the right controller model.
  49919. */
  49920. static MODEL_RIGHT_FILENAME: string;
  49921. /**
  49922. * Base Url for the Quest controller model.
  49923. */
  49924. static QUEST_MODEL_BASE_URL: string;
  49925. /**
  49926. * @hidden
  49927. * If the controllers are running on a device that needs the updated Quest controller models
  49928. */
  49929. static _IsQuest: boolean;
  49930. /**
  49931. * Fired when the secondary trigger on this controller is modified
  49932. */
  49933. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49934. /**
  49935. * Fired when the thumb rest on this controller is modified
  49936. */
  49937. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49938. /**
  49939. * Creates a new OculusTouchController from a gamepad
  49940. * @param vrGamepad the gamepad that the controller should be created from
  49941. */
  49942. constructor(vrGamepad: any);
  49943. /**
  49944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49945. * @param scene scene in which to add meshes
  49946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49947. */
  49948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49949. /**
  49950. * Fired when the A button on this controller is modified
  49951. */
  49952. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49953. /**
  49954. * Fired when the B button on this controller is modified
  49955. */
  49956. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49957. /**
  49958. * Fired when the X button on this controller is modified
  49959. */
  49960. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49961. /**
  49962. * Fired when the Y button on this controller is modified
  49963. */
  49964. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49965. /**
  49966. * Called once for each button that changed state since the last frame
  49967. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49968. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49969. * 2) secondary trigger (same)
  49970. * 3) A (right) X (left), touch, pressed = value
  49971. * 4) B / Y
  49972. * 5) thumb rest
  49973. * @param buttonIdx Which button index changed
  49974. * @param state New state of the button
  49975. * @param changes Which properties on the state changed since last frame
  49976. */
  49977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49978. }
  49979. }
  49980. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49981. import { Scene } from "babylonjs/scene";
  49982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49983. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49984. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49985. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49986. import { Observable } from "babylonjs/Misc/observable";
  49987. /**
  49988. * Vive Controller
  49989. */
  49990. export class ViveController extends WebVRController {
  49991. /**
  49992. * Base Url for the controller model.
  49993. */
  49994. static MODEL_BASE_URL: string;
  49995. /**
  49996. * File name for the controller model.
  49997. */
  49998. static MODEL_FILENAME: string;
  49999. /**
  50000. * Creates a new ViveController from a gamepad
  50001. * @param vrGamepad the gamepad that the controller should be created from
  50002. */
  50003. constructor(vrGamepad: any);
  50004. /**
  50005. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50006. * @param scene scene in which to add meshes
  50007. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50008. */
  50009. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50010. /**
  50011. * Fired when the left button on this controller is modified
  50012. */
  50013. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50014. /**
  50015. * Fired when the right button on this controller is modified
  50016. */
  50017. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50018. /**
  50019. * Fired when the menu button on this controller is modified
  50020. */
  50021. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50022. /**
  50023. * Called once for each button that changed state since the last frame
  50024. * Vive mapping:
  50025. * 0: touchpad
  50026. * 1: trigger
  50027. * 2: left AND right buttons
  50028. * 3: menu button
  50029. * @param buttonIdx Which button index changed
  50030. * @param state New state of the button
  50031. * @param changes Which properties on the state changed since last frame
  50032. */
  50033. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50034. }
  50035. }
  50036. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50037. import { Observable } from "babylonjs/Misc/observable";
  50038. import { Scene } from "babylonjs/scene";
  50039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50040. import { Ray } from "babylonjs/Culling/ray";
  50041. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50042. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50043. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50044. /**
  50045. * Defines the WindowsMotionController object that the state of the windows motion controller
  50046. */
  50047. export class WindowsMotionController extends WebVRController {
  50048. /**
  50049. * The base url used to load the left and right controller models
  50050. */
  50051. static MODEL_BASE_URL: string;
  50052. /**
  50053. * The name of the left controller model file
  50054. */
  50055. static MODEL_LEFT_FILENAME: string;
  50056. /**
  50057. * The name of the right controller model file
  50058. */
  50059. static MODEL_RIGHT_FILENAME: string;
  50060. /**
  50061. * The controller name prefix for this controller type
  50062. */
  50063. static readonly GAMEPAD_ID_PREFIX: string;
  50064. /**
  50065. * The controller id pattern for this controller type
  50066. */
  50067. private static readonly GAMEPAD_ID_PATTERN;
  50068. private _loadedMeshInfo;
  50069. protected readonly _mapping: {
  50070. buttons: string[];
  50071. buttonMeshNames: {
  50072. 'trigger': string;
  50073. 'menu': string;
  50074. 'grip': string;
  50075. 'thumbstick': string;
  50076. 'trackpad': string;
  50077. };
  50078. buttonObservableNames: {
  50079. 'trigger': string;
  50080. 'menu': string;
  50081. 'grip': string;
  50082. 'thumbstick': string;
  50083. 'trackpad': string;
  50084. };
  50085. axisMeshNames: string[];
  50086. pointingPoseMeshName: string;
  50087. };
  50088. /**
  50089. * Fired when the trackpad on this controller is clicked
  50090. */
  50091. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50092. /**
  50093. * Fired when the trackpad on this controller is modified
  50094. */
  50095. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50096. /**
  50097. * The current x and y values of this controller's trackpad
  50098. */
  50099. trackpad: StickValues;
  50100. /**
  50101. * Creates a new WindowsMotionController from a gamepad
  50102. * @param vrGamepad the gamepad that the controller should be created from
  50103. */
  50104. constructor(vrGamepad: any);
  50105. /**
  50106. * Fired when the trigger on this controller is modified
  50107. */
  50108. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50109. /**
  50110. * Fired when the menu button on this controller is modified
  50111. */
  50112. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50113. /**
  50114. * Fired when the grip button on this controller is modified
  50115. */
  50116. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50117. /**
  50118. * Fired when the thumbstick button on this controller is modified
  50119. */
  50120. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50121. /**
  50122. * Fired when the touchpad button on this controller is modified
  50123. */
  50124. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50125. /**
  50126. * Fired when the touchpad values on this controller are modified
  50127. */
  50128. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50129. protected _updateTrackpad(): void;
  50130. /**
  50131. * Called once per frame by the engine.
  50132. */
  50133. update(): void;
  50134. /**
  50135. * Called once for each button that changed state since the last frame
  50136. * @param buttonIdx Which button index changed
  50137. * @param state New state of the button
  50138. * @param changes Which properties on the state changed since last frame
  50139. */
  50140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50141. /**
  50142. * Moves the buttons on the controller mesh based on their current state
  50143. * @param buttonName the name of the button to move
  50144. * @param buttonValue the value of the button which determines the buttons new position
  50145. */
  50146. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50147. /**
  50148. * Moves the axis on the controller mesh based on its current state
  50149. * @param axis the index of the axis
  50150. * @param axisValue the value of the axis which determines the meshes new position
  50151. * @hidden
  50152. */
  50153. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50154. /**
  50155. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50156. * @param scene scene in which to add meshes
  50157. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50158. */
  50159. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50160. /**
  50161. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50162. * can be transformed by button presses and axes values, based on this._mapping.
  50163. *
  50164. * @param scene scene in which the meshes exist
  50165. * @param meshes list of meshes that make up the controller model to process
  50166. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50167. */
  50168. private processModel;
  50169. private createMeshInfo;
  50170. /**
  50171. * Gets the ray of the controller in the direction the controller is pointing
  50172. * @param length the length the resulting ray should be
  50173. * @returns a ray in the direction the controller is pointing
  50174. */
  50175. getForwardRay(length?: number): Ray;
  50176. /**
  50177. * Disposes of the controller
  50178. */
  50179. dispose(): void;
  50180. }
  50181. /**
  50182. * This class represents a new windows motion controller in XR.
  50183. */
  50184. export class XRWindowsMotionController extends WindowsMotionController {
  50185. /**
  50186. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50187. */
  50188. protected readonly _mapping: {
  50189. buttons: string[];
  50190. buttonMeshNames: {
  50191. 'trigger': string;
  50192. 'menu': string;
  50193. 'grip': string;
  50194. 'thumbstick': string;
  50195. 'trackpad': string;
  50196. };
  50197. buttonObservableNames: {
  50198. 'trigger': string;
  50199. 'menu': string;
  50200. 'grip': string;
  50201. 'thumbstick': string;
  50202. 'trackpad': string;
  50203. };
  50204. axisMeshNames: string[];
  50205. pointingPoseMeshName: string;
  50206. };
  50207. /**
  50208. * Construct a new XR-Based windows motion controller
  50209. *
  50210. * @param gamepadInfo the gamepad object from the browser
  50211. */
  50212. constructor(gamepadInfo: any);
  50213. /**
  50214. * holds the thumbstick values (X,Y)
  50215. */
  50216. thumbstickValues: StickValues;
  50217. /**
  50218. * Fired when the thumbstick on this controller is clicked
  50219. */
  50220. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50221. /**
  50222. * Fired when the thumbstick on this controller is modified
  50223. */
  50224. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50225. /**
  50226. * Fired when the touchpad button on this controller is modified
  50227. */
  50228. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50229. /**
  50230. * Fired when the touchpad values on this controller are modified
  50231. */
  50232. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50233. /**
  50234. * Fired when the thumbstick button on this controller is modified
  50235. * here to prevent breaking changes
  50236. */
  50237. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50238. /**
  50239. * updating the thumbstick(!) and not the trackpad.
  50240. * This is named this way due to the difference between WebVR and XR and to avoid
  50241. * changing the parent class.
  50242. */
  50243. protected _updateTrackpad(): void;
  50244. /**
  50245. * Disposes the class with joy
  50246. */
  50247. dispose(): void;
  50248. }
  50249. }
  50250. declare module "babylonjs/Gamepads/Controllers/index" {
  50251. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50252. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50253. export * from "babylonjs/Gamepads/Controllers/genericController";
  50254. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50255. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50256. export * from "babylonjs/Gamepads/Controllers/viveController";
  50257. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50258. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50259. }
  50260. declare module "babylonjs/Gamepads/index" {
  50261. export * from "babylonjs/Gamepads/Controllers/index";
  50262. export * from "babylonjs/Gamepads/gamepad";
  50263. export * from "babylonjs/Gamepads/gamepadManager";
  50264. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50265. export * from "babylonjs/Gamepads/xboxGamepad";
  50266. export * from "babylonjs/Gamepads/dualShockGamepad";
  50267. }
  50268. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50269. import { Scene } from "babylonjs/scene";
  50270. import { Vector4 } from "babylonjs/Maths/math.vector";
  50271. import { Color4 } from "babylonjs/Maths/math.color";
  50272. import { Mesh } from "babylonjs/Meshes/mesh";
  50273. import { Nullable } from "babylonjs/types";
  50274. /**
  50275. * Class containing static functions to help procedurally build meshes
  50276. */
  50277. export class PolyhedronBuilder {
  50278. /**
  50279. * Creates a polyhedron mesh
  50280. * * 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
  50281. * * The parameter `size` (positive float, default 1) sets the polygon size
  50282. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50283. * * 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`
  50284. * * 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
  50285. * * 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)`)
  50286. * * 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
  50287. * * 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
  50288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50291. * @param name defines the name of the mesh
  50292. * @param options defines the options used to create the mesh
  50293. * @param scene defines the hosting scene
  50294. * @returns the polyhedron mesh
  50295. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50296. */
  50297. static CreatePolyhedron(name: string, options: {
  50298. type?: number;
  50299. size?: number;
  50300. sizeX?: number;
  50301. sizeY?: number;
  50302. sizeZ?: number;
  50303. custom?: any;
  50304. faceUV?: Vector4[];
  50305. faceColors?: Color4[];
  50306. flat?: boolean;
  50307. updatable?: boolean;
  50308. sideOrientation?: number;
  50309. frontUVs?: Vector4;
  50310. backUVs?: Vector4;
  50311. }, scene?: Nullable<Scene>): Mesh;
  50312. }
  50313. }
  50314. declare module "babylonjs/Gizmos/scaleGizmo" {
  50315. import { Observable } from "babylonjs/Misc/observable";
  50316. import { Nullable } from "babylonjs/types";
  50317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50318. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50319. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50321. /**
  50322. * Gizmo that enables scaling a mesh along 3 axis
  50323. */
  50324. export class ScaleGizmo extends Gizmo {
  50325. /**
  50326. * Internal gizmo used for interactions on the x axis
  50327. */
  50328. xGizmo: AxisScaleGizmo;
  50329. /**
  50330. * Internal gizmo used for interactions on the y axis
  50331. */
  50332. yGizmo: AxisScaleGizmo;
  50333. /**
  50334. * Internal gizmo used for interactions on the z axis
  50335. */
  50336. zGizmo: AxisScaleGizmo;
  50337. /**
  50338. * Internal gizmo used to scale all axis equally
  50339. */
  50340. uniformScaleGizmo: AxisScaleGizmo;
  50341. private _meshAttached;
  50342. private _updateGizmoRotationToMatchAttachedMesh;
  50343. private _snapDistance;
  50344. private _scaleRatio;
  50345. private _uniformScalingMesh;
  50346. private _octahedron;
  50347. private _sensitivity;
  50348. /** Fires an event when any of it's sub gizmos are dragged */
  50349. onDragStartObservable: Observable<unknown>;
  50350. /** Fires an event when any of it's sub gizmos are released from dragging */
  50351. onDragEndObservable: Observable<unknown>;
  50352. get attachedMesh(): Nullable<AbstractMesh>;
  50353. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50354. /**
  50355. * Creates a ScaleGizmo
  50356. * @param gizmoLayer The utility layer the gizmo will be added to
  50357. */
  50358. constructor(gizmoLayer?: UtilityLayerRenderer);
  50359. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50360. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50361. /**
  50362. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50363. */
  50364. set snapDistance(value: number);
  50365. get snapDistance(): number;
  50366. /**
  50367. * Ratio for the scale of the gizmo (Default: 1)
  50368. */
  50369. set scaleRatio(value: number);
  50370. get scaleRatio(): number;
  50371. /**
  50372. * Sensitivity factor for dragging (Default: 1)
  50373. */
  50374. set sensitivity(value: number);
  50375. get sensitivity(): number;
  50376. /**
  50377. * Disposes of the gizmo
  50378. */
  50379. dispose(): void;
  50380. }
  50381. }
  50382. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50383. import { Observable } from "babylonjs/Misc/observable";
  50384. import { Nullable } from "babylonjs/types";
  50385. import { Vector3 } from "babylonjs/Maths/math.vector";
  50386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50387. import { Mesh } from "babylonjs/Meshes/mesh";
  50388. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50389. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50390. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50391. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50392. import { Color3 } from "babylonjs/Maths/math.color";
  50393. /**
  50394. * Single axis scale gizmo
  50395. */
  50396. export class AxisScaleGizmo extends Gizmo {
  50397. /**
  50398. * Drag behavior responsible for the gizmos dragging interactions
  50399. */
  50400. dragBehavior: PointerDragBehavior;
  50401. private _pointerObserver;
  50402. /**
  50403. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50404. */
  50405. snapDistance: number;
  50406. /**
  50407. * Event that fires each time the gizmo snaps to a new location.
  50408. * * snapDistance is the the change in distance
  50409. */
  50410. onSnapObservable: Observable<{
  50411. snapDistance: number;
  50412. }>;
  50413. /**
  50414. * If the scaling operation should be done on all axis (default: false)
  50415. */
  50416. uniformScaling: boolean;
  50417. /**
  50418. * Custom sensitivity value for the drag strength
  50419. */
  50420. sensitivity: number;
  50421. private _isEnabled;
  50422. private _parent;
  50423. private _arrow;
  50424. private _coloredMaterial;
  50425. private _hoverMaterial;
  50426. /**
  50427. * Creates an AxisScaleGizmo
  50428. * @param gizmoLayer The utility layer the gizmo will be added to
  50429. * @param dragAxis The axis which the gizmo will be able to scale on
  50430. * @param color The color of the gizmo
  50431. */
  50432. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50433. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50434. /**
  50435. * If the gizmo is enabled
  50436. */
  50437. set isEnabled(value: boolean);
  50438. get isEnabled(): boolean;
  50439. /**
  50440. * Disposes of the gizmo
  50441. */
  50442. dispose(): void;
  50443. /**
  50444. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50445. * @param mesh The mesh to replace the default mesh of the gizmo
  50446. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50447. */
  50448. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50449. }
  50450. }
  50451. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50452. import { Observable } from "babylonjs/Misc/observable";
  50453. import { Nullable } from "babylonjs/types";
  50454. import { Vector3 } from "babylonjs/Maths/math.vector";
  50455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50456. import { Mesh } from "babylonjs/Meshes/mesh";
  50457. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50458. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50459. import { Color3 } from "babylonjs/Maths/math.color";
  50460. import "babylonjs/Meshes/Builders/boxBuilder";
  50461. /**
  50462. * Bounding box gizmo
  50463. */
  50464. export class BoundingBoxGizmo extends Gizmo {
  50465. private _lineBoundingBox;
  50466. private _rotateSpheresParent;
  50467. private _scaleBoxesParent;
  50468. private _boundingDimensions;
  50469. private _renderObserver;
  50470. private _pointerObserver;
  50471. private _scaleDragSpeed;
  50472. private _tmpQuaternion;
  50473. private _tmpVector;
  50474. private _tmpRotationMatrix;
  50475. /**
  50476. * 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)
  50477. */
  50478. ignoreChildren: boolean;
  50479. /**
  50480. * 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)
  50481. */
  50482. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50483. /**
  50484. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50485. */
  50486. rotationSphereSize: number;
  50487. /**
  50488. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50489. */
  50490. scaleBoxSize: number;
  50491. /**
  50492. * 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)
  50493. */
  50494. fixedDragMeshScreenSize: boolean;
  50495. /**
  50496. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50497. */
  50498. fixedDragMeshScreenSizeDistanceFactor: number;
  50499. /**
  50500. * Fired when a rotation sphere or scale box is dragged
  50501. */
  50502. onDragStartObservable: Observable<{}>;
  50503. /**
  50504. * Fired when a scale box is dragged
  50505. */
  50506. onScaleBoxDragObservable: Observable<{}>;
  50507. /**
  50508. * Fired when a scale box drag is ended
  50509. */
  50510. onScaleBoxDragEndObservable: Observable<{}>;
  50511. /**
  50512. * Fired when a rotation sphere is dragged
  50513. */
  50514. onRotationSphereDragObservable: Observable<{}>;
  50515. /**
  50516. * Fired when a rotation sphere drag is ended
  50517. */
  50518. onRotationSphereDragEndObservable: Observable<{}>;
  50519. /**
  50520. * 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)
  50521. */
  50522. scalePivot: Nullable<Vector3>;
  50523. /**
  50524. * Mesh used as a pivot to rotate the attached mesh
  50525. */
  50526. private _anchorMesh;
  50527. private _existingMeshScale;
  50528. private _dragMesh;
  50529. private pointerDragBehavior;
  50530. private coloredMaterial;
  50531. private hoverColoredMaterial;
  50532. /**
  50533. * Sets the color of the bounding box gizmo
  50534. * @param color the color to set
  50535. */
  50536. setColor(color: Color3): void;
  50537. /**
  50538. * Creates an BoundingBoxGizmo
  50539. * @param gizmoLayer The utility layer the gizmo will be added to
  50540. * @param color The color of the gizmo
  50541. */
  50542. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50543. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50544. private _selectNode;
  50545. /**
  50546. * Updates the bounding box information for the Gizmo
  50547. */
  50548. updateBoundingBox(): void;
  50549. private _updateRotationSpheres;
  50550. private _updateScaleBoxes;
  50551. /**
  50552. * Enables rotation on the specified axis and disables rotation on the others
  50553. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50554. */
  50555. setEnabledRotationAxis(axis: string): void;
  50556. /**
  50557. * Enables/disables scaling
  50558. * @param enable if scaling should be enabled
  50559. */
  50560. setEnabledScaling(enable: boolean): void;
  50561. private _updateDummy;
  50562. /**
  50563. * Enables a pointer drag behavior on the bounding box of the gizmo
  50564. */
  50565. enableDragBehavior(): void;
  50566. /**
  50567. * Disposes of the gizmo
  50568. */
  50569. dispose(): void;
  50570. /**
  50571. * 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)
  50572. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50573. * @returns the bounding box mesh with the passed in mesh as a child
  50574. */
  50575. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50576. /**
  50577. * CustomMeshes are not supported by this gizmo
  50578. * @param mesh The mesh to replace the default mesh of the gizmo
  50579. */
  50580. setCustomMesh(mesh: Mesh): void;
  50581. }
  50582. }
  50583. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50584. import { Observable } from "babylonjs/Misc/observable";
  50585. import { Nullable } from "babylonjs/types";
  50586. import { Vector3 } from "babylonjs/Maths/math.vector";
  50587. import { Color3 } from "babylonjs/Maths/math.color";
  50588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50589. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50590. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50591. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50592. import "babylonjs/Meshes/Builders/linesBuilder";
  50593. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50594. /**
  50595. * Single plane rotation gizmo
  50596. */
  50597. export class PlaneRotationGizmo extends Gizmo {
  50598. /**
  50599. * Drag behavior responsible for the gizmos dragging interactions
  50600. */
  50601. dragBehavior: PointerDragBehavior;
  50602. private _pointerObserver;
  50603. /**
  50604. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50605. */
  50606. snapDistance: number;
  50607. /**
  50608. * Event that fires each time the gizmo snaps to a new location.
  50609. * * snapDistance is the the change in distance
  50610. */
  50611. onSnapObservable: Observable<{
  50612. snapDistance: number;
  50613. }>;
  50614. private _isEnabled;
  50615. private _parent;
  50616. /**
  50617. * Creates a PlaneRotationGizmo
  50618. * @param gizmoLayer The utility layer the gizmo will be added to
  50619. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50620. * @param color The color of the gizmo
  50621. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50622. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50623. */
  50624. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50625. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50626. /**
  50627. * If the gizmo is enabled
  50628. */
  50629. set isEnabled(value: boolean);
  50630. get isEnabled(): boolean;
  50631. /**
  50632. * Disposes of the gizmo
  50633. */
  50634. dispose(): void;
  50635. }
  50636. }
  50637. declare module "babylonjs/Gizmos/rotationGizmo" {
  50638. import { Observable } from "babylonjs/Misc/observable";
  50639. import { Nullable } from "babylonjs/types";
  50640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50641. import { Mesh } from "babylonjs/Meshes/mesh";
  50642. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50643. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50644. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50645. /**
  50646. * Gizmo that enables rotating a mesh along 3 axis
  50647. */
  50648. export class RotationGizmo extends Gizmo {
  50649. /**
  50650. * Internal gizmo used for interactions on the x axis
  50651. */
  50652. xGizmo: PlaneRotationGizmo;
  50653. /**
  50654. * Internal gizmo used for interactions on the y axis
  50655. */
  50656. yGizmo: PlaneRotationGizmo;
  50657. /**
  50658. * Internal gizmo used for interactions on the z axis
  50659. */
  50660. zGizmo: PlaneRotationGizmo;
  50661. /** Fires an event when any of it's sub gizmos are dragged */
  50662. onDragStartObservable: Observable<unknown>;
  50663. /** Fires an event when any of it's sub gizmos are released from dragging */
  50664. onDragEndObservable: Observable<unknown>;
  50665. private _meshAttached;
  50666. get attachedMesh(): Nullable<AbstractMesh>;
  50667. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50668. /**
  50669. * Creates a RotationGizmo
  50670. * @param gizmoLayer The utility layer the gizmo will be added to
  50671. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50672. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50673. */
  50674. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50675. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50676. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50677. /**
  50678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50679. */
  50680. set snapDistance(value: number);
  50681. get snapDistance(): number;
  50682. /**
  50683. * Ratio for the scale of the gizmo (Default: 1)
  50684. */
  50685. set scaleRatio(value: number);
  50686. get scaleRatio(): number;
  50687. /**
  50688. * Disposes of the gizmo
  50689. */
  50690. dispose(): void;
  50691. /**
  50692. * CustomMeshes are not supported by this gizmo
  50693. * @param mesh The mesh to replace the default mesh of the gizmo
  50694. */
  50695. setCustomMesh(mesh: Mesh): void;
  50696. }
  50697. }
  50698. declare module "babylonjs/Gizmos/gizmoManager" {
  50699. import { Observable } from "babylonjs/Misc/observable";
  50700. import { Nullable } from "babylonjs/types";
  50701. import { Scene, IDisposable } from "babylonjs/scene";
  50702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50703. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50704. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50705. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50706. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50707. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50708. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50709. /**
  50710. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50711. */
  50712. export class GizmoManager implements IDisposable {
  50713. private scene;
  50714. /**
  50715. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50716. */
  50717. gizmos: {
  50718. positionGizmo: Nullable<PositionGizmo>;
  50719. rotationGizmo: Nullable<RotationGizmo>;
  50720. scaleGizmo: Nullable<ScaleGizmo>;
  50721. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50722. };
  50723. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50724. clearGizmoOnEmptyPointerEvent: boolean;
  50725. /** Fires an event when the manager is attached to a mesh */
  50726. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50727. private _gizmosEnabled;
  50728. private _pointerObserver;
  50729. private _attachedMesh;
  50730. private _boundingBoxColor;
  50731. private _defaultUtilityLayer;
  50732. private _defaultKeepDepthUtilityLayer;
  50733. /**
  50734. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50735. */
  50736. boundingBoxDragBehavior: SixDofDragBehavior;
  50737. /**
  50738. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50739. */
  50740. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50741. /**
  50742. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50743. */
  50744. usePointerToAttachGizmos: boolean;
  50745. /**
  50746. * Utility layer that the bounding box gizmo belongs to
  50747. */
  50748. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50749. /**
  50750. * Utility layer that all gizmos besides bounding box belong to
  50751. */
  50752. get utilityLayer(): UtilityLayerRenderer;
  50753. /**
  50754. * Instatiates a gizmo manager
  50755. * @param scene the scene to overlay the gizmos on top of
  50756. */
  50757. constructor(scene: Scene);
  50758. /**
  50759. * Attaches a set of gizmos to the specified mesh
  50760. * @param mesh The mesh the gizmo's should be attached to
  50761. */
  50762. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50763. /**
  50764. * If the position gizmo is enabled
  50765. */
  50766. set positionGizmoEnabled(value: boolean);
  50767. get positionGizmoEnabled(): boolean;
  50768. /**
  50769. * If the rotation gizmo is enabled
  50770. */
  50771. set rotationGizmoEnabled(value: boolean);
  50772. get rotationGizmoEnabled(): boolean;
  50773. /**
  50774. * If the scale gizmo is enabled
  50775. */
  50776. set scaleGizmoEnabled(value: boolean);
  50777. get scaleGizmoEnabled(): boolean;
  50778. /**
  50779. * If the boundingBox gizmo is enabled
  50780. */
  50781. set boundingBoxGizmoEnabled(value: boolean);
  50782. get boundingBoxGizmoEnabled(): boolean;
  50783. /**
  50784. * Disposes of the gizmo manager
  50785. */
  50786. dispose(): void;
  50787. }
  50788. }
  50789. declare module "babylonjs/Lights/directionalLight" {
  50790. import { Camera } from "babylonjs/Cameras/camera";
  50791. import { Scene } from "babylonjs/scene";
  50792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50794. import { Light } from "babylonjs/Lights/light";
  50795. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50796. import { Effect } from "babylonjs/Materials/effect";
  50797. /**
  50798. * A directional light is defined by a direction (what a surprise!).
  50799. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50800. * 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.
  50801. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50802. */
  50803. export class DirectionalLight extends ShadowLight {
  50804. private _shadowFrustumSize;
  50805. /**
  50806. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50807. */
  50808. get shadowFrustumSize(): number;
  50809. /**
  50810. * Specifies a fix frustum size for the shadow generation.
  50811. */
  50812. set shadowFrustumSize(value: number);
  50813. private _shadowOrthoScale;
  50814. /**
  50815. * Gets the shadow projection scale against the optimal computed one.
  50816. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50817. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50818. */
  50819. get shadowOrthoScale(): number;
  50820. /**
  50821. * Sets the shadow projection scale against the optimal computed one.
  50822. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50823. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50824. */
  50825. set shadowOrthoScale(value: number);
  50826. /**
  50827. * Automatically compute the projection matrix to best fit (including all the casters)
  50828. * on each frame.
  50829. */
  50830. autoUpdateExtends: boolean;
  50831. /**
  50832. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50833. * on each frame. autoUpdateExtends must be set to true for this to work
  50834. */
  50835. autoCalcShadowZBounds: boolean;
  50836. private _orthoLeft;
  50837. private _orthoRight;
  50838. private _orthoTop;
  50839. private _orthoBottom;
  50840. /**
  50841. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50842. * The directional light is emitted from everywhere in the given direction.
  50843. * It can cast shadows.
  50844. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50845. * @param name The friendly name of the light
  50846. * @param direction The direction of the light
  50847. * @param scene The scene the light belongs to
  50848. */
  50849. constructor(name: string, direction: Vector3, scene: Scene);
  50850. /**
  50851. * Returns the string "DirectionalLight".
  50852. * @return The class name
  50853. */
  50854. getClassName(): string;
  50855. /**
  50856. * Returns the integer 1.
  50857. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50858. */
  50859. getTypeID(): number;
  50860. /**
  50861. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50862. * Returns the DirectionalLight Shadow projection matrix.
  50863. */
  50864. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50865. /**
  50866. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50867. * Returns the DirectionalLight Shadow projection matrix.
  50868. */
  50869. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50870. /**
  50871. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50872. * Returns the DirectionalLight Shadow projection matrix.
  50873. */
  50874. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50875. protected _buildUniformLayout(): void;
  50876. /**
  50877. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50878. * @param effect The effect to update
  50879. * @param lightIndex The index of the light in the effect to update
  50880. * @returns The directional light
  50881. */
  50882. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50883. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50884. /**
  50885. * Gets the minZ used for shadow according to both the scene and the light.
  50886. *
  50887. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50888. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50889. * @param activeCamera The camera we are returning the min for
  50890. * @returns the depth min z
  50891. */
  50892. getDepthMinZ(activeCamera: Camera): number;
  50893. /**
  50894. * Gets the maxZ used for shadow according to both the scene and the light.
  50895. *
  50896. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50897. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50898. * @param activeCamera The camera we are returning the max for
  50899. * @returns the depth max z
  50900. */
  50901. getDepthMaxZ(activeCamera: Camera): number;
  50902. /**
  50903. * Prepares the list of defines specific to the light type.
  50904. * @param defines the list of defines
  50905. * @param lightIndex defines the index of the light for the effect
  50906. */
  50907. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50908. }
  50909. }
  50910. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50911. import { Mesh } from "babylonjs/Meshes/mesh";
  50912. /**
  50913. * Class containing static functions to help procedurally build meshes
  50914. */
  50915. export class HemisphereBuilder {
  50916. /**
  50917. * Creates a hemisphere mesh
  50918. * @param name defines the name of the mesh
  50919. * @param options defines the options used to create the mesh
  50920. * @param scene defines the hosting scene
  50921. * @returns the hemisphere mesh
  50922. */
  50923. static CreateHemisphere(name: string, options: {
  50924. segments?: number;
  50925. diameter?: number;
  50926. sideOrientation?: number;
  50927. }, scene: any): Mesh;
  50928. }
  50929. }
  50930. declare module "babylonjs/Lights/spotLight" {
  50931. import { Nullable } from "babylonjs/types";
  50932. import { Scene } from "babylonjs/scene";
  50933. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50935. import { Effect } from "babylonjs/Materials/effect";
  50936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50937. import { Light } from "babylonjs/Lights/light";
  50938. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50939. /**
  50940. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50941. * These values define a cone of light starting from the position, emitting toward the direction.
  50942. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50943. * and the exponent defines the speed of the decay of the light with distance (reach).
  50944. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50945. */
  50946. export class SpotLight extends ShadowLight {
  50947. private _angle;
  50948. private _innerAngle;
  50949. private _cosHalfAngle;
  50950. private _lightAngleScale;
  50951. private _lightAngleOffset;
  50952. /**
  50953. * Gets the cone angle of the spot light in Radians.
  50954. */
  50955. get angle(): number;
  50956. /**
  50957. * Sets the cone angle of the spot light in Radians.
  50958. */
  50959. set angle(value: number);
  50960. /**
  50961. * Only used in gltf falloff mode, this defines the angle where
  50962. * the directional falloff will start before cutting at angle which could be seen
  50963. * as outer angle.
  50964. */
  50965. get innerAngle(): number;
  50966. /**
  50967. * Only used in gltf falloff mode, this defines the angle where
  50968. * the directional falloff will start before cutting at angle which could be seen
  50969. * as outer angle.
  50970. */
  50971. set innerAngle(value: number);
  50972. private _shadowAngleScale;
  50973. /**
  50974. * Allows scaling the angle of the light for shadow generation only.
  50975. */
  50976. get shadowAngleScale(): number;
  50977. /**
  50978. * Allows scaling the angle of the light for shadow generation only.
  50979. */
  50980. set shadowAngleScale(value: number);
  50981. /**
  50982. * The light decay speed with the distance from the emission spot.
  50983. */
  50984. exponent: number;
  50985. private _projectionTextureMatrix;
  50986. /**
  50987. * Allows reading the projecton texture
  50988. */
  50989. get projectionTextureMatrix(): Matrix;
  50990. protected _projectionTextureLightNear: number;
  50991. /**
  50992. * Gets the near clip of the Spotlight for texture projection.
  50993. */
  50994. get projectionTextureLightNear(): number;
  50995. /**
  50996. * Sets the near clip of the Spotlight for texture projection.
  50997. */
  50998. set projectionTextureLightNear(value: number);
  50999. protected _projectionTextureLightFar: number;
  51000. /**
  51001. * Gets the far clip of the Spotlight for texture projection.
  51002. */
  51003. get projectionTextureLightFar(): number;
  51004. /**
  51005. * Sets the far clip of the Spotlight for texture projection.
  51006. */
  51007. set projectionTextureLightFar(value: number);
  51008. protected _projectionTextureUpDirection: Vector3;
  51009. /**
  51010. * Gets the Up vector of the Spotlight for texture projection.
  51011. */
  51012. get projectionTextureUpDirection(): Vector3;
  51013. /**
  51014. * Sets the Up vector of the Spotlight for texture projection.
  51015. */
  51016. set projectionTextureUpDirection(value: Vector3);
  51017. private _projectionTexture;
  51018. /**
  51019. * Gets the projection texture of the light.
  51020. */
  51021. get projectionTexture(): Nullable<BaseTexture>;
  51022. /**
  51023. * Sets the projection texture of the light.
  51024. */
  51025. set projectionTexture(value: Nullable<BaseTexture>);
  51026. private _projectionTextureViewLightDirty;
  51027. private _projectionTextureProjectionLightDirty;
  51028. private _projectionTextureDirty;
  51029. private _projectionTextureViewTargetVector;
  51030. private _projectionTextureViewLightMatrix;
  51031. private _projectionTextureProjectionLightMatrix;
  51032. private _projectionTextureScalingMatrix;
  51033. /**
  51034. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51035. * It can cast shadows.
  51036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51037. * @param name The light friendly name
  51038. * @param position The position of the spot light in the scene
  51039. * @param direction The direction of the light in the scene
  51040. * @param angle The cone angle of the light in Radians
  51041. * @param exponent The light decay speed with the distance from the emission spot
  51042. * @param scene The scene the lights belongs to
  51043. */
  51044. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51045. /**
  51046. * Returns the string "SpotLight".
  51047. * @returns the class name
  51048. */
  51049. getClassName(): string;
  51050. /**
  51051. * Returns the integer 2.
  51052. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51053. */
  51054. getTypeID(): number;
  51055. /**
  51056. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51057. */
  51058. protected _setDirection(value: Vector3): void;
  51059. /**
  51060. * Overrides the position setter to recompute the projection texture view light Matrix.
  51061. */
  51062. protected _setPosition(value: Vector3): void;
  51063. /**
  51064. * 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.
  51065. * Returns the SpotLight.
  51066. */
  51067. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51068. protected _computeProjectionTextureViewLightMatrix(): void;
  51069. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51070. /**
  51071. * Main function for light texture projection matrix computing.
  51072. */
  51073. protected _computeProjectionTextureMatrix(): void;
  51074. protected _buildUniformLayout(): void;
  51075. private _computeAngleValues;
  51076. /**
  51077. * Sets the passed Effect "effect" with the Light textures.
  51078. * @param effect The effect to update
  51079. * @param lightIndex The index of the light in the effect to update
  51080. * @returns The light
  51081. */
  51082. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51083. /**
  51084. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51085. * @param effect The effect to update
  51086. * @param lightIndex The index of the light in the effect to update
  51087. * @returns The spot light
  51088. */
  51089. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51090. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51091. /**
  51092. * Disposes the light and the associated resources.
  51093. */
  51094. dispose(): void;
  51095. /**
  51096. * Prepares the list of defines specific to the light type.
  51097. * @param defines the list of defines
  51098. * @param lightIndex defines the index of the light for the effect
  51099. */
  51100. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51101. }
  51102. }
  51103. declare module "babylonjs/Gizmos/lightGizmo" {
  51104. import { Nullable } from "babylonjs/types";
  51105. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51106. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51107. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51108. import { Light } from "babylonjs/Lights/light";
  51109. /**
  51110. * Gizmo that enables viewing a light
  51111. */
  51112. export class LightGizmo extends Gizmo {
  51113. private _lightMesh;
  51114. private _material;
  51115. private _cachedPosition;
  51116. private _cachedForward;
  51117. private _attachedMeshParent;
  51118. /**
  51119. * Creates a LightGizmo
  51120. * @param gizmoLayer The utility layer the gizmo will be added to
  51121. */
  51122. constructor(gizmoLayer?: UtilityLayerRenderer);
  51123. private _light;
  51124. /**
  51125. * The light that the gizmo is attached to
  51126. */
  51127. set light(light: Nullable<Light>);
  51128. get light(): Nullable<Light>;
  51129. /**
  51130. * Gets the material used to render the light gizmo
  51131. */
  51132. get material(): StandardMaterial;
  51133. /**
  51134. * @hidden
  51135. * Updates the gizmo to match the attached mesh's position/rotation
  51136. */
  51137. protected _update(): void;
  51138. private static _Scale;
  51139. /**
  51140. * Creates the lines for a light mesh
  51141. */
  51142. private static _CreateLightLines;
  51143. /**
  51144. * Disposes of the light gizmo
  51145. */
  51146. dispose(): void;
  51147. private static _CreateHemisphericLightMesh;
  51148. private static _CreatePointLightMesh;
  51149. private static _CreateSpotLightMesh;
  51150. private static _CreateDirectionalLightMesh;
  51151. }
  51152. }
  51153. declare module "babylonjs/Gizmos/index" {
  51154. export * from "babylonjs/Gizmos/axisDragGizmo";
  51155. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51156. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51157. export * from "babylonjs/Gizmos/gizmo";
  51158. export * from "babylonjs/Gizmos/gizmoManager";
  51159. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51160. export * from "babylonjs/Gizmos/positionGizmo";
  51161. export * from "babylonjs/Gizmos/rotationGizmo";
  51162. export * from "babylonjs/Gizmos/scaleGizmo";
  51163. export * from "babylonjs/Gizmos/lightGizmo";
  51164. export * from "babylonjs/Gizmos/planeDragGizmo";
  51165. }
  51166. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51167. /** @hidden */
  51168. export var backgroundFragmentDeclaration: {
  51169. name: string;
  51170. shader: string;
  51171. };
  51172. }
  51173. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51174. /** @hidden */
  51175. export var backgroundUboDeclaration: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module "babylonjs/Shaders/background.fragment" {
  51181. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51182. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51183. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51184. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51185. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51186. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51187. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51188. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51189. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51190. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51191. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51192. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51193. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51194. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51195. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51196. /** @hidden */
  51197. export var backgroundPixelShader: {
  51198. name: string;
  51199. shader: string;
  51200. };
  51201. }
  51202. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51203. /** @hidden */
  51204. export var backgroundVertexDeclaration: {
  51205. name: string;
  51206. shader: string;
  51207. };
  51208. }
  51209. declare module "babylonjs/Shaders/background.vertex" {
  51210. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51211. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51212. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51213. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51214. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51215. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51216. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51217. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51218. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51219. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51220. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51221. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51222. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51223. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51224. /** @hidden */
  51225. export var backgroundVertexShader: {
  51226. name: string;
  51227. shader: string;
  51228. };
  51229. }
  51230. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51231. import { Nullable, int, float } from "babylonjs/types";
  51232. import { Scene } from "babylonjs/scene";
  51233. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51236. import { Mesh } from "babylonjs/Meshes/mesh";
  51237. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51238. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51239. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51241. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51242. import { Color3 } from "babylonjs/Maths/math.color";
  51243. import "babylonjs/Shaders/background.fragment";
  51244. import "babylonjs/Shaders/background.vertex";
  51245. /**
  51246. * Background material used to create an efficient environement around your scene.
  51247. */
  51248. export class BackgroundMaterial extends PushMaterial {
  51249. /**
  51250. * Standard reflectance value at parallel view angle.
  51251. */
  51252. static StandardReflectance0: number;
  51253. /**
  51254. * Standard reflectance value at grazing angle.
  51255. */
  51256. static StandardReflectance90: number;
  51257. protected _primaryColor: Color3;
  51258. /**
  51259. * Key light Color (multiply against the environement texture)
  51260. */
  51261. primaryColor: Color3;
  51262. protected __perceptualColor: Nullable<Color3>;
  51263. /**
  51264. * Experimental Internal Use Only.
  51265. *
  51266. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51267. * This acts as a helper to set the primary color to a more "human friendly" value.
  51268. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51269. * output color as close as possible from the chosen value.
  51270. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51271. * part of lighting setup.)
  51272. */
  51273. get _perceptualColor(): Nullable<Color3>;
  51274. set _perceptualColor(value: Nullable<Color3>);
  51275. protected _primaryColorShadowLevel: float;
  51276. /**
  51277. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51278. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51279. */
  51280. get primaryColorShadowLevel(): float;
  51281. set primaryColorShadowLevel(value: float);
  51282. protected _primaryColorHighlightLevel: float;
  51283. /**
  51284. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51285. * The primary color is used at the level chosen to define what the white area would look.
  51286. */
  51287. get primaryColorHighlightLevel(): float;
  51288. set primaryColorHighlightLevel(value: float);
  51289. protected _reflectionTexture: Nullable<BaseTexture>;
  51290. /**
  51291. * Reflection Texture used in the material.
  51292. * Should be author in a specific way for the best result (refer to the documentation).
  51293. */
  51294. reflectionTexture: Nullable<BaseTexture>;
  51295. protected _reflectionBlur: float;
  51296. /**
  51297. * Reflection Texture level of blur.
  51298. *
  51299. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51300. * texture twice.
  51301. */
  51302. reflectionBlur: float;
  51303. protected _diffuseTexture: Nullable<BaseTexture>;
  51304. /**
  51305. * Diffuse Texture used in the material.
  51306. * Should be author in a specific way for the best result (refer to the documentation).
  51307. */
  51308. diffuseTexture: Nullable<BaseTexture>;
  51309. protected _shadowLights: Nullable<IShadowLight[]>;
  51310. /**
  51311. * Specify the list of lights casting shadow on the material.
  51312. * All scene shadow lights will be included if null.
  51313. */
  51314. shadowLights: Nullable<IShadowLight[]>;
  51315. protected _shadowLevel: float;
  51316. /**
  51317. * Helps adjusting the shadow to a softer level if required.
  51318. * 0 means black shadows and 1 means no shadows.
  51319. */
  51320. shadowLevel: float;
  51321. protected _sceneCenter: Vector3;
  51322. /**
  51323. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51324. * It is usually zero but might be interesting to modify according to your setup.
  51325. */
  51326. sceneCenter: Vector3;
  51327. protected _opacityFresnel: boolean;
  51328. /**
  51329. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51330. * This helps ensuring a nice transition when the camera goes under the ground.
  51331. */
  51332. opacityFresnel: boolean;
  51333. protected _reflectionFresnel: boolean;
  51334. /**
  51335. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51336. * This helps adding a mirror texture on the ground.
  51337. */
  51338. reflectionFresnel: boolean;
  51339. protected _reflectionFalloffDistance: number;
  51340. /**
  51341. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51342. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51343. */
  51344. reflectionFalloffDistance: number;
  51345. protected _reflectionAmount: number;
  51346. /**
  51347. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51348. */
  51349. reflectionAmount: number;
  51350. protected _reflectionReflectance0: number;
  51351. /**
  51352. * This specifies the weight of the reflection at grazing angle.
  51353. */
  51354. reflectionReflectance0: number;
  51355. protected _reflectionReflectance90: number;
  51356. /**
  51357. * This specifies the weight of the reflection at a perpendicular point of view.
  51358. */
  51359. reflectionReflectance90: number;
  51360. /**
  51361. * Sets the reflection reflectance fresnel values according to the default standard
  51362. * empirically know to work well :-)
  51363. */
  51364. set reflectionStandardFresnelWeight(value: number);
  51365. protected _useRGBColor: boolean;
  51366. /**
  51367. * Helps to directly use the maps channels instead of their level.
  51368. */
  51369. useRGBColor: boolean;
  51370. protected _enableNoise: boolean;
  51371. /**
  51372. * This helps reducing the banding effect that could occur on the background.
  51373. */
  51374. enableNoise: boolean;
  51375. /**
  51376. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51377. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51378. * Recommended to be keep at 1.0 except for special cases.
  51379. */
  51380. get fovMultiplier(): number;
  51381. set fovMultiplier(value: number);
  51382. private _fovMultiplier;
  51383. /**
  51384. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51385. */
  51386. useEquirectangularFOV: boolean;
  51387. private _maxSimultaneousLights;
  51388. /**
  51389. * Number of Simultaneous lights allowed on the material.
  51390. */
  51391. maxSimultaneousLights: int;
  51392. /**
  51393. * Default configuration related to image processing available in the Background Material.
  51394. */
  51395. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51396. /**
  51397. * Keep track of the image processing observer to allow dispose and replace.
  51398. */
  51399. private _imageProcessingObserver;
  51400. /**
  51401. * Attaches a new image processing configuration to the PBR Material.
  51402. * @param configuration (if null the scene configuration will be use)
  51403. */
  51404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51405. /**
  51406. * Gets the image processing configuration used either in this material.
  51407. */
  51408. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51409. /**
  51410. * Sets the Default image processing configuration used either in the this material.
  51411. *
  51412. * If sets to null, the scene one is in use.
  51413. */
  51414. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51415. /**
  51416. * Gets wether the color curves effect is enabled.
  51417. */
  51418. get cameraColorCurvesEnabled(): boolean;
  51419. /**
  51420. * Sets wether the color curves effect is enabled.
  51421. */
  51422. set cameraColorCurvesEnabled(value: boolean);
  51423. /**
  51424. * Gets wether the color grading effect is enabled.
  51425. */
  51426. get cameraColorGradingEnabled(): boolean;
  51427. /**
  51428. * Gets wether the color grading effect is enabled.
  51429. */
  51430. set cameraColorGradingEnabled(value: boolean);
  51431. /**
  51432. * Gets wether tonemapping is enabled or not.
  51433. */
  51434. get cameraToneMappingEnabled(): boolean;
  51435. /**
  51436. * Sets wether tonemapping is enabled or not
  51437. */
  51438. set cameraToneMappingEnabled(value: boolean);
  51439. /**
  51440. * The camera exposure used on this material.
  51441. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51442. * This corresponds to a photographic exposure.
  51443. */
  51444. get cameraExposure(): float;
  51445. /**
  51446. * The camera exposure used on this material.
  51447. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51448. * This corresponds to a photographic exposure.
  51449. */
  51450. set cameraExposure(value: float);
  51451. /**
  51452. * Gets The camera contrast used on this material.
  51453. */
  51454. get cameraContrast(): float;
  51455. /**
  51456. * Sets The camera contrast used on this material.
  51457. */
  51458. set cameraContrast(value: float);
  51459. /**
  51460. * Gets the Color Grading 2D Lookup Texture.
  51461. */
  51462. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51463. /**
  51464. * Sets the Color Grading 2D Lookup Texture.
  51465. */
  51466. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51467. /**
  51468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51470. * 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;
  51471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51472. */
  51473. get cameraColorCurves(): Nullable<ColorCurves>;
  51474. /**
  51475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51477. * 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;
  51478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51479. */
  51480. set cameraColorCurves(value: Nullable<ColorCurves>);
  51481. /**
  51482. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51483. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51484. */
  51485. switchToBGR: boolean;
  51486. private _renderTargets;
  51487. private _reflectionControls;
  51488. private _white;
  51489. private _primaryShadowColor;
  51490. private _primaryHighlightColor;
  51491. /**
  51492. * Instantiates a Background Material in the given scene
  51493. * @param name The friendly name of the material
  51494. * @param scene The scene to add the material to
  51495. */
  51496. constructor(name: string, scene: Scene);
  51497. /**
  51498. * Gets a boolean indicating that current material needs to register RTT
  51499. */
  51500. get hasRenderTargetTextures(): boolean;
  51501. /**
  51502. * The entire material has been created in order to prevent overdraw.
  51503. * @returns false
  51504. */
  51505. needAlphaTesting(): boolean;
  51506. /**
  51507. * The entire material has been created in order to prevent overdraw.
  51508. * @returns true if blending is enable
  51509. */
  51510. needAlphaBlending(): boolean;
  51511. /**
  51512. * Checks wether the material is ready to be rendered for a given mesh.
  51513. * @param mesh The mesh to render
  51514. * @param subMesh The submesh to check against
  51515. * @param useInstances Specify wether or not the material is used with instances
  51516. * @returns true if all the dependencies are ready (Textures, Effects...)
  51517. */
  51518. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51519. /**
  51520. * Compute the primary color according to the chosen perceptual color.
  51521. */
  51522. private _computePrimaryColorFromPerceptualColor;
  51523. /**
  51524. * Compute the highlights and shadow colors according to their chosen levels.
  51525. */
  51526. private _computePrimaryColors;
  51527. /**
  51528. * Build the uniform buffer used in the material.
  51529. */
  51530. buildUniformLayout(): void;
  51531. /**
  51532. * Unbind the material.
  51533. */
  51534. unbind(): void;
  51535. /**
  51536. * Bind only the world matrix to the material.
  51537. * @param world The world matrix to bind.
  51538. */
  51539. bindOnlyWorldMatrix(world: Matrix): void;
  51540. /**
  51541. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51542. * @param world The world matrix to bind.
  51543. * @param subMesh The submesh to bind for.
  51544. */
  51545. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51546. /**
  51547. * Checks to see if a texture is used in the material.
  51548. * @param texture - Base texture to use.
  51549. * @returns - Boolean specifying if a texture is used in the material.
  51550. */
  51551. hasTexture(texture: BaseTexture): boolean;
  51552. /**
  51553. * Dispose the material.
  51554. * @param forceDisposeEffect Force disposal of the associated effect.
  51555. * @param forceDisposeTextures Force disposal of the associated textures.
  51556. */
  51557. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51558. /**
  51559. * Clones the material.
  51560. * @param name The cloned name.
  51561. * @returns The cloned material.
  51562. */
  51563. clone(name: string): BackgroundMaterial;
  51564. /**
  51565. * Serializes the current material to its JSON representation.
  51566. * @returns The JSON representation.
  51567. */
  51568. serialize(): any;
  51569. /**
  51570. * Gets the class name of the material
  51571. * @returns "BackgroundMaterial"
  51572. */
  51573. getClassName(): string;
  51574. /**
  51575. * Parse a JSON input to create back a background material.
  51576. * @param source The JSON data to parse
  51577. * @param scene The scene to create the parsed material in
  51578. * @param rootUrl The root url of the assets the material depends upon
  51579. * @returns the instantiated BackgroundMaterial.
  51580. */
  51581. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51582. }
  51583. }
  51584. declare module "babylonjs/Helpers/environmentHelper" {
  51585. import { Observable } from "babylonjs/Misc/observable";
  51586. import { Nullable } from "babylonjs/types";
  51587. import { Scene } from "babylonjs/scene";
  51588. import { Vector3 } from "babylonjs/Maths/math.vector";
  51589. import { Color3 } from "babylonjs/Maths/math.color";
  51590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51591. import { Mesh } from "babylonjs/Meshes/mesh";
  51592. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51593. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51594. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51595. import "babylonjs/Meshes/Builders/planeBuilder";
  51596. import "babylonjs/Meshes/Builders/boxBuilder";
  51597. /**
  51598. * Represents the different options available during the creation of
  51599. * a Environment helper.
  51600. *
  51601. * This can control the default ground, skybox and image processing setup of your scene.
  51602. */
  51603. export interface IEnvironmentHelperOptions {
  51604. /**
  51605. * Specifies whether or not to create a ground.
  51606. * True by default.
  51607. */
  51608. createGround: boolean;
  51609. /**
  51610. * Specifies the ground size.
  51611. * 15 by default.
  51612. */
  51613. groundSize: number;
  51614. /**
  51615. * The texture used on the ground for the main color.
  51616. * Comes from the BabylonJS CDN by default.
  51617. *
  51618. * Remarks: Can be either a texture or a url.
  51619. */
  51620. groundTexture: string | BaseTexture;
  51621. /**
  51622. * The color mixed in the ground texture by default.
  51623. * BabylonJS clearColor by default.
  51624. */
  51625. groundColor: Color3;
  51626. /**
  51627. * Specifies the ground opacity.
  51628. * 1 by default.
  51629. */
  51630. groundOpacity: number;
  51631. /**
  51632. * Enables the ground to receive shadows.
  51633. * True by default.
  51634. */
  51635. enableGroundShadow: boolean;
  51636. /**
  51637. * Helps preventing the shadow to be fully black on the ground.
  51638. * 0.5 by default.
  51639. */
  51640. groundShadowLevel: number;
  51641. /**
  51642. * Creates a mirror texture attach to the ground.
  51643. * false by default.
  51644. */
  51645. enableGroundMirror: boolean;
  51646. /**
  51647. * Specifies the ground mirror size ratio.
  51648. * 0.3 by default as the default kernel is 64.
  51649. */
  51650. groundMirrorSizeRatio: number;
  51651. /**
  51652. * Specifies the ground mirror blur kernel size.
  51653. * 64 by default.
  51654. */
  51655. groundMirrorBlurKernel: number;
  51656. /**
  51657. * Specifies the ground mirror visibility amount.
  51658. * 1 by default
  51659. */
  51660. groundMirrorAmount: number;
  51661. /**
  51662. * Specifies the ground mirror reflectance weight.
  51663. * This uses the standard weight of the background material to setup the fresnel effect
  51664. * of the mirror.
  51665. * 1 by default.
  51666. */
  51667. groundMirrorFresnelWeight: number;
  51668. /**
  51669. * Specifies the ground mirror Falloff distance.
  51670. * This can helps reducing the size of the reflection.
  51671. * 0 by Default.
  51672. */
  51673. groundMirrorFallOffDistance: number;
  51674. /**
  51675. * Specifies the ground mirror texture type.
  51676. * Unsigned Int by Default.
  51677. */
  51678. groundMirrorTextureType: number;
  51679. /**
  51680. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51681. * the shown objects.
  51682. */
  51683. groundYBias: number;
  51684. /**
  51685. * Specifies whether or not to create a skybox.
  51686. * True by default.
  51687. */
  51688. createSkybox: boolean;
  51689. /**
  51690. * Specifies the skybox size.
  51691. * 20 by default.
  51692. */
  51693. skyboxSize: number;
  51694. /**
  51695. * The texture used on the skybox for the main color.
  51696. * Comes from the BabylonJS CDN by default.
  51697. *
  51698. * Remarks: Can be either a texture or a url.
  51699. */
  51700. skyboxTexture: string | BaseTexture;
  51701. /**
  51702. * The color mixed in the skybox texture by default.
  51703. * BabylonJS clearColor by default.
  51704. */
  51705. skyboxColor: Color3;
  51706. /**
  51707. * The background rotation around the Y axis of the scene.
  51708. * This helps aligning the key lights of your scene with the background.
  51709. * 0 by default.
  51710. */
  51711. backgroundYRotation: number;
  51712. /**
  51713. * Compute automatically the size of the elements to best fit with the scene.
  51714. */
  51715. sizeAuto: boolean;
  51716. /**
  51717. * Default position of the rootMesh if autoSize is not true.
  51718. */
  51719. rootPosition: Vector3;
  51720. /**
  51721. * Sets up the image processing in the scene.
  51722. * true by default.
  51723. */
  51724. setupImageProcessing: boolean;
  51725. /**
  51726. * The texture used as your environment texture in the scene.
  51727. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51728. *
  51729. * Remarks: Can be either a texture or a url.
  51730. */
  51731. environmentTexture: string | BaseTexture;
  51732. /**
  51733. * The value of the exposure to apply to the scene.
  51734. * 0.6 by default if setupImageProcessing is true.
  51735. */
  51736. cameraExposure: number;
  51737. /**
  51738. * The value of the contrast to apply to the scene.
  51739. * 1.6 by default if setupImageProcessing is true.
  51740. */
  51741. cameraContrast: number;
  51742. /**
  51743. * Specifies whether or not tonemapping should be enabled in the scene.
  51744. * true by default if setupImageProcessing is true.
  51745. */
  51746. toneMappingEnabled: boolean;
  51747. }
  51748. /**
  51749. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51750. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51751. * It also helps with the default setup of your imageProcessing configuration.
  51752. */
  51753. export class EnvironmentHelper {
  51754. /**
  51755. * Default ground texture URL.
  51756. */
  51757. private static _groundTextureCDNUrl;
  51758. /**
  51759. * Default skybox texture URL.
  51760. */
  51761. private static _skyboxTextureCDNUrl;
  51762. /**
  51763. * Default environment texture URL.
  51764. */
  51765. private static _environmentTextureCDNUrl;
  51766. /**
  51767. * Creates the default options for the helper.
  51768. */
  51769. private static _getDefaultOptions;
  51770. private _rootMesh;
  51771. /**
  51772. * Gets the root mesh created by the helper.
  51773. */
  51774. get rootMesh(): Mesh;
  51775. private _skybox;
  51776. /**
  51777. * Gets the skybox created by the helper.
  51778. */
  51779. get skybox(): Nullable<Mesh>;
  51780. private _skyboxTexture;
  51781. /**
  51782. * Gets the skybox texture created by the helper.
  51783. */
  51784. get skyboxTexture(): Nullable<BaseTexture>;
  51785. private _skyboxMaterial;
  51786. /**
  51787. * Gets the skybox material created by the helper.
  51788. */
  51789. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51790. private _ground;
  51791. /**
  51792. * Gets the ground mesh created by the helper.
  51793. */
  51794. get ground(): Nullable<Mesh>;
  51795. private _groundTexture;
  51796. /**
  51797. * Gets the ground texture created by the helper.
  51798. */
  51799. get groundTexture(): Nullable<BaseTexture>;
  51800. private _groundMirror;
  51801. /**
  51802. * Gets the ground mirror created by the helper.
  51803. */
  51804. get groundMirror(): Nullable<MirrorTexture>;
  51805. /**
  51806. * Gets the ground mirror render list to helps pushing the meshes
  51807. * you wish in the ground reflection.
  51808. */
  51809. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51810. private _groundMaterial;
  51811. /**
  51812. * Gets the ground material created by the helper.
  51813. */
  51814. get groundMaterial(): Nullable<BackgroundMaterial>;
  51815. /**
  51816. * Stores the creation options.
  51817. */
  51818. private readonly _scene;
  51819. private _options;
  51820. /**
  51821. * This observable will be notified with any error during the creation of the environment,
  51822. * mainly texture creation errors.
  51823. */
  51824. onErrorObservable: Observable<{
  51825. message?: string;
  51826. exception?: any;
  51827. }>;
  51828. /**
  51829. * constructor
  51830. * @param options Defines the options we want to customize the helper
  51831. * @param scene The scene to add the material to
  51832. */
  51833. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51834. /**
  51835. * Updates the background according to the new options
  51836. * @param options
  51837. */
  51838. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51839. /**
  51840. * Sets the primary color of all the available elements.
  51841. * @param color the main color to affect to the ground and the background
  51842. */
  51843. setMainColor(color: Color3): void;
  51844. /**
  51845. * Setup the image processing according to the specified options.
  51846. */
  51847. private _setupImageProcessing;
  51848. /**
  51849. * Setup the environment texture according to the specified options.
  51850. */
  51851. private _setupEnvironmentTexture;
  51852. /**
  51853. * Setup the background according to the specified options.
  51854. */
  51855. private _setupBackground;
  51856. /**
  51857. * Get the scene sizes according to the setup.
  51858. */
  51859. private _getSceneSize;
  51860. /**
  51861. * Setup the ground according to the specified options.
  51862. */
  51863. private _setupGround;
  51864. /**
  51865. * Setup the ground material according to the specified options.
  51866. */
  51867. private _setupGroundMaterial;
  51868. /**
  51869. * Setup the ground diffuse texture according to the specified options.
  51870. */
  51871. private _setupGroundDiffuseTexture;
  51872. /**
  51873. * Setup the ground mirror texture according to the specified options.
  51874. */
  51875. private _setupGroundMirrorTexture;
  51876. /**
  51877. * Setup the ground to receive the mirror texture.
  51878. */
  51879. private _setupMirrorInGroundMaterial;
  51880. /**
  51881. * Setup the skybox according to the specified options.
  51882. */
  51883. private _setupSkybox;
  51884. /**
  51885. * Setup the skybox material according to the specified options.
  51886. */
  51887. private _setupSkyboxMaterial;
  51888. /**
  51889. * Setup the skybox reflection texture according to the specified options.
  51890. */
  51891. private _setupSkyboxReflectionTexture;
  51892. private _errorHandler;
  51893. /**
  51894. * Dispose all the elements created by the Helper.
  51895. */
  51896. dispose(): void;
  51897. }
  51898. }
  51899. declare module "babylonjs/Helpers/photoDome" {
  51900. import { Observable } from "babylonjs/Misc/observable";
  51901. import { Nullable } from "babylonjs/types";
  51902. import { Scene } from "babylonjs/scene";
  51903. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51904. import { Mesh } from "babylonjs/Meshes/mesh";
  51905. import { Texture } from "babylonjs/Materials/Textures/texture";
  51906. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51907. import "babylonjs/Meshes/Builders/sphereBuilder";
  51908. /**
  51909. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51910. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51911. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51912. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51913. */
  51914. export class PhotoDome extends TransformNode {
  51915. /**
  51916. * Define the image as a Monoscopic panoramic 360 image.
  51917. */
  51918. static readonly MODE_MONOSCOPIC: number;
  51919. /**
  51920. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51921. */
  51922. static readonly MODE_TOPBOTTOM: number;
  51923. /**
  51924. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51925. */
  51926. static readonly MODE_SIDEBYSIDE: number;
  51927. private _useDirectMapping;
  51928. /**
  51929. * The texture being displayed on the sphere
  51930. */
  51931. protected _photoTexture: Texture;
  51932. /**
  51933. * Gets or sets the texture being displayed on the sphere
  51934. */
  51935. get photoTexture(): Texture;
  51936. set photoTexture(value: Texture);
  51937. /**
  51938. * Observable raised when an error occured while loading the 360 image
  51939. */
  51940. onLoadErrorObservable: Observable<string>;
  51941. /**
  51942. * The skybox material
  51943. */
  51944. protected _material: BackgroundMaterial;
  51945. /**
  51946. * The surface used for the skybox
  51947. */
  51948. protected _mesh: Mesh;
  51949. /**
  51950. * Gets the mesh used for the skybox.
  51951. */
  51952. get mesh(): Mesh;
  51953. /**
  51954. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51955. * Also see the options.resolution property.
  51956. */
  51957. get fovMultiplier(): number;
  51958. set fovMultiplier(value: number);
  51959. private _imageMode;
  51960. /**
  51961. * Gets or set the current video mode for the video. It can be:
  51962. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51963. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51964. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51965. */
  51966. get imageMode(): number;
  51967. set imageMode(value: number);
  51968. /**
  51969. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51970. * @param name Element's name, child elements will append suffixes for their own names.
  51971. * @param urlsOfPhoto defines the url of the photo to display
  51972. * @param options defines an object containing optional or exposed sub element properties
  51973. * @param onError defines a callback called when an error occured while loading the texture
  51974. */
  51975. constructor(name: string, urlOfPhoto: string, options: {
  51976. resolution?: number;
  51977. size?: number;
  51978. useDirectMapping?: boolean;
  51979. faceForward?: boolean;
  51980. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51981. private _onBeforeCameraRenderObserver;
  51982. private _changeImageMode;
  51983. /**
  51984. * Releases resources associated with this node.
  51985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51987. */
  51988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51989. }
  51990. }
  51991. declare module "babylonjs/Misc/rgbdTextureTools" {
  51992. import "babylonjs/Shaders/rgbdDecode.fragment";
  51993. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51994. import { Texture } from "babylonjs/Materials/Textures/texture";
  51995. /**
  51996. * Class used to host RGBD texture specific utilities
  51997. */
  51998. export class RGBDTextureTools {
  51999. /**
  52000. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52001. * @param texture the texture to expand.
  52002. */
  52003. static ExpandRGBDTexture(texture: Texture): void;
  52004. }
  52005. }
  52006. declare module "babylonjs/Misc/brdfTextureTools" {
  52007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52008. import { Scene } from "babylonjs/scene";
  52009. /**
  52010. * Class used to host texture specific utilities
  52011. */
  52012. export class BRDFTextureTools {
  52013. private static _instanceNumber;
  52014. /**
  52015. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52016. * @param scene defines the hosting scene
  52017. * @returns the environment BRDF texture
  52018. */
  52019. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52020. private static _environmentBRDFBase64Texture;
  52021. }
  52022. }
  52023. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52024. import { Nullable } from "babylonjs/types";
  52025. import { Color3 } from "babylonjs/Maths/math.color";
  52026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52027. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52028. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52029. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52030. import { Engine } from "babylonjs/Engines/engine";
  52031. import { Scene } from "babylonjs/scene";
  52032. /**
  52033. * @hidden
  52034. */
  52035. export interface IMaterialClearCoatDefines {
  52036. CLEARCOAT: boolean;
  52037. CLEARCOAT_DEFAULTIOR: boolean;
  52038. CLEARCOAT_TEXTURE: boolean;
  52039. CLEARCOAT_TEXTUREDIRECTUV: number;
  52040. CLEARCOAT_BUMP: boolean;
  52041. CLEARCOAT_BUMPDIRECTUV: number;
  52042. CLEARCOAT_TINT: boolean;
  52043. CLEARCOAT_TINT_TEXTURE: boolean;
  52044. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52045. /** @hidden */
  52046. _areTexturesDirty: boolean;
  52047. }
  52048. /**
  52049. * Define the code related to the clear coat parameters of the pbr material.
  52050. */
  52051. export class PBRClearCoatConfiguration {
  52052. /**
  52053. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52054. * The default fits with a polyurethane material.
  52055. */
  52056. private static readonly _DefaultIndexOfRefraction;
  52057. private _isEnabled;
  52058. /**
  52059. * Defines if the clear coat is enabled in the material.
  52060. */
  52061. isEnabled: boolean;
  52062. /**
  52063. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52064. */
  52065. intensity: number;
  52066. /**
  52067. * Defines the clear coat layer roughness.
  52068. */
  52069. roughness: number;
  52070. private _indexOfRefraction;
  52071. /**
  52072. * Defines the index of refraction of the clear coat.
  52073. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52074. * The default fits with a polyurethane material.
  52075. * Changing the default value is more performance intensive.
  52076. */
  52077. indexOfRefraction: number;
  52078. private _texture;
  52079. /**
  52080. * Stores the clear coat values in a texture.
  52081. */
  52082. texture: Nullable<BaseTexture>;
  52083. private _bumpTexture;
  52084. /**
  52085. * Define the clear coat specific bump texture.
  52086. */
  52087. bumpTexture: Nullable<BaseTexture>;
  52088. private _isTintEnabled;
  52089. /**
  52090. * Defines if the clear coat tint is enabled in the material.
  52091. */
  52092. isTintEnabled: boolean;
  52093. /**
  52094. * Defines the clear coat tint of the material.
  52095. * This is only use if tint is enabled
  52096. */
  52097. tintColor: Color3;
  52098. /**
  52099. * Defines the distance at which the tint color should be found in the
  52100. * clear coat media.
  52101. * This is only use if tint is enabled
  52102. */
  52103. tintColorAtDistance: number;
  52104. /**
  52105. * Defines the clear coat layer thickness.
  52106. * This is only use if tint is enabled
  52107. */
  52108. tintThickness: number;
  52109. private _tintTexture;
  52110. /**
  52111. * Stores the clear tint values in a texture.
  52112. * rgb is tint
  52113. * a is a thickness factor
  52114. */
  52115. tintTexture: Nullable<BaseTexture>;
  52116. /** @hidden */
  52117. private _internalMarkAllSubMeshesAsTexturesDirty;
  52118. /** @hidden */
  52119. _markAllSubMeshesAsTexturesDirty(): void;
  52120. /**
  52121. * Instantiate a new istance of clear coat configuration.
  52122. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52123. */
  52124. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52125. /**
  52126. * Gets wehter the submesh is ready to be used or not.
  52127. * @param defines the list of "defines" to update.
  52128. * @param scene defines the scene the material belongs to.
  52129. * @param engine defines the engine the material belongs to.
  52130. * @param disableBumpMap defines wether the material disables bump or not.
  52131. * @returns - boolean indicating that the submesh is ready or not.
  52132. */
  52133. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52134. /**
  52135. * Checks to see if a texture is used in the material.
  52136. * @param defines the list of "defines" to update.
  52137. * @param scene defines the scene to the material belongs to.
  52138. */
  52139. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52140. /**
  52141. * Binds the material data.
  52142. * @param uniformBuffer defines the Uniform buffer to fill in.
  52143. * @param scene defines the scene the material belongs to.
  52144. * @param engine defines the engine the material belongs to.
  52145. * @param disableBumpMap defines wether the material disables bump or not.
  52146. * @param isFrozen defines wether the material is frozen or not.
  52147. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52148. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52149. */
  52150. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52151. /**
  52152. * Checks to see if a texture is used in the material.
  52153. * @param texture - Base texture to use.
  52154. * @returns - Boolean specifying if a texture is used in the material.
  52155. */
  52156. hasTexture(texture: BaseTexture): boolean;
  52157. /**
  52158. * Returns an array of the actively used textures.
  52159. * @param activeTextures Array of BaseTextures
  52160. */
  52161. getActiveTextures(activeTextures: BaseTexture[]): void;
  52162. /**
  52163. * Returns the animatable textures.
  52164. * @param animatables Array of animatable textures.
  52165. */
  52166. getAnimatables(animatables: IAnimatable[]): void;
  52167. /**
  52168. * Disposes the resources of the material.
  52169. * @param forceDisposeTextures - Forces the disposal of all textures.
  52170. */
  52171. dispose(forceDisposeTextures?: boolean): void;
  52172. /**
  52173. * Get the current class name of the texture useful for serialization or dynamic coding.
  52174. * @returns "PBRClearCoatConfiguration"
  52175. */
  52176. getClassName(): string;
  52177. /**
  52178. * Add fallbacks to the effect fallbacks list.
  52179. * @param defines defines the Base texture to use.
  52180. * @param fallbacks defines the current fallback list.
  52181. * @param currentRank defines the current fallback rank.
  52182. * @returns the new fallback rank.
  52183. */
  52184. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52185. /**
  52186. * Add the required uniforms to the current list.
  52187. * @param uniforms defines the current uniform list.
  52188. */
  52189. static AddUniforms(uniforms: string[]): void;
  52190. /**
  52191. * Add the required samplers to the current list.
  52192. * @param samplers defines the current sampler list.
  52193. */
  52194. static AddSamplers(samplers: string[]): void;
  52195. /**
  52196. * Add the required uniforms to the current buffer.
  52197. * @param uniformBuffer defines the current uniform buffer.
  52198. */
  52199. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52200. /**
  52201. * Makes a duplicate of the current configuration into another one.
  52202. * @param clearCoatConfiguration define the config where to copy the info
  52203. */
  52204. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52205. /**
  52206. * Serializes this clear coat configuration.
  52207. * @returns - An object with the serialized config.
  52208. */
  52209. serialize(): any;
  52210. /**
  52211. * Parses a anisotropy Configuration from a serialized object.
  52212. * @param source - Serialized object.
  52213. * @param scene Defines the scene we are parsing for
  52214. * @param rootUrl Defines the rootUrl to load from
  52215. */
  52216. parse(source: any, scene: Scene, rootUrl: string): void;
  52217. }
  52218. }
  52219. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52220. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52222. import { Vector2 } from "babylonjs/Maths/math.vector";
  52223. import { Scene } from "babylonjs/scene";
  52224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52225. import { Nullable } from "babylonjs/types";
  52226. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52227. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52228. /**
  52229. * @hidden
  52230. */
  52231. export interface IMaterialAnisotropicDefines {
  52232. ANISOTROPIC: boolean;
  52233. ANISOTROPIC_TEXTURE: boolean;
  52234. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52235. MAINUV1: boolean;
  52236. _areTexturesDirty: boolean;
  52237. _needUVs: boolean;
  52238. }
  52239. /**
  52240. * Define the code related to the anisotropic parameters of the pbr material.
  52241. */
  52242. export class PBRAnisotropicConfiguration {
  52243. private _isEnabled;
  52244. /**
  52245. * Defines if the anisotropy is enabled in the material.
  52246. */
  52247. isEnabled: boolean;
  52248. /**
  52249. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52250. */
  52251. intensity: number;
  52252. /**
  52253. * Defines if the effect is along the tangents, bitangents or in between.
  52254. * By default, the effect is "strectching" the highlights along the tangents.
  52255. */
  52256. direction: Vector2;
  52257. private _texture;
  52258. /**
  52259. * Stores the anisotropy values in a texture.
  52260. * rg is direction (like normal from -1 to 1)
  52261. * b is a intensity
  52262. */
  52263. texture: Nullable<BaseTexture>;
  52264. /** @hidden */
  52265. private _internalMarkAllSubMeshesAsTexturesDirty;
  52266. /** @hidden */
  52267. _markAllSubMeshesAsTexturesDirty(): void;
  52268. /**
  52269. * Instantiate a new istance of anisotropy configuration.
  52270. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52271. */
  52272. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52273. /**
  52274. * Specifies that the submesh is ready to be used.
  52275. * @param defines the list of "defines" to update.
  52276. * @param scene defines the scene the material belongs to.
  52277. * @returns - boolean indicating that the submesh is ready or not.
  52278. */
  52279. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52280. /**
  52281. * Checks to see if a texture is used in the material.
  52282. * @param defines the list of "defines" to update.
  52283. * @param mesh the mesh we are preparing the defines for.
  52284. * @param scene defines the scene the material belongs to.
  52285. */
  52286. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52287. /**
  52288. * Binds the material data.
  52289. * @param uniformBuffer defines the Uniform buffer to fill in.
  52290. * @param scene defines the scene the material belongs to.
  52291. * @param isFrozen defines wether the material is frozen or not.
  52292. */
  52293. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52294. /**
  52295. * Checks to see if a texture is used in the material.
  52296. * @param texture - Base texture to use.
  52297. * @returns - Boolean specifying if a texture is used in the material.
  52298. */
  52299. hasTexture(texture: BaseTexture): boolean;
  52300. /**
  52301. * Returns an array of the actively used textures.
  52302. * @param activeTextures Array of BaseTextures
  52303. */
  52304. getActiveTextures(activeTextures: BaseTexture[]): void;
  52305. /**
  52306. * Returns the animatable textures.
  52307. * @param animatables Array of animatable textures.
  52308. */
  52309. getAnimatables(animatables: IAnimatable[]): void;
  52310. /**
  52311. * Disposes the resources of the material.
  52312. * @param forceDisposeTextures - Forces the disposal of all textures.
  52313. */
  52314. dispose(forceDisposeTextures?: boolean): void;
  52315. /**
  52316. * Get the current class name of the texture useful for serialization or dynamic coding.
  52317. * @returns "PBRAnisotropicConfiguration"
  52318. */
  52319. getClassName(): string;
  52320. /**
  52321. * Add fallbacks to the effect fallbacks list.
  52322. * @param defines defines the Base texture to use.
  52323. * @param fallbacks defines the current fallback list.
  52324. * @param currentRank defines the current fallback rank.
  52325. * @returns the new fallback rank.
  52326. */
  52327. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52328. /**
  52329. * Add the required uniforms to the current list.
  52330. * @param uniforms defines the current uniform list.
  52331. */
  52332. static AddUniforms(uniforms: string[]): void;
  52333. /**
  52334. * Add the required uniforms to the current buffer.
  52335. * @param uniformBuffer defines the current uniform buffer.
  52336. */
  52337. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52338. /**
  52339. * Add the required samplers to the current list.
  52340. * @param samplers defines the current sampler list.
  52341. */
  52342. static AddSamplers(samplers: string[]): void;
  52343. /**
  52344. * Makes a duplicate of the current configuration into another one.
  52345. * @param anisotropicConfiguration define the config where to copy the info
  52346. */
  52347. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52348. /**
  52349. * Serializes this anisotropy configuration.
  52350. * @returns - An object with the serialized config.
  52351. */
  52352. serialize(): any;
  52353. /**
  52354. * Parses a anisotropy Configuration from a serialized object.
  52355. * @param source - Serialized object.
  52356. * @param scene Defines the scene we are parsing for
  52357. * @param rootUrl Defines the rootUrl to load from
  52358. */
  52359. parse(source: any, scene: Scene, rootUrl: string): void;
  52360. }
  52361. }
  52362. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52363. import { Scene } from "babylonjs/scene";
  52364. /**
  52365. * @hidden
  52366. */
  52367. export interface IMaterialBRDFDefines {
  52368. BRDF_V_HEIGHT_CORRELATED: boolean;
  52369. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52370. SPHERICAL_HARMONICS: boolean;
  52371. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52372. /** @hidden */
  52373. _areMiscDirty: boolean;
  52374. }
  52375. /**
  52376. * Define the code related to the BRDF parameters of the pbr material.
  52377. */
  52378. export class PBRBRDFConfiguration {
  52379. /**
  52380. * Default value used for the energy conservation.
  52381. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52382. */
  52383. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52384. /**
  52385. * Default value used for the Smith Visibility Height Correlated mode.
  52386. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52387. */
  52388. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52389. /**
  52390. * Default value used for the IBL diffuse part.
  52391. * This can help switching back to the polynomials mode globally which is a tiny bit
  52392. * less GPU intensive at the drawback of a lower quality.
  52393. */
  52394. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52395. /**
  52396. * Default value used for activating energy conservation for the specular workflow.
  52397. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52398. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52399. */
  52400. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52401. private _useEnergyConservation;
  52402. /**
  52403. * Defines if the material uses energy conservation.
  52404. */
  52405. useEnergyConservation: boolean;
  52406. private _useSmithVisibilityHeightCorrelated;
  52407. /**
  52408. * LEGACY Mode set to false
  52409. * Defines if the material uses height smith correlated visibility term.
  52410. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52411. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52412. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52413. * Not relying on height correlated will also disable energy conservation.
  52414. */
  52415. useSmithVisibilityHeightCorrelated: boolean;
  52416. private _useSphericalHarmonics;
  52417. /**
  52418. * LEGACY Mode set to false
  52419. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52420. * diffuse part of the IBL.
  52421. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52422. * to the ground truth.
  52423. */
  52424. useSphericalHarmonics: boolean;
  52425. private _useSpecularGlossinessInputEnergyConservation;
  52426. /**
  52427. * Defines if the material uses energy conservation, when the specular workflow is active.
  52428. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52429. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52430. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52431. */
  52432. useSpecularGlossinessInputEnergyConservation: boolean;
  52433. /** @hidden */
  52434. private _internalMarkAllSubMeshesAsMiscDirty;
  52435. /** @hidden */
  52436. _markAllSubMeshesAsMiscDirty(): void;
  52437. /**
  52438. * Instantiate a new istance of clear coat configuration.
  52439. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52440. */
  52441. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52442. /**
  52443. * Checks to see if a texture is used in the material.
  52444. * @param defines the list of "defines" to update.
  52445. */
  52446. prepareDefines(defines: IMaterialBRDFDefines): void;
  52447. /**
  52448. * Get the current class name of the texture useful for serialization or dynamic coding.
  52449. * @returns "PBRClearCoatConfiguration"
  52450. */
  52451. getClassName(): string;
  52452. /**
  52453. * Makes a duplicate of the current configuration into another one.
  52454. * @param brdfConfiguration define the config where to copy the info
  52455. */
  52456. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52457. /**
  52458. * Serializes this BRDF configuration.
  52459. * @returns - An object with the serialized config.
  52460. */
  52461. serialize(): any;
  52462. /**
  52463. * Parses a anisotropy Configuration from a serialized object.
  52464. * @param source - Serialized object.
  52465. * @param scene Defines the scene we are parsing for
  52466. * @param rootUrl Defines the rootUrl to load from
  52467. */
  52468. parse(source: any, scene: Scene, rootUrl: string): void;
  52469. }
  52470. }
  52471. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52472. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52473. import { Color3 } from "babylonjs/Maths/math.color";
  52474. import { Scene } from "babylonjs/scene";
  52475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52476. import { Nullable } from "babylonjs/types";
  52477. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52478. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52479. /**
  52480. * @hidden
  52481. */
  52482. export interface IMaterialSheenDefines {
  52483. SHEEN: boolean;
  52484. SHEEN_TEXTURE: boolean;
  52485. SHEEN_TEXTUREDIRECTUV: number;
  52486. SHEEN_LINKWITHALBEDO: boolean;
  52487. SHEEN_ROUGHNESS: boolean;
  52488. SHEEN_ALBEDOSCALING: boolean;
  52489. /** @hidden */
  52490. _areTexturesDirty: boolean;
  52491. }
  52492. /**
  52493. * Define the code related to the Sheen parameters of the pbr material.
  52494. */
  52495. export class PBRSheenConfiguration {
  52496. private _isEnabled;
  52497. /**
  52498. * Defines if the material uses sheen.
  52499. */
  52500. isEnabled: boolean;
  52501. private _linkSheenWithAlbedo;
  52502. /**
  52503. * Defines if the sheen is linked to the sheen color.
  52504. */
  52505. linkSheenWithAlbedo: boolean;
  52506. /**
  52507. * Defines the sheen intensity.
  52508. */
  52509. intensity: number;
  52510. /**
  52511. * Defines the sheen color.
  52512. */
  52513. color: Color3;
  52514. private _texture;
  52515. /**
  52516. * Stores the sheen tint values in a texture.
  52517. * rgb is tint
  52518. * a is a intensity
  52519. */
  52520. texture: Nullable<BaseTexture>;
  52521. private _roughness;
  52522. /**
  52523. * Defines the sheen roughness.
  52524. * It is not taken into account if linkSheenWithAlbedo is true.
  52525. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52526. */
  52527. roughness: Nullable<number>;
  52528. private _albedoScaling;
  52529. /**
  52530. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52531. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52532. * making it easier to setup and tweak the effect
  52533. */
  52534. albedoScaling: boolean;
  52535. /** @hidden */
  52536. private _internalMarkAllSubMeshesAsTexturesDirty;
  52537. /** @hidden */
  52538. _markAllSubMeshesAsTexturesDirty(): void;
  52539. /**
  52540. * Instantiate a new istance of clear coat configuration.
  52541. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52542. */
  52543. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52544. /**
  52545. * Specifies that the submesh is ready to be used.
  52546. * @param defines the list of "defines" to update.
  52547. * @param scene defines the scene the material belongs to.
  52548. * @returns - boolean indicating that the submesh is ready or not.
  52549. */
  52550. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52551. /**
  52552. * Checks to see if a texture is used in the material.
  52553. * @param defines the list of "defines" to update.
  52554. * @param scene defines the scene the material belongs to.
  52555. */
  52556. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52557. /**
  52558. * Binds the material data.
  52559. * @param uniformBuffer defines the Uniform buffer to fill in.
  52560. * @param scene defines the scene the material belongs to.
  52561. * @param isFrozen defines wether the material is frozen or not.
  52562. */
  52563. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52564. /**
  52565. * Checks to see if a texture is used in the material.
  52566. * @param texture - Base texture to use.
  52567. * @returns - Boolean specifying if a texture is used in the material.
  52568. */
  52569. hasTexture(texture: BaseTexture): boolean;
  52570. /**
  52571. * Returns an array of the actively used textures.
  52572. * @param activeTextures Array of BaseTextures
  52573. */
  52574. getActiveTextures(activeTextures: BaseTexture[]): void;
  52575. /**
  52576. * Returns the animatable textures.
  52577. * @param animatables Array of animatable textures.
  52578. */
  52579. getAnimatables(animatables: IAnimatable[]): void;
  52580. /**
  52581. * Disposes the resources of the material.
  52582. * @param forceDisposeTextures - Forces the disposal of all textures.
  52583. */
  52584. dispose(forceDisposeTextures?: boolean): void;
  52585. /**
  52586. * Get the current class name of the texture useful for serialization or dynamic coding.
  52587. * @returns "PBRSheenConfiguration"
  52588. */
  52589. getClassName(): string;
  52590. /**
  52591. * Add fallbacks to the effect fallbacks list.
  52592. * @param defines defines the Base texture to use.
  52593. * @param fallbacks defines the current fallback list.
  52594. * @param currentRank defines the current fallback rank.
  52595. * @returns the new fallback rank.
  52596. */
  52597. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52598. /**
  52599. * Add the required uniforms to the current list.
  52600. * @param uniforms defines the current uniform list.
  52601. */
  52602. static AddUniforms(uniforms: string[]): void;
  52603. /**
  52604. * Add the required uniforms to the current buffer.
  52605. * @param uniformBuffer defines the current uniform buffer.
  52606. */
  52607. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52608. /**
  52609. * Add the required samplers to the current list.
  52610. * @param samplers defines the current sampler list.
  52611. */
  52612. static AddSamplers(samplers: string[]): void;
  52613. /**
  52614. * Makes a duplicate of the current configuration into another one.
  52615. * @param sheenConfiguration define the config where to copy the info
  52616. */
  52617. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52618. /**
  52619. * Serializes this BRDF configuration.
  52620. * @returns - An object with the serialized config.
  52621. */
  52622. serialize(): any;
  52623. /**
  52624. * Parses a anisotropy Configuration from a serialized object.
  52625. * @param source - Serialized object.
  52626. * @param scene Defines the scene we are parsing for
  52627. * @param rootUrl Defines the rootUrl to load from
  52628. */
  52629. parse(source: any, scene: Scene, rootUrl: string): void;
  52630. }
  52631. }
  52632. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52633. import { Nullable } from "babylonjs/types";
  52634. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52635. import { Color3 } from "babylonjs/Maths/math.color";
  52636. import { SmartArray } from "babylonjs/Misc/smartArray";
  52637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52638. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52639. import { Effect } from "babylonjs/Materials/effect";
  52640. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52641. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52642. import { Engine } from "babylonjs/Engines/engine";
  52643. import { Scene } from "babylonjs/scene";
  52644. /**
  52645. * @hidden
  52646. */
  52647. export interface IMaterialSubSurfaceDefines {
  52648. SUBSURFACE: boolean;
  52649. SS_REFRACTION: boolean;
  52650. SS_TRANSLUCENCY: boolean;
  52651. SS_SCATERRING: boolean;
  52652. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52653. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52654. SS_REFRACTIONMAP_3D: boolean;
  52655. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52656. SS_LODINREFRACTIONALPHA: boolean;
  52657. SS_GAMMAREFRACTION: boolean;
  52658. SS_RGBDREFRACTION: boolean;
  52659. SS_LINEARSPECULARREFRACTION: boolean;
  52660. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52661. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52662. /** @hidden */
  52663. _areTexturesDirty: boolean;
  52664. }
  52665. /**
  52666. * Define the code related to the sub surface parameters of the pbr material.
  52667. */
  52668. export class PBRSubSurfaceConfiguration {
  52669. private _isRefractionEnabled;
  52670. /**
  52671. * Defines if the refraction is enabled in the material.
  52672. */
  52673. isRefractionEnabled: boolean;
  52674. private _isTranslucencyEnabled;
  52675. /**
  52676. * Defines if the translucency is enabled in the material.
  52677. */
  52678. isTranslucencyEnabled: boolean;
  52679. private _isScatteringEnabled;
  52680. /**
  52681. * Defines the refraction intensity of the material.
  52682. * The refraction when enabled replaces the Diffuse part of the material.
  52683. * The intensity helps transitionning between diffuse and refraction.
  52684. */
  52685. refractionIntensity: number;
  52686. /**
  52687. * Defines the translucency intensity of the material.
  52688. * When translucency has been enabled, this defines how much of the "translucency"
  52689. * is addded to the diffuse part of the material.
  52690. */
  52691. translucencyIntensity: number;
  52692. /**
  52693. * Defines the scattering intensity of the material.
  52694. * When scattering has been enabled, this defines how much of the "scattered light"
  52695. * is addded to the diffuse part of the material.
  52696. */
  52697. scatteringIntensity: number;
  52698. private _thicknessTexture;
  52699. /**
  52700. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52701. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52702. * 0 would mean minimumThickness
  52703. * 1 would mean maximumThickness
  52704. * The other channels might be use as a mask to vary the different effects intensity.
  52705. */
  52706. thicknessTexture: Nullable<BaseTexture>;
  52707. private _refractionTexture;
  52708. /**
  52709. * Defines the texture to use for refraction.
  52710. */
  52711. refractionTexture: Nullable<BaseTexture>;
  52712. private _indexOfRefraction;
  52713. /**
  52714. * Defines the index of refraction used in the material.
  52715. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52716. */
  52717. indexOfRefraction: number;
  52718. private _invertRefractionY;
  52719. /**
  52720. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52721. */
  52722. invertRefractionY: boolean;
  52723. private _linkRefractionWithTransparency;
  52724. /**
  52725. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52726. * Materials half opaque for instance using refraction could benefit from this control.
  52727. */
  52728. linkRefractionWithTransparency: boolean;
  52729. /**
  52730. * Defines the minimum thickness stored in the thickness map.
  52731. * If no thickness map is defined, this value will be used to simulate thickness.
  52732. */
  52733. minimumThickness: number;
  52734. /**
  52735. * Defines the maximum thickness stored in the thickness map.
  52736. */
  52737. maximumThickness: number;
  52738. /**
  52739. * Defines the volume tint of the material.
  52740. * This is used for both translucency and scattering.
  52741. */
  52742. tintColor: Color3;
  52743. /**
  52744. * Defines the distance at which the tint color should be found in the media.
  52745. * This is used for refraction only.
  52746. */
  52747. tintColorAtDistance: number;
  52748. /**
  52749. * Defines how far each channel transmit through the media.
  52750. * It is defined as a color to simplify it selection.
  52751. */
  52752. diffusionDistance: Color3;
  52753. private _useMaskFromThicknessTexture;
  52754. /**
  52755. * Stores the intensity of the different subsurface effects in the thickness texture.
  52756. * * the green channel is the translucency intensity.
  52757. * * the blue channel is the scattering intensity.
  52758. * * the alpha channel is the refraction intensity.
  52759. */
  52760. useMaskFromThicknessTexture: boolean;
  52761. /** @hidden */
  52762. private _internalMarkAllSubMeshesAsTexturesDirty;
  52763. /** @hidden */
  52764. _markAllSubMeshesAsTexturesDirty(): void;
  52765. /**
  52766. * Instantiate a new istance of sub surface configuration.
  52767. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52768. */
  52769. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52770. /**
  52771. * Gets wehter the submesh is ready to be used or not.
  52772. * @param defines the list of "defines" to update.
  52773. * @param scene defines the scene the material belongs to.
  52774. * @returns - boolean indicating that the submesh is ready or not.
  52775. */
  52776. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52777. /**
  52778. * Checks to see if a texture is used in the material.
  52779. * @param defines the list of "defines" to update.
  52780. * @param scene defines the scene to the material belongs to.
  52781. */
  52782. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52783. /**
  52784. * Binds the material data.
  52785. * @param uniformBuffer defines the Uniform buffer to fill in.
  52786. * @param scene defines the scene the material belongs to.
  52787. * @param engine defines the engine the material belongs to.
  52788. * @param isFrozen defines wether the material is frozen or not.
  52789. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52790. */
  52791. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52792. /**
  52793. * Unbinds the material from the mesh.
  52794. * @param activeEffect defines the effect that should be unbound from.
  52795. * @returns true if unbound, otherwise false
  52796. */
  52797. unbind(activeEffect: Effect): boolean;
  52798. /**
  52799. * Returns the texture used for refraction or null if none is used.
  52800. * @param scene defines the scene the material belongs to.
  52801. * @returns - Refraction texture if present. If no refraction texture and refraction
  52802. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52803. */
  52804. private _getRefractionTexture;
  52805. /**
  52806. * Returns true if alpha blending should be disabled.
  52807. */
  52808. get disableAlphaBlending(): boolean;
  52809. /**
  52810. * Fills the list of render target textures.
  52811. * @param renderTargets the list of render targets to update
  52812. */
  52813. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52814. /**
  52815. * Checks to see if a texture is used in the material.
  52816. * @param texture - Base texture to use.
  52817. * @returns - Boolean specifying if a texture is used in the material.
  52818. */
  52819. hasTexture(texture: BaseTexture): boolean;
  52820. /**
  52821. * Gets a boolean indicating that current material needs to register RTT
  52822. * @returns true if this uses a render target otherwise false.
  52823. */
  52824. hasRenderTargetTextures(): boolean;
  52825. /**
  52826. * Returns an array of the actively used textures.
  52827. * @param activeTextures Array of BaseTextures
  52828. */
  52829. getActiveTextures(activeTextures: BaseTexture[]): void;
  52830. /**
  52831. * Returns the animatable textures.
  52832. * @param animatables Array of animatable textures.
  52833. */
  52834. getAnimatables(animatables: IAnimatable[]): void;
  52835. /**
  52836. * Disposes the resources of the material.
  52837. * @param forceDisposeTextures - Forces the disposal of all textures.
  52838. */
  52839. dispose(forceDisposeTextures?: boolean): void;
  52840. /**
  52841. * Get the current class name of the texture useful for serialization or dynamic coding.
  52842. * @returns "PBRSubSurfaceConfiguration"
  52843. */
  52844. getClassName(): string;
  52845. /**
  52846. * Add fallbacks to the effect fallbacks list.
  52847. * @param defines defines the Base texture to use.
  52848. * @param fallbacks defines the current fallback list.
  52849. * @param currentRank defines the current fallback rank.
  52850. * @returns the new fallback rank.
  52851. */
  52852. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52853. /**
  52854. * Add the required uniforms to the current list.
  52855. * @param uniforms defines the current uniform list.
  52856. */
  52857. static AddUniforms(uniforms: string[]): void;
  52858. /**
  52859. * Add the required samplers to the current list.
  52860. * @param samplers defines the current sampler list.
  52861. */
  52862. static AddSamplers(samplers: string[]): void;
  52863. /**
  52864. * Add the required uniforms to the current buffer.
  52865. * @param uniformBuffer defines the current uniform buffer.
  52866. */
  52867. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52868. /**
  52869. * Makes a duplicate of the current configuration into another one.
  52870. * @param configuration define the config where to copy the info
  52871. */
  52872. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52873. /**
  52874. * Serializes this Sub Surface configuration.
  52875. * @returns - An object with the serialized config.
  52876. */
  52877. serialize(): any;
  52878. /**
  52879. * Parses a anisotropy Configuration from a serialized object.
  52880. * @param source - Serialized object.
  52881. * @param scene Defines the scene we are parsing for
  52882. * @param rootUrl Defines the rootUrl to load from
  52883. */
  52884. parse(source: any, scene: Scene, rootUrl: string): void;
  52885. }
  52886. }
  52887. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52888. /** @hidden */
  52889. export var pbrFragmentDeclaration: {
  52890. name: string;
  52891. shader: string;
  52892. };
  52893. }
  52894. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52895. /** @hidden */
  52896. export var pbrUboDeclaration: {
  52897. name: string;
  52898. shader: string;
  52899. };
  52900. }
  52901. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52902. /** @hidden */
  52903. export var pbrFragmentExtraDeclaration: {
  52904. name: string;
  52905. shader: string;
  52906. };
  52907. }
  52908. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52909. /** @hidden */
  52910. export var pbrFragmentSamplersDeclaration: {
  52911. name: string;
  52912. shader: string;
  52913. };
  52914. }
  52915. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52916. /** @hidden */
  52917. export var pbrHelperFunctions: {
  52918. name: string;
  52919. shader: string;
  52920. };
  52921. }
  52922. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52923. /** @hidden */
  52924. export var harmonicsFunctions: {
  52925. name: string;
  52926. shader: string;
  52927. };
  52928. }
  52929. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52930. /** @hidden */
  52931. export var pbrDirectLightingSetupFunctions: {
  52932. name: string;
  52933. shader: string;
  52934. };
  52935. }
  52936. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52937. /** @hidden */
  52938. export var pbrDirectLightingFalloffFunctions: {
  52939. name: string;
  52940. shader: string;
  52941. };
  52942. }
  52943. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52944. /** @hidden */
  52945. export var pbrBRDFFunctions: {
  52946. name: string;
  52947. shader: string;
  52948. };
  52949. }
  52950. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52951. /** @hidden */
  52952. export var pbrDirectLightingFunctions: {
  52953. name: string;
  52954. shader: string;
  52955. };
  52956. }
  52957. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52958. /** @hidden */
  52959. export var pbrIBLFunctions: {
  52960. name: string;
  52961. shader: string;
  52962. };
  52963. }
  52964. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52965. /** @hidden */
  52966. export var pbrDebug: {
  52967. name: string;
  52968. shader: string;
  52969. };
  52970. }
  52971. declare module "babylonjs/Shaders/pbr.fragment" {
  52972. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52973. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52974. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52975. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52976. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52977. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52978. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52979. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52980. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52981. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52983. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52984. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52985. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52986. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52987. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52988. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52989. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52990. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52991. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52992. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52993. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52995. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52996. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52997. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52998. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52999. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53000. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53001. /** @hidden */
  53002. export var pbrPixelShader: {
  53003. name: string;
  53004. shader: string;
  53005. };
  53006. }
  53007. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53008. /** @hidden */
  53009. export var pbrVertexDeclaration: {
  53010. name: string;
  53011. shader: string;
  53012. };
  53013. }
  53014. declare module "babylonjs/Shaders/pbr.vertex" {
  53015. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53016. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53017. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53018. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53019. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53020. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53021. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53022. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53023. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53024. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53025. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53026. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53027. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53028. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53029. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53030. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53031. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53032. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53033. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53034. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53035. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53036. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53037. /** @hidden */
  53038. export var pbrVertexShader: {
  53039. name: string;
  53040. shader: string;
  53041. };
  53042. }
  53043. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53044. import { Nullable } from "babylonjs/types";
  53045. import { Scene } from "babylonjs/scene";
  53046. import { Matrix } from "babylonjs/Maths/math.vector";
  53047. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53049. import { Mesh } from "babylonjs/Meshes/mesh";
  53050. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53051. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53052. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53053. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53054. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53055. import { Color3 } from "babylonjs/Maths/math.color";
  53056. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53057. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53058. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53059. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53062. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53063. import "babylonjs/Shaders/pbr.fragment";
  53064. import "babylonjs/Shaders/pbr.vertex";
  53065. /**
  53066. * Manages the defines for the PBR Material.
  53067. * @hidden
  53068. */
  53069. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53070. PBR: boolean;
  53071. MAINUV1: boolean;
  53072. MAINUV2: boolean;
  53073. UV1: boolean;
  53074. UV2: boolean;
  53075. ALBEDO: boolean;
  53076. GAMMAALBEDO: boolean;
  53077. ALBEDODIRECTUV: number;
  53078. VERTEXCOLOR: boolean;
  53079. AMBIENT: boolean;
  53080. AMBIENTDIRECTUV: number;
  53081. AMBIENTINGRAYSCALE: boolean;
  53082. OPACITY: boolean;
  53083. VERTEXALPHA: boolean;
  53084. OPACITYDIRECTUV: number;
  53085. OPACITYRGB: boolean;
  53086. ALPHATEST: boolean;
  53087. DEPTHPREPASS: boolean;
  53088. ALPHABLEND: boolean;
  53089. ALPHAFROMALBEDO: boolean;
  53090. ALPHATESTVALUE: string;
  53091. SPECULAROVERALPHA: boolean;
  53092. RADIANCEOVERALPHA: boolean;
  53093. ALPHAFRESNEL: boolean;
  53094. LINEARALPHAFRESNEL: boolean;
  53095. PREMULTIPLYALPHA: boolean;
  53096. EMISSIVE: boolean;
  53097. EMISSIVEDIRECTUV: number;
  53098. REFLECTIVITY: boolean;
  53099. REFLECTIVITYDIRECTUV: number;
  53100. SPECULARTERM: boolean;
  53101. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53102. MICROSURFACEAUTOMATIC: boolean;
  53103. LODBASEDMICROSFURACE: boolean;
  53104. MICROSURFACEMAP: boolean;
  53105. MICROSURFACEMAPDIRECTUV: number;
  53106. METALLICWORKFLOW: boolean;
  53107. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53108. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53109. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53110. AOSTOREINMETALMAPRED: boolean;
  53111. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53112. ENVIRONMENTBRDF: boolean;
  53113. ENVIRONMENTBRDF_RGBD: boolean;
  53114. NORMAL: boolean;
  53115. TANGENT: boolean;
  53116. BUMP: boolean;
  53117. BUMPDIRECTUV: number;
  53118. OBJECTSPACE_NORMALMAP: boolean;
  53119. PARALLAX: boolean;
  53120. PARALLAXOCCLUSION: boolean;
  53121. NORMALXYSCALE: boolean;
  53122. LIGHTMAP: boolean;
  53123. LIGHTMAPDIRECTUV: number;
  53124. USELIGHTMAPASSHADOWMAP: boolean;
  53125. GAMMALIGHTMAP: boolean;
  53126. RGBDLIGHTMAP: boolean;
  53127. REFLECTION: boolean;
  53128. REFLECTIONMAP_3D: boolean;
  53129. REFLECTIONMAP_SPHERICAL: boolean;
  53130. REFLECTIONMAP_PLANAR: boolean;
  53131. REFLECTIONMAP_CUBIC: boolean;
  53132. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53133. REFLECTIONMAP_PROJECTION: boolean;
  53134. REFLECTIONMAP_SKYBOX: boolean;
  53135. REFLECTIONMAP_EXPLICIT: boolean;
  53136. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53137. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53138. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53139. INVERTCUBICMAP: boolean;
  53140. USESPHERICALFROMREFLECTIONMAP: boolean;
  53141. USEIRRADIANCEMAP: boolean;
  53142. SPHERICAL_HARMONICS: boolean;
  53143. USESPHERICALINVERTEX: boolean;
  53144. REFLECTIONMAP_OPPOSITEZ: boolean;
  53145. LODINREFLECTIONALPHA: boolean;
  53146. GAMMAREFLECTION: boolean;
  53147. RGBDREFLECTION: boolean;
  53148. LINEARSPECULARREFLECTION: boolean;
  53149. RADIANCEOCCLUSION: boolean;
  53150. HORIZONOCCLUSION: boolean;
  53151. INSTANCES: boolean;
  53152. NUM_BONE_INFLUENCERS: number;
  53153. BonesPerMesh: number;
  53154. BONETEXTURE: boolean;
  53155. NONUNIFORMSCALING: boolean;
  53156. MORPHTARGETS: boolean;
  53157. MORPHTARGETS_NORMAL: boolean;
  53158. MORPHTARGETS_TANGENT: boolean;
  53159. MORPHTARGETS_UV: boolean;
  53160. NUM_MORPH_INFLUENCERS: number;
  53161. IMAGEPROCESSING: boolean;
  53162. VIGNETTE: boolean;
  53163. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53164. VIGNETTEBLENDMODEOPAQUE: boolean;
  53165. TONEMAPPING: boolean;
  53166. TONEMAPPING_ACES: boolean;
  53167. CONTRAST: boolean;
  53168. COLORCURVES: boolean;
  53169. COLORGRADING: boolean;
  53170. COLORGRADING3D: boolean;
  53171. SAMPLER3DGREENDEPTH: boolean;
  53172. SAMPLER3DBGRMAP: boolean;
  53173. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53174. EXPOSURE: boolean;
  53175. MULTIVIEW: boolean;
  53176. USEPHYSICALLIGHTFALLOFF: boolean;
  53177. USEGLTFLIGHTFALLOFF: boolean;
  53178. TWOSIDEDLIGHTING: boolean;
  53179. SHADOWFLOAT: boolean;
  53180. CLIPPLANE: boolean;
  53181. CLIPPLANE2: boolean;
  53182. CLIPPLANE3: boolean;
  53183. CLIPPLANE4: boolean;
  53184. CLIPPLANE5: boolean;
  53185. CLIPPLANE6: boolean;
  53186. POINTSIZE: boolean;
  53187. FOG: boolean;
  53188. LOGARITHMICDEPTH: boolean;
  53189. FORCENORMALFORWARD: boolean;
  53190. SPECULARAA: boolean;
  53191. CLEARCOAT: boolean;
  53192. CLEARCOAT_DEFAULTIOR: boolean;
  53193. CLEARCOAT_TEXTURE: boolean;
  53194. CLEARCOAT_TEXTUREDIRECTUV: number;
  53195. CLEARCOAT_BUMP: boolean;
  53196. CLEARCOAT_BUMPDIRECTUV: number;
  53197. CLEARCOAT_TINT: boolean;
  53198. CLEARCOAT_TINT_TEXTURE: boolean;
  53199. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53200. ANISOTROPIC: boolean;
  53201. ANISOTROPIC_TEXTURE: boolean;
  53202. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53203. BRDF_V_HEIGHT_CORRELATED: boolean;
  53204. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53205. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53206. SHEEN: boolean;
  53207. SHEEN_TEXTURE: boolean;
  53208. SHEEN_TEXTUREDIRECTUV: number;
  53209. SHEEN_LINKWITHALBEDO: boolean;
  53210. SHEEN_ROUGHNESS: boolean;
  53211. SHEEN_ALBEDOSCALING: boolean;
  53212. SUBSURFACE: boolean;
  53213. SS_REFRACTION: boolean;
  53214. SS_TRANSLUCENCY: boolean;
  53215. SS_SCATERRING: boolean;
  53216. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53217. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53218. SS_REFRACTIONMAP_3D: boolean;
  53219. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53220. SS_LODINREFRACTIONALPHA: boolean;
  53221. SS_GAMMAREFRACTION: boolean;
  53222. SS_RGBDREFRACTION: boolean;
  53223. SS_LINEARSPECULARREFRACTION: boolean;
  53224. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53225. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53226. UNLIT: boolean;
  53227. DEBUGMODE: number;
  53228. /**
  53229. * Initializes the PBR Material defines.
  53230. */
  53231. constructor();
  53232. /**
  53233. * Resets the PBR Material defines.
  53234. */
  53235. reset(): void;
  53236. }
  53237. /**
  53238. * The Physically based material base class of BJS.
  53239. *
  53240. * This offers the main features of a standard PBR material.
  53241. * For more information, please refer to the documentation :
  53242. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53243. */
  53244. export abstract class PBRBaseMaterial extends PushMaterial {
  53245. /**
  53246. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53247. */
  53248. static readonly PBRMATERIAL_OPAQUE: number;
  53249. /**
  53250. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53251. */
  53252. static readonly PBRMATERIAL_ALPHATEST: number;
  53253. /**
  53254. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53255. */
  53256. static readonly PBRMATERIAL_ALPHABLEND: number;
  53257. /**
  53258. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53259. * They are also discarded below the alpha cutoff threshold to improve performances.
  53260. */
  53261. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53262. /**
  53263. * Defines the default value of how much AO map is occluding the analytical lights
  53264. * (point spot...).
  53265. */
  53266. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53267. /**
  53268. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53269. */
  53270. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53271. /**
  53272. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53273. * to enhance interoperability with other engines.
  53274. */
  53275. static readonly LIGHTFALLOFF_GLTF: number;
  53276. /**
  53277. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53278. * to enhance interoperability with other materials.
  53279. */
  53280. static readonly LIGHTFALLOFF_STANDARD: number;
  53281. /**
  53282. * Intensity of the direct lights e.g. the four lights available in your scene.
  53283. * This impacts both the direct diffuse and specular highlights.
  53284. */
  53285. protected _directIntensity: number;
  53286. /**
  53287. * Intensity of the emissive part of the material.
  53288. * This helps controlling the emissive effect without modifying the emissive color.
  53289. */
  53290. protected _emissiveIntensity: number;
  53291. /**
  53292. * Intensity of the environment e.g. how much the environment will light the object
  53293. * either through harmonics for rough material or through the refelction for shiny ones.
  53294. */
  53295. protected _environmentIntensity: number;
  53296. /**
  53297. * This is a special control allowing the reduction of the specular highlights coming from the
  53298. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53299. */
  53300. protected _specularIntensity: number;
  53301. /**
  53302. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53303. */
  53304. private _lightingInfos;
  53305. /**
  53306. * Debug Control allowing disabling the bump map on this material.
  53307. */
  53308. protected _disableBumpMap: boolean;
  53309. /**
  53310. * AKA Diffuse Texture in standard nomenclature.
  53311. */
  53312. protected _albedoTexture: Nullable<BaseTexture>;
  53313. /**
  53314. * AKA Occlusion Texture in other nomenclature.
  53315. */
  53316. protected _ambientTexture: Nullable<BaseTexture>;
  53317. /**
  53318. * AKA Occlusion Texture Intensity in other nomenclature.
  53319. */
  53320. protected _ambientTextureStrength: number;
  53321. /**
  53322. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53323. * 1 means it completely occludes it
  53324. * 0 mean it has no impact
  53325. */
  53326. protected _ambientTextureImpactOnAnalyticalLights: number;
  53327. /**
  53328. * Stores the alpha values in a texture.
  53329. */
  53330. protected _opacityTexture: Nullable<BaseTexture>;
  53331. /**
  53332. * Stores the reflection values in a texture.
  53333. */
  53334. protected _reflectionTexture: Nullable<BaseTexture>;
  53335. /**
  53336. * Stores the emissive values in a texture.
  53337. */
  53338. protected _emissiveTexture: Nullable<BaseTexture>;
  53339. /**
  53340. * AKA Specular texture in other nomenclature.
  53341. */
  53342. protected _reflectivityTexture: Nullable<BaseTexture>;
  53343. /**
  53344. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53345. */
  53346. protected _metallicTexture: Nullable<BaseTexture>;
  53347. /**
  53348. * Specifies the metallic scalar of the metallic/roughness workflow.
  53349. * Can also be used to scale the metalness values of the metallic texture.
  53350. */
  53351. protected _metallic: Nullable<number>;
  53352. /**
  53353. * Specifies the roughness scalar of the metallic/roughness workflow.
  53354. * Can also be used to scale the roughness values of the metallic texture.
  53355. */
  53356. protected _roughness: Nullable<number>;
  53357. /**
  53358. * Specifies the an F0 factor to help configuring the material F0.
  53359. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53360. * to 0.5 the previously hard coded value stays the same.
  53361. * Can also be used to scale the F0 values of the metallic texture.
  53362. */
  53363. protected _metallicF0Factor: number;
  53364. /**
  53365. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53366. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53367. * your expectation as it multiplies with the texture data.
  53368. */
  53369. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53370. /**
  53371. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53372. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53373. */
  53374. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53375. /**
  53376. * Stores surface normal data used to displace a mesh in a texture.
  53377. */
  53378. protected _bumpTexture: Nullable<BaseTexture>;
  53379. /**
  53380. * Stores the pre-calculated light information of a mesh in a texture.
  53381. */
  53382. protected _lightmapTexture: Nullable<BaseTexture>;
  53383. /**
  53384. * The color of a material in ambient lighting.
  53385. */
  53386. protected _ambientColor: Color3;
  53387. /**
  53388. * AKA Diffuse Color in other nomenclature.
  53389. */
  53390. protected _albedoColor: Color3;
  53391. /**
  53392. * AKA Specular Color in other nomenclature.
  53393. */
  53394. protected _reflectivityColor: Color3;
  53395. /**
  53396. * The color applied when light is reflected from a material.
  53397. */
  53398. protected _reflectionColor: Color3;
  53399. /**
  53400. * The color applied when light is emitted from a material.
  53401. */
  53402. protected _emissiveColor: Color3;
  53403. /**
  53404. * AKA Glossiness in other nomenclature.
  53405. */
  53406. protected _microSurface: number;
  53407. /**
  53408. * Specifies that the material will use the light map as a show map.
  53409. */
  53410. protected _useLightmapAsShadowmap: boolean;
  53411. /**
  53412. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53413. * makes the reflect vector face the model (under horizon).
  53414. */
  53415. protected _useHorizonOcclusion: boolean;
  53416. /**
  53417. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53418. * too much the area relying on ambient texture to define their ambient occlusion.
  53419. */
  53420. protected _useRadianceOcclusion: boolean;
  53421. /**
  53422. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53423. */
  53424. protected _useAlphaFromAlbedoTexture: boolean;
  53425. /**
  53426. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53427. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53428. */
  53429. protected _useSpecularOverAlpha: boolean;
  53430. /**
  53431. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53432. */
  53433. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53434. /**
  53435. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53436. */
  53437. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53438. /**
  53439. * Specifies if the metallic texture contains the roughness information in its green channel.
  53440. */
  53441. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53442. /**
  53443. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53444. */
  53445. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53446. /**
  53447. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53448. */
  53449. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53450. /**
  53451. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53452. */
  53453. protected _useAmbientInGrayScale: boolean;
  53454. /**
  53455. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53456. * The material will try to infer what glossiness each pixel should be.
  53457. */
  53458. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53459. /**
  53460. * Defines the falloff type used in this material.
  53461. * It by default is Physical.
  53462. */
  53463. protected _lightFalloff: number;
  53464. /**
  53465. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53466. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53467. */
  53468. protected _useRadianceOverAlpha: boolean;
  53469. /**
  53470. * Allows using an object space normal map (instead of tangent space).
  53471. */
  53472. protected _useObjectSpaceNormalMap: boolean;
  53473. /**
  53474. * Allows using the bump map in parallax mode.
  53475. */
  53476. protected _useParallax: boolean;
  53477. /**
  53478. * Allows using the bump map in parallax occlusion mode.
  53479. */
  53480. protected _useParallaxOcclusion: boolean;
  53481. /**
  53482. * Controls the scale bias of the parallax mode.
  53483. */
  53484. protected _parallaxScaleBias: number;
  53485. /**
  53486. * If sets to true, disables all the lights affecting the material.
  53487. */
  53488. protected _disableLighting: boolean;
  53489. /**
  53490. * Number of Simultaneous lights allowed on the material.
  53491. */
  53492. protected _maxSimultaneousLights: number;
  53493. /**
  53494. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53495. */
  53496. protected _invertNormalMapX: boolean;
  53497. /**
  53498. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53499. */
  53500. protected _invertNormalMapY: boolean;
  53501. /**
  53502. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53503. */
  53504. protected _twoSidedLighting: boolean;
  53505. /**
  53506. * Defines the alpha limits in alpha test mode.
  53507. */
  53508. protected _alphaCutOff: number;
  53509. /**
  53510. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53511. */
  53512. protected _forceAlphaTest: boolean;
  53513. /**
  53514. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53515. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53516. */
  53517. protected _useAlphaFresnel: boolean;
  53518. /**
  53519. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53520. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53521. */
  53522. protected _useLinearAlphaFresnel: boolean;
  53523. /**
  53524. * The transparency mode of the material.
  53525. */
  53526. protected _transparencyMode: Nullable<number>;
  53527. /**
  53528. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53529. * from cos thetav and roughness:
  53530. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53531. */
  53532. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53533. /**
  53534. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53535. */
  53536. protected _forceIrradianceInFragment: boolean;
  53537. /**
  53538. * Force normal to face away from face.
  53539. */
  53540. protected _forceNormalForward: boolean;
  53541. /**
  53542. * Enables specular anti aliasing in the PBR shader.
  53543. * It will both interacts on the Geometry for analytical and IBL lighting.
  53544. * It also prefilter the roughness map based on the bump values.
  53545. */
  53546. protected _enableSpecularAntiAliasing: boolean;
  53547. /**
  53548. * Default configuration related to image processing available in the PBR Material.
  53549. */
  53550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53551. /**
  53552. * Keep track of the image processing observer to allow dispose and replace.
  53553. */
  53554. private _imageProcessingObserver;
  53555. /**
  53556. * Attaches a new image processing configuration to the PBR Material.
  53557. * @param configuration
  53558. */
  53559. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53560. /**
  53561. * Stores the available render targets.
  53562. */
  53563. private _renderTargets;
  53564. /**
  53565. * Sets the global ambient color for the material used in lighting calculations.
  53566. */
  53567. private _globalAmbientColor;
  53568. /**
  53569. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53570. */
  53571. private _useLogarithmicDepth;
  53572. /**
  53573. * If set to true, no lighting calculations will be applied.
  53574. */
  53575. private _unlit;
  53576. private _debugMode;
  53577. /**
  53578. * @hidden
  53579. * This is reserved for the inspector.
  53580. * Defines the material debug mode.
  53581. * It helps seeing only some components of the material while troubleshooting.
  53582. */
  53583. debugMode: number;
  53584. /**
  53585. * @hidden
  53586. * This is reserved for the inspector.
  53587. * Specify from where on screen the debug mode should start.
  53588. * The value goes from -1 (full screen) to 1 (not visible)
  53589. * It helps with side by side comparison against the final render
  53590. * This defaults to -1
  53591. */
  53592. private debugLimit;
  53593. /**
  53594. * @hidden
  53595. * This is reserved for the inspector.
  53596. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53597. * You can use the factor to better multiply the final value.
  53598. */
  53599. private debugFactor;
  53600. /**
  53601. * Defines the clear coat layer parameters for the material.
  53602. */
  53603. readonly clearCoat: PBRClearCoatConfiguration;
  53604. /**
  53605. * Defines the anisotropic parameters for the material.
  53606. */
  53607. readonly anisotropy: PBRAnisotropicConfiguration;
  53608. /**
  53609. * Defines the BRDF parameters for the material.
  53610. */
  53611. readonly brdf: PBRBRDFConfiguration;
  53612. /**
  53613. * Defines the Sheen parameters for the material.
  53614. */
  53615. readonly sheen: PBRSheenConfiguration;
  53616. /**
  53617. * Defines the SubSurface parameters for the material.
  53618. */
  53619. readonly subSurface: PBRSubSurfaceConfiguration;
  53620. /**
  53621. * Custom callback helping to override the default shader used in the material.
  53622. */
  53623. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53624. protected _rebuildInParallel: boolean;
  53625. /**
  53626. * Instantiates a new PBRMaterial instance.
  53627. *
  53628. * @param name The material name
  53629. * @param scene The scene the material will be use in.
  53630. */
  53631. constructor(name: string, scene: Scene);
  53632. /**
  53633. * Gets a boolean indicating that current material needs to register RTT
  53634. */
  53635. get hasRenderTargetTextures(): boolean;
  53636. /**
  53637. * Gets the name of the material class.
  53638. */
  53639. getClassName(): string;
  53640. /**
  53641. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53642. */
  53643. get useLogarithmicDepth(): boolean;
  53644. /**
  53645. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53646. */
  53647. set useLogarithmicDepth(value: boolean);
  53648. /**
  53649. * Gets the current transparency mode.
  53650. */
  53651. get transparencyMode(): Nullable<number>;
  53652. /**
  53653. * Sets the transparency mode of the material.
  53654. *
  53655. * | Value | Type | Description |
  53656. * | ----- | ----------------------------------- | ----------- |
  53657. * | 0 | OPAQUE | |
  53658. * | 1 | ALPHATEST | |
  53659. * | 2 | ALPHABLEND | |
  53660. * | 3 | ALPHATESTANDBLEND | |
  53661. *
  53662. */
  53663. set transparencyMode(value: Nullable<number>);
  53664. /**
  53665. * Returns true if alpha blending should be disabled.
  53666. */
  53667. private get _disableAlphaBlending();
  53668. /**
  53669. * Specifies whether or not this material should be rendered in alpha blend mode.
  53670. */
  53671. needAlphaBlending(): boolean;
  53672. /**
  53673. * Specifies if the mesh will require alpha blending.
  53674. * @param mesh - BJS mesh.
  53675. */
  53676. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53677. /**
  53678. * Specifies whether or not this material should be rendered in alpha test mode.
  53679. */
  53680. needAlphaTesting(): boolean;
  53681. /**
  53682. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53683. */
  53684. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53685. /**
  53686. * Gets the texture used for the alpha test.
  53687. */
  53688. getAlphaTestTexture(): Nullable<BaseTexture>;
  53689. /**
  53690. * Specifies that the submesh is ready to be used.
  53691. * @param mesh - BJS mesh.
  53692. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53693. * @param useInstances - Specifies that instances should be used.
  53694. * @returns - boolean indicating that the submesh is ready or not.
  53695. */
  53696. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53697. /**
  53698. * Specifies if the material uses metallic roughness workflow.
  53699. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53700. */
  53701. isMetallicWorkflow(): boolean;
  53702. private _prepareEffect;
  53703. private _prepareDefines;
  53704. /**
  53705. * Force shader compilation
  53706. */
  53707. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53708. /**
  53709. * Initializes the uniform buffer layout for the shader.
  53710. */
  53711. buildUniformLayout(): void;
  53712. /**
  53713. * Unbinds the material from the mesh
  53714. */
  53715. unbind(): void;
  53716. /**
  53717. * Binds the submesh data.
  53718. * @param world - The world matrix.
  53719. * @param mesh - The BJS mesh.
  53720. * @param subMesh - A submesh of the BJS mesh.
  53721. */
  53722. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53723. /**
  53724. * Returns the animatable textures.
  53725. * @returns - Array of animatable textures.
  53726. */
  53727. getAnimatables(): IAnimatable[];
  53728. /**
  53729. * Returns the texture used for reflections.
  53730. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53731. */
  53732. private _getReflectionTexture;
  53733. /**
  53734. * Returns an array of the actively used textures.
  53735. * @returns - Array of BaseTextures
  53736. */
  53737. getActiveTextures(): BaseTexture[];
  53738. /**
  53739. * Checks to see if a texture is used in the material.
  53740. * @param texture - Base texture to use.
  53741. * @returns - Boolean specifying if a texture is used in the material.
  53742. */
  53743. hasTexture(texture: BaseTexture): boolean;
  53744. /**
  53745. * Disposes the resources of the material.
  53746. * @param forceDisposeEffect - Forces the disposal of effects.
  53747. * @param forceDisposeTextures - Forces the disposal of all textures.
  53748. */
  53749. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53750. }
  53751. }
  53752. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53753. import { Nullable } from "babylonjs/types";
  53754. import { Scene } from "babylonjs/scene";
  53755. import { Color3 } from "babylonjs/Maths/math.color";
  53756. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53757. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53758. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53759. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53760. /**
  53761. * The Physically based material of BJS.
  53762. *
  53763. * This offers the main features of a standard PBR material.
  53764. * For more information, please refer to the documentation :
  53765. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53766. */
  53767. export class PBRMaterial extends PBRBaseMaterial {
  53768. /**
  53769. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53770. */
  53771. static readonly PBRMATERIAL_OPAQUE: number;
  53772. /**
  53773. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53774. */
  53775. static readonly PBRMATERIAL_ALPHATEST: number;
  53776. /**
  53777. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53778. */
  53779. static readonly PBRMATERIAL_ALPHABLEND: number;
  53780. /**
  53781. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53782. * They are also discarded below the alpha cutoff threshold to improve performances.
  53783. */
  53784. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53785. /**
  53786. * Defines the default value of how much AO map is occluding the analytical lights
  53787. * (point spot...).
  53788. */
  53789. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53790. /**
  53791. * Intensity of the direct lights e.g. the four lights available in your scene.
  53792. * This impacts both the direct diffuse and specular highlights.
  53793. */
  53794. directIntensity: number;
  53795. /**
  53796. * Intensity of the emissive part of the material.
  53797. * This helps controlling the emissive effect without modifying the emissive color.
  53798. */
  53799. emissiveIntensity: number;
  53800. /**
  53801. * Intensity of the environment e.g. how much the environment will light the object
  53802. * either through harmonics for rough material or through the refelction for shiny ones.
  53803. */
  53804. environmentIntensity: number;
  53805. /**
  53806. * This is a special control allowing the reduction of the specular highlights coming from the
  53807. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53808. */
  53809. specularIntensity: number;
  53810. /**
  53811. * Debug Control allowing disabling the bump map on this material.
  53812. */
  53813. disableBumpMap: boolean;
  53814. /**
  53815. * AKA Diffuse Texture in standard nomenclature.
  53816. */
  53817. albedoTexture: BaseTexture;
  53818. /**
  53819. * AKA Occlusion Texture in other nomenclature.
  53820. */
  53821. ambientTexture: BaseTexture;
  53822. /**
  53823. * AKA Occlusion Texture Intensity in other nomenclature.
  53824. */
  53825. ambientTextureStrength: number;
  53826. /**
  53827. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53828. * 1 means it completely occludes it
  53829. * 0 mean it has no impact
  53830. */
  53831. ambientTextureImpactOnAnalyticalLights: number;
  53832. /**
  53833. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53834. */
  53835. opacityTexture: BaseTexture;
  53836. /**
  53837. * Stores the reflection values in a texture.
  53838. */
  53839. reflectionTexture: Nullable<BaseTexture>;
  53840. /**
  53841. * Stores the emissive values in a texture.
  53842. */
  53843. emissiveTexture: BaseTexture;
  53844. /**
  53845. * AKA Specular texture in other nomenclature.
  53846. */
  53847. reflectivityTexture: BaseTexture;
  53848. /**
  53849. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53850. */
  53851. metallicTexture: BaseTexture;
  53852. /**
  53853. * Specifies the metallic scalar of the metallic/roughness workflow.
  53854. * Can also be used to scale the metalness values of the metallic texture.
  53855. */
  53856. metallic: Nullable<number>;
  53857. /**
  53858. * Specifies the roughness scalar of the metallic/roughness workflow.
  53859. * Can also be used to scale the roughness values of the metallic texture.
  53860. */
  53861. roughness: Nullable<number>;
  53862. /**
  53863. * Specifies the an F0 factor to help configuring the material F0.
  53864. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53865. * to 0.5 the previously hard coded value stays the same.
  53866. * Can also be used to scale the F0 values of the metallic texture.
  53867. */
  53868. metallicF0Factor: number;
  53869. /**
  53870. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53871. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53872. * your expectation as it multiplies with the texture data.
  53873. */
  53874. useMetallicF0FactorFromMetallicTexture: boolean;
  53875. /**
  53876. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53877. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53878. */
  53879. microSurfaceTexture: BaseTexture;
  53880. /**
  53881. * Stores surface normal data used to displace a mesh in a texture.
  53882. */
  53883. bumpTexture: BaseTexture;
  53884. /**
  53885. * Stores the pre-calculated light information of a mesh in a texture.
  53886. */
  53887. lightmapTexture: BaseTexture;
  53888. /**
  53889. * Stores the refracted light information in a texture.
  53890. */
  53891. get refractionTexture(): Nullable<BaseTexture>;
  53892. set refractionTexture(value: Nullable<BaseTexture>);
  53893. /**
  53894. * The color of a material in ambient lighting.
  53895. */
  53896. ambientColor: Color3;
  53897. /**
  53898. * AKA Diffuse Color in other nomenclature.
  53899. */
  53900. albedoColor: Color3;
  53901. /**
  53902. * AKA Specular Color in other nomenclature.
  53903. */
  53904. reflectivityColor: Color3;
  53905. /**
  53906. * The color reflected from the material.
  53907. */
  53908. reflectionColor: Color3;
  53909. /**
  53910. * The color emitted from the material.
  53911. */
  53912. emissiveColor: Color3;
  53913. /**
  53914. * AKA Glossiness in other nomenclature.
  53915. */
  53916. microSurface: number;
  53917. /**
  53918. * source material index of refraction (IOR)' / 'destination material IOR.
  53919. */
  53920. get indexOfRefraction(): number;
  53921. set indexOfRefraction(value: number);
  53922. /**
  53923. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53924. */
  53925. get invertRefractionY(): boolean;
  53926. set invertRefractionY(value: boolean);
  53927. /**
  53928. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53929. * Materials half opaque for instance using refraction could benefit from this control.
  53930. */
  53931. get linkRefractionWithTransparency(): boolean;
  53932. set linkRefractionWithTransparency(value: boolean);
  53933. /**
  53934. * If true, the light map contains occlusion information instead of lighting info.
  53935. */
  53936. useLightmapAsShadowmap: boolean;
  53937. /**
  53938. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53939. */
  53940. useAlphaFromAlbedoTexture: boolean;
  53941. /**
  53942. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53943. */
  53944. forceAlphaTest: boolean;
  53945. /**
  53946. * Defines the alpha limits in alpha test mode.
  53947. */
  53948. alphaCutOff: number;
  53949. /**
  53950. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53951. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53952. */
  53953. useSpecularOverAlpha: boolean;
  53954. /**
  53955. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53956. */
  53957. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53958. /**
  53959. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53960. */
  53961. useRoughnessFromMetallicTextureAlpha: boolean;
  53962. /**
  53963. * Specifies if the metallic texture contains the roughness information in its green channel.
  53964. */
  53965. useRoughnessFromMetallicTextureGreen: boolean;
  53966. /**
  53967. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53968. */
  53969. useMetallnessFromMetallicTextureBlue: boolean;
  53970. /**
  53971. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53972. */
  53973. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53974. /**
  53975. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53976. */
  53977. useAmbientInGrayScale: boolean;
  53978. /**
  53979. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53980. * The material will try to infer what glossiness each pixel should be.
  53981. */
  53982. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53983. /**
  53984. * BJS is using an harcoded light falloff based on a manually sets up range.
  53985. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53986. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53987. */
  53988. get usePhysicalLightFalloff(): boolean;
  53989. /**
  53990. * BJS is using an harcoded light falloff based on a manually sets up range.
  53991. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53992. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53993. */
  53994. set usePhysicalLightFalloff(value: boolean);
  53995. /**
  53996. * In order to support the falloff compatibility with gltf, a special mode has been added
  53997. * to reproduce the gltf light falloff.
  53998. */
  53999. get useGLTFLightFalloff(): boolean;
  54000. /**
  54001. * In order to support the falloff compatibility with gltf, a special mode has been added
  54002. * to reproduce the gltf light falloff.
  54003. */
  54004. set useGLTFLightFalloff(value: boolean);
  54005. /**
  54006. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54007. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54008. */
  54009. useRadianceOverAlpha: boolean;
  54010. /**
  54011. * Allows using an object space normal map (instead of tangent space).
  54012. */
  54013. useObjectSpaceNormalMap: boolean;
  54014. /**
  54015. * Allows using the bump map in parallax mode.
  54016. */
  54017. useParallax: boolean;
  54018. /**
  54019. * Allows using the bump map in parallax occlusion mode.
  54020. */
  54021. useParallaxOcclusion: boolean;
  54022. /**
  54023. * Controls the scale bias of the parallax mode.
  54024. */
  54025. parallaxScaleBias: number;
  54026. /**
  54027. * If sets to true, disables all the lights affecting the material.
  54028. */
  54029. disableLighting: boolean;
  54030. /**
  54031. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54032. */
  54033. forceIrradianceInFragment: boolean;
  54034. /**
  54035. * Number of Simultaneous lights allowed on the material.
  54036. */
  54037. maxSimultaneousLights: number;
  54038. /**
  54039. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54040. */
  54041. invertNormalMapX: boolean;
  54042. /**
  54043. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54044. */
  54045. invertNormalMapY: boolean;
  54046. /**
  54047. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54048. */
  54049. twoSidedLighting: boolean;
  54050. /**
  54051. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54052. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54053. */
  54054. useAlphaFresnel: boolean;
  54055. /**
  54056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54057. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54058. */
  54059. useLinearAlphaFresnel: boolean;
  54060. /**
  54061. * Let user defines the brdf lookup texture used for IBL.
  54062. * A default 8bit version is embedded but you could point at :
  54063. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54064. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54065. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54066. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54067. */
  54068. environmentBRDFTexture: Nullable<BaseTexture>;
  54069. /**
  54070. * Force normal to face away from face.
  54071. */
  54072. forceNormalForward: boolean;
  54073. /**
  54074. * Enables specular anti aliasing in the PBR shader.
  54075. * It will both interacts on the Geometry for analytical and IBL lighting.
  54076. * It also prefilter the roughness map based on the bump values.
  54077. */
  54078. enableSpecularAntiAliasing: boolean;
  54079. /**
  54080. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54081. * makes the reflect vector face the model (under horizon).
  54082. */
  54083. useHorizonOcclusion: boolean;
  54084. /**
  54085. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54086. * too much the area relying on ambient texture to define their ambient occlusion.
  54087. */
  54088. useRadianceOcclusion: boolean;
  54089. /**
  54090. * If set to true, no lighting calculations will be applied.
  54091. */
  54092. unlit: boolean;
  54093. /**
  54094. * Gets the image processing configuration used either in this material.
  54095. */
  54096. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54097. /**
  54098. * Sets the Default image processing configuration used either in the this material.
  54099. *
  54100. * If sets to null, the scene one is in use.
  54101. */
  54102. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54103. /**
  54104. * Gets wether the color curves effect is enabled.
  54105. */
  54106. get cameraColorCurvesEnabled(): boolean;
  54107. /**
  54108. * Sets wether the color curves effect is enabled.
  54109. */
  54110. set cameraColorCurvesEnabled(value: boolean);
  54111. /**
  54112. * Gets wether the color grading effect is enabled.
  54113. */
  54114. get cameraColorGradingEnabled(): boolean;
  54115. /**
  54116. * Gets wether the color grading effect is enabled.
  54117. */
  54118. set cameraColorGradingEnabled(value: boolean);
  54119. /**
  54120. * Gets wether tonemapping is enabled or not.
  54121. */
  54122. get cameraToneMappingEnabled(): boolean;
  54123. /**
  54124. * Sets wether tonemapping is enabled or not
  54125. */
  54126. set cameraToneMappingEnabled(value: boolean);
  54127. /**
  54128. * The camera exposure used on this material.
  54129. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54130. * This corresponds to a photographic exposure.
  54131. */
  54132. get cameraExposure(): number;
  54133. /**
  54134. * The camera exposure used on this material.
  54135. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54136. * This corresponds to a photographic exposure.
  54137. */
  54138. set cameraExposure(value: number);
  54139. /**
  54140. * Gets The camera contrast used on this material.
  54141. */
  54142. get cameraContrast(): number;
  54143. /**
  54144. * Sets The camera contrast used on this material.
  54145. */
  54146. set cameraContrast(value: number);
  54147. /**
  54148. * Gets the Color Grading 2D Lookup Texture.
  54149. */
  54150. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54151. /**
  54152. * Sets the Color Grading 2D Lookup Texture.
  54153. */
  54154. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54155. /**
  54156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54158. * 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;
  54159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54160. */
  54161. get cameraColorCurves(): Nullable<ColorCurves>;
  54162. /**
  54163. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54164. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54165. * 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;
  54166. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54167. */
  54168. set cameraColorCurves(value: Nullable<ColorCurves>);
  54169. /**
  54170. * Instantiates a new PBRMaterial instance.
  54171. *
  54172. * @param name The material name
  54173. * @param scene The scene the material will be use in.
  54174. */
  54175. constructor(name: string, scene: Scene);
  54176. /**
  54177. * Returns the name of this material class.
  54178. */
  54179. getClassName(): string;
  54180. /**
  54181. * Makes a duplicate of the current material.
  54182. * @param name - name to use for the new material.
  54183. */
  54184. clone(name: string): PBRMaterial;
  54185. /**
  54186. * Serializes this PBR Material.
  54187. * @returns - An object with the serialized material.
  54188. */
  54189. serialize(): any;
  54190. /**
  54191. * Parses a PBR Material from a serialized object.
  54192. * @param source - Serialized object.
  54193. * @param scene - BJS scene instance.
  54194. * @param rootUrl - url for the scene object
  54195. * @returns - PBRMaterial
  54196. */
  54197. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54198. }
  54199. }
  54200. declare module "babylonjs/Misc/dds" {
  54201. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54202. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54203. import { Nullable } from "babylonjs/types";
  54204. import { Scene } from "babylonjs/scene";
  54205. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54206. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54207. /**
  54208. * Direct draw surface info
  54209. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54210. */
  54211. export interface DDSInfo {
  54212. /**
  54213. * Width of the texture
  54214. */
  54215. width: number;
  54216. /**
  54217. * Width of the texture
  54218. */
  54219. height: number;
  54220. /**
  54221. * Number of Mipmaps for the texture
  54222. * @see https://en.wikipedia.org/wiki/Mipmap
  54223. */
  54224. mipmapCount: number;
  54225. /**
  54226. * If the textures format is a known fourCC format
  54227. * @see https://www.fourcc.org/
  54228. */
  54229. isFourCC: boolean;
  54230. /**
  54231. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54232. */
  54233. isRGB: boolean;
  54234. /**
  54235. * If the texture is a lumincance format
  54236. */
  54237. isLuminance: boolean;
  54238. /**
  54239. * If this is a cube texture
  54240. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54241. */
  54242. isCube: boolean;
  54243. /**
  54244. * If the texture is a compressed format eg. FOURCC_DXT1
  54245. */
  54246. isCompressed: boolean;
  54247. /**
  54248. * The dxgiFormat of the texture
  54249. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54250. */
  54251. dxgiFormat: number;
  54252. /**
  54253. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54254. */
  54255. textureType: number;
  54256. /**
  54257. * Sphericle polynomial created for the dds texture
  54258. */
  54259. sphericalPolynomial?: SphericalPolynomial;
  54260. }
  54261. /**
  54262. * Class used to provide DDS decompression tools
  54263. */
  54264. export class DDSTools {
  54265. /**
  54266. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54267. */
  54268. static StoreLODInAlphaChannel: boolean;
  54269. /**
  54270. * Gets DDS information from an array buffer
  54271. * @param data defines the array buffer view to read data from
  54272. * @returns the DDS information
  54273. */
  54274. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54275. private static _FloatView;
  54276. private static _Int32View;
  54277. private static _ToHalfFloat;
  54278. private static _FromHalfFloat;
  54279. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54280. private static _GetHalfFloatRGBAArrayBuffer;
  54281. private static _GetFloatRGBAArrayBuffer;
  54282. private static _GetFloatAsUIntRGBAArrayBuffer;
  54283. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54284. private static _GetRGBAArrayBuffer;
  54285. private static _ExtractLongWordOrder;
  54286. private static _GetRGBArrayBuffer;
  54287. private static _GetLuminanceArrayBuffer;
  54288. /**
  54289. * Uploads DDS Levels to a Babylon Texture
  54290. * @hidden
  54291. */
  54292. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54293. }
  54294. module "babylonjs/Engines/thinEngine" {
  54295. interface ThinEngine {
  54296. /**
  54297. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54298. * @param rootUrl defines the url where the file to load is located
  54299. * @param scene defines the current scene
  54300. * @param lodScale defines scale to apply to the mip map selection
  54301. * @param lodOffset defines offset to apply to the mip map selection
  54302. * @param onLoad defines an optional callback raised when the texture is loaded
  54303. * @param onError defines an optional callback raised if there is an issue to load the texture
  54304. * @param format defines the format of the data
  54305. * @param forcedExtension defines the extension to use to pick the right loader
  54306. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54307. * @returns the cube texture as an InternalTexture
  54308. */
  54309. 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;
  54310. }
  54311. }
  54312. }
  54313. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54314. import { Nullable } from "babylonjs/types";
  54315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54316. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54317. /**
  54318. * Implementation of the DDS Texture Loader.
  54319. * @hidden
  54320. */
  54321. export class _DDSTextureLoader implements IInternalTextureLoader {
  54322. /**
  54323. * Defines wether the loader supports cascade loading the different faces.
  54324. */
  54325. readonly supportCascades: boolean;
  54326. /**
  54327. * This returns if the loader support the current file information.
  54328. * @param extension defines the file extension of the file being loaded
  54329. * @returns true if the loader can load the specified file
  54330. */
  54331. canLoad(extension: string): boolean;
  54332. /**
  54333. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54334. * @param data contains the texture data
  54335. * @param texture defines the BabylonJS internal texture
  54336. * @param createPolynomials will be true if polynomials have been requested
  54337. * @param onLoad defines the callback to trigger once the texture is ready
  54338. * @param onError defines the callback to trigger in case of error
  54339. */
  54340. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54341. /**
  54342. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54343. * @param data contains the texture data
  54344. * @param texture defines the BabylonJS internal texture
  54345. * @param callback defines the method to call once ready to upload
  54346. */
  54347. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54348. }
  54349. }
  54350. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54351. import { Nullable } from "babylonjs/types";
  54352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54353. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54354. /**
  54355. * Implementation of the ENV Texture Loader.
  54356. * @hidden
  54357. */
  54358. export class _ENVTextureLoader implements IInternalTextureLoader {
  54359. /**
  54360. * Defines wether the loader supports cascade loading the different faces.
  54361. */
  54362. readonly supportCascades: boolean;
  54363. /**
  54364. * This returns if the loader support the current file information.
  54365. * @param extension defines the file extension of the file being loaded
  54366. * @returns true if the loader can load the specified file
  54367. */
  54368. canLoad(extension: string): boolean;
  54369. /**
  54370. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54371. * @param data contains the texture data
  54372. * @param texture defines the BabylonJS internal texture
  54373. * @param createPolynomials will be true if polynomials have been requested
  54374. * @param onLoad defines the callback to trigger once the texture is ready
  54375. * @param onError defines the callback to trigger in case of error
  54376. */
  54377. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54378. /**
  54379. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54380. * @param data contains the texture data
  54381. * @param texture defines the BabylonJS internal texture
  54382. * @param callback defines the method to call once ready to upload
  54383. */
  54384. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54385. }
  54386. }
  54387. declare module "babylonjs/Misc/khronosTextureContainer" {
  54388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54389. /**
  54390. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54391. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54392. */
  54393. export class KhronosTextureContainer {
  54394. /** contents of the KTX container file */
  54395. data: ArrayBufferView;
  54396. private static HEADER_LEN;
  54397. private static COMPRESSED_2D;
  54398. private static COMPRESSED_3D;
  54399. private static TEX_2D;
  54400. private static TEX_3D;
  54401. /**
  54402. * Gets the openGL type
  54403. */
  54404. glType: number;
  54405. /**
  54406. * Gets the openGL type size
  54407. */
  54408. glTypeSize: number;
  54409. /**
  54410. * Gets the openGL format
  54411. */
  54412. glFormat: number;
  54413. /**
  54414. * Gets the openGL internal format
  54415. */
  54416. glInternalFormat: number;
  54417. /**
  54418. * Gets the base internal format
  54419. */
  54420. glBaseInternalFormat: number;
  54421. /**
  54422. * Gets image width in pixel
  54423. */
  54424. pixelWidth: number;
  54425. /**
  54426. * Gets image height in pixel
  54427. */
  54428. pixelHeight: number;
  54429. /**
  54430. * Gets image depth in pixels
  54431. */
  54432. pixelDepth: number;
  54433. /**
  54434. * Gets the number of array elements
  54435. */
  54436. numberOfArrayElements: number;
  54437. /**
  54438. * Gets the number of faces
  54439. */
  54440. numberOfFaces: number;
  54441. /**
  54442. * Gets the number of mipmap levels
  54443. */
  54444. numberOfMipmapLevels: number;
  54445. /**
  54446. * Gets the bytes of key value data
  54447. */
  54448. bytesOfKeyValueData: number;
  54449. /**
  54450. * Gets the load type
  54451. */
  54452. loadType: number;
  54453. /**
  54454. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54455. */
  54456. isInvalid: boolean;
  54457. /**
  54458. * Creates a new KhronosTextureContainer
  54459. * @param data contents of the KTX container file
  54460. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54461. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54462. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54463. */
  54464. constructor(
  54465. /** contents of the KTX container file */
  54466. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54467. /**
  54468. * Uploads KTX content to a Babylon Texture.
  54469. * It is assumed that the texture has already been created & is currently bound
  54470. * @hidden
  54471. */
  54472. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54473. private _upload2DCompressedLevels;
  54474. /**
  54475. * Checks if the given data starts with a KTX file identifier.
  54476. * @param data the data to check
  54477. * @returns true if the data is a KTX file or false otherwise
  54478. */
  54479. static IsValid(data: ArrayBufferView): boolean;
  54480. }
  54481. }
  54482. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54484. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54485. /**
  54486. * Class for loading KTX2 files
  54487. * !!! Experimental Extension Subject to Changes !!!
  54488. * @hidden
  54489. */
  54490. export class KhronosTextureContainer2 {
  54491. private static _ModulePromise;
  54492. private static _TranscodeFormat;
  54493. constructor(engine: ThinEngine);
  54494. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54495. private _determineTranscodeFormat;
  54496. /**
  54497. * Checks if the given data starts with a KTX2 file identifier.
  54498. * @param data the data to check
  54499. * @returns true if the data is a KTX2 file or false otherwise
  54500. */
  54501. static IsValid(data: ArrayBufferView): boolean;
  54502. }
  54503. }
  54504. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54505. import { Nullable } from "babylonjs/types";
  54506. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54507. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54508. /**
  54509. * Implementation of the KTX Texture Loader.
  54510. * @hidden
  54511. */
  54512. export class _KTXTextureLoader implements IInternalTextureLoader {
  54513. /**
  54514. * Defines wether the loader supports cascade loading the different faces.
  54515. */
  54516. readonly supportCascades: boolean;
  54517. /**
  54518. * This returns if the loader support the current file information.
  54519. * @param extension defines the file extension of the file being loaded
  54520. * @returns true if the loader can load the specified file
  54521. */
  54522. canLoad(extension: string): boolean;
  54523. /**
  54524. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54525. * @param data contains the texture data
  54526. * @param texture defines the BabylonJS internal texture
  54527. * @param createPolynomials will be true if polynomials have been requested
  54528. * @param onLoad defines the callback to trigger once the texture is ready
  54529. * @param onError defines the callback to trigger in case of error
  54530. */
  54531. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54532. /**
  54533. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54534. * @param data contains the texture data
  54535. * @param texture defines the BabylonJS internal texture
  54536. * @param callback defines the method to call once ready to upload
  54537. */
  54538. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54539. }
  54540. }
  54541. declare module "babylonjs/Helpers/sceneHelpers" {
  54542. import { Nullable } from "babylonjs/types";
  54543. import { Mesh } from "babylonjs/Meshes/mesh";
  54544. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54545. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54546. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54547. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54548. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54549. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54550. import "babylonjs/Meshes/Builders/boxBuilder";
  54551. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54552. /** @hidden */
  54553. export var _forceSceneHelpersToBundle: boolean;
  54554. module "babylonjs/scene" {
  54555. interface Scene {
  54556. /**
  54557. * Creates a default light for the scene.
  54558. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54559. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54560. */
  54561. createDefaultLight(replace?: boolean): void;
  54562. /**
  54563. * Creates a default camera for the scene.
  54564. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54565. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54566. * @param replace has default false, when true replaces the active camera in the scene
  54567. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54568. */
  54569. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54570. /**
  54571. * Creates a default camera and a default light.
  54572. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54573. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54574. * @param replace has the default false, when true replaces the active camera/light in the scene
  54575. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54576. */
  54577. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54578. /**
  54579. * Creates a new sky box
  54580. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54581. * @param environmentTexture defines the texture to use as environment texture
  54582. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54583. * @param scale defines the overall scale of the skybox
  54584. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54585. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54586. * @returns a new mesh holding the sky box
  54587. */
  54588. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54589. /**
  54590. * Creates a new environment
  54591. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54592. * @param options defines the options you can use to configure the environment
  54593. * @returns the new EnvironmentHelper
  54594. */
  54595. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54596. /**
  54597. * Creates a new VREXperienceHelper
  54598. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54599. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54600. * @returns a new VREXperienceHelper
  54601. */
  54602. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54603. /**
  54604. * Creates a new WebXRDefaultExperience
  54605. * @see http://doc.babylonjs.com/how_to/webxr
  54606. * @param options experience options
  54607. * @returns a promise for a new WebXRDefaultExperience
  54608. */
  54609. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54610. }
  54611. }
  54612. }
  54613. declare module "babylonjs/Helpers/videoDome" {
  54614. import { Scene } from "babylonjs/scene";
  54615. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54616. import { Mesh } from "babylonjs/Meshes/mesh";
  54617. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54618. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54619. import "babylonjs/Meshes/Builders/sphereBuilder";
  54620. /**
  54621. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54622. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54623. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54624. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54625. */
  54626. export class VideoDome extends TransformNode {
  54627. /**
  54628. * Define the video source as a Monoscopic panoramic 360 video.
  54629. */
  54630. static readonly MODE_MONOSCOPIC: number;
  54631. /**
  54632. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54633. */
  54634. static readonly MODE_TOPBOTTOM: number;
  54635. /**
  54636. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54637. */
  54638. static readonly MODE_SIDEBYSIDE: number;
  54639. private _halfDome;
  54640. private _useDirectMapping;
  54641. /**
  54642. * The video texture being displayed on the sphere
  54643. */
  54644. protected _videoTexture: VideoTexture;
  54645. /**
  54646. * Gets the video texture being displayed on the sphere
  54647. */
  54648. get videoTexture(): VideoTexture;
  54649. /**
  54650. * The skybox material
  54651. */
  54652. protected _material: BackgroundMaterial;
  54653. /**
  54654. * The surface used for the skybox
  54655. */
  54656. protected _mesh: Mesh;
  54657. /**
  54658. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54659. */
  54660. private _halfDomeMask;
  54661. /**
  54662. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54663. * Also see the options.resolution property.
  54664. */
  54665. get fovMultiplier(): number;
  54666. set fovMultiplier(value: number);
  54667. private _videoMode;
  54668. /**
  54669. * Gets or set the current video mode for the video. It can be:
  54670. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54671. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54672. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54673. */
  54674. get videoMode(): number;
  54675. set videoMode(value: number);
  54676. /**
  54677. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54678. *
  54679. */
  54680. get halfDome(): boolean;
  54681. /**
  54682. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54683. */
  54684. set halfDome(enabled: boolean);
  54685. /**
  54686. * Oberserver used in Stereoscopic VR Mode.
  54687. */
  54688. private _onBeforeCameraRenderObserver;
  54689. /**
  54690. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54691. * @param name Element's name, child elements will append suffixes for their own names.
  54692. * @param urlsOrVideo defines the url(s) or the video element to use
  54693. * @param options An object containing optional or exposed sub element properties
  54694. */
  54695. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54696. resolution?: number;
  54697. clickToPlay?: boolean;
  54698. autoPlay?: boolean;
  54699. loop?: boolean;
  54700. size?: number;
  54701. poster?: string;
  54702. faceForward?: boolean;
  54703. useDirectMapping?: boolean;
  54704. halfDomeMode?: boolean;
  54705. }, scene: Scene);
  54706. private _changeVideoMode;
  54707. /**
  54708. * Releases resources associated with this node.
  54709. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54710. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54711. */
  54712. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54713. }
  54714. }
  54715. declare module "babylonjs/Helpers/index" {
  54716. export * from "babylonjs/Helpers/environmentHelper";
  54717. export * from "babylonjs/Helpers/photoDome";
  54718. export * from "babylonjs/Helpers/sceneHelpers";
  54719. export * from "babylonjs/Helpers/videoDome";
  54720. }
  54721. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54722. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54723. import { IDisposable } from "babylonjs/scene";
  54724. import { Engine } from "babylonjs/Engines/engine";
  54725. /**
  54726. * This class can be used to get instrumentation data from a Babylon engine
  54727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54728. */
  54729. export class EngineInstrumentation implements IDisposable {
  54730. /**
  54731. * Define the instrumented engine.
  54732. */
  54733. engine: Engine;
  54734. private _captureGPUFrameTime;
  54735. private _gpuFrameTimeToken;
  54736. private _gpuFrameTime;
  54737. private _captureShaderCompilationTime;
  54738. private _shaderCompilationTime;
  54739. private _onBeginFrameObserver;
  54740. private _onEndFrameObserver;
  54741. private _onBeforeShaderCompilationObserver;
  54742. private _onAfterShaderCompilationObserver;
  54743. /**
  54744. * Gets the perf counter used for GPU frame time
  54745. */
  54746. get gpuFrameTimeCounter(): PerfCounter;
  54747. /**
  54748. * Gets the GPU frame time capture status
  54749. */
  54750. get captureGPUFrameTime(): boolean;
  54751. /**
  54752. * Enable or disable the GPU frame time capture
  54753. */
  54754. set captureGPUFrameTime(value: boolean);
  54755. /**
  54756. * Gets the perf counter used for shader compilation time
  54757. */
  54758. get shaderCompilationTimeCounter(): PerfCounter;
  54759. /**
  54760. * Gets the shader compilation time capture status
  54761. */
  54762. get captureShaderCompilationTime(): boolean;
  54763. /**
  54764. * Enable or disable the shader compilation time capture
  54765. */
  54766. set captureShaderCompilationTime(value: boolean);
  54767. /**
  54768. * Instantiates a new engine instrumentation.
  54769. * This class can be used to get instrumentation data from a Babylon engine
  54770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54771. * @param engine Defines the engine to instrument
  54772. */
  54773. constructor(
  54774. /**
  54775. * Define the instrumented engine.
  54776. */
  54777. engine: Engine);
  54778. /**
  54779. * Dispose and release associated resources.
  54780. */
  54781. dispose(): void;
  54782. }
  54783. }
  54784. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54785. import { Scene, IDisposable } from "babylonjs/scene";
  54786. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54787. /**
  54788. * This class can be used to get instrumentation data from a Babylon engine
  54789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54790. */
  54791. export class SceneInstrumentation implements IDisposable {
  54792. /**
  54793. * Defines the scene to instrument
  54794. */
  54795. scene: Scene;
  54796. private _captureActiveMeshesEvaluationTime;
  54797. private _activeMeshesEvaluationTime;
  54798. private _captureRenderTargetsRenderTime;
  54799. private _renderTargetsRenderTime;
  54800. private _captureFrameTime;
  54801. private _frameTime;
  54802. private _captureRenderTime;
  54803. private _renderTime;
  54804. private _captureInterFrameTime;
  54805. private _interFrameTime;
  54806. private _captureParticlesRenderTime;
  54807. private _particlesRenderTime;
  54808. private _captureSpritesRenderTime;
  54809. private _spritesRenderTime;
  54810. private _capturePhysicsTime;
  54811. private _physicsTime;
  54812. private _captureAnimationsTime;
  54813. private _animationsTime;
  54814. private _captureCameraRenderTime;
  54815. private _cameraRenderTime;
  54816. private _onBeforeActiveMeshesEvaluationObserver;
  54817. private _onAfterActiveMeshesEvaluationObserver;
  54818. private _onBeforeRenderTargetsRenderObserver;
  54819. private _onAfterRenderTargetsRenderObserver;
  54820. private _onAfterRenderObserver;
  54821. private _onBeforeDrawPhaseObserver;
  54822. private _onAfterDrawPhaseObserver;
  54823. private _onBeforeAnimationsObserver;
  54824. private _onBeforeParticlesRenderingObserver;
  54825. private _onAfterParticlesRenderingObserver;
  54826. private _onBeforeSpritesRenderingObserver;
  54827. private _onAfterSpritesRenderingObserver;
  54828. private _onBeforePhysicsObserver;
  54829. private _onAfterPhysicsObserver;
  54830. private _onAfterAnimationsObserver;
  54831. private _onBeforeCameraRenderObserver;
  54832. private _onAfterCameraRenderObserver;
  54833. /**
  54834. * Gets the perf counter used for active meshes evaluation time
  54835. */
  54836. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54837. /**
  54838. * Gets the active meshes evaluation time capture status
  54839. */
  54840. get captureActiveMeshesEvaluationTime(): boolean;
  54841. /**
  54842. * Enable or disable the active meshes evaluation time capture
  54843. */
  54844. set captureActiveMeshesEvaluationTime(value: boolean);
  54845. /**
  54846. * Gets the perf counter used for render targets render time
  54847. */
  54848. get renderTargetsRenderTimeCounter(): PerfCounter;
  54849. /**
  54850. * Gets the render targets render time capture status
  54851. */
  54852. get captureRenderTargetsRenderTime(): boolean;
  54853. /**
  54854. * Enable or disable the render targets render time capture
  54855. */
  54856. set captureRenderTargetsRenderTime(value: boolean);
  54857. /**
  54858. * Gets the perf counter used for particles render time
  54859. */
  54860. get particlesRenderTimeCounter(): PerfCounter;
  54861. /**
  54862. * Gets the particles render time capture status
  54863. */
  54864. get captureParticlesRenderTime(): boolean;
  54865. /**
  54866. * Enable or disable the particles render time capture
  54867. */
  54868. set captureParticlesRenderTime(value: boolean);
  54869. /**
  54870. * Gets the perf counter used for sprites render time
  54871. */
  54872. get spritesRenderTimeCounter(): PerfCounter;
  54873. /**
  54874. * Gets the sprites render time capture status
  54875. */
  54876. get captureSpritesRenderTime(): boolean;
  54877. /**
  54878. * Enable or disable the sprites render time capture
  54879. */
  54880. set captureSpritesRenderTime(value: boolean);
  54881. /**
  54882. * Gets the perf counter used for physics time
  54883. */
  54884. get physicsTimeCounter(): PerfCounter;
  54885. /**
  54886. * Gets the physics time capture status
  54887. */
  54888. get capturePhysicsTime(): boolean;
  54889. /**
  54890. * Enable or disable the physics time capture
  54891. */
  54892. set capturePhysicsTime(value: boolean);
  54893. /**
  54894. * Gets the perf counter used for animations time
  54895. */
  54896. get animationsTimeCounter(): PerfCounter;
  54897. /**
  54898. * Gets the animations time capture status
  54899. */
  54900. get captureAnimationsTime(): boolean;
  54901. /**
  54902. * Enable or disable the animations time capture
  54903. */
  54904. set captureAnimationsTime(value: boolean);
  54905. /**
  54906. * Gets the perf counter used for frame time capture
  54907. */
  54908. get frameTimeCounter(): PerfCounter;
  54909. /**
  54910. * Gets the frame time capture status
  54911. */
  54912. get captureFrameTime(): boolean;
  54913. /**
  54914. * Enable or disable the frame time capture
  54915. */
  54916. set captureFrameTime(value: boolean);
  54917. /**
  54918. * Gets the perf counter used for inter-frames time capture
  54919. */
  54920. get interFrameTimeCounter(): PerfCounter;
  54921. /**
  54922. * Gets the inter-frames time capture status
  54923. */
  54924. get captureInterFrameTime(): boolean;
  54925. /**
  54926. * Enable or disable the inter-frames time capture
  54927. */
  54928. set captureInterFrameTime(value: boolean);
  54929. /**
  54930. * Gets the perf counter used for render time capture
  54931. */
  54932. get renderTimeCounter(): PerfCounter;
  54933. /**
  54934. * Gets the render time capture status
  54935. */
  54936. get captureRenderTime(): boolean;
  54937. /**
  54938. * Enable or disable the render time capture
  54939. */
  54940. set captureRenderTime(value: boolean);
  54941. /**
  54942. * Gets the perf counter used for camera render time capture
  54943. */
  54944. get cameraRenderTimeCounter(): PerfCounter;
  54945. /**
  54946. * Gets the camera render time capture status
  54947. */
  54948. get captureCameraRenderTime(): boolean;
  54949. /**
  54950. * Enable or disable the camera render time capture
  54951. */
  54952. set captureCameraRenderTime(value: boolean);
  54953. /**
  54954. * Gets the perf counter used for draw calls
  54955. */
  54956. get drawCallsCounter(): PerfCounter;
  54957. /**
  54958. * Instantiates a new scene instrumentation.
  54959. * This class can be used to get instrumentation data from a Babylon engine
  54960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54961. * @param scene Defines the scene to instrument
  54962. */
  54963. constructor(
  54964. /**
  54965. * Defines the scene to instrument
  54966. */
  54967. scene: Scene);
  54968. /**
  54969. * Dispose and release associated resources.
  54970. */
  54971. dispose(): void;
  54972. }
  54973. }
  54974. declare module "babylonjs/Instrumentation/index" {
  54975. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54976. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54977. export * from "babylonjs/Instrumentation/timeToken";
  54978. }
  54979. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54980. /** @hidden */
  54981. export var glowMapGenerationPixelShader: {
  54982. name: string;
  54983. shader: string;
  54984. };
  54985. }
  54986. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54987. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54990. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54994. /** @hidden */
  54995. export var glowMapGenerationVertexShader: {
  54996. name: string;
  54997. shader: string;
  54998. };
  54999. }
  55000. declare module "babylonjs/Layers/effectLayer" {
  55001. import { Observable } from "babylonjs/Misc/observable";
  55002. import { Nullable } from "babylonjs/types";
  55003. import { Camera } from "babylonjs/Cameras/camera";
  55004. import { Scene } from "babylonjs/scene";
  55005. import { ISize } from "babylonjs/Maths/math.size";
  55006. import { Color4 } from "babylonjs/Maths/math.color";
  55007. import { Engine } from "babylonjs/Engines/engine";
  55008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55010. import { Mesh } from "babylonjs/Meshes/mesh";
  55011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55014. import { Effect } from "babylonjs/Materials/effect";
  55015. import { Material } from "babylonjs/Materials/material";
  55016. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55017. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55018. /**
  55019. * Effect layer options. This helps customizing the behaviour
  55020. * of the effect layer.
  55021. */
  55022. export interface IEffectLayerOptions {
  55023. /**
  55024. * Multiplication factor apply to the canvas size to compute the render target size
  55025. * used to generated the objects (the smaller the faster).
  55026. */
  55027. mainTextureRatio: number;
  55028. /**
  55029. * Enforces a fixed size texture to ensure effect stability across devices.
  55030. */
  55031. mainTextureFixedSize?: number;
  55032. /**
  55033. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55034. */
  55035. alphaBlendingMode: number;
  55036. /**
  55037. * The camera attached to the layer.
  55038. */
  55039. camera: Nullable<Camera>;
  55040. /**
  55041. * The rendering group to draw the layer in.
  55042. */
  55043. renderingGroupId: number;
  55044. }
  55045. /**
  55046. * The effect layer Helps adding post process effect blended with the main pass.
  55047. *
  55048. * This can be for instance use to generate glow or higlight effects on the scene.
  55049. *
  55050. * The effect layer class can not be used directly and is intented to inherited from to be
  55051. * customized per effects.
  55052. */
  55053. export abstract class EffectLayer {
  55054. private _vertexBuffers;
  55055. private _indexBuffer;
  55056. private _cachedDefines;
  55057. private _effectLayerMapGenerationEffect;
  55058. private _effectLayerOptions;
  55059. private _mergeEffect;
  55060. protected _scene: Scene;
  55061. protected _engine: Engine;
  55062. protected _maxSize: number;
  55063. protected _mainTextureDesiredSize: ISize;
  55064. protected _mainTexture: RenderTargetTexture;
  55065. protected _shouldRender: boolean;
  55066. protected _postProcesses: PostProcess[];
  55067. protected _textures: BaseTexture[];
  55068. protected _emissiveTextureAndColor: {
  55069. texture: Nullable<BaseTexture>;
  55070. color: Color4;
  55071. };
  55072. /**
  55073. * The name of the layer
  55074. */
  55075. name: string;
  55076. /**
  55077. * The clear color of the texture used to generate the glow map.
  55078. */
  55079. neutralColor: Color4;
  55080. /**
  55081. * Specifies whether the highlight layer is enabled or not.
  55082. */
  55083. isEnabled: boolean;
  55084. /**
  55085. * Gets the camera attached to the layer.
  55086. */
  55087. get camera(): Nullable<Camera>;
  55088. /**
  55089. * Gets the rendering group id the layer should render in.
  55090. */
  55091. get renderingGroupId(): number;
  55092. set renderingGroupId(renderingGroupId: number);
  55093. /**
  55094. * An event triggered when the effect layer has been disposed.
  55095. */
  55096. onDisposeObservable: Observable<EffectLayer>;
  55097. /**
  55098. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55099. */
  55100. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55101. /**
  55102. * An event triggered when the generated texture is being merged in the scene.
  55103. */
  55104. onBeforeComposeObservable: Observable<EffectLayer>;
  55105. /**
  55106. * An event triggered when the mesh is rendered into the effect render target.
  55107. */
  55108. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55109. /**
  55110. * An event triggered after the mesh has been rendered into the effect render target.
  55111. */
  55112. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55113. /**
  55114. * An event triggered when the generated texture has been merged in the scene.
  55115. */
  55116. onAfterComposeObservable: Observable<EffectLayer>;
  55117. /**
  55118. * An event triggered when the efffect layer changes its size.
  55119. */
  55120. onSizeChangedObservable: Observable<EffectLayer>;
  55121. /** @hidden */
  55122. static _SceneComponentInitialization: (scene: Scene) => void;
  55123. /**
  55124. * Instantiates a new effect Layer and references it in the scene.
  55125. * @param name The name of the layer
  55126. * @param scene The scene to use the layer in
  55127. */
  55128. constructor(
  55129. /** The Friendly of the effect in the scene */
  55130. name: string, scene: Scene);
  55131. /**
  55132. * Get the effect name of the layer.
  55133. * @return The effect name
  55134. */
  55135. abstract getEffectName(): string;
  55136. /**
  55137. * Checks for the readiness of the element composing the layer.
  55138. * @param subMesh the mesh to check for
  55139. * @param useInstances specify whether or not to use instances to render the mesh
  55140. * @return true if ready otherwise, false
  55141. */
  55142. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55143. /**
  55144. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55145. * @returns true if the effect requires stencil during the main canvas render pass.
  55146. */
  55147. abstract needStencil(): boolean;
  55148. /**
  55149. * Create the merge effect. This is the shader use to blit the information back
  55150. * to the main canvas at the end of the scene rendering.
  55151. * @returns The effect containing the shader used to merge the effect on the main canvas
  55152. */
  55153. protected abstract _createMergeEffect(): Effect;
  55154. /**
  55155. * Creates the render target textures and post processes used in the effect layer.
  55156. */
  55157. protected abstract _createTextureAndPostProcesses(): void;
  55158. /**
  55159. * Implementation specific of rendering the generating effect on the main canvas.
  55160. * @param effect The effect used to render through
  55161. */
  55162. protected abstract _internalRender(effect: Effect): void;
  55163. /**
  55164. * Sets the required values for both the emissive texture and and the main color.
  55165. */
  55166. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55167. /**
  55168. * Free any resources and references associated to a mesh.
  55169. * Internal use
  55170. * @param mesh The mesh to free.
  55171. */
  55172. abstract _disposeMesh(mesh: Mesh): void;
  55173. /**
  55174. * Serializes this layer (Glow or Highlight for example)
  55175. * @returns a serialized layer object
  55176. */
  55177. abstract serialize?(): any;
  55178. /**
  55179. * Initializes the effect layer with the required options.
  55180. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55181. */
  55182. protected _init(options: Partial<IEffectLayerOptions>): void;
  55183. /**
  55184. * Generates the index buffer of the full screen quad blending to the main canvas.
  55185. */
  55186. private _generateIndexBuffer;
  55187. /**
  55188. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55189. */
  55190. private _generateVertexBuffer;
  55191. /**
  55192. * Sets the main texture desired size which is the closest power of two
  55193. * of the engine canvas size.
  55194. */
  55195. private _setMainTextureSize;
  55196. /**
  55197. * Creates the main texture for the effect layer.
  55198. */
  55199. protected _createMainTexture(): void;
  55200. /**
  55201. * Adds specific effects defines.
  55202. * @param defines The defines to add specifics to.
  55203. */
  55204. protected _addCustomEffectDefines(defines: string[]): void;
  55205. /**
  55206. * Checks for the readiness of the element composing the layer.
  55207. * @param subMesh the mesh to check for
  55208. * @param useInstances specify whether or not to use instances to render the mesh
  55209. * @param emissiveTexture the associated emissive texture used to generate the glow
  55210. * @return true if ready otherwise, false
  55211. */
  55212. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55213. /**
  55214. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55215. */
  55216. render(): void;
  55217. /**
  55218. * Determine if a given mesh will be used in the current effect.
  55219. * @param mesh mesh to test
  55220. * @returns true if the mesh will be used
  55221. */
  55222. hasMesh(mesh: AbstractMesh): boolean;
  55223. /**
  55224. * Returns true if the layer contains information to display, otherwise false.
  55225. * @returns true if the glow layer should be rendered
  55226. */
  55227. shouldRender(): boolean;
  55228. /**
  55229. * Returns true if the mesh should render, otherwise false.
  55230. * @param mesh The mesh to render
  55231. * @returns true if it should render otherwise false
  55232. */
  55233. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55234. /**
  55235. * Returns true if the mesh can be rendered, otherwise false.
  55236. * @param mesh The mesh to render
  55237. * @param material The material used on the mesh
  55238. * @returns true if it can be rendered otherwise false
  55239. */
  55240. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55241. /**
  55242. * Returns true if the mesh should render, otherwise false.
  55243. * @param mesh The mesh to render
  55244. * @returns true if it should render otherwise false
  55245. */
  55246. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55247. /**
  55248. * Renders the submesh passed in parameter to the generation map.
  55249. */
  55250. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55251. /**
  55252. * Defines whether the current material of the mesh should be use to render the effect.
  55253. * @param mesh defines the current mesh to render
  55254. */
  55255. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55256. /**
  55257. * Rebuild the required buffers.
  55258. * @hidden Internal use only.
  55259. */
  55260. _rebuild(): void;
  55261. /**
  55262. * Dispose only the render target textures and post process.
  55263. */
  55264. private _disposeTextureAndPostProcesses;
  55265. /**
  55266. * Dispose the highlight layer and free resources.
  55267. */
  55268. dispose(): void;
  55269. /**
  55270. * Gets the class name of the effect layer
  55271. * @returns the string with the class name of the effect layer
  55272. */
  55273. getClassName(): string;
  55274. /**
  55275. * Creates an effect layer from parsed effect layer data
  55276. * @param parsedEffectLayer defines effect layer data
  55277. * @param scene defines the current scene
  55278. * @param rootUrl defines the root URL containing the effect layer information
  55279. * @returns a parsed effect Layer
  55280. */
  55281. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55282. }
  55283. }
  55284. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55285. import { Scene } from "babylonjs/scene";
  55286. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55287. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55288. import { AbstractScene } from "babylonjs/abstractScene";
  55289. module "babylonjs/abstractScene" {
  55290. interface AbstractScene {
  55291. /**
  55292. * The list of effect layers (highlights/glow) added to the scene
  55293. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55294. * @see http://doc.babylonjs.com/how_to/glow_layer
  55295. */
  55296. effectLayers: Array<EffectLayer>;
  55297. /**
  55298. * Removes the given effect layer from this scene.
  55299. * @param toRemove defines the effect layer to remove
  55300. * @returns the index of the removed effect layer
  55301. */
  55302. removeEffectLayer(toRemove: EffectLayer): number;
  55303. /**
  55304. * Adds the given effect layer to this scene
  55305. * @param newEffectLayer defines the effect layer to add
  55306. */
  55307. addEffectLayer(newEffectLayer: EffectLayer): void;
  55308. }
  55309. }
  55310. /**
  55311. * Defines the layer scene component responsible to manage any effect layers
  55312. * in a given scene.
  55313. */
  55314. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55315. /**
  55316. * The component name helpfull to identify the component in the list of scene components.
  55317. */
  55318. readonly name: string;
  55319. /**
  55320. * The scene the component belongs to.
  55321. */
  55322. scene: Scene;
  55323. private _engine;
  55324. private _renderEffects;
  55325. private _needStencil;
  55326. private _previousStencilState;
  55327. /**
  55328. * Creates a new instance of the component for the given scene
  55329. * @param scene Defines the scene to register the component in
  55330. */
  55331. constructor(scene: Scene);
  55332. /**
  55333. * Registers the component in a given scene
  55334. */
  55335. register(): void;
  55336. /**
  55337. * Rebuilds the elements related to this component in case of
  55338. * context lost for instance.
  55339. */
  55340. rebuild(): void;
  55341. /**
  55342. * Serializes the component data to the specified json object
  55343. * @param serializationObject The object to serialize to
  55344. */
  55345. serialize(serializationObject: any): void;
  55346. /**
  55347. * Adds all the elements from the container to the scene
  55348. * @param container the container holding the elements
  55349. */
  55350. addFromContainer(container: AbstractScene): void;
  55351. /**
  55352. * Removes all the elements in the container from the scene
  55353. * @param container contains the elements to remove
  55354. * @param dispose if the removed element should be disposed (default: false)
  55355. */
  55356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55357. /**
  55358. * Disposes the component and the associated ressources.
  55359. */
  55360. dispose(): void;
  55361. private _isReadyForMesh;
  55362. private _renderMainTexture;
  55363. private _setStencil;
  55364. private _setStencilBack;
  55365. private _draw;
  55366. private _drawCamera;
  55367. private _drawRenderingGroup;
  55368. }
  55369. }
  55370. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55371. /** @hidden */
  55372. export var glowMapMergePixelShader: {
  55373. name: string;
  55374. shader: string;
  55375. };
  55376. }
  55377. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55378. /** @hidden */
  55379. export var glowMapMergeVertexShader: {
  55380. name: string;
  55381. shader: string;
  55382. };
  55383. }
  55384. declare module "babylonjs/Layers/glowLayer" {
  55385. import { Nullable } from "babylonjs/types";
  55386. import { Camera } from "babylonjs/Cameras/camera";
  55387. import { Scene } from "babylonjs/scene";
  55388. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55390. import { Mesh } from "babylonjs/Meshes/mesh";
  55391. import { Texture } from "babylonjs/Materials/Textures/texture";
  55392. import { Effect } from "babylonjs/Materials/effect";
  55393. import { Material } from "babylonjs/Materials/material";
  55394. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55395. import { Color4 } from "babylonjs/Maths/math.color";
  55396. import "babylonjs/Shaders/glowMapMerge.fragment";
  55397. import "babylonjs/Shaders/glowMapMerge.vertex";
  55398. import "babylonjs/Layers/effectLayerSceneComponent";
  55399. module "babylonjs/abstractScene" {
  55400. interface AbstractScene {
  55401. /**
  55402. * Return a the first highlight layer of the scene with a given name.
  55403. * @param name The name of the highlight layer to look for.
  55404. * @return The highlight layer if found otherwise null.
  55405. */
  55406. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55407. }
  55408. }
  55409. /**
  55410. * Glow layer options. This helps customizing the behaviour
  55411. * of the glow layer.
  55412. */
  55413. export interface IGlowLayerOptions {
  55414. /**
  55415. * Multiplication factor apply to the canvas size to compute the render target size
  55416. * used to generated the glowing objects (the smaller the faster).
  55417. */
  55418. mainTextureRatio: number;
  55419. /**
  55420. * Enforces a fixed size texture to ensure resize independant blur.
  55421. */
  55422. mainTextureFixedSize?: number;
  55423. /**
  55424. * How big is the kernel of the blur texture.
  55425. */
  55426. blurKernelSize: number;
  55427. /**
  55428. * The camera attached to the layer.
  55429. */
  55430. camera: Nullable<Camera>;
  55431. /**
  55432. * Enable MSAA by chosing the number of samples.
  55433. */
  55434. mainTextureSamples?: number;
  55435. /**
  55436. * The rendering group to draw the layer in.
  55437. */
  55438. renderingGroupId: number;
  55439. }
  55440. /**
  55441. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55442. *
  55443. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55444. *
  55445. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55446. */
  55447. export class GlowLayer extends EffectLayer {
  55448. /**
  55449. * Effect Name of the layer.
  55450. */
  55451. static readonly EffectName: string;
  55452. /**
  55453. * The default blur kernel size used for the glow.
  55454. */
  55455. static DefaultBlurKernelSize: number;
  55456. /**
  55457. * The default texture size ratio used for the glow.
  55458. */
  55459. static DefaultTextureRatio: number;
  55460. /**
  55461. * Sets the kernel size of the blur.
  55462. */
  55463. set blurKernelSize(value: number);
  55464. /**
  55465. * Gets the kernel size of the blur.
  55466. */
  55467. get blurKernelSize(): number;
  55468. /**
  55469. * Sets the glow intensity.
  55470. */
  55471. set intensity(value: number);
  55472. /**
  55473. * Gets the glow intensity.
  55474. */
  55475. get intensity(): number;
  55476. private _options;
  55477. private _intensity;
  55478. private _horizontalBlurPostprocess1;
  55479. private _verticalBlurPostprocess1;
  55480. private _horizontalBlurPostprocess2;
  55481. private _verticalBlurPostprocess2;
  55482. private _blurTexture1;
  55483. private _blurTexture2;
  55484. private _postProcesses1;
  55485. private _postProcesses2;
  55486. private _includedOnlyMeshes;
  55487. private _excludedMeshes;
  55488. private _meshesUsingTheirOwnMaterials;
  55489. /**
  55490. * Callback used to let the user override the color selection on a per mesh basis
  55491. */
  55492. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55493. /**
  55494. * Callback used to let the user override the texture selection on a per mesh basis
  55495. */
  55496. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55497. /**
  55498. * Instantiates a new glow Layer and references it to the scene.
  55499. * @param name The name of the layer
  55500. * @param scene The scene to use the layer in
  55501. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55502. */
  55503. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55504. /**
  55505. * Get the effect name of the layer.
  55506. * @return The effect name
  55507. */
  55508. getEffectName(): string;
  55509. /**
  55510. * Create the merge effect. This is the shader use to blit the information back
  55511. * to the main canvas at the end of the scene rendering.
  55512. */
  55513. protected _createMergeEffect(): Effect;
  55514. /**
  55515. * Creates the render target textures and post processes used in the glow layer.
  55516. */
  55517. protected _createTextureAndPostProcesses(): void;
  55518. /**
  55519. * Checks for the readiness of the element composing the layer.
  55520. * @param subMesh the mesh to check for
  55521. * @param useInstances specify wether or not to use instances to render the mesh
  55522. * @param emissiveTexture the associated emissive texture used to generate the glow
  55523. * @return true if ready otherwise, false
  55524. */
  55525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55526. /**
  55527. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55528. */
  55529. needStencil(): boolean;
  55530. /**
  55531. * Returns true if the mesh can be rendered, otherwise false.
  55532. * @param mesh The mesh to render
  55533. * @param material The material used on the mesh
  55534. * @returns true if it can be rendered otherwise false
  55535. */
  55536. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55537. /**
  55538. * Implementation specific of rendering the generating effect on the main canvas.
  55539. * @param effect The effect used to render through
  55540. */
  55541. protected _internalRender(effect: Effect): void;
  55542. /**
  55543. * Sets the required values for both the emissive texture and and the main color.
  55544. */
  55545. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55546. /**
  55547. * Returns true if the mesh should render, otherwise false.
  55548. * @param mesh The mesh to render
  55549. * @returns true if it should render otherwise false
  55550. */
  55551. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55552. /**
  55553. * Adds specific effects defines.
  55554. * @param defines The defines to add specifics to.
  55555. */
  55556. protected _addCustomEffectDefines(defines: string[]): void;
  55557. /**
  55558. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55559. * @param mesh The mesh to exclude from the glow layer
  55560. */
  55561. addExcludedMesh(mesh: Mesh): void;
  55562. /**
  55563. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55564. * @param mesh The mesh to remove
  55565. */
  55566. removeExcludedMesh(mesh: Mesh): void;
  55567. /**
  55568. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55569. * @param mesh The mesh to include in the glow layer
  55570. */
  55571. addIncludedOnlyMesh(mesh: Mesh): void;
  55572. /**
  55573. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55574. * @param mesh The mesh to remove
  55575. */
  55576. removeIncludedOnlyMesh(mesh: Mesh): void;
  55577. /**
  55578. * Determine if a given mesh will be used in the glow layer
  55579. * @param mesh The mesh to test
  55580. * @returns true if the mesh will be highlighted by the current glow layer
  55581. */
  55582. hasMesh(mesh: AbstractMesh): boolean;
  55583. /**
  55584. * Defines whether the current material of the mesh should be use to render the effect.
  55585. * @param mesh defines the current mesh to render
  55586. */
  55587. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55588. /**
  55589. * Add a mesh to be rendered through its own material and not with emissive only.
  55590. * @param mesh The mesh for which we need to use its material
  55591. */
  55592. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55593. /**
  55594. * Remove a mesh from being rendered through its own material and not with emissive only.
  55595. * @param mesh The mesh for which we need to not use its material
  55596. */
  55597. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55598. /**
  55599. * Free any resources and references associated to a mesh.
  55600. * Internal use
  55601. * @param mesh The mesh to free.
  55602. * @hidden
  55603. */
  55604. _disposeMesh(mesh: Mesh): void;
  55605. /**
  55606. * Gets the class name of the effect layer
  55607. * @returns the string with the class name of the effect layer
  55608. */
  55609. getClassName(): string;
  55610. /**
  55611. * Serializes this glow layer
  55612. * @returns a serialized glow layer object
  55613. */
  55614. serialize(): any;
  55615. /**
  55616. * Creates a Glow Layer from parsed glow layer data
  55617. * @param parsedGlowLayer defines glow layer data
  55618. * @param scene defines the current scene
  55619. * @param rootUrl defines the root URL containing the glow layer information
  55620. * @returns a parsed Glow Layer
  55621. */
  55622. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55623. }
  55624. }
  55625. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55626. /** @hidden */
  55627. export var glowBlurPostProcessPixelShader: {
  55628. name: string;
  55629. shader: string;
  55630. };
  55631. }
  55632. declare module "babylonjs/Layers/highlightLayer" {
  55633. import { Observable } from "babylonjs/Misc/observable";
  55634. import { Nullable } from "babylonjs/types";
  55635. import { Camera } from "babylonjs/Cameras/camera";
  55636. import { Scene } from "babylonjs/scene";
  55637. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55639. import { Mesh } from "babylonjs/Meshes/mesh";
  55640. import { Effect } from "babylonjs/Materials/effect";
  55641. import { Material } from "babylonjs/Materials/material";
  55642. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55643. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55644. import "babylonjs/Shaders/glowMapMerge.fragment";
  55645. import "babylonjs/Shaders/glowMapMerge.vertex";
  55646. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55647. module "babylonjs/abstractScene" {
  55648. interface AbstractScene {
  55649. /**
  55650. * Return a the first highlight layer of the scene with a given name.
  55651. * @param name The name of the highlight layer to look for.
  55652. * @return The highlight layer if found otherwise null.
  55653. */
  55654. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55655. }
  55656. }
  55657. /**
  55658. * Highlight layer options. This helps customizing the behaviour
  55659. * of the highlight layer.
  55660. */
  55661. export interface IHighlightLayerOptions {
  55662. /**
  55663. * Multiplication factor apply to the canvas size to compute the render target size
  55664. * used to generated the glowing objects (the smaller the faster).
  55665. */
  55666. mainTextureRatio: number;
  55667. /**
  55668. * Enforces a fixed size texture to ensure resize independant blur.
  55669. */
  55670. mainTextureFixedSize?: number;
  55671. /**
  55672. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55673. * of the picture to blur (the smaller the faster).
  55674. */
  55675. blurTextureSizeRatio: number;
  55676. /**
  55677. * How big in texel of the blur texture is the vertical blur.
  55678. */
  55679. blurVerticalSize: number;
  55680. /**
  55681. * How big in texel of the blur texture is the horizontal blur.
  55682. */
  55683. blurHorizontalSize: number;
  55684. /**
  55685. * Alpha blending mode used to apply the blur. Default is combine.
  55686. */
  55687. alphaBlendingMode: number;
  55688. /**
  55689. * The camera attached to the layer.
  55690. */
  55691. camera: Nullable<Camera>;
  55692. /**
  55693. * Should we display highlight as a solid stroke?
  55694. */
  55695. isStroke?: boolean;
  55696. /**
  55697. * The rendering group to draw the layer in.
  55698. */
  55699. renderingGroupId: number;
  55700. }
  55701. /**
  55702. * The highlight layer Helps adding a glow effect around a mesh.
  55703. *
  55704. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55705. * glowy meshes to your scene.
  55706. *
  55707. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55708. */
  55709. export class HighlightLayer extends EffectLayer {
  55710. name: string;
  55711. /**
  55712. * Effect Name of the highlight layer.
  55713. */
  55714. static readonly EffectName: string;
  55715. /**
  55716. * The neutral color used during the preparation of the glow effect.
  55717. * This is black by default as the blend operation is a blend operation.
  55718. */
  55719. static NeutralColor: Color4;
  55720. /**
  55721. * Stencil value used for glowing meshes.
  55722. */
  55723. static GlowingMeshStencilReference: number;
  55724. /**
  55725. * Stencil value used for the other meshes in the scene.
  55726. */
  55727. static NormalMeshStencilReference: number;
  55728. /**
  55729. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55730. */
  55731. innerGlow: boolean;
  55732. /**
  55733. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55734. */
  55735. outerGlow: boolean;
  55736. /**
  55737. * Specifies the horizontal size of the blur.
  55738. */
  55739. set blurHorizontalSize(value: number);
  55740. /**
  55741. * Specifies the vertical size of the blur.
  55742. */
  55743. set blurVerticalSize(value: number);
  55744. /**
  55745. * Gets the horizontal size of the blur.
  55746. */
  55747. get blurHorizontalSize(): number;
  55748. /**
  55749. * Gets the vertical size of the blur.
  55750. */
  55751. get blurVerticalSize(): number;
  55752. /**
  55753. * An event triggered when the highlight layer is being blurred.
  55754. */
  55755. onBeforeBlurObservable: Observable<HighlightLayer>;
  55756. /**
  55757. * An event triggered when the highlight layer has been blurred.
  55758. */
  55759. onAfterBlurObservable: Observable<HighlightLayer>;
  55760. private _instanceGlowingMeshStencilReference;
  55761. private _options;
  55762. private _downSamplePostprocess;
  55763. private _horizontalBlurPostprocess;
  55764. private _verticalBlurPostprocess;
  55765. private _blurTexture;
  55766. private _meshes;
  55767. private _excludedMeshes;
  55768. /**
  55769. * Instantiates a new highlight Layer and references it to the scene..
  55770. * @param name The name of the layer
  55771. * @param scene The scene to use the layer in
  55772. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55773. */
  55774. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55775. /**
  55776. * Get the effect name of the layer.
  55777. * @return The effect name
  55778. */
  55779. getEffectName(): string;
  55780. /**
  55781. * Create the merge effect. This is the shader use to blit the information back
  55782. * to the main canvas at the end of the scene rendering.
  55783. */
  55784. protected _createMergeEffect(): Effect;
  55785. /**
  55786. * Creates the render target textures and post processes used in the highlight layer.
  55787. */
  55788. protected _createTextureAndPostProcesses(): void;
  55789. /**
  55790. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55791. */
  55792. needStencil(): boolean;
  55793. /**
  55794. * Checks for the readiness of the element composing the layer.
  55795. * @param subMesh the mesh to check for
  55796. * @param useInstances specify wether or not to use instances to render the mesh
  55797. * @param emissiveTexture the associated emissive texture used to generate the glow
  55798. * @return true if ready otherwise, false
  55799. */
  55800. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55801. /**
  55802. * Implementation specific of rendering the generating effect on the main canvas.
  55803. * @param effect The effect used to render through
  55804. */
  55805. protected _internalRender(effect: Effect): void;
  55806. /**
  55807. * Returns true if the layer contains information to display, otherwise false.
  55808. */
  55809. shouldRender(): boolean;
  55810. /**
  55811. * Returns true if the mesh should render, otherwise false.
  55812. * @param mesh The mesh to render
  55813. * @returns true if it should render otherwise false
  55814. */
  55815. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55816. /**
  55817. * Sets the required values for both the emissive texture and and the main color.
  55818. */
  55819. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55820. /**
  55821. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55822. * @param mesh The mesh to exclude from the highlight layer
  55823. */
  55824. addExcludedMesh(mesh: Mesh): void;
  55825. /**
  55826. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55827. * @param mesh The mesh to highlight
  55828. */
  55829. removeExcludedMesh(mesh: Mesh): void;
  55830. /**
  55831. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55832. * @param mesh mesh to test
  55833. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55834. */
  55835. hasMesh(mesh: AbstractMesh): boolean;
  55836. /**
  55837. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55838. * @param mesh The mesh to highlight
  55839. * @param color The color of the highlight
  55840. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55841. */
  55842. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55843. /**
  55844. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55845. * @param mesh The mesh to highlight
  55846. */
  55847. removeMesh(mesh: Mesh): void;
  55848. /**
  55849. * Remove all the meshes currently referenced in the highlight layer
  55850. */
  55851. removeAllMeshes(): void;
  55852. /**
  55853. * Force the stencil to the normal expected value for none glowing parts
  55854. */
  55855. private _defaultStencilReference;
  55856. /**
  55857. * Free any resources and references associated to a mesh.
  55858. * Internal use
  55859. * @param mesh The mesh to free.
  55860. * @hidden
  55861. */
  55862. _disposeMesh(mesh: Mesh): void;
  55863. /**
  55864. * Dispose the highlight layer and free resources.
  55865. */
  55866. dispose(): void;
  55867. /**
  55868. * Gets the class name of the effect layer
  55869. * @returns the string with the class name of the effect layer
  55870. */
  55871. getClassName(): string;
  55872. /**
  55873. * Serializes this Highlight layer
  55874. * @returns a serialized Highlight layer object
  55875. */
  55876. serialize(): any;
  55877. /**
  55878. * Creates a Highlight layer from parsed Highlight layer data
  55879. * @param parsedHightlightLayer defines the Highlight layer data
  55880. * @param scene defines the current scene
  55881. * @param rootUrl defines the root URL containing the Highlight layer information
  55882. * @returns a parsed Highlight layer
  55883. */
  55884. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55885. }
  55886. }
  55887. declare module "babylonjs/Layers/layerSceneComponent" {
  55888. import { Scene } from "babylonjs/scene";
  55889. import { ISceneComponent } from "babylonjs/sceneComponent";
  55890. import { Layer } from "babylonjs/Layers/layer";
  55891. import { AbstractScene } from "babylonjs/abstractScene";
  55892. module "babylonjs/abstractScene" {
  55893. interface AbstractScene {
  55894. /**
  55895. * The list of layers (background and foreground) of the scene
  55896. */
  55897. layers: Array<Layer>;
  55898. }
  55899. }
  55900. /**
  55901. * Defines the layer scene component responsible to manage any layers
  55902. * in a given scene.
  55903. */
  55904. export class LayerSceneComponent implements ISceneComponent {
  55905. /**
  55906. * The component name helpfull to identify the component in the list of scene components.
  55907. */
  55908. readonly name: string;
  55909. /**
  55910. * The scene the component belongs to.
  55911. */
  55912. scene: Scene;
  55913. private _engine;
  55914. /**
  55915. * Creates a new instance of the component for the given scene
  55916. * @param scene Defines the scene to register the component in
  55917. */
  55918. constructor(scene: Scene);
  55919. /**
  55920. * Registers the component in a given scene
  55921. */
  55922. register(): void;
  55923. /**
  55924. * Rebuilds the elements related to this component in case of
  55925. * context lost for instance.
  55926. */
  55927. rebuild(): void;
  55928. /**
  55929. * Disposes the component and the associated ressources.
  55930. */
  55931. dispose(): void;
  55932. private _draw;
  55933. private _drawCameraPredicate;
  55934. private _drawCameraBackground;
  55935. private _drawCameraForeground;
  55936. private _drawRenderTargetPredicate;
  55937. private _drawRenderTargetBackground;
  55938. private _drawRenderTargetForeground;
  55939. /**
  55940. * Adds all the elements from the container to the scene
  55941. * @param container the container holding the elements
  55942. */
  55943. addFromContainer(container: AbstractScene): void;
  55944. /**
  55945. * Removes all the elements in the container from the scene
  55946. * @param container contains the elements to remove
  55947. * @param dispose if the removed element should be disposed (default: false)
  55948. */
  55949. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55950. }
  55951. }
  55952. declare module "babylonjs/Shaders/layer.fragment" {
  55953. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55954. /** @hidden */
  55955. export var layerPixelShader: {
  55956. name: string;
  55957. shader: string;
  55958. };
  55959. }
  55960. declare module "babylonjs/Shaders/layer.vertex" {
  55961. /** @hidden */
  55962. export var layerVertexShader: {
  55963. name: string;
  55964. shader: string;
  55965. };
  55966. }
  55967. declare module "babylonjs/Layers/layer" {
  55968. import { Observable } from "babylonjs/Misc/observable";
  55969. import { Nullable } from "babylonjs/types";
  55970. import { Scene } from "babylonjs/scene";
  55971. import { Vector2 } from "babylonjs/Maths/math.vector";
  55972. import { Color4 } from "babylonjs/Maths/math.color";
  55973. import { Texture } from "babylonjs/Materials/Textures/texture";
  55974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55975. import "babylonjs/Shaders/layer.fragment";
  55976. import "babylonjs/Shaders/layer.vertex";
  55977. /**
  55978. * This represents a full screen 2d layer.
  55979. * This can be useful to display a picture in the background of your scene for instance.
  55980. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55981. */
  55982. export class Layer {
  55983. /**
  55984. * Define the name of the layer.
  55985. */
  55986. name: string;
  55987. /**
  55988. * Define the texture the layer should display.
  55989. */
  55990. texture: Nullable<Texture>;
  55991. /**
  55992. * Is the layer in background or foreground.
  55993. */
  55994. isBackground: boolean;
  55995. /**
  55996. * Define the color of the layer (instead of texture).
  55997. */
  55998. color: Color4;
  55999. /**
  56000. * Define the scale of the layer in order to zoom in out of the texture.
  56001. */
  56002. scale: Vector2;
  56003. /**
  56004. * Define an offset for the layer in order to shift the texture.
  56005. */
  56006. offset: Vector2;
  56007. /**
  56008. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56009. */
  56010. alphaBlendingMode: number;
  56011. /**
  56012. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56013. * Alpha test will not mix with the background color in case of transparency.
  56014. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56015. */
  56016. alphaTest: boolean;
  56017. /**
  56018. * Define a mask to restrict the layer to only some of the scene cameras.
  56019. */
  56020. layerMask: number;
  56021. /**
  56022. * Define the list of render target the layer is visible into.
  56023. */
  56024. renderTargetTextures: RenderTargetTexture[];
  56025. /**
  56026. * Define if the layer is only used in renderTarget or if it also
  56027. * renders in the main frame buffer of the canvas.
  56028. */
  56029. renderOnlyInRenderTargetTextures: boolean;
  56030. private _scene;
  56031. private _vertexBuffers;
  56032. private _indexBuffer;
  56033. private _effect;
  56034. private _previousDefines;
  56035. /**
  56036. * An event triggered when the layer is disposed.
  56037. */
  56038. onDisposeObservable: Observable<Layer>;
  56039. private _onDisposeObserver;
  56040. /**
  56041. * Back compatibility with callback before the onDisposeObservable existed.
  56042. * The set callback will be triggered when the layer has been disposed.
  56043. */
  56044. set onDispose(callback: () => void);
  56045. /**
  56046. * An event triggered before rendering the scene
  56047. */
  56048. onBeforeRenderObservable: Observable<Layer>;
  56049. private _onBeforeRenderObserver;
  56050. /**
  56051. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56052. * The set callback will be triggered just before rendering the layer.
  56053. */
  56054. set onBeforeRender(callback: () => void);
  56055. /**
  56056. * An event triggered after rendering the scene
  56057. */
  56058. onAfterRenderObservable: Observable<Layer>;
  56059. private _onAfterRenderObserver;
  56060. /**
  56061. * Back compatibility with callback before the onAfterRenderObservable existed.
  56062. * The set callback will be triggered just after rendering the layer.
  56063. */
  56064. set onAfterRender(callback: () => void);
  56065. /**
  56066. * Instantiates a new layer.
  56067. * This represents a full screen 2d layer.
  56068. * This can be useful to display a picture in the background of your scene for instance.
  56069. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56070. * @param name Define the name of the layer in the scene
  56071. * @param imgUrl Define the url of the texture to display in the layer
  56072. * @param scene Define the scene the layer belongs to
  56073. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56074. * @param color Defines a color for the layer
  56075. */
  56076. constructor(
  56077. /**
  56078. * Define the name of the layer.
  56079. */
  56080. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56081. private _createIndexBuffer;
  56082. /** @hidden */
  56083. _rebuild(): void;
  56084. /**
  56085. * Renders the layer in the scene.
  56086. */
  56087. render(): void;
  56088. /**
  56089. * Disposes and releases the associated ressources.
  56090. */
  56091. dispose(): void;
  56092. }
  56093. }
  56094. declare module "babylonjs/Layers/index" {
  56095. export * from "babylonjs/Layers/effectLayer";
  56096. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56097. export * from "babylonjs/Layers/glowLayer";
  56098. export * from "babylonjs/Layers/highlightLayer";
  56099. export * from "babylonjs/Layers/layer";
  56100. export * from "babylonjs/Layers/layerSceneComponent";
  56101. }
  56102. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56103. /** @hidden */
  56104. export var lensFlarePixelShader: {
  56105. name: string;
  56106. shader: string;
  56107. };
  56108. }
  56109. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56110. /** @hidden */
  56111. export var lensFlareVertexShader: {
  56112. name: string;
  56113. shader: string;
  56114. };
  56115. }
  56116. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56117. import { Scene } from "babylonjs/scene";
  56118. import { Vector3 } from "babylonjs/Maths/math.vector";
  56119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56120. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56121. import "babylonjs/Shaders/lensFlare.fragment";
  56122. import "babylonjs/Shaders/lensFlare.vertex";
  56123. import { Viewport } from "babylonjs/Maths/math.viewport";
  56124. /**
  56125. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56126. * It is usually composed of several `lensFlare`.
  56127. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56128. */
  56129. export class LensFlareSystem {
  56130. /**
  56131. * Define the name of the lens flare system
  56132. */
  56133. name: string;
  56134. /**
  56135. * List of lens flares used in this system.
  56136. */
  56137. lensFlares: LensFlare[];
  56138. /**
  56139. * Define a limit from the border the lens flare can be visible.
  56140. */
  56141. borderLimit: number;
  56142. /**
  56143. * Define a viewport border we do not want to see the lens flare in.
  56144. */
  56145. viewportBorder: number;
  56146. /**
  56147. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56148. */
  56149. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56150. /**
  56151. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56152. */
  56153. layerMask: number;
  56154. /**
  56155. * Define the id of the lens flare system in the scene.
  56156. * (equal to name by default)
  56157. */
  56158. id: string;
  56159. private _scene;
  56160. private _emitter;
  56161. private _vertexBuffers;
  56162. private _indexBuffer;
  56163. private _effect;
  56164. private _positionX;
  56165. private _positionY;
  56166. private _isEnabled;
  56167. /** @hidden */
  56168. static _SceneComponentInitialization: (scene: Scene) => void;
  56169. /**
  56170. * Instantiates a lens flare system.
  56171. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56172. * It is usually composed of several `lensFlare`.
  56173. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56174. * @param name Define the name of the lens flare system in the scene
  56175. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56176. * @param scene Define the scene the lens flare system belongs to
  56177. */
  56178. constructor(
  56179. /**
  56180. * Define the name of the lens flare system
  56181. */
  56182. name: string, emitter: any, scene: Scene);
  56183. /**
  56184. * Define if the lens flare system is enabled.
  56185. */
  56186. get isEnabled(): boolean;
  56187. set isEnabled(value: boolean);
  56188. /**
  56189. * Get the scene the effects belongs to.
  56190. * @returns the scene holding the lens flare system
  56191. */
  56192. getScene(): Scene;
  56193. /**
  56194. * Get the emitter of the lens flare system.
  56195. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56196. * @returns the emitter of the lens flare system
  56197. */
  56198. getEmitter(): any;
  56199. /**
  56200. * Set the emitter of the lens flare system.
  56201. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56202. * @param newEmitter Define the new emitter of the system
  56203. */
  56204. setEmitter(newEmitter: any): void;
  56205. /**
  56206. * Get the lens flare system emitter position.
  56207. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56208. * @returns the position
  56209. */
  56210. getEmitterPosition(): Vector3;
  56211. /**
  56212. * @hidden
  56213. */
  56214. computeEffectivePosition(globalViewport: Viewport): boolean;
  56215. /** @hidden */
  56216. _isVisible(): boolean;
  56217. /**
  56218. * @hidden
  56219. */
  56220. render(): boolean;
  56221. /**
  56222. * Dispose and release the lens flare with its associated resources.
  56223. */
  56224. dispose(): void;
  56225. /**
  56226. * Parse a lens flare system from a JSON repressentation
  56227. * @param parsedLensFlareSystem Define the JSON to parse
  56228. * @param scene Define the scene the parsed system should be instantiated in
  56229. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56230. * @returns the parsed system
  56231. */
  56232. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56233. /**
  56234. * Serialize the current Lens Flare System into a JSON representation.
  56235. * @returns the serialized JSON
  56236. */
  56237. serialize(): any;
  56238. }
  56239. }
  56240. declare module "babylonjs/LensFlares/lensFlare" {
  56241. import { Nullable } from "babylonjs/types";
  56242. import { Color3 } from "babylonjs/Maths/math.color";
  56243. import { Texture } from "babylonjs/Materials/Textures/texture";
  56244. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56245. /**
  56246. * This represents one of the lens effect in a `lensFlareSystem`.
  56247. * It controls one of the indiviual texture used in the effect.
  56248. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56249. */
  56250. export class LensFlare {
  56251. /**
  56252. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56253. */
  56254. size: number;
  56255. /**
  56256. * 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.
  56257. */
  56258. position: number;
  56259. /**
  56260. * Define the lens color.
  56261. */
  56262. color: Color3;
  56263. /**
  56264. * Define the lens texture.
  56265. */
  56266. texture: Nullable<Texture>;
  56267. /**
  56268. * Define the alpha mode to render this particular lens.
  56269. */
  56270. alphaMode: number;
  56271. private _system;
  56272. /**
  56273. * Creates a new Lens Flare.
  56274. * This represents one of the lens effect in a `lensFlareSystem`.
  56275. * It controls one of the indiviual texture used in the effect.
  56276. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56277. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56278. * @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.
  56279. * @param color Define the lens color
  56280. * @param imgUrl Define the lens texture url
  56281. * @param system Define the `lensFlareSystem` this flare is part of
  56282. * @returns The newly created Lens Flare
  56283. */
  56284. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56285. /**
  56286. * Instantiates a new Lens Flare.
  56287. * This represents one of the lens effect in a `lensFlareSystem`.
  56288. * It controls one of the indiviual texture used in the effect.
  56289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56290. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56291. * @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.
  56292. * @param color Define the lens color
  56293. * @param imgUrl Define the lens texture url
  56294. * @param system Define the `lensFlareSystem` this flare is part of
  56295. */
  56296. constructor(
  56297. /**
  56298. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56299. */
  56300. size: number,
  56301. /**
  56302. * 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.
  56303. */
  56304. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56305. /**
  56306. * Dispose and release the lens flare with its associated resources.
  56307. */
  56308. dispose(): void;
  56309. }
  56310. }
  56311. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56312. import { Nullable } from "babylonjs/types";
  56313. import { Scene } from "babylonjs/scene";
  56314. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56315. import { AbstractScene } from "babylonjs/abstractScene";
  56316. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56317. module "babylonjs/abstractScene" {
  56318. interface AbstractScene {
  56319. /**
  56320. * The list of lens flare system added to the scene
  56321. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56322. */
  56323. lensFlareSystems: Array<LensFlareSystem>;
  56324. /**
  56325. * Removes the given lens flare system from this scene.
  56326. * @param toRemove The lens flare system to remove
  56327. * @returns The index of the removed lens flare system
  56328. */
  56329. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56330. /**
  56331. * Adds the given lens flare system to this scene
  56332. * @param newLensFlareSystem The lens flare system to add
  56333. */
  56334. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56335. /**
  56336. * Gets a lens flare system using its name
  56337. * @param name defines the name to look for
  56338. * @returns the lens flare system or null if not found
  56339. */
  56340. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56341. /**
  56342. * Gets a lens flare system using its id
  56343. * @param id defines the id to look for
  56344. * @returns the lens flare system or null if not found
  56345. */
  56346. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56347. }
  56348. }
  56349. /**
  56350. * Defines the lens flare scene component responsible to manage any lens flares
  56351. * in a given scene.
  56352. */
  56353. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56354. /**
  56355. * The component name helpfull to identify the component in the list of scene components.
  56356. */
  56357. readonly name: string;
  56358. /**
  56359. * The scene the component belongs to.
  56360. */
  56361. scene: Scene;
  56362. /**
  56363. * Creates a new instance of the component for the given scene
  56364. * @param scene Defines the scene to register the component in
  56365. */
  56366. constructor(scene: Scene);
  56367. /**
  56368. * Registers the component in a given scene
  56369. */
  56370. register(): void;
  56371. /**
  56372. * Rebuilds the elements related to this component in case of
  56373. * context lost for instance.
  56374. */
  56375. rebuild(): void;
  56376. /**
  56377. * Adds all the elements from the container to the scene
  56378. * @param container the container holding the elements
  56379. */
  56380. addFromContainer(container: AbstractScene): void;
  56381. /**
  56382. * Removes all the elements in the container from the scene
  56383. * @param container contains the elements to remove
  56384. * @param dispose if the removed element should be disposed (default: false)
  56385. */
  56386. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56387. /**
  56388. * Serializes the component data to the specified json object
  56389. * @param serializationObject The object to serialize to
  56390. */
  56391. serialize(serializationObject: any): void;
  56392. /**
  56393. * Disposes the component and the associated ressources.
  56394. */
  56395. dispose(): void;
  56396. private _draw;
  56397. }
  56398. }
  56399. declare module "babylonjs/LensFlares/index" {
  56400. export * from "babylonjs/LensFlares/lensFlare";
  56401. export * from "babylonjs/LensFlares/lensFlareSystem";
  56402. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56403. }
  56404. declare module "babylonjs/Shaders/depth.fragment" {
  56405. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56406. /** @hidden */
  56407. export var depthPixelShader: {
  56408. name: string;
  56409. shader: string;
  56410. };
  56411. }
  56412. declare module "babylonjs/Shaders/depth.vertex" {
  56413. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56414. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56415. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56416. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56418. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56419. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56420. /** @hidden */
  56421. export var depthVertexShader: {
  56422. name: string;
  56423. shader: string;
  56424. };
  56425. }
  56426. declare module "babylonjs/Rendering/depthRenderer" {
  56427. import { Nullable } from "babylonjs/types";
  56428. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56429. import { Scene } from "babylonjs/scene";
  56430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56431. import { Camera } from "babylonjs/Cameras/camera";
  56432. import "babylonjs/Shaders/depth.fragment";
  56433. import "babylonjs/Shaders/depth.vertex";
  56434. /**
  56435. * This represents a depth renderer in Babylon.
  56436. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56437. */
  56438. export class DepthRenderer {
  56439. private _scene;
  56440. private _depthMap;
  56441. private _effect;
  56442. private readonly _storeNonLinearDepth;
  56443. private readonly _clearColor;
  56444. /** Get if the depth renderer is using packed depth or not */
  56445. readonly isPacked: boolean;
  56446. private _cachedDefines;
  56447. private _camera;
  56448. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56449. enabled: boolean;
  56450. /**
  56451. * Specifiess that the depth renderer will only be used within
  56452. * the camera it is created for.
  56453. * This can help forcing its rendering during the camera processing.
  56454. */
  56455. useOnlyInActiveCamera: boolean;
  56456. /** @hidden */
  56457. static _SceneComponentInitialization: (scene: Scene) => void;
  56458. /**
  56459. * Instantiates a depth renderer
  56460. * @param scene The scene the renderer belongs to
  56461. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56462. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56463. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56464. */
  56465. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56466. /**
  56467. * Creates the depth rendering effect and checks if the effect is ready.
  56468. * @param subMesh The submesh to be used to render the depth map of
  56469. * @param useInstances If multiple world instances should be used
  56470. * @returns if the depth renderer is ready to render the depth map
  56471. */
  56472. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56473. /**
  56474. * Gets the texture which the depth map will be written to.
  56475. * @returns The depth map texture
  56476. */
  56477. getDepthMap(): RenderTargetTexture;
  56478. /**
  56479. * Disposes of the depth renderer.
  56480. */
  56481. dispose(): void;
  56482. }
  56483. }
  56484. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56485. /** @hidden */
  56486. export var minmaxReduxPixelShader: {
  56487. name: string;
  56488. shader: string;
  56489. };
  56490. }
  56491. declare module "babylonjs/Misc/minMaxReducer" {
  56492. import { Nullable } from "babylonjs/types";
  56493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56494. import { Camera } from "babylonjs/Cameras/camera";
  56495. import { Observer } from "babylonjs/Misc/observable";
  56496. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56497. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56498. import { Observable } from "babylonjs/Misc/observable";
  56499. import "babylonjs/Shaders/minmaxRedux.fragment";
  56500. /**
  56501. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56502. * and maximum values from all values of the texture.
  56503. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56504. * The source values are read from the red channel of the texture.
  56505. */
  56506. export class MinMaxReducer {
  56507. /**
  56508. * Observable triggered when the computation has been performed
  56509. */
  56510. onAfterReductionPerformed: Observable<{
  56511. min: number;
  56512. max: number;
  56513. }>;
  56514. protected _camera: Camera;
  56515. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56516. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56517. protected _postProcessManager: PostProcessManager;
  56518. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56519. protected _forceFullscreenViewport: boolean;
  56520. /**
  56521. * Creates a min/max reducer
  56522. * @param camera The camera to use for the post processes
  56523. */
  56524. constructor(camera: Camera);
  56525. /**
  56526. * Gets the texture used to read the values from.
  56527. */
  56528. get sourceTexture(): Nullable<RenderTargetTexture>;
  56529. /**
  56530. * Sets the source texture to read the values from.
  56531. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56532. * because in such textures '1' value must not be taken into account to compute the maximum
  56533. * as this value is used to clear the texture.
  56534. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56535. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56536. * @param depthRedux Indicates if the texture is a depth texture or not
  56537. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56538. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56539. */
  56540. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56541. /**
  56542. * Defines the refresh rate of the computation.
  56543. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56544. */
  56545. get refreshRate(): number;
  56546. set refreshRate(value: number);
  56547. protected _activated: boolean;
  56548. /**
  56549. * Gets the activation status of the reducer
  56550. */
  56551. get activated(): boolean;
  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 min/max 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/Misc/depthReducer" {
  56570. import { Nullable } from "babylonjs/types";
  56571. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56572. import { Camera } from "babylonjs/Cameras/camera";
  56573. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56574. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56575. /**
  56576. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56577. */
  56578. export class DepthReducer extends MinMaxReducer {
  56579. private _depthRenderer;
  56580. private _depthRendererId;
  56581. /**
  56582. * Gets the depth renderer used for the computation.
  56583. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56584. */
  56585. get depthRenderer(): Nullable<DepthRenderer>;
  56586. /**
  56587. * Creates a depth reducer
  56588. * @param camera The camera used to render the depth texture
  56589. */
  56590. constructor(camera: Camera);
  56591. /**
  56592. * Sets the depth renderer to use to generate the depth map
  56593. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56594. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56595. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56596. */
  56597. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56598. /** @hidden */
  56599. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56600. /**
  56601. * Activates the reduction computation.
  56602. * When activated, the observers registered in onAfterReductionPerformed are
  56603. * called after the compuation is performed
  56604. */
  56605. activate(): void;
  56606. /**
  56607. * Deactivates the reduction computation.
  56608. */
  56609. deactivate(): void;
  56610. /**
  56611. * Disposes the depth reducer
  56612. * @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.
  56613. */
  56614. dispose(disposeAll?: boolean): void;
  56615. }
  56616. }
  56617. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56618. import { Nullable } from "babylonjs/types";
  56619. import { Scene } from "babylonjs/scene";
  56620. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56621. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56622. import { Effect } from "babylonjs/Materials/effect";
  56623. import "babylonjs/Shaders/shadowMap.fragment";
  56624. import "babylonjs/Shaders/shadowMap.vertex";
  56625. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56626. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56627. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56628. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56629. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56630. /**
  56631. * A CSM implementation allowing casting shadows on large scenes.
  56632. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56633. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56634. */
  56635. export class CascadedShadowGenerator extends ShadowGenerator {
  56636. private static readonly frustumCornersNDCSpace;
  56637. /**
  56638. * Name of the CSM class
  56639. */
  56640. static CLASSNAME: string;
  56641. /**
  56642. * Defines the default number of cascades used by the CSM.
  56643. */
  56644. static readonly DEFAULT_CASCADES_COUNT: number;
  56645. /**
  56646. * Defines the minimum number of cascades used by the CSM.
  56647. */
  56648. static readonly MIN_CASCADES_COUNT: number;
  56649. /**
  56650. * Defines the maximum number of cascades used by the CSM.
  56651. */
  56652. static readonly MAX_CASCADES_COUNT: number;
  56653. protected _validateFilter(filter: number): number;
  56654. /**
  56655. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56656. */
  56657. penumbraDarkness: number;
  56658. private _numCascades;
  56659. /**
  56660. * Gets or set the number of cascades used by the CSM.
  56661. */
  56662. get numCascades(): number;
  56663. set numCascades(value: number);
  56664. /**
  56665. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56666. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56667. */
  56668. stabilizeCascades: boolean;
  56669. private _freezeShadowCastersBoundingInfo;
  56670. private _freezeShadowCastersBoundingInfoObservable;
  56671. /**
  56672. * Enables or disables the shadow casters bounding info computation.
  56673. * If your shadow casters don't move, you can disable this feature.
  56674. * If it is enabled, the bounding box computation is done every frame.
  56675. */
  56676. get freezeShadowCastersBoundingInfo(): boolean;
  56677. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56678. private _scbiMin;
  56679. private _scbiMax;
  56680. protected _computeShadowCastersBoundingInfo(): void;
  56681. protected _shadowCastersBoundingInfo: BoundingInfo;
  56682. /**
  56683. * Gets or sets the shadow casters bounding info.
  56684. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56685. * so that the system won't overwrite the bounds you provide
  56686. */
  56687. get shadowCastersBoundingInfo(): BoundingInfo;
  56688. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56689. protected _breaksAreDirty: boolean;
  56690. protected _minDistance: number;
  56691. protected _maxDistance: number;
  56692. /**
  56693. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56694. *
  56695. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56696. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56697. * @param min minimal distance for the breaks (default to 0.)
  56698. * @param max maximal distance for the breaks (default to 1.)
  56699. */
  56700. setMinMaxDistance(min: number, max: number): void;
  56701. /** Gets the minimal distance used in the cascade break computation */
  56702. get minDistance(): number;
  56703. /** Gets the maximal distance used in the cascade break computation */
  56704. get maxDistance(): number;
  56705. /**
  56706. * Gets the class name of that object
  56707. * @returns "CascadedShadowGenerator"
  56708. */
  56709. getClassName(): string;
  56710. private _cascadeMinExtents;
  56711. private _cascadeMaxExtents;
  56712. /**
  56713. * Gets a cascade minimum extents
  56714. * @param cascadeIndex index of the cascade
  56715. * @returns the minimum cascade extents
  56716. */
  56717. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56718. /**
  56719. * Gets a cascade maximum extents
  56720. * @param cascadeIndex index of the cascade
  56721. * @returns the maximum cascade extents
  56722. */
  56723. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56724. private _cascades;
  56725. private _currentLayer;
  56726. private _viewSpaceFrustumsZ;
  56727. private _viewMatrices;
  56728. private _projectionMatrices;
  56729. private _transformMatrices;
  56730. private _transformMatricesAsArray;
  56731. private _frustumLengths;
  56732. private _lightSizeUVCorrection;
  56733. private _depthCorrection;
  56734. private _frustumCornersWorldSpace;
  56735. private _frustumCenter;
  56736. private _shadowCameraPos;
  56737. private _shadowMaxZ;
  56738. /**
  56739. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56740. * It defaults to camera.maxZ
  56741. */
  56742. get shadowMaxZ(): number;
  56743. /**
  56744. * Sets the shadow max z distance.
  56745. */
  56746. set shadowMaxZ(value: number);
  56747. protected _debug: boolean;
  56748. /**
  56749. * Gets or sets the debug flag.
  56750. * When enabled, the cascades are materialized by different colors on the screen.
  56751. */
  56752. get debug(): boolean;
  56753. set debug(dbg: boolean);
  56754. private _depthClamp;
  56755. /**
  56756. * Gets or sets the depth clamping value.
  56757. *
  56758. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56759. * to account for the shadow casters far away.
  56760. *
  56761. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56762. */
  56763. get depthClamp(): boolean;
  56764. set depthClamp(value: boolean);
  56765. private _cascadeBlendPercentage;
  56766. /**
  56767. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56768. * It defaults to 0.1 (10% blending).
  56769. */
  56770. get cascadeBlendPercentage(): number;
  56771. set cascadeBlendPercentage(value: number);
  56772. private _lambda;
  56773. /**
  56774. * Gets or set the lambda parameter.
  56775. * This parameter is used to split the camera frustum and create the cascades.
  56776. * 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.
  56777. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56778. */
  56779. get lambda(): number;
  56780. set lambda(value: number);
  56781. /**
  56782. * Gets the view matrix corresponding to a given cascade
  56783. * @param cascadeNum cascade to retrieve the view matrix from
  56784. * @returns the cascade view matrix
  56785. */
  56786. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56787. /**
  56788. * Gets the projection matrix corresponding to a given cascade
  56789. * @param cascadeNum cascade to retrieve the projection matrix from
  56790. * @returns the cascade projection matrix
  56791. */
  56792. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56793. /**
  56794. * Gets the transformation matrix corresponding to a given cascade
  56795. * @param cascadeNum cascade to retrieve the transformation matrix from
  56796. * @returns the cascade transformation matrix
  56797. */
  56798. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56799. private _depthRenderer;
  56800. /**
  56801. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56802. *
  56803. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56804. *
  56805. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56806. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56807. * @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
  56808. */
  56809. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56810. private _depthReducer;
  56811. private _autoCalcDepthBounds;
  56812. /**
  56813. * Gets or sets the autoCalcDepthBounds property.
  56814. *
  56815. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56816. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56817. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56818. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56819. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56820. */
  56821. get autoCalcDepthBounds(): boolean;
  56822. set autoCalcDepthBounds(value: boolean);
  56823. /**
  56824. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56825. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56826. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56827. * for setting the refresh rate on the renderer yourself!
  56828. */
  56829. get autoCalcDepthBoundsRefreshRate(): number;
  56830. set autoCalcDepthBoundsRefreshRate(value: number);
  56831. /**
  56832. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56833. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56834. * you change the camera near/far planes!
  56835. */
  56836. splitFrustum(): void;
  56837. private _splitFrustum;
  56838. private _computeMatrices;
  56839. private _computeFrustumInWorldSpace;
  56840. private _computeCascadeFrustum;
  56841. /** @hidden */
  56842. static _SceneComponentInitialization: (scene: Scene) => void;
  56843. /**
  56844. * Creates a Cascaded Shadow Generator object.
  56845. * A ShadowGenerator is the required tool to use the shadows.
  56846. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56847. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56848. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56849. * @param light The directional light object generating the shadows.
  56850. * @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.
  56851. */
  56852. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56853. protected _initializeGenerator(): void;
  56854. protected _createTargetRenderTexture(): void;
  56855. protected _initializeShadowMap(): void;
  56856. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56857. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56858. /**
  56859. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56860. * @param defines Defines of the material we want to update
  56861. * @param lightIndex Index of the light in the enabled light list of the material
  56862. */
  56863. prepareDefines(defines: any, lightIndex: number): void;
  56864. /**
  56865. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56866. * defined in the generator but impacting the effect).
  56867. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56868. * @param effect The effect we are binfing the information for
  56869. */
  56870. bindShadowLight(lightIndex: string, effect: Effect): void;
  56871. /**
  56872. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56873. * (eq to view projection * shadow projection matrices)
  56874. * @returns The transform matrix used to create the shadow map
  56875. */
  56876. getTransformMatrix(): Matrix;
  56877. /**
  56878. * Disposes the ShadowGenerator.
  56879. * Returns nothing.
  56880. */
  56881. dispose(): void;
  56882. /**
  56883. * Serializes the shadow generator setup to a json object.
  56884. * @returns The serialized JSON object
  56885. */
  56886. serialize(): any;
  56887. /**
  56888. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56889. * @param parsedShadowGenerator The JSON object to parse
  56890. * @param scene The scene to create the shadow map for
  56891. * @returns The parsed shadow generator
  56892. */
  56893. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56894. }
  56895. }
  56896. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56897. import { Scene } from "babylonjs/scene";
  56898. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56899. import { AbstractScene } from "babylonjs/abstractScene";
  56900. /**
  56901. * Defines the shadow generator component responsible to manage any shadow generators
  56902. * in a given scene.
  56903. */
  56904. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56905. /**
  56906. * The component name helpfull to identify the component in the list of scene components.
  56907. */
  56908. readonly name: string;
  56909. /**
  56910. * The scene the component belongs to.
  56911. */
  56912. scene: Scene;
  56913. /**
  56914. * Creates a new instance of the component for the given scene
  56915. * @param scene Defines the scene to register the component in
  56916. */
  56917. constructor(scene: Scene);
  56918. /**
  56919. * Registers the component in a given scene
  56920. */
  56921. register(): void;
  56922. /**
  56923. * Rebuilds the elements related to this component in case of
  56924. * context lost for instance.
  56925. */
  56926. rebuild(): void;
  56927. /**
  56928. * Serializes the component data to the specified json object
  56929. * @param serializationObject The object to serialize to
  56930. */
  56931. serialize(serializationObject: any): void;
  56932. /**
  56933. * Adds all the elements from the container to the scene
  56934. * @param container the container holding the elements
  56935. */
  56936. addFromContainer(container: AbstractScene): void;
  56937. /**
  56938. * Removes all the elements in the container from the scene
  56939. * @param container contains the elements to remove
  56940. * @param dispose if the removed element should be disposed (default: false)
  56941. */
  56942. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56943. /**
  56944. * Rebuilds the elements related to this component in case of
  56945. * context lost for instance.
  56946. */
  56947. dispose(): void;
  56948. private _gatherRenderTargets;
  56949. }
  56950. }
  56951. declare module "babylonjs/Lights/Shadows/index" {
  56952. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56953. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56954. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56955. }
  56956. declare module "babylonjs/Lights/pointLight" {
  56957. import { Scene } from "babylonjs/scene";
  56958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56960. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56961. import { Effect } from "babylonjs/Materials/effect";
  56962. /**
  56963. * A point light is a light defined by an unique point in world space.
  56964. * The light is emitted in every direction from this point.
  56965. * A good example of a point light is a standard light bulb.
  56966. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56967. */
  56968. export class PointLight extends ShadowLight {
  56969. private _shadowAngle;
  56970. /**
  56971. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56972. * This specifies what angle the shadow will use to be created.
  56973. *
  56974. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56975. */
  56976. get shadowAngle(): number;
  56977. /**
  56978. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56979. * This specifies what angle the shadow will use to be created.
  56980. *
  56981. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56982. */
  56983. set shadowAngle(value: number);
  56984. /**
  56985. * Gets the direction if it has been set.
  56986. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56987. */
  56988. get direction(): Vector3;
  56989. /**
  56990. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56991. */
  56992. set direction(value: Vector3);
  56993. /**
  56994. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56995. * A PointLight emits the light in every direction.
  56996. * It can cast shadows.
  56997. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56998. * ```javascript
  56999. * var pointLight = new PointLight("pl", camera.position, scene);
  57000. * ```
  57001. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57002. * @param name The light friendly name
  57003. * @param position The position of the point light in the scene
  57004. * @param scene The scene the lights belongs to
  57005. */
  57006. constructor(name: string, position: Vector3, scene: Scene);
  57007. /**
  57008. * Returns the string "PointLight"
  57009. * @returns the class name
  57010. */
  57011. getClassName(): string;
  57012. /**
  57013. * Returns the integer 0.
  57014. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57015. */
  57016. getTypeID(): number;
  57017. /**
  57018. * Specifies wether or not the shadowmap should be a cube texture.
  57019. * @returns true if the shadowmap needs to be a cube texture.
  57020. */
  57021. needCube(): boolean;
  57022. /**
  57023. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57026. */
  57027. getShadowDirection(faceIndex?: number): Vector3;
  57028. /**
  57029. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57030. * - fov = PI / 2
  57031. * - aspect ratio : 1.0
  57032. * - z-near and far equal to the active camera minZ and maxZ.
  57033. * Returns the PointLight.
  57034. */
  57035. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57036. protected _buildUniformLayout(): void;
  57037. /**
  57038. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57039. * @param effect The effect to update
  57040. * @param lightIndex The index of the light in the effect to update
  57041. * @returns The point light
  57042. */
  57043. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57044. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57045. /**
  57046. * Prepares the list of defines specific to the light type.
  57047. * @param defines the list of defines
  57048. * @param lightIndex defines the index of the light for the effect
  57049. */
  57050. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57051. }
  57052. }
  57053. declare module "babylonjs/Lights/index" {
  57054. export * from "babylonjs/Lights/light";
  57055. export * from "babylonjs/Lights/shadowLight";
  57056. export * from "babylonjs/Lights/Shadows/index";
  57057. export * from "babylonjs/Lights/directionalLight";
  57058. export * from "babylonjs/Lights/hemisphericLight";
  57059. export * from "babylonjs/Lights/pointLight";
  57060. export * from "babylonjs/Lights/spotLight";
  57061. }
  57062. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57063. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57064. /**
  57065. * Header information of HDR texture files.
  57066. */
  57067. export interface HDRInfo {
  57068. /**
  57069. * The height of the texture in pixels.
  57070. */
  57071. height: number;
  57072. /**
  57073. * The width of the texture in pixels.
  57074. */
  57075. width: number;
  57076. /**
  57077. * The index of the beginning of the data in the binary file.
  57078. */
  57079. dataPosition: number;
  57080. }
  57081. /**
  57082. * This groups tools to convert HDR texture to native colors array.
  57083. */
  57084. export class HDRTools {
  57085. private static Ldexp;
  57086. private static Rgbe2float;
  57087. private static readStringLine;
  57088. /**
  57089. * Reads header information from an RGBE texture stored in a native array.
  57090. * More information on this format are available here:
  57091. * https://en.wikipedia.org/wiki/RGBE_image_format
  57092. *
  57093. * @param uint8array The binary file stored in native array.
  57094. * @return The header information.
  57095. */
  57096. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57097. /**
  57098. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57099. * This RGBE texture needs to store the information as a panorama.
  57100. *
  57101. * More information on this format are available here:
  57102. * https://en.wikipedia.org/wiki/RGBE_image_format
  57103. *
  57104. * @param buffer The binary file stored in an array buffer.
  57105. * @param size The expected size of the extracted cubemap.
  57106. * @return The Cube Map information.
  57107. */
  57108. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57109. /**
  57110. * Returns the pixels data extracted from an RGBE texture.
  57111. * This pixels will be stored left to right up to down in the R G B order in one array.
  57112. *
  57113. * More information on this format are available here:
  57114. * https://en.wikipedia.org/wiki/RGBE_image_format
  57115. *
  57116. * @param uint8array The binary file stored in an array buffer.
  57117. * @param hdrInfo The header information of the file.
  57118. * @return The pixels data in RGB right to left up to down order.
  57119. */
  57120. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57121. private static RGBE_ReadPixels_RLE;
  57122. }
  57123. }
  57124. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57125. import { Nullable } from "babylonjs/types";
  57126. import { Scene } from "babylonjs/scene";
  57127. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57129. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57130. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57131. /**
  57132. * This represents a texture coming from an HDR input.
  57133. *
  57134. * The only supported format is currently panorama picture stored in RGBE format.
  57135. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57136. */
  57137. export class HDRCubeTexture extends BaseTexture {
  57138. private static _facesMapping;
  57139. private _generateHarmonics;
  57140. private _noMipmap;
  57141. private _textureMatrix;
  57142. private _size;
  57143. private _onLoad;
  57144. private _onError;
  57145. /**
  57146. * The texture URL.
  57147. */
  57148. url: string;
  57149. /**
  57150. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57151. */
  57152. coordinatesMode: number;
  57153. protected _isBlocking: boolean;
  57154. /**
  57155. * Sets wether or not the texture is blocking during loading.
  57156. */
  57157. set isBlocking(value: boolean);
  57158. /**
  57159. * Gets wether or not the texture is blocking during loading.
  57160. */
  57161. get isBlocking(): boolean;
  57162. protected _rotationY: number;
  57163. /**
  57164. * Sets texture matrix rotation angle around Y axis in radians.
  57165. */
  57166. set rotationY(value: number);
  57167. /**
  57168. * Gets texture matrix rotation angle around Y axis radians.
  57169. */
  57170. get rotationY(): number;
  57171. /**
  57172. * Gets or sets the center of the bounding box associated with the cube texture
  57173. * It must define where the camera used to render the texture was set
  57174. */
  57175. boundingBoxPosition: Vector3;
  57176. private _boundingBoxSize;
  57177. /**
  57178. * Gets or sets the size of the bounding box associated with the cube texture
  57179. * When defined, the cubemap will switch to local mode
  57180. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57181. * @example https://www.babylonjs-playground.com/#RNASML
  57182. */
  57183. set boundingBoxSize(value: Vector3);
  57184. get boundingBoxSize(): Vector3;
  57185. /**
  57186. * Instantiates an HDRTexture from the following parameters.
  57187. *
  57188. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57189. * @param scene The scene the texture will be used in
  57190. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57191. * @param noMipmap Forces to not generate the mipmap if true
  57192. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57193. * @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)
  57194. * @param reserved Reserved flag for internal use.
  57195. */
  57196. 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>);
  57197. /**
  57198. * Get the current class name of the texture useful for serialization or dynamic coding.
  57199. * @returns "HDRCubeTexture"
  57200. */
  57201. getClassName(): string;
  57202. /**
  57203. * Occurs when the file is raw .hdr file.
  57204. */
  57205. private loadTexture;
  57206. clone(): HDRCubeTexture;
  57207. delayLoad(): void;
  57208. /**
  57209. * Get the texture reflection matrix used to rotate/transform the reflection.
  57210. * @returns the reflection matrix
  57211. */
  57212. getReflectionTextureMatrix(): Matrix;
  57213. /**
  57214. * Set the texture reflection matrix used to rotate/transform the reflection.
  57215. * @param value Define the reflection matrix to set
  57216. */
  57217. setReflectionTextureMatrix(value: Matrix): void;
  57218. /**
  57219. * Parses a JSON representation of an HDR Texture in order to create the texture
  57220. * @param parsedTexture Define the JSON representation
  57221. * @param scene Define the scene the texture should be created in
  57222. * @param rootUrl Define the root url in case we need to load relative dependencies
  57223. * @returns the newly created texture after parsing
  57224. */
  57225. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57226. serialize(): any;
  57227. }
  57228. }
  57229. declare module "babylonjs/Physics/physicsEngine" {
  57230. import { Nullable } from "babylonjs/types";
  57231. import { Vector3 } from "babylonjs/Maths/math.vector";
  57232. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57233. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57234. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57235. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57236. /**
  57237. * Class used to control physics engine
  57238. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57239. */
  57240. export class PhysicsEngine implements IPhysicsEngine {
  57241. private _physicsPlugin;
  57242. /**
  57243. * Global value used to control the smallest number supported by the simulation
  57244. */
  57245. static Epsilon: number;
  57246. private _impostors;
  57247. private _joints;
  57248. private _subTimeStep;
  57249. /**
  57250. * Gets the gravity vector used by the simulation
  57251. */
  57252. gravity: Vector3;
  57253. /**
  57254. * Factory used to create the default physics plugin.
  57255. * @returns The default physics plugin
  57256. */
  57257. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57258. /**
  57259. * Creates a new Physics Engine
  57260. * @param gravity defines the gravity vector used by the simulation
  57261. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57262. */
  57263. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57264. /**
  57265. * Sets the gravity vector used by the simulation
  57266. * @param gravity defines the gravity vector to use
  57267. */
  57268. setGravity(gravity: Vector3): void;
  57269. /**
  57270. * Set the time step of the physics engine.
  57271. * Default is 1/60.
  57272. * To slow it down, enter 1/600 for example.
  57273. * To speed it up, 1/30
  57274. * @param newTimeStep defines the new timestep to apply to this world.
  57275. */
  57276. setTimeStep(newTimeStep?: number): void;
  57277. /**
  57278. * Get the time step of the physics engine.
  57279. * @returns the current time step
  57280. */
  57281. getTimeStep(): number;
  57282. /**
  57283. * Set the sub time step of the physics engine.
  57284. * Default is 0 meaning there is no sub steps
  57285. * To increase physics resolution precision, set a small value (like 1 ms)
  57286. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57287. */
  57288. setSubTimeStep(subTimeStep?: number): void;
  57289. /**
  57290. * Get the sub time step of the physics engine.
  57291. * @returns the current sub time step
  57292. */
  57293. getSubTimeStep(): number;
  57294. /**
  57295. * Release all resources
  57296. */
  57297. dispose(): void;
  57298. /**
  57299. * Gets the name of the current physics plugin
  57300. * @returns the name of the plugin
  57301. */
  57302. getPhysicsPluginName(): string;
  57303. /**
  57304. * Adding a new impostor for the impostor tracking.
  57305. * This will be done by the impostor itself.
  57306. * @param impostor the impostor to add
  57307. */
  57308. addImpostor(impostor: PhysicsImpostor): void;
  57309. /**
  57310. * Remove an impostor from the engine.
  57311. * This impostor and its mesh will not longer be updated by the physics engine.
  57312. * @param impostor the impostor to remove
  57313. */
  57314. removeImpostor(impostor: PhysicsImpostor): void;
  57315. /**
  57316. * Add a joint to the physics engine
  57317. * @param mainImpostor defines the main impostor to which the joint is added.
  57318. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57319. * @param joint defines the joint that will connect both impostors.
  57320. */
  57321. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57322. /**
  57323. * Removes a joint from the simulation
  57324. * @param mainImpostor defines the impostor used with the joint
  57325. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57326. * @param joint defines the joint to remove
  57327. */
  57328. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57329. /**
  57330. * Called by the scene. No need to call it.
  57331. * @param delta defines the timespam between frames
  57332. */
  57333. _step(delta: number): void;
  57334. /**
  57335. * Gets the current plugin used to run the simulation
  57336. * @returns current plugin
  57337. */
  57338. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57339. /**
  57340. * Gets the list of physic impostors
  57341. * @returns an array of PhysicsImpostor
  57342. */
  57343. getImpostors(): Array<PhysicsImpostor>;
  57344. /**
  57345. * Gets the impostor for a physics enabled object
  57346. * @param object defines the object impersonated by the impostor
  57347. * @returns the PhysicsImpostor or null if not found
  57348. */
  57349. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57350. /**
  57351. * Gets the impostor for a physics body object
  57352. * @param body defines physics body used by the impostor
  57353. * @returns the PhysicsImpostor or null if not found
  57354. */
  57355. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57356. /**
  57357. * Does a raycast in the physics world
  57358. * @param from when should the ray start?
  57359. * @param to when should the ray end?
  57360. * @returns PhysicsRaycastResult
  57361. */
  57362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57363. }
  57364. }
  57365. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57366. import { Nullable } from "babylonjs/types";
  57367. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57369. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57370. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57371. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57372. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57373. /** @hidden */
  57374. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57375. private _useDeltaForWorldStep;
  57376. world: any;
  57377. name: string;
  57378. private _physicsMaterials;
  57379. private _fixedTimeStep;
  57380. private _cannonRaycastResult;
  57381. private _raycastResult;
  57382. private _physicsBodysToRemoveAfterStep;
  57383. BJSCANNON: any;
  57384. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57385. setGravity(gravity: Vector3): void;
  57386. setTimeStep(timeStep: number): void;
  57387. getTimeStep(): number;
  57388. executeStep(delta: number): void;
  57389. private _removeMarkedPhysicsBodiesFromWorld;
  57390. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57391. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57392. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57393. private _processChildMeshes;
  57394. removePhysicsBody(impostor: PhysicsImpostor): void;
  57395. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57396. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57397. private _addMaterial;
  57398. private _checkWithEpsilon;
  57399. private _createShape;
  57400. private _createHeightmap;
  57401. private _minus90X;
  57402. private _plus90X;
  57403. private _tmpPosition;
  57404. private _tmpDeltaPosition;
  57405. private _tmpUnityRotation;
  57406. private _updatePhysicsBodyTransformation;
  57407. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57408. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57409. isSupported(): boolean;
  57410. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57411. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57412. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57413. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57414. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57415. getBodyMass(impostor: PhysicsImpostor): number;
  57416. getBodyFriction(impostor: PhysicsImpostor): number;
  57417. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57418. getBodyRestitution(impostor: PhysicsImpostor): number;
  57419. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57420. sleepBody(impostor: PhysicsImpostor): void;
  57421. wakeUpBody(impostor: PhysicsImpostor): void;
  57422. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57423. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57424. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57425. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57426. getRadius(impostor: PhysicsImpostor): number;
  57427. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57428. dispose(): void;
  57429. private _extendNamespace;
  57430. /**
  57431. * Does a raycast in the physics world
  57432. * @param from when should the ray start?
  57433. * @param to when should the ray end?
  57434. * @returns PhysicsRaycastResult
  57435. */
  57436. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57437. }
  57438. }
  57439. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57440. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57441. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57442. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57444. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57445. import { Nullable } from "babylonjs/types";
  57446. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57447. /** @hidden */
  57448. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57449. world: any;
  57450. name: string;
  57451. BJSOIMO: any;
  57452. private _raycastResult;
  57453. constructor(iterations?: number, oimoInjection?: any);
  57454. setGravity(gravity: Vector3): void;
  57455. setTimeStep(timeStep: number): void;
  57456. getTimeStep(): number;
  57457. private _tmpImpostorsArray;
  57458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57462. private _tmpPositionVector;
  57463. removePhysicsBody(impostor: PhysicsImpostor): void;
  57464. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57465. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57466. isSupported(): boolean;
  57467. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57468. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57469. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57470. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57471. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57472. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57473. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57474. getBodyMass(impostor: PhysicsImpostor): number;
  57475. getBodyFriction(impostor: PhysicsImpostor): number;
  57476. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57477. getBodyRestitution(impostor: PhysicsImpostor): number;
  57478. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57479. sleepBody(impostor: PhysicsImpostor): void;
  57480. wakeUpBody(impostor: PhysicsImpostor): void;
  57481. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57482. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57483. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57484. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57485. getRadius(impostor: PhysicsImpostor): number;
  57486. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57487. dispose(): void;
  57488. /**
  57489. * Does a raycast in the physics world
  57490. * @param from when should the ray start?
  57491. * @param to when should the ray end?
  57492. * @returns PhysicsRaycastResult
  57493. */
  57494. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57495. }
  57496. }
  57497. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57498. import { Nullable } from "babylonjs/types";
  57499. import { Scene } from "babylonjs/scene";
  57500. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57501. import { Color4 } from "babylonjs/Maths/math.color";
  57502. import { Mesh } from "babylonjs/Meshes/mesh";
  57503. /**
  57504. * Class containing static functions to help procedurally build meshes
  57505. */
  57506. export class RibbonBuilder {
  57507. /**
  57508. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57509. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57510. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57511. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57512. * * 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
  57513. * * 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
  57514. * * 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
  57515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57518. * * 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
  57519. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57520. * * 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
  57521. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57523. * @param name defines the name of the mesh
  57524. * @param options defines the options used to create the mesh
  57525. * @param scene defines the hosting scene
  57526. * @returns the ribbon mesh
  57527. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57528. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57529. */
  57530. static CreateRibbon(name: string, options: {
  57531. pathArray: Vector3[][];
  57532. closeArray?: boolean;
  57533. closePath?: boolean;
  57534. offset?: number;
  57535. updatable?: boolean;
  57536. sideOrientation?: number;
  57537. frontUVs?: Vector4;
  57538. backUVs?: Vector4;
  57539. instance?: Mesh;
  57540. invertUV?: boolean;
  57541. uvs?: Vector2[];
  57542. colors?: Color4[];
  57543. }, scene?: Nullable<Scene>): Mesh;
  57544. }
  57545. }
  57546. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57547. import { Nullable } from "babylonjs/types";
  57548. import { Scene } from "babylonjs/scene";
  57549. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57550. import { Mesh } from "babylonjs/Meshes/mesh";
  57551. /**
  57552. * Class containing static functions to help procedurally build meshes
  57553. */
  57554. export class ShapeBuilder {
  57555. /**
  57556. * 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.
  57557. * * 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.
  57558. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57559. * * 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.
  57560. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57561. * * 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
  57562. * * 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
  57563. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57568. * @param name defines the name of the mesh
  57569. * @param options defines the options used to create the mesh
  57570. * @param scene defines the hosting scene
  57571. * @returns the extruded shape mesh
  57572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57574. */
  57575. static ExtrudeShape(name: string, options: {
  57576. shape: Vector3[];
  57577. path: Vector3[];
  57578. scale?: number;
  57579. rotation?: number;
  57580. cap?: number;
  57581. updatable?: boolean;
  57582. sideOrientation?: number;
  57583. frontUVs?: Vector4;
  57584. backUVs?: Vector4;
  57585. instance?: Mesh;
  57586. invertUV?: boolean;
  57587. }, scene?: Nullable<Scene>): Mesh;
  57588. /**
  57589. * Creates an custom extruded shape mesh.
  57590. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57591. * * 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.
  57592. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57593. * * 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
  57594. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57595. * * 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
  57596. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57597. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57598. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57599. * * 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
  57600. * * 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
  57601. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57606. * @param name defines the name of the mesh
  57607. * @param options defines the options used to create the mesh
  57608. * @param scene defines the hosting scene
  57609. * @returns the custom extruded shape mesh
  57610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57611. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57613. */
  57614. static ExtrudeShapeCustom(name: string, options: {
  57615. shape: Vector3[];
  57616. path: Vector3[];
  57617. scaleFunction?: any;
  57618. rotationFunction?: any;
  57619. ribbonCloseArray?: boolean;
  57620. ribbonClosePath?: boolean;
  57621. cap?: number;
  57622. updatable?: boolean;
  57623. sideOrientation?: number;
  57624. frontUVs?: Vector4;
  57625. backUVs?: Vector4;
  57626. instance?: Mesh;
  57627. invertUV?: boolean;
  57628. }, scene?: Nullable<Scene>): Mesh;
  57629. private static _ExtrudeShapeGeneric;
  57630. }
  57631. }
  57632. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57633. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57634. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57635. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57636. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57637. import { Nullable } from "babylonjs/types";
  57638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57639. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57640. /**
  57641. * AmmoJS Physics plugin
  57642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57643. * @see https://github.com/kripken/ammo.js/
  57644. */
  57645. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57646. private _useDeltaForWorldStep;
  57647. /**
  57648. * Reference to the Ammo library
  57649. */
  57650. bjsAMMO: any;
  57651. /**
  57652. * Created ammoJS world which physics bodies are added to
  57653. */
  57654. world: any;
  57655. /**
  57656. * Name of the plugin
  57657. */
  57658. name: string;
  57659. private _timeStep;
  57660. private _fixedTimeStep;
  57661. private _maxSteps;
  57662. private _tmpQuaternion;
  57663. private _tmpAmmoTransform;
  57664. private _tmpAmmoQuaternion;
  57665. private _tmpAmmoConcreteContactResultCallback;
  57666. private _collisionConfiguration;
  57667. private _dispatcher;
  57668. private _overlappingPairCache;
  57669. private _solver;
  57670. private _softBodySolver;
  57671. private _tmpAmmoVectorA;
  57672. private _tmpAmmoVectorB;
  57673. private _tmpAmmoVectorC;
  57674. private _tmpAmmoVectorD;
  57675. private _tmpContactCallbackResult;
  57676. private _tmpAmmoVectorRCA;
  57677. private _tmpAmmoVectorRCB;
  57678. private _raycastResult;
  57679. private static readonly DISABLE_COLLISION_FLAG;
  57680. private static readonly KINEMATIC_FLAG;
  57681. private static readonly DISABLE_DEACTIVATION_FLAG;
  57682. /**
  57683. * Initializes the ammoJS plugin
  57684. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57685. * @param ammoInjection can be used to inject your own ammo reference
  57686. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57687. */
  57688. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57689. /**
  57690. * Sets the gravity of the physics world (m/(s^2))
  57691. * @param gravity Gravity to set
  57692. */
  57693. setGravity(gravity: Vector3): void;
  57694. /**
  57695. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57696. * @param timeStep timestep to use in seconds
  57697. */
  57698. setTimeStep(timeStep: number): void;
  57699. /**
  57700. * 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)
  57701. * @param fixedTimeStep fixedTimeStep to use in seconds
  57702. */
  57703. setFixedTimeStep(fixedTimeStep: number): void;
  57704. /**
  57705. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57706. * @param maxSteps the maximum number of steps by the physics engine per frame
  57707. */
  57708. setMaxSteps(maxSteps: number): void;
  57709. /**
  57710. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57711. * @returns the current timestep in seconds
  57712. */
  57713. getTimeStep(): number;
  57714. /**
  57715. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57716. */
  57717. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57718. private _isImpostorInContact;
  57719. private _isImpostorPairInContact;
  57720. private _stepSimulation;
  57721. /**
  57722. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57723. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57724. * After the step the babylon meshes are set to the position of the physics imposters
  57725. * @param delta amount of time to step forward
  57726. * @param impostors array of imposters to update before/after the step
  57727. */
  57728. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57729. /**
  57730. * Update babylon mesh to match physics world object
  57731. * @param impostor imposter to match
  57732. */
  57733. private _afterSoftStep;
  57734. /**
  57735. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57736. * @param impostor imposter to match
  57737. */
  57738. private _ropeStep;
  57739. /**
  57740. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57741. * @param impostor imposter to match
  57742. */
  57743. private _softbodyOrClothStep;
  57744. private _tmpVector;
  57745. private _tmpMatrix;
  57746. /**
  57747. * Applies an impulse on the imposter
  57748. * @param impostor imposter to apply impulse to
  57749. * @param force amount of force to be applied to the imposter
  57750. * @param contactPoint the location to apply the impulse on the imposter
  57751. */
  57752. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57753. /**
  57754. * Applies a force on the imposter
  57755. * @param impostor imposter to apply force
  57756. * @param force amount of force to be applied to the imposter
  57757. * @param contactPoint the location to apply the force on the imposter
  57758. */
  57759. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57760. /**
  57761. * Creates a physics body using the plugin
  57762. * @param impostor the imposter to create the physics body on
  57763. */
  57764. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57765. /**
  57766. * Removes the physics body from the imposter and disposes of the body's memory
  57767. * @param impostor imposter to remove the physics body from
  57768. */
  57769. removePhysicsBody(impostor: PhysicsImpostor): void;
  57770. /**
  57771. * Generates a joint
  57772. * @param impostorJoint the imposter joint to create the joint with
  57773. */
  57774. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57775. /**
  57776. * Removes a joint
  57777. * @param impostorJoint the imposter joint to remove the joint from
  57778. */
  57779. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57780. private _addMeshVerts;
  57781. /**
  57782. * Initialise the soft body vertices to match its object's (mesh) vertices
  57783. * Softbody vertices (nodes) are in world space and to match this
  57784. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57785. * @param impostor to create the softbody for
  57786. */
  57787. private _softVertexData;
  57788. /**
  57789. * Create an impostor's soft body
  57790. * @param impostor to create the softbody for
  57791. */
  57792. private _createSoftbody;
  57793. /**
  57794. * Create cloth for an impostor
  57795. * @param impostor to create the softbody for
  57796. */
  57797. private _createCloth;
  57798. /**
  57799. * Create rope for an impostor
  57800. * @param impostor to create the softbody for
  57801. */
  57802. private _createRope;
  57803. /**
  57804. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57805. * @param impostor to create the custom physics shape for
  57806. */
  57807. private _createCustom;
  57808. private _addHullVerts;
  57809. private _createShape;
  57810. /**
  57811. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57812. * @param impostor imposter containing the physics body and babylon object
  57813. */
  57814. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57815. /**
  57816. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57817. * @param impostor imposter containing the physics body and babylon object
  57818. * @param newPosition new position
  57819. * @param newRotation new rotation
  57820. */
  57821. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57822. /**
  57823. * If this plugin is supported
  57824. * @returns true if its supported
  57825. */
  57826. isSupported(): boolean;
  57827. /**
  57828. * Sets the linear velocity of the physics body
  57829. * @param impostor imposter to set the velocity on
  57830. * @param velocity velocity to set
  57831. */
  57832. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57833. /**
  57834. * Sets the angular velocity of the physics body
  57835. * @param impostor imposter to set the velocity on
  57836. * @param velocity velocity to set
  57837. */
  57838. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57839. /**
  57840. * gets the linear velocity
  57841. * @param impostor imposter to get linear velocity from
  57842. * @returns linear velocity
  57843. */
  57844. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57845. /**
  57846. * gets the angular velocity
  57847. * @param impostor imposter to get angular velocity from
  57848. * @returns angular velocity
  57849. */
  57850. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57851. /**
  57852. * Sets the mass of physics body
  57853. * @param impostor imposter to set the mass on
  57854. * @param mass mass to set
  57855. */
  57856. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57857. /**
  57858. * Gets the mass of the physics body
  57859. * @param impostor imposter to get the mass from
  57860. * @returns mass
  57861. */
  57862. getBodyMass(impostor: PhysicsImpostor): number;
  57863. /**
  57864. * Gets friction of the impostor
  57865. * @param impostor impostor to get friction from
  57866. * @returns friction value
  57867. */
  57868. getBodyFriction(impostor: PhysicsImpostor): number;
  57869. /**
  57870. * Sets friction of the impostor
  57871. * @param impostor impostor to set friction on
  57872. * @param friction friction value
  57873. */
  57874. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57875. /**
  57876. * Gets restitution of the impostor
  57877. * @param impostor impostor to get restitution from
  57878. * @returns restitution value
  57879. */
  57880. getBodyRestitution(impostor: PhysicsImpostor): number;
  57881. /**
  57882. * Sets resitution of the impostor
  57883. * @param impostor impostor to set resitution on
  57884. * @param restitution resitution value
  57885. */
  57886. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57887. /**
  57888. * Gets pressure inside the impostor
  57889. * @param impostor impostor to get pressure from
  57890. * @returns pressure value
  57891. */
  57892. getBodyPressure(impostor: PhysicsImpostor): number;
  57893. /**
  57894. * Sets pressure inside a soft body impostor
  57895. * Cloth and rope must remain 0 pressure
  57896. * @param impostor impostor to set pressure on
  57897. * @param pressure pressure value
  57898. */
  57899. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57900. /**
  57901. * Gets stiffness of the impostor
  57902. * @param impostor impostor to get stiffness from
  57903. * @returns pressure value
  57904. */
  57905. getBodyStiffness(impostor: PhysicsImpostor): number;
  57906. /**
  57907. * Sets stiffness of the impostor
  57908. * @param impostor impostor to set stiffness on
  57909. * @param stiffness stiffness value from 0 to 1
  57910. */
  57911. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57912. /**
  57913. * Gets velocityIterations of the impostor
  57914. * @param impostor impostor to get velocity iterations from
  57915. * @returns velocityIterations value
  57916. */
  57917. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57918. /**
  57919. * Sets velocityIterations of the impostor
  57920. * @param impostor impostor to set velocity iterations on
  57921. * @param velocityIterations velocityIterations value
  57922. */
  57923. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57924. /**
  57925. * Gets positionIterations of the impostor
  57926. * @param impostor impostor to get position iterations from
  57927. * @returns positionIterations value
  57928. */
  57929. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57930. /**
  57931. * Sets positionIterations of the impostor
  57932. * @param impostor impostor to set position on
  57933. * @param positionIterations positionIterations value
  57934. */
  57935. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57936. /**
  57937. * Append an anchor to a cloth object
  57938. * @param impostor is the cloth impostor to add anchor to
  57939. * @param otherImpostor is the rigid impostor to anchor to
  57940. * @param width ratio across width from 0 to 1
  57941. * @param height ratio up height from 0 to 1
  57942. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57943. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57944. */
  57945. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57946. /**
  57947. * Append an hook to a rope object
  57948. * @param impostor is the rope impostor to add hook to
  57949. * @param otherImpostor is the rigid impostor to hook to
  57950. * @param length ratio along the rope from 0 to 1
  57951. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57952. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57953. */
  57954. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57955. /**
  57956. * Sleeps the physics body and stops it from being active
  57957. * @param impostor impostor to sleep
  57958. */
  57959. sleepBody(impostor: PhysicsImpostor): void;
  57960. /**
  57961. * Activates the physics body
  57962. * @param impostor impostor to activate
  57963. */
  57964. wakeUpBody(impostor: PhysicsImpostor): void;
  57965. /**
  57966. * Updates the distance parameters of the joint
  57967. * @param joint joint to update
  57968. * @param maxDistance maximum distance of the joint
  57969. * @param minDistance minimum distance of the joint
  57970. */
  57971. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57972. /**
  57973. * Sets a motor on the joint
  57974. * @param joint joint to set motor on
  57975. * @param speed speed of the motor
  57976. * @param maxForce maximum force of the motor
  57977. * @param motorIndex index of the motor
  57978. */
  57979. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57980. /**
  57981. * Sets the motors limit
  57982. * @param joint joint to set limit on
  57983. * @param upperLimit upper limit
  57984. * @param lowerLimit lower limit
  57985. */
  57986. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57987. /**
  57988. * Syncs the position and rotation of a mesh with the impostor
  57989. * @param mesh mesh to sync
  57990. * @param impostor impostor to update the mesh with
  57991. */
  57992. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57993. /**
  57994. * Gets the radius of the impostor
  57995. * @param impostor impostor to get radius from
  57996. * @returns the radius
  57997. */
  57998. getRadius(impostor: PhysicsImpostor): number;
  57999. /**
  58000. * Gets the box size of the impostor
  58001. * @param impostor impostor to get box size from
  58002. * @param result the resulting box size
  58003. */
  58004. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58005. /**
  58006. * Disposes of the impostor
  58007. */
  58008. dispose(): void;
  58009. /**
  58010. * Does a raycast in the physics world
  58011. * @param from when should the ray start?
  58012. * @param to when should the ray end?
  58013. * @returns PhysicsRaycastResult
  58014. */
  58015. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58016. }
  58017. }
  58018. declare module "babylonjs/Probes/reflectionProbe" {
  58019. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58020. import { Vector3 } from "babylonjs/Maths/math.vector";
  58021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58022. import { Nullable } from "babylonjs/types";
  58023. import { Scene } from "babylonjs/scene";
  58024. module "babylonjs/abstractScene" {
  58025. interface AbstractScene {
  58026. /**
  58027. * The list of reflection probes added to the scene
  58028. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58029. */
  58030. reflectionProbes: Array<ReflectionProbe>;
  58031. /**
  58032. * Removes the given reflection probe from this scene.
  58033. * @param toRemove The reflection probe to remove
  58034. * @returns The index of the removed reflection probe
  58035. */
  58036. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58037. /**
  58038. * Adds the given reflection probe to this scene.
  58039. * @param newReflectionProbe The reflection probe to add
  58040. */
  58041. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58042. }
  58043. }
  58044. /**
  58045. * Class used to generate realtime reflection / refraction cube textures
  58046. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58047. */
  58048. export class ReflectionProbe {
  58049. /** defines the name of the probe */
  58050. name: string;
  58051. private _scene;
  58052. private _renderTargetTexture;
  58053. private _projectionMatrix;
  58054. private _viewMatrix;
  58055. private _target;
  58056. private _add;
  58057. private _attachedMesh;
  58058. private _invertYAxis;
  58059. /** Gets or sets probe position (center of the cube map) */
  58060. position: Vector3;
  58061. /**
  58062. * Creates a new reflection probe
  58063. * @param name defines the name of the probe
  58064. * @param size defines the texture resolution (for each face)
  58065. * @param scene defines the hosting scene
  58066. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58067. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58068. */
  58069. constructor(
  58070. /** defines the name of the probe */
  58071. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58072. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58073. get samples(): number;
  58074. set samples(value: number);
  58075. /** Gets or sets the refresh rate to use (on every frame by default) */
  58076. get refreshRate(): number;
  58077. set refreshRate(value: number);
  58078. /**
  58079. * Gets the hosting scene
  58080. * @returns a Scene
  58081. */
  58082. getScene(): Scene;
  58083. /** Gets the internal CubeTexture used to render to */
  58084. get cubeTexture(): RenderTargetTexture;
  58085. /** Gets the list of meshes to render */
  58086. get renderList(): Nullable<AbstractMesh[]>;
  58087. /**
  58088. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58089. * @param mesh defines the mesh to attach to
  58090. */
  58091. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58092. /**
  58093. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58094. * @param renderingGroupId The rendering group id corresponding to its index
  58095. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58096. */
  58097. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58098. /**
  58099. * Clean all associated resources
  58100. */
  58101. dispose(): void;
  58102. /**
  58103. * Converts the reflection probe information to a readable string for debug purpose.
  58104. * @param fullDetails Supports for multiple levels of logging within scene loading
  58105. * @returns the human readable reflection probe info
  58106. */
  58107. toString(fullDetails?: boolean): string;
  58108. /**
  58109. * Get the class name of the relfection probe.
  58110. * @returns "ReflectionProbe"
  58111. */
  58112. getClassName(): string;
  58113. /**
  58114. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58115. * @returns The JSON representation of the texture
  58116. */
  58117. serialize(): any;
  58118. /**
  58119. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58120. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58121. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58122. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58123. * @returns The parsed reflection probe if successful
  58124. */
  58125. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58126. }
  58127. }
  58128. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58129. /** @hidden */
  58130. export var _BabylonLoaderRegistered: boolean;
  58131. /**
  58132. * Helps setting up some configuration for the babylon file loader.
  58133. */
  58134. export class BabylonFileLoaderConfiguration {
  58135. /**
  58136. * The loader does not allow injecting custom physix engine into the plugins.
  58137. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58138. * So you could set this variable to your engine import to make it work.
  58139. */
  58140. static LoaderInjectedPhysicsEngine: any;
  58141. }
  58142. }
  58143. declare module "babylonjs/Loading/Plugins/index" {
  58144. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58145. }
  58146. declare module "babylonjs/Loading/index" {
  58147. export * from "babylonjs/Loading/loadingScreen";
  58148. export * from "babylonjs/Loading/Plugins/index";
  58149. export * from "babylonjs/Loading/sceneLoader";
  58150. export * from "babylonjs/Loading/sceneLoaderFlags";
  58151. }
  58152. declare module "babylonjs/Materials/Background/index" {
  58153. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58154. }
  58155. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58156. import { Scene } from "babylonjs/scene";
  58157. import { Color3 } from "babylonjs/Maths/math.color";
  58158. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58160. /**
  58161. * The Physically based simple base material of BJS.
  58162. *
  58163. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58164. * It is used as the base class for both the specGloss and metalRough conventions.
  58165. */
  58166. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58167. /**
  58168. * Number of Simultaneous lights allowed on the material.
  58169. */
  58170. maxSimultaneousLights: number;
  58171. /**
  58172. * If sets to true, disables all the lights affecting the material.
  58173. */
  58174. disableLighting: boolean;
  58175. /**
  58176. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58177. */
  58178. environmentTexture: BaseTexture;
  58179. /**
  58180. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58181. */
  58182. invertNormalMapX: boolean;
  58183. /**
  58184. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58185. */
  58186. invertNormalMapY: boolean;
  58187. /**
  58188. * Normal map used in the model.
  58189. */
  58190. normalTexture: BaseTexture;
  58191. /**
  58192. * Emissivie color used to self-illuminate the model.
  58193. */
  58194. emissiveColor: Color3;
  58195. /**
  58196. * Emissivie texture used to self-illuminate the model.
  58197. */
  58198. emissiveTexture: BaseTexture;
  58199. /**
  58200. * Occlusion Channel Strenght.
  58201. */
  58202. occlusionStrength: number;
  58203. /**
  58204. * Occlusion Texture of the material (adding extra occlusion effects).
  58205. */
  58206. occlusionTexture: BaseTexture;
  58207. /**
  58208. * Defines the alpha limits in alpha test mode.
  58209. */
  58210. alphaCutOff: number;
  58211. /**
  58212. * Gets the current double sided mode.
  58213. */
  58214. get doubleSided(): boolean;
  58215. /**
  58216. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58217. */
  58218. set doubleSided(value: boolean);
  58219. /**
  58220. * Stores the pre-calculated light information of a mesh in a texture.
  58221. */
  58222. lightmapTexture: BaseTexture;
  58223. /**
  58224. * If true, the light map contains occlusion information instead of lighting info.
  58225. */
  58226. useLightmapAsShadowmap: boolean;
  58227. /**
  58228. * Instantiates a new PBRMaterial instance.
  58229. *
  58230. * @param name The material name
  58231. * @param scene The scene the material will be use in.
  58232. */
  58233. constructor(name: string, scene: Scene);
  58234. getClassName(): string;
  58235. }
  58236. }
  58237. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58238. import { Scene } from "babylonjs/scene";
  58239. import { Color3 } from "babylonjs/Maths/math.color";
  58240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58241. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58242. /**
  58243. * The PBR material of BJS following the metal roughness convention.
  58244. *
  58245. * This fits to the PBR convention in the GLTF definition:
  58246. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58247. */
  58248. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58249. /**
  58250. * The base color has two different interpretations depending on the value of metalness.
  58251. * When the material is a metal, the base color is the specific measured reflectance value
  58252. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58253. * of the material.
  58254. */
  58255. baseColor: Color3;
  58256. /**
  58257. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58258. * well as opacity information in the alpha channel.
  58259. */
  58260. baseTexture: BaseTexture;
  58261. /**
  58262. * Specifies the metallic scalar value of the material.
  58263. * Can also be used to scale the metalness values of the metallic texture.
  58264. */
  58265. metallic: number;
  58266. /**
  58267. * Specifies the roughness scalar value of the material.
  58268. * Can also be used to scale the roughness values of the metallic texture.
  58269. */
  58270. roughness: number;
  58271. /**
  58272. * Texture containing both the metallic value in the B channel and the
  58273. * roughness value in the G channel to keep better precision.
  58274. */
  58275. metallicRoughnessTexture: BaseTexture;
  58276. /**
  58277. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58278. *
  58279. * @param name The material name
  58280. * @param scene The scene the material will be use in.
  58281. */
  58282. constructor(name: string, scene: Scene);
  58283. /**
  58284. * Return the currrent class name of the material.
  58285. */
  58286. getClassName(): string;
  58287. /**
  58288. * Makes a duplicate of the current material.
  58289. * @param name - name to use for the new material.
  58290. */
  58291. clone(name: string): PBRMetallicRoughnessMaterial;
  58292. /**
  58293. * Serialize the material to a parsable JSON object.
  58294. */
  58295. serialize(): any;
  58296. /**
  58297. * Parses a JSON object correponding to the serialize function.
  58298. */
  58299. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58300. }
  58301. }
  58302. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58303. import { Scene } from "babylonjs/scene";
  58304. import { Color3 } from "babylonjs/Maths/math.color";
  58305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58306. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58307. /**
  58308. * The PBR material of BJS following the specular glossiness convention.
  58309. *
  58310. * This fits to the PBR convention in the GLTF definition:
  58311. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58312. */
  58313. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58314. /**
  58315. * Specifies the diffuse color of the material.
  58316. */
  58317. diffuseColor: Color3;
  58318. /**
  58319. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58320. * channel.
  58321. */
  58322. diffuseTexture: BaseTexture;
  58323. /**
  58324. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58325. */
  58326. specularColor: Color3;
  58327. /**
  58328. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58329. */
  58330. glossiness: number;
  58331. /**
  58332. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58333. */
  58334. specularGlossinessTexture: BaseTexture;
  58335. /**
  58336. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58337. *
  58338. * @param name The material name
  58339. * @param scene The scene the material will be use in.
  58340. */
  58341. constructor(name: string, scene: Scene);
  58342. /**
  58343. * Return the currrent class name of the material.
  58344. */
  58345. getClassName(): string;
  58346. /**
  58347. * Makes a duplicate of the current material.
  58348. * @param name - name to use for the new material.
  58349. */
  58350. clone(name: string): PBRSpecularGlossinessMaterial;
  58351. /**
  58352. * Serialize the material to a parsable JSON object.
  58353. */
  58354. serialize(): any;
  58355. /**
  58356. * Parses a JSON object correponding to the serialize function.
  58357. */
  58358. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58359. }
  58360. }
  58361. declare module "babylonjs/Materials/PBR/index" {
  58362. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58363. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58364. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58365. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58366. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58367. }
  58368. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58369. import { Nullable } from "babylonjs/types";
  58370. import { Scene } from "babylonjs/scene";
  58371. import { Matrix } from "babylonjs/Maths/math.vector";
  58372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58373. /**
  58374. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58375. * It can help converting any input color in a desired output one. This can then be used to create effects
  58376. * from sepia, black and white to sixties or futuristic rendering...
  58377. *
  58378. * The only supported format is currently 3dl.
  58379. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58380. */
  58381. export class ColorGradingTexture extends BaseTexture {
  58382. /**
  58383. * The current texture matrix. (will always be identity in color grading texture)
  58384. */
  58385. private _textureMatrix;
  58386. /**
  58387. * The texture URL.
  58388. */
  58389. url: string;
  58390. /**
  58391. * Empty line regex stored for GC.
  58392. */
  58393. private static _noneEmptyLineRegex;
  58394. private _engine;
  58395. /**
  58396. * Instantiates a ColorGradingTexture from the following parameters.
  58397. *
  58398. * @param url The location of the color gradind data (currently only supporting 3dl)
  58399. * @param scene The scene the texture will be used in
  58400. */
  58401. constructor(url: string, scene: Scene);
  58402. /**
  58403. * Returns the texture matrix used in most of the material.
  58404. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58405. */
  58406. getTextureMatrix(): Matrix;
  58407. /**
  58408. * Occurs when the file being loaded is a .3dl LUT file.
  58409. */
  58410. private load3dlTexture;
  58411. /**
  58412. * Starts the loading process of the texture.
  58413. */
  58414. private loadTexture;
  58415. /**
  58416. * Clones the color gradind texture.
  58417. */
  58418. clone(): ColorGradingTexture;
  58419. /**
  58420. * Called during delayed load for textures.
  58421. */
  58422. delayLoad(): void;
  58423. /**
  58424. * Parses a color grading texture serialized by Babylon.
  58425. * @param parsedTexture The texture information being parsedTexture
  58426. * @param scene The scene to load the texture in
  58427. * @param rootUrl The root url of the data assets to load
  58428. * @return A color gradind texture
  58429. */
  58430. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58431. /**
  58432. * Serializes the LUT texture to json format.
  58433. */
  58434. serialize(): any;
  58435. }
  58436. }
  58437. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58439. import { Scene } from "babylonjs/scene";
  58440. import { Nullable } from "babylonjs/types";
  58441. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58442. /**
  58443. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58444. */
  58445. export class EquiRectangularCubeTexture extends BaseTexture {
  58446. /** The six faces of the cube. */
  58447. private static _FacesMapping;
  58448. private _noMipmap;
  58449. private _onLoad;
  58450. private _onError;
  58451. /** The size of the cubemap. */
  58452. private _size;
  58453. /** The buffer of the image. */
  58454. private _buffer;
  58455. /** The width of the input image. */
  58456. private _width;
  58457. /** The height of the input image. */
  58458. private _height;
  58459. /** The URL to the image. */
  58460. url: string;
  58461. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58462. coordinatesMode: number;
  58463. /**
  58464. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58465. * @param url The location of the image
  58466. * @param scene The scene the texture will be used in
  58467. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58468. * @param noMipmap Forces to not generate the mipmap if true
  58469. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58470. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58471. * @param onLoad — defines a callback called when texture is loaded
  58472. * @param onError — defines a callback called if there is an error
  58473. */
  58474. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58475. /**
  58476. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58477. */
  58478. private loadImage;
  58479. /**
  58480. * Convert the image buffer into a cubemap and create a CubeTexture.
  58481. */
  58482. private loadTexture;
  58483. /**
  58484. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58485. * @param buffer The ArrayBuffer that should be converted.
  58486. * @returns The buffer as Float32Array.
  58487. */
  58488. private getFloat32ArrayFromArrayBuffer;
  58489. /**
  58490. * Get the current class name of the texture useful for serialization or dynamic coding.
  58491. * @returns "EquiRectangularCubeTexture"
  58492. */
  58493. getClassName(): string;
  58494. /**
  58495. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58496. * @returns A clone of the current EquiRectangularCubeTexture.
  58497. */
  58498. clone(): EquiRectangularCubeTexture;
  58499. }
  58500. }
  58501. declare module "babylonjs/Misc/tga" {
  58502. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58503. /**
  58504. * Based on jsTGALoader - Javascript loader for TGA file
  58505. * By Vincent Thibault
  58506. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58507. */
  58508. export class TGATools {
  58509. private static _TYPE_INDEXED;
  58510. private static _TYPE_RGB;
  58511. private static _TYPE_GREY;
  58512. private static _TYPE_RLE_INDEXED;
  58513. private static _TYPE_RLE_RGB;
  58514. private static _TYPE_RLE_GREY;
  58515. private static _ORIGIN_MASK;
  58516. private static _ORIGIN_SHIFT;
  58517. private static _ORIGIN_BL;
  58518. private static _ORIGIN_BR;
  58519. private static _ORIGIN_UL;
  58520. private static _ORIGIN_UR;
  58521. /**
  58522. * Gets the header of a TGA file
  58523. * @param data defines the TGA data
  58524. * @returns the header
  58525. */
  58526. static GetTGAHeader(data: Uint8Array): any;
  58527. /**
  58528. * Uploads TGA content to a Babylon Texture
  58529. * @hidden
  58530. */
  58531. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58532. /** @hidden */
  58533. 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;
  58534. /** @hidden */
  58535. 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;
  58536. /** @hidden */
  58537. 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;
  58538. /** @hidden */
  58539. 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;
  58540. /** @hidden */
  58541. 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;
  58542. /** @hidden */
  58543. 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;
  58544. }
  58545. }
  58546. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58547. import { Nullable } from "babylonjs/types";
  58548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58549. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58550. /**
  58551. * Implementation of the TGA Texture Loader.
  58552. * @hidden
  58553. */
  58554. export class _TGATextureLoader implements IInternalTextureLoader {
  58555. /**
  58556. * Defines wether the loader supports cascade loading the different faces.
  58557. */
  58558. readonly supportCascades: boolean;
  58559. /**
  58560. * This returns if the loader support the current file information.
  58561. * @param extension defines the file extension of the file being loaded
  58562. * @returns true if the loader can load the specified file
  58563. */
  58564. canLoad(extension: string): boolean;
  58565. /**
  58566. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58567. * @param data contains the texture data
  58568. * @param texture defines the BabylonJS internal texture
  58569. * @param createPolynomials will be true if polynomials have been requested
  58570. * @param onLoad defines the callback to trigger once the texture is ready
  58571. * @param onError defines the callback to trigger in case of error
  58572. */
  58573. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58574. /**
  58575. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58576. * @param data contains the texture data
  58577. * @param texture defines the BabylonJS internal texture
  58578. * @param callback defines the method to call once ready to upload
  58579. */
  58580. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58581. }
  58582. }
  58583. declare module "babylonjs/Misc/basis" {
  58584. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58585. /**
  58586. * Info about the .basis files
  58587. */
  58588. class BasisFileInfo {
  58589. /**
  58590. * If the file has alpha
  58591. */
  58592. hasAlpha: boolean;
  58593. /**
  58594. * Info about each image of the basis file
  58595. */
  58596. images: Array<{
  58597. levels: Array<{
  58598. width: number;
  58599. height: number;
  58600. transcodedPixels: ArrayBufferView;
  58601. }>;
  58602. }>;
  58603. }
  58604. /**
  58605. * Result of transcoding a basis file
  58606. */
  58607. class TranscodeResult {
  58608. /**
  58609. * Info about the .basis file
  58610. */
  58611. fileInfo: BasisFileInfo;
  58612. /**
  58613. * Format to use when loading the file
  58614. */
  58615. format: number;
  58616. }
  58617. /**
  58618. * Configuration options for the Basis transcoder
  58619. */
  58620. export class BasisTranscodeConfiguration {
  58621. /**
  58622. * Supported compression formats used to determine the supported output format of the transcoder
  58623. */
  58624. supportedCompressionFormats?: {
  58625. /**
  58626. * etc1 compression format
  58627. */
  58628. etc1?: boolean;
  58629. /**
  58630. * s3tc compression format
  58631. */
  58632. s3tc?: boolean;
  58633. /**
  58634. * pvrtc compression format
  58635. */
  58636. pvrtc?: boolean;
  58637. /**
  58638. * etc2 compression format
  58639. */
  58640. etc2?: boolean;
  58641. };
  58642. /**
  58643. * If mipmap levels should be loaded for transcoded images (Default: true)
  58644. */
  58645. loadMipmapLevels?: boolean;
  58646. /**
  58647. * Index of a single image to load (Default: all images)
  58648. */
  58649. loadSingleImage?: number;
  58650. }
  58651. /**
  58652. * Used to load .Basis files
  58653. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58654. */
  58655. export class BasisTools {
  58656. private static _IgnoreSupportedFormats;
  58657. /**
  58658. * URL to use when loading the basis transcoder
  58659. */
  58660. static JSModuleURL: string;
  58661. /**
  58662. * URL to use when loading the wasm module for the transcoder
  58663. */
  58664. static WasmModuleURL: string;
  58665. /**
  58666. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58667. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58668. * @returns internal format corresponding to the Basis format
  58669. */
  58670. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58671. private static _WorkerPromise;
  58672. private static _Worker;
  58673. private static _actionId;
  58674. private static _CreateWorkerAsync;
  58675. /**
  58676. * Transcodes a loaded image file to compressed pixel data
  58677. * @param data image data to transcode
  58678. * @param config configuration options for the transcoding
  58679. * @returns a promise resulting in the transcoded image
  58680. */
  58681. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58682. /**
  58683. * Loads a texture from the transcode result
  58684. * @param texture texture load to
  58685. * @param transcodeResult the result of transcoding the basis file to load from
  58686. */
  58687. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58688. }
  58689. }
  58690. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58691. import { Nullable } from "babylonjs/types";
  58692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58693. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58694. /**
  58695. * Loader for .basis file format
  58696. */
  58697. export class _BasisTextureLoader implements IInternalTextureLoader {
  58698. /**
  58699. * Defines whether the loader supports cascade loading the different faces.
  58700. */
  58701. readonly supportCascades: boolean;
  58702. /**
  58703. * This returns if the loader support the current file information.
  58704. * @param extension defines the file extension of the file being loaded
  58705. * @returns true if the loader can load the specified file
  58706. */
  58707. canLoad(extension: string): boolean;
  58708. /**
  58709. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58710. * @param data contains the texture data
  58711. * @param texture defines the BabylonJS internal texture
  58712. * @param createPolynomials will be true if polynomials have been requested
  58713. * @param onLoad defines the callback to trigger once the texture is ready
  58714. * @param onError defines the callback to trigger in case of error
  58715. */
  58716. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58717. /**
  58718. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58719. * @param data contains the texture data
  58720. * @param texture defines the BabylonJS internal texture
  58721. * @param callback defines the method to call once ready to upload
  58722. */
  58723. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58724. }
  58725. }
  58726. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58727. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58728. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58729. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58730. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58731. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58732. }
  58733. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58734. import { Scene } from "babylonjs/scene";
  58735. import { Texture } from "babylonjs/Materials/Textures/texture";
  58736. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58737. /**
  58738. * 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.
  58739. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58740. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58741. */
  58742. export class CustomProceduralTexture extends ProceduralTexture {
  58743. private _animate;
  58744. private _time;
  58745. private _config;
  58746. private _texturePath;
  58747. /**
  58748. * Instantiates a new Custom Procedural Texture.
  58749. * 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.
  58750. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58751. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58752. * @param name Define the name of the texture
  58753. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58754. * @param size Define the size of the texture to create
  58755. * @param scene Define the scene the texture belongs to
  58756. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58757. * @param generateMipMaps Define if the texture should creates mip maps or not
  58758. */
  58759. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58760. private _loadJson;
  58761. /**
  58762. * Is the texture ready to be used ? (rendered at least once)
  58763. * @returns true if ready, otherwise, false.
  58764. */
  58765. isReady(): boolean;
  58766. /**
  58767. * Render the texture to its associated render target.
  58768. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58769. */
  58770. render(useCameraPostProcess?: boolean): void;
  58771. /**
  58772. * Update the list of dependant textures samplers in the shader.
  58773. */
  58774. updateTextures(): void;
  58775. /**
  58776. * Update the uniform values of the procedural texture in the shader.
  58777. */
  58778. updateShaderUniforms(): void;
  58779. /**
  58780. * Define if the texture animates or not.
  58781. */
  58782. get animate(): boolean;
  58783. set animate(value: boolean);
  58784. }
  58785. }
  58786. declare module "babylonjs/Shaders/noise.fragment" {
  58787. /** @hidden */
  58788. export var noisePixelShader: {
  58789. name: string;
  58790. shader: string;
  58791. };
  58792. }
  58793. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58794. import { Nullable } from "babylonjs/types";
  58795. import { Scene } from "babylonjs/scene";
  58796. import { Texture } from "babylonjs/Materials/Textures/texture";
  58797. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58798. import "babylonjs/Shaders/noise.fragment";
  58799. /**
  58800. * Class used to generate noise procedural textures
  58801. */
  58802. export class NoiseProceduralTexture extends ProceduralTexture {
  58803. private _time;
  58804. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58805. brightness: number;
  58806. /** Defines the number of octaves to process */
  58807. octaves: number;
  58808. /** Defines the level of persistence (0.8 by default) */
  58809. persistence: number;
  58810. /** Gets or sets animation speed factor (default is 1) */
  58811. animationSpeedFactor: number;
  58812. /**
  58813. * Creates a new NoiseProceduralTexture
  58814. * @param name defines the name fo the texture
  58815. * @param size defines the size of the texture (default is 256)
  58816. * @param scene defines the hosting scene
  58817. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58818. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58819. */
  58820. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58821. private _updateShaderUniforms;
  58822. protected _getDefines(): string;
  58823. /** Generate the current state of the procedural texture */
  58824. render(useCameraPostProcess?: boolean): void;
  58825. /**
  58826. * Serializes this noise procedural texture
  58827. * @returns a serialized noise procedural texture object
  58828. */
  58829. serialize(): any;
  58830. /**
  58831. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58832. * @param parsedTexture defines parsed texture data
  58833. * @param scene defines the current scene
  58834. * @param rootUrl defines the root URL containing noise procedural texture information
  58835. * @returns a parsed NoiseProceduralTexture
  58836. */
  58837. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58838. }
  58839. }
  58840. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58841. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58842. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58843. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58844. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58845. }
  58846. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58847. import { Nullable } from "babylonjs/types";
  58848. import { Scene } from "babylonjs/scene";
  58849. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58850. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58851. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58853. /**
  58854. * Raw cube texture where the raw buffers are passed in
  58855. */
  58856. export class RawCubeTexture extends CubeTexture {
  58857. /**
  58858. * Creates a cube texture where the raw buffers are passed in.
  58859. * @param scene defines the scene the texture is attached to
  58860. * @param data defines the array of data to use to create each face
  58861. * @param size defines the size of the textures
  58862. * @param format defines the format of the data
  58863. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58864. * @param generateMipMaps defines if the engine should generate the mip levels
  58865. * @param invertY defines if data must be stored with Y axis inverted
  58866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58867. * @param compression defines the compression used (null by default)
  58868. */
  58869. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58870. /**
  58871. * Updates the raw cube texture.
  58872. * @param data defines the data to store
  58873. * @param format defines the data format
  58874. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58875. * @param invertY defines if data must be stored with Y axis inverted
  58876. * @param compression defines the compression used (null by default)
  58877. * @param level defines which level of the texture to update
  58878. */
  58879. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58880. /**
  58881. * Updates a raw cube texture with RGBD encoded data.
  58882. * @param data defines the array of data [mipmap][face] to use to create each face
  58883. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58884. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58885. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58886. * @returns a promsie that resolves when the operation is complete
  58887. */
  58888. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58889. /**
  58890. * Clones the raw cube texture.
  58891. * @return a new cube texture
  58892. */
  58893. clone(): CubeTexture;
  58894. /** @hidden */
  58895. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58896. }
  58897. }
  58898. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58899. import { Scene } from "babylonjs/scene";
  58900. import { Texture } from "babylonjs/Materials/Textures/texture";
  58901. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58902. /**
  58903. * Class used to store 3D textures containing user data
  58904. */
  58905. export class RawTexture3D extends Texture {
  58906. /** Gets or sets the texture format to use */
  58907. format: number;
  58908. private _engine;
  58909. /**
  58910. * Create a new RawTexture3D
  58911. * @param data defines the data of the texture
  58912. * @param width defines the width of the texture
  58913. * @param height defines the height of the texture
  58914. * @param depth defines the depth of the texture
  58915. * @param format defines the texture format to use
  58916. * @param scene defines the hosting scene
  58917. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58918. * @param invertY defines if texture must be stored with Y axis inverted
  58919. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58920. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58921. */
  58922. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58923. /** Gets or sets the texture format to use */
  58924. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58925. /**
  58926. * Update the texture with new data
  58927. * @param data defines the data to store in the texture
  58928. */
  58929. update(data: ArrayBufferView): void;
  58930. }
  58931. }
  58932. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58933. import { Scene } from "babylonjs/scene";
  58934. import { Texture } from "babylonjs/Materials/Textures/texture";
  58935. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58936. /**
  58937. * Class used to store 2D array textures containing user data
  58938. */
  58939. export class RawTexture2DArray extends Texture {
  58940. /** Gets or sets the texture format to use */
  58941. format: number;
  58942. private _engine;
  58943. /**
  58944. * Create a new RawTexture2DArray
  58945. * @param data defines the data of the texture
  58946. * @param width defines the width of the texture
  58947. * @param height defines the height of the texture
  58948. * @param depth defines the number of layers of the texture
  58949. * @param format defines the texture format to use
  58950. * @param scene defines the hosting scene
  58951. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58952. * @param invertY defines if texture must be stored with Y axis inverted
  58953. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58954. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58955. */
  58956. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58957. /** Gets or sets the texture format to use */
  58958. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58959. /**
  58960. * Update the texture with new data
  58961. * @param data defines the data to store in the texture
  58962. */
  58963. update(data: ArrayBufferView): void;
  58964. }
  58965. }
  58966. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58967. import { Scene } from "babylonjs/scene";
  58968. import { Plane } from "babylonjs/Maths/math.plane";
  58969. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58970. /**
  58971. * Creates a refraction texture used by refraction channel of the standard material.
  58972. * It is like a mirror but to see through a material.
  58973. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58974. */
  58975. export class RefractionTexture extends RenderTargetTexture {
  58976. /**
  58977. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58978. * 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.
  58979. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58980. */
  58981. refractionPlane: Plane;
  58982. /**
  58983. * Define how deep under the surface we should see.
  58984. */
  58985. depth: number;
  58986. /**
  58987. * Creates a refraction texture used by refraction channel of the standard material.
  58988. * It is like a mirror but to see through a material.
  58989. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58990. * @param name Define the texture name
  58991. * @param size Define the size of the underlying texture
  58992. * @param scene Define the scene the refraction belongs to
  58993. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58994. */
  58995. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58996. /**
  58997. * Clone the refraction texture.
  58998. * @returns the cloned texture
  58999. */
  59000. clone(): RefractionTexture;
  59001. /**
  59002. * Serialize the texture to a JSON representation you could use in Parse later on
  59003. * @returns the serialized JSON representation
  59004. */
  59005. serialize(): any;
  59006. }
  59007. }
  59008. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59009. import { Nullable } from "babylonjs/types";
  59010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59011. import { Matrix } from "babylonjs/Maths/math.vector";
  59012. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59013. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59014. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59015. import { Scene } from "babylonjs/scene";
  59016. /**
  59017. * Defines the options related to the creation of an HtmlElementTexture
  59018. */
  59019. export interface IHtmlElementTextureOptions {
  59020. /**
  59021. * Defines wether mip maps should be created or not.
  59022. */
  59023. generateMipMaps?: boolean;
  59024. /**
  59025. * Defines the sampling mode of the texture.
  59026. */
  59027. samplingMode?: number;
  59028. /**
  59029. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59030. */
  59031. engine: Nullable<ThinEngine>;
  59032. /**
  59033. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59034. */
  59035. scene: Nullable<Scene>;
  59036. }
  59037. /**
  59038. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59039. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59040. * is automatically managed.
  59041. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59042. * in your application.
  59043. *
  59044. * As the update is not automatic, you need to call them manually.
  59045. */
  59046. export class HtmlElementTexture extends BaseTexture {
  59047. /**
  59048. * The texture URL.
  59049. */
  59050. element: HTMLVideoElement | HTMLCanvasElement;
  59051. private static readonly DefaultOptions;
  59052. private _textureMatrix;
  59053. private _engine;
  59054. private _isVideo;
  59055. private _generateMipMaps;
  59056. private _samplingMode;
  59057. /**
  59058. * Instantiates a HtmlElementTexture from the following parameters.
  59059. *
  59060. * @param name Defines the name of the texture
  59061. * @param element Defines the video or canvas the texture is filled with
  59062. * @param options Defines the other none mandatory texture creation options
  59063. */
  59064. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59065. private _createInternalTexture;
  59066. /**
  59067. * Returns the texture matrix used in most of the material.
  59068. */
  59069. getTextureMatrix(): Matrix;
  59070. /**
  59071. * Updates the content of the texture.
  59072. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59073. */
  59074. update(invertY?: Nullable<boolean>): void;
  59075. }
  59076. }
  59077. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59078. import { Vector2 } from "babylonjs/Maths/math.vector";
  59079. /**
  59080. * Defines the basic options interface of a TexturePacker Frame
  59081. */
  59082. export interface ITexturePackerFrame {
  59083. /**
  59084. * The frame ID
  59085. */
  59086. id: number;
  59087. /**
  59088. * The frames Scale
  59089. */
  59090. scale: Vector2;
  59091. /**
  59092. * The Frames offset
  59093. */
  59094. offset: Vector2;
  59095. }
  59096. /**
  59097. * This is a support class for frame Data on texture packer sets.
  59098. */
  59099. export class TexturePackerFrame implements ITexturePackerFrame {
  59100. /**
  59101. * The frame ID
  59102. */
  59103. id: number;
  59104. /**
  59105. * The frames Scale
  59106. */
  59107. scale: Vector2;
  59108. /**
  59109. * The Frames offset
  59110. */
  59111. offset: Vector2;
  59112. /**
  59113. * Initializes a texture package frame.
  59114. * @param id The numerical frame identifier
  59115. * @param scale Scalar Vector2 for UV frame
  59116. * @param offset Vector2 for the frame position in UV units.
  59117. * @returns TexturePackerFrame
  59118. */
  59119. constructor(id: number, scale: Vector2, offset: Vector2);
  59120. }
  59121. }
  59122. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59124. import { Scene } from "babylonjs/scene";
  59125. import { Nullable } from "babylonjs/types";
  59126. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59127. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59128. /**
  59129. * Defines the basic options interface of a TexturePacker
  59130. */
  59131. export interface ITexturePackerOptions {
  59132. /**
  59133. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59134. */
  59135. map?: string[];
  59136. /**
  59137. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59138. */
  59139. uvsIn?: string;
  59140. /**
  59141. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59142. */
  59143. uvsOut?: string;
  59144. /**
  59145. * number representing the layout style. Defaults to LAYOUT_STRIP
  59146. */
  59147. layout?: number;
  59148. /**
  59149. * number of columns if using custom column count layout(2). This defaults to 4.
  59150. */
  59151. colnum?: number;
  59152. /**
  59153. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59154. */
  59155. updateInputMeshes?: boolean;
  59156. /**
  59157. * boolean flag to dispose all the source textures. Defaults to true.
  59158. */
  59159. disposeSources?: boolean;
  59160. /**
  59161. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59162. */
  59163. fillBlanks?: boolean;
  59164. /**
  59165. * string value representing the context fill style color. Defaults to 'black'.
  59166. */
  59167. customFillColor?: string;
  59168. /**
  59169. * Width and Height Value of each Frame in the TexturePacker Sets
  59170. */
  59171. frameSize?: number;
  59172. /**
  59173. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59174. */
  59175. paddingRatio?: number;
  59176. /**
  59177. * Number that declares the fill method for the padding gutter.
  59178. */
  59179. paddingMode?: number;
  59180. /**
  59181. * If in SUBUV_COLOR padding mode what color to use.
  59182. */
  59183. paddingColor?: Color3 | Color4;
  59184. }
  59185. /**
  59186. * Defines the basic interface of a TexturePacker JSON File
  59187. */
  59188. export interface ITexturePackerJSON {
  59189. /**
  59190. * The frame ID
  59191. */
  59192. name: string;
  59193. /**
  59194. * The base64 channel data
  59195. */
  59196. sets: any;
  59197. /**
  59198. * The options of the Packer
  59199. */
  59200. options: ITexturePackerOptions;
  59201. /**
  59202. * The frame data of the Packer
  59203. */
  59204. frames: Array<number>;
  59205. }
  59206. /**
  59207. * This is a support class that generates a series of packed texture sets.
  59208. * @see https://doc.babylonjs.com/babylon101/materials
  59209. */
  59210. export class TexturePacker {
  59211. /** Packer Layout Constant 0 */
  59212. static readonly LAYOUT_STRIP: number;
  59213. /** Packer Layout Constant 1 */
  59214. static readonly LAYOUT_POWER2: number;
  59215. /** Packer Layout Constant 2 */
  59216. static readonly LAYOUT_COLNUM: number;
  59217. /** Packer Layout Constant 0 */
  59218. static readonly SUBUV_WRAP: number;
  59219. /** Packer Layout Constant 1 */
  59220. static readonly SUBUV_EXTEND: number;
  59221. /** Packer Layout Constant 2 */
  59222. static readonly SUBUV_COLOR: number;
  59223. /** The Name of the Texture Package */
  59224. name: string;
  59225. /** The scene scope of the TexturePacker */
  59226. scene: Scene;
  59227. /** The Meshes to target */
  59228. meshes: AbstractMesh[];
  59229. /** Arguments passed with the Constructor */
  59230. options: ITexturePackerOptions;
  59231. /** The promise that is started upon initialization */
  59232. promise: Nullable<Promise<TexturePacker | string>>;
  59233. /** The Container object for the channel sets that are generated */
  59234. sets: object;
  59235. /** The Container array for the frames that are generated */
  59236. frames: TexturePackerFrame[];
  59237. /** The expected number of textures the system is parsing. */
  59238. private _expecting;
  59239. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59240. private _paddingValue;
  59241. /**
  59242. * Initializes a texture package series from an array of meshes or a single mesh.
  59243. * @param name The name of the package
  59244. * @param meshes The target meshes to compose the package from
  59245. * @param options The arguments that texture packer should follow while building.
  59246. * @param scene The scene which the textures are scoped to.
  59247. * @returns TexturePacker
  59248. */
  59249. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59250. /**
  59251. * Starts the package process
  59252. * @param resolve The promises resolution function
  59253. * @returns TexturePacker
  59254. */
  59255. private _createFrames;
  59256. /**
  59257. * Calculates the Size of the Channel Sets
  59258. * @returns Vector2
  59259. */
  59260. private _calculateSize;
  59261. /**
  59262. * Calculates the UV data for the frames.
  59263. * @param baseSize the base frameSize
  59264. * @param padding the base frame padding
  59265. * @param dtSize size of the Dynamic Texture for that channel
  59266. * @param dtUnits is 1/dtSize
  59267. * @param update flag to update the input meshes
  59268. */
  59269. private _calculateMeshUVFrames;
  59270. /**
  59271. * Calculates the frames Offset.
  59272. * @param index of the frame
  59273. * @returns Vector2
  59274. */
  59275. private _getFrameOffset;
  59276. /**
  59277. * Updates a Mesh to the frame data
  59278. * @param mesh that is the target
  59279. * @param frameID or the frame index
  59280. */
  59281. private _updateMeshUV;
  59282. /**
  59283. * Updates a Meshes materials to use the texture packer channels
  59284. * @param m is the mesh to target
  59285. * @param force all channels on the packer to be set.
  59286. */
  59287. private _updateTextureReferences;
  59288. /**
  59289. * Public method to set a Mesh to a frame
  59290. * @param m that is the target
  59291. * @param frameID or the frame index
  59292. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59293. */
  59294. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59295. /**
  59296. * Starts the async promise to compile the texture packer.
  59297. * @returns Promise<void>
  59298. */
  59299. processAsync(): Promise<void>;
  59300. /**
  59301. * Disposes all textures associated with this packer
  59302. */
  59303. dispose(): void;
  59304. /**
  59305. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59306. * @param imageType is the image type to use.
  59307. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59308. */
  59309. download(imageType?: string, quality?: number): void;
  59310. /**
  59311. * Public method to load a texturePacker JSON file.
  59312. * @param data of the JSON file in string format.
  59313. */
  59314. updateFromJSON(data: string): void;
  59315. }
  59316. }
  59317. declare module "babylonjs/Materials/Textures/Packer/index" {
  59318. export * from "babylonjs/Materials/Textures/Packer/packer";
  59319. export * from "babylonjs/Materials/Textures/Packer/frame";
  59320. }
  59321. declare module "babylonjs/Materials/Textures/index" {
  59322. export * from "babylonjs/Materials/Textures/baseTexture";
  59323. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59324. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59325. export * from "babylonjs/Materials/Textures/cubeTexture";
  59326. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59327. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59328. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59329. export * from "babylonjs/Materials/Textures/internalTexture";
  59330. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59331. export * from "babylonjs/Materials/Textures/Loaders/index";
  59332. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59333. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59334. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59335. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59336. export * from "babylonjs/Materials/Textures/rawTexture";
  59337. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59338. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59339. export * from "babylonjs/Materials/Textures/refractionTexture";
  59340. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59341. export * from "babylonjs/Materials/Textures/texture";
  59342. export * from "babylonjs/Materials/Textures/videoTexture";
  59343. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59344. export * from "babylonjs/Materials/Textures/Packer/index";
  59345. }
  59346. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59347. /**
  59348. * Enum used to define the target of a block
  59349. */
  59350. export enum NodeMaterialBlockTargets {
  59351. /** Vertex shader */
  59352. Vertex = 1,
  59353. /** Fragment shader */
  59354. Fragment = 2,
  59355. /** Neutral */
  59356. Neutral = 4,
  59357. /** Vertex and Fragment */
  59358. VertexAndFragment = 3
  59359. }
  59360. }
  59361. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59362. /**
  59363. * Defines the kind of connection point for node based material
  59364. */
  59365. export enum NodeMaterialBlockConnectionPointTypes {
  59366. /** Float */
  59367. Float = 1,
  59368. /** Int */
  59369. Int = 2,
  59370. /** Vector2 */
  59371. Vector2 = 4,
  59372. /** Vector3 */
  59373. Vector3 = 8,
  59374. /** Vector4 */
  59375. Vector4 = 16,
  59376. /** Color3 */
  59377. Color3 = 32,
  59378. /** Color4 */
  59379. Color4 = 64,
  59380. /** Matrix */
  59381. Matrix = 128,
  59382. /** Detect type based on connection */
  59383. AutoDetect = 1024,
  59384. /** Output type that will be defined by input type */
  59385. BasedOnInput = 2048
  59386. }
  59387. }
  59388. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59389. /**
  59390. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59391. */
  59392. export enum NodeMaterialBlockConnectionPointMode {
  59393. /** Value is an uniform */
  59394. Uniform = 0,
  59395. /** Value is a mesh attribute */
  59396. Attribute = 1,
  59397. /** Value is a varying between vertex and fragment shaders */
  59398. Varying = 2,
  59399. /** Mode is undefined */
  59400. Undefined = 3
  59401. }
  59402. }
  59403. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59404. /**
  59405. * Enum used to define system values e.g. values automatically provided by the system
  59406. */
  59407. export enum NodeMaterialSystemValues {
  59408. /** World */
  59409. World = 1,
  59410. /** View */
  59411. View = 2,
  59412. /** Projection */
  59413. Projection = 3,
  59414. /** ViewProjection */
  59415. ViewProjection = 4,
  59416. /** WorldView */
  59417. WorldView = 5,
  59418. /** WorldViewProjection */
  59419. WorldViewProjection = 6,
  59420. /** CameraPosition */
  59421. CameraPosition = 7,
  59422. /** Fog Color */
  59423. FogColor = 8,
  59424. /** Delta time */
  59425. DeltaTime = 9
  59426. }
  59427. }
  59428. declare module "babylonjs/Materials/Node/Enums/index" {
  59429. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59430. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59431. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59432. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59433. }
  59434. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59436. /**
  59437. * Root class for all node material optimizers
  59438. */
  59439. export class NodeMaterialOptimizer {
  59440. /**
  59441. * Function used to optimize a NodeMaterial graph
  59442. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59443. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59444. */
  59445. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59446. }
  59447. }
  59448. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59452. import { Scene } from "babylonjs/scene";
  59453. /**
  59454. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59455. */
  59456. export class TransformBlock extends NodeMaterialBlock {
  59457. /**
  59458. * Defines the value to use to complement W value to transform it to a Vector4
  59459. */
  59460. complementW: number;
  59461. /**
  59462. * Defines the value to use to complement z value to transform it to a Vector4
  59463. */
  59464. complementZ: number;
  59465. /**
  59466. * Creates a new TransformBlock
  59467. * @param name defines the block name
  59468. */
  59469. constructor(name: string);
  59470. /**
  59471. * Gets the current class name
  59472. * @returns the class name
  59473. */
  59474. getClassName(): string;
  59475. /**
  59476. * Gets the vector input
  59477. */
  59478. get vector(): NodeMaterialConnectionPoint;
  59479. /**
  59480. * Gets the output component
  59481. */
  59482. get output(): NodeMaterialConnectionPoint;
  59483. /**
  59484. * Gets the xyz output component
  59485. */
  59486. get xyz(): NodeMaterialConnectionPoint;
  59487. /**
  59488. * Gets the matrix transform input
  59489. */
  59490. get transform(): NodeMaterialConnectionPoint;
  59491. protected _buildBlock(state: NodeMaterialBuildState): this;
  59492. serialize(): any;
  59493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59494. protected _dumpPropertiesCode(): string;
  59495. }
  59496. }
  59497. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59501. /**
  59502. * Block used to output the vertex position
  59503. */
  59504. export class VertexOutputBlock extends NodeMaterialBlock {
  59505. /**
  59506. * Creates a new VertexOutputBlock
  59507. * @param name defines the block name
  59508. */
  59509. constructor(name: string);
  59510. /**
  59511. * Gets the current class name
  59512. * @returns the class name
  59513. */
  59514. getClassName(): string;
  59515. /**
  59516. * Gets the vector input component
  59517. */
  59518. get vector(): NodeMaterialConnectionPoint;
  59519. protected _buildBlock(state: NodeMaterialBuildState): this;
  59520. }
  59521. }
  59522. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59526. /**
  59527. * Block used to output the final color
  59528. */
  59529. export class FragmentOutputBlock extends NodeMaterialBlock {
  59530. /**
  59531. * Create a new FragmentOutputBlock
  59532. * @param name defines the block name
  59533. */
  59534. constructor(name: string);
  59535. /**
  59536. * Gets the current class name
  59537. * @returns the class name
  59538. */
  59539. getClassName(): string;
  59540. /**
  59541. * Gets the rgba input component
  59542. */
  59543. get rgba(): NodeMaterialConnectionPoint;
  59544. /**
  59545. * Gets the rgb input component
  59546. */
  59547. get rgb(): NodeMaterialConnectionPoint;
  59548. /**
  59549. * Gets the a input component
  59550. */
  59551. get a(): NodeMaterialConnectionPoint;
  59552. protected _buildBlock(state: NodeMaterialBuildState): this;
  59553. }
  59554. }
  59555. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59561. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59562. import { Effect } from "babylonjs/Materials/effect";
  59563. import { Mesh } from "babylonjs/Meshes/mesh";
  59564. import { Nullable } from "babylonjs/types";
  59565. import { Scene } from "babylonjs/scene";
  59566. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59567. /**
  59568. * Block used to read a reflection texture from a sampler
  59569. */
  59570. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59571. private _define3DName;
  59572. private _defineCubicName;
  59573. private _defineExplicitName;
  59574. private _defineProjectionName;
  59575. private _defineLocalCubicName;
  59576. private _defineSphericalName;
  59577. private _definePlanarName;
  59578. private _defineEquirectangularName;
  59579. private _defineMirroredEquirectangularFixedName;
  59580. private _defineEquirectangularFixedName;
  59581. private _defineSkyboxName;
  59582. private _cubeSamplerName;
  59583. private _2DSamplerName;
  59584. private _positionUVWName;
  59585. private _directionWName;
  59586. private _reflectionCoordsName;
  59587. private _reflection2DCoordsName;
  59588. private _reflectionColorName;
  59589. private _reflectionMatrixName;
  59590. /**
  59591. * Gets or sets the texture associated with the node
  59592. */
  59593. texture: Nullable<BaseTexture>;
  59594. /**
  59595. * Create a new TextureBlock
  59596. * @param name defines the block name
  59597. */
  59598. constructor(name: string);
  59599. /**
  59600. * Gets the current class name
  59601. * @returns the class name
  59602. */
  59603. getClassName(): string;
  59604. /**
  59605. * Gets the world position input component
  59606. */
  59607. get position(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the world position input component
  59610. */
  59611. get worldPosition(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the world normal input component
  59614. */
  59615. get worldNormal(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the world input component
  59618. */
  59619. get world(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the camera (or eye) position component
  59622. */
  59623. get cameraPosition(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the view input component
  59626. */
  59627. get view(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the rgb output component
  59630. */
  59631. get rgb(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the r output component
  59634. */
  59635. get r(): NodeMaterialConnectionPoint;
  59636. /**
  59637. * Gets the g output component
  59638. */
  59639. get g(): NodeMaterialConnectionPoint;
  59640. /**
  59641. * Gets the b output component
  59642. */
  59643. get b(): NodeMaterialConnectionPoint;
  59644. autoConfigure(material: NodeMaterial): void;
  59645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59646. isReady(): boolean;
  59647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59648. private _injectVertexCode;
  59649. private _writeOutput;
  59650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59651. protected _dumpPropertiesCode(): string;
  59652. serialize(): any;
  59653. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59654. }
  59655. }
  59656. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59658. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59659. import { Scene } from "babylonjs/scene";
  59660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59661. import { Matrix } from "babylonjs/Maths/math.vector";
  59662. import { Mesh } from "babylonjs/Meshes/mesh";
  59663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59664. import { Observable } from "babylonjs/Misc/observable";
  59665. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59666. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59667. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59668. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59669. import { Nullable } from "babylonjs/types";
  59670. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59671. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59672. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59673. /**
  59674. * Interface used to configure the node material editor
  59675. */
  59676. export interface INodeMaterialEditorOptions {
  59677. /** Define the URl to load node editor script */
  59678. editorURL?: string;
  59679. }
  59680. /** @hidden */
  59681. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59682. NORMAL: boolean;
  59683. TANGENT: boolean;
  59684. UV1: boolean;
  59685. /** BONES */
  59686. NUM_BONE_INFLUENCERS: number;
  59687. BonesPerMesh: number;
  59688. BONETEXTURE: boolean;
  59689. /** MORPH TARGETS */
  59690. MORPHTARGETS: boolean;
  59691. MORPHTARGETS_NORMAL: boolean;
  59692. MORPHTARGETS_TANGENT: boolean;
  59693. MORPHTARGETS_UV: boolean;
  59694. NUM_MORPH_INFLUENCERS: number;
  59695. /** IMAGE PROCESSING */
  59696. IMAGEPROCESSING: boolean;
  59697. VIGNETTE: boolean;
  59698. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59699. VIGNETTEBLENDMODEOPAQUE: boolean;
  59700. TONEMAPPING: boolean;
  59701. TONEMAPPING_ACES: boolean;
  59702. CONTRAST: boolean;
  59703. EXPOSURE: boolean;
  59704. COLORCURVES: boolean;
  59705. COLORGRADING: boolean;
  59706. COLORGRADING3D: boolean;
  59707. SAMPLER3DGREENDEPTH: boolean;
  59708. SAMPLER3DBGRMAP: boolean;
  59709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59710. /** MISC. */
  59711. BUMPDIRECTUV: number;
  59712. constructor();
  59713. setValue(name: string, value: boolean): void;
  59714. }
  59715. /**
  59716. * Class used to configure NodeMaterial
  59717. */
  59718. export interface INodeMaterialOptions {
  59719. /**
  59720. * Defines if blocks should emit comments
  59721. */
  59722. emitComments: boolean;
  59723. }
  59724. /**
  59725. * Class used to create a node based material built by assembling shader blocks
  59726. */
  59727. export class NodeMaterial extends PushMaterial {
  59728. private static _BuildIdGenerator;
  59729. private _options;
  59730. private _vertexCompilationState;
  59731. private _fragmentCompilationState;
  59732. private _sharedData;
  59733. private _buildId;
  59734. private _buildWasSuccessful;
  59735. private _cachedWorldViewMatrix;
  59736. private _cachedWorldViewProjectionMatrix;
  59737. private _optimizers;
  59738. private _animationFrame;
  59739. /** Define the Url to load node editor script */
  59740. static EditorURL: string;
  59741. /** Define the Url to load snippets */
  59742. static SnippetUrl: string;
  59743. private BJSNODEMATERIALEDITOR;
  59744. /** Get the inspector from bundle or global */
  59745. private _getGlobalNodeMaterialEditor;
  59746. /**
  59747. * Gets or sets data used by visual editor
  59748. * @see https://nme.babylonjs.com
  59749. */
  59750. editorData: any;
  59751. /**
  59752. * 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)
  59753. */
  59754. ignoreAlpha: boolean;
  59755. /**
  59756. * Defines the maximum number of lights that can be used in the material
  59757. */
  59758. maxSimultaneousLights: number;
  59759. /**
  59760. * Observable raised when the material is built
  59761. */
  59762. onBuildObservable: Observable<NodeMaterial>;
  59763. /**
  59764. * Gets or sets the root nodes of the material vertex shader
  59765. */
  59766. _vertexOutputNodes: NodeMaterialBlock[];
  59767. /**
  59768. * Gets or sets the root nodes of the material fragment (pixel) shader
  59769. */
  59770. _fragmentOutputNodes: NodeMaterialBlock[];
  59771. /** Gets or sets options to control the node material overall behavior */
  59772. get options(): INodeMaterialOptions;
  59773. set options(options: INodeMaterialOptions);
  59774. /**
  59775. * Default configuration related to image processing available in the standard Material.
  59776. */
  59777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59778. /**
  59779. * Gets the image processing configuration used either in this material.
  59780. */
  59781. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59782. /**
  59783. * Sets the Default image processing configuration used either in the this material.
  59784. *
  59785. * If sets to null, the scene one is in use.
  59786. */
  59787. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59788. /**
  59789. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59790. */
  59791. attachedBlocks: NodeMaterialBlock[];
  59792. /**
  59793. * Create a new node based material
  59794. * @param name defines the material name
  59795. * @param scene defines the hosting scene
  59796. * @param options defines creation option
  59797. */
  59798. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59799. /**
  59800. * Gets the current class name of the material e.g. "NodeMaterial"
  59801. * @returns the class name
  59802. */
  59803. getClassName(): string;
  59804. /**
  59805. * Keep track of the image processing observer to allow dispose and replace.
  59806. */
  59807. private _imageProcessingObserver;
  59808. /**
  59809. * Attaches a new image processing configuration to the Standard Material.
  59810. * @param configuration
  59811. */
  59812. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59813. /**
  59814. * Get a block by its name
  59815. * @param name defines the name of the block to retrieve
  59816. * @returns the required block or null if not found
  59817. */
  59818. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59819. /**
  59820. * Get a block by its name
  59821. * @param predicate defines the predicate used to find the good candidate
  59822. * @returns the required block or null if not found
  59823. */
  59824. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59825. /**
  59826. * Get an input block by its name
  59827. * @param predicate defines the predicate used to find the good candidate
  59828. * @returns the required input block or null if not found
  59829. */
  59830. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59831. /**
  59832. * Gets the list of input blocks attached to this material
  59833. * @returns an array of InputBlocks
  59834. */
  59835. getInputBlocks(): InputBlock[];
  59836. /**
  59837. * Adds a new optimizer to the list of optimizers
  59838. * @param optimizer defines the optimizers to add
  59839. * @returns the current material
  59840. */
  59841. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59842. /**
  59843. * Remove an optimizer from the list of optimizers
  59844. * @param optimizer defines the optimizers to remove
  59845. * @returns the current material
  59846. */
  59847. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59848. /**
  59849. * Add a new block to the list of output nodes
  59850. * @param node defines the node to add
  59851. * @returns the current material
  59852. */
  59853. addOutputNode(node: NodeMaterialBlock): this;
  59854. /**
  59855. * Remove a block from the list of root nodes
  59856. * @param node defines the node to remove
  59857. * @returns the current material
  59858. */
  59859. removeOutputNode(node: NodeMaterialBlock): this;
  59860. private _addVertexOutputNode;
  59861. private _removeVertexOutputNode;
  59862. private _addFragmentOutputNode;
  59863. private _removeFragmentOutputNode;
  59864. /**
  59865. * Specifies if the material will require alpha blending
  59866. * @returns a boolean specifying if alpha blending is needed
  59867. */
  59868. needAlphaBlending(): boolean;
  59869. /**
  59870. * Specifies if this material should be rendered in alpha test mode
  59871. * @returns a boolean specifying if an alpha test is needed.
  59872. */
  59873. needAlphaTesting(): boolean;
  59874. private _initializeBlock;
  59875. private _resetDualBlocks;
  59876. /**
  59877. * Remove a block from the current node material
  59878. * @param block defines the block to remove
  59879. */
  59880. removeBlock(block: NodeMaterialBlock): void;
  59881. /**
  59882. * Build the material and generates the inner effect
  59883. * @param verbose defines if the build should log activity
  59884. */
  59885. build(verbose?: boolean): void;
  59886. /**
  59887. * Runs an otpimization phase to try to improve the shader code
  59888. */
  59889. optimize(): void;
  59890. private _prepareDefinesForAttributes;
  59891. /**
  59892. * Get if the submesh is ready to be used and all its information available.
  59893. * Child classes can use it to update shaders
  59894. * @param mesh defines the mesh to check
  59895. * @param subMesh defines which submesh to check
  59896. * @param useInstances specifies that instances should be used
  59897. * @returns a boolean indicating that the submesh is ready or not
  59898. */
  59899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59900. /**
  59901. * Get a string representing the shaders built by the current node graph
  59902. */
  59903. get compiledShaders(): string;
  59904. /**
  59905. * Binds the world matrix to the material
  59906. * @param world defines the world transformation matrix
  59907. */
  59908. bindOnlyWorldMatrix(world: Matrix): void;
  59909. /**
  59910. * Binds the submesh to this material by preparing the effect and shader to draw
  59911. * @param world defines the world transformation matrix
  59912. * @param mesh defines the mesh containing the submesh
  59913. * @param subMesh defines the submesh to bind the material to
  59914. */
  59915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59916. /**
  59917. * Gets the active textures from the material
  59918. * @returns an array of textures
  59919. */
  59920. getActiveTextures(): BaseTexture[];
  59921. /**
  59922. * Gets the list of texture blocks
  59923. * @returns an array of texture blocks
  59924. */
  59925. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59926. /**
  59927. * Specifies if the material uses a texture
  59928. * @param texture defines the texture to check against the material
  59929. * @returns a boolean specifying if the material uses the texture
  59930. */
  59931. hasTexture(texture: BaseTexture): boolean;
  59932. /**
  59933. * Disposes the material
  59934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59936. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59937. */
  59938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59939. /** Creates the node editor window. */
  59940. private _createNodeEditor;
  59941. /**
  59942. * Launch the node material editor
  59943. * @param config Define the configuration of the editor
  59944. * @return a promise fulfilled when the node editor is visible
  59945. */
  59946. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59947. /**
  59948. * Clear the current material
  59949. */
  59950. clear(): void;
  59951. /**
  59952. * Clear the current material and set it to a default state
  59953. */
  59954. setToDefault(): void;
  59955. /**
  59956. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59957. * @param url defines the url to load from
  59958. * @returns a promise that will fullfil when the material is fully loaded
  59959. */
  59960. loadAsync(url: string): Promise<void>;
  59961. private _gatherBlocks;
  59962. /**
  59963. * Generate a string containing the code declaration required to create an equivalent of this material
  59964. * @returns a string
  59965. */
  59966. generateCode(): string;
  59967. /**
  59968. * Serializes this material in a JSON representation
  59969. * @returns the serialized material object
  59970. */
  59971. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59972. private _restoreConnections;
  59973. /**
  59974. * Clear the current graph and load a new one from a serialization object
  59975. * @param source defines the JSON representation of the material
  59976. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59977. */
  59978. loadFromSerialization(source: any, rootUrl?: string): void;
  59979. /**
  59980. * Creates a node material from parsed material data
  59981. * @param source defines the JSON representation of the material
  59982. * @param scene defines the hosting scene
  59983. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59984. * @returns a new node material
  59985. */
  59986. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59987. /**
  59988. * Creates a node material from a snippet saved in a remote file
  59989. * @param name defines the name of the material to create
  59990. * @param url defines the url to load from
  59991. * @param scene defines the hosting scene
  59992. * @returns a promise that will resolve to the new node material
  59993. */
  59994. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59995. /**
  59996. * Creates a node material from a snippet saved by the node material editor
  59997. * @param snippetId defines the snippet to load
  59998. * @param scene defines the hosting scene
  59999. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60000. * @returns a promise that will resolve to the new node material
  60001. */
  60002. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  60003. /**
  60004. * Creates a new node material set to default basic configuration
  60005. * @param name defines the name of the material
  60006. * @param scene defines the hosting scene
  60007. * @returns a new NodeMaterial
  60008. */
  60009. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60010. }
  60011. }
  60012. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60015. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60018. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60019. import { Effect } from "babylonjs/Materials/effect";
  60020. import { Mesh } from "babylonjs/Meshes/mesh";
  60021. import { Nullable } from "babylonjs/types";
  60022. import { Texture } from "babylonjs/Materials/Textures/texture";
  60023. import { Scene } from "babylonjs/scene";
  60024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60025. /**
  60026. * Block used to read a texture from a sampler
  60027. */
  60028. export class TextureBlock extends NodeMaterialBlock {
  60029. private _defineName;
  60030. private _linearDefineName;
  60031. private _tempTextureRead;
  60032. private _samplerName;
  60033. private _transformedUVName;
  60034. private _textureTransformName;
  60035. private _textureInfoName;
  60036. private _mainUVName;
  60037. private _mainUVDefineName;
  60038. /**
  60039. * Gets or sets the texture associated with the node
  60040. */
  60041. texture: Nullable<Texture>;
  60042. /**
  60043. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60044. */
  60045. convertToGammaSpace: boolean;
  60046. /**
  60047. * Create a new TextureBlock
  60048. * @param name defines the block name
  60049. */
  60050. constructor(name: string);
  60051. /**
  60052. * Gets the current class name
  60053. * @returns the class name
  60054. */
  60055. getClassName(): string;
  60056. /**
  60057. * Gets the uv input component
  60058. */
  60059. get uv(): NodeMaterialConnectionPoint;
  60060. /**
  60061. * Gets the rgba output component
  60062. */
  60063. get rgba(): NodeMaterialConnectionPoint;
  60064. /**
  60065. * Gets the rgb output component
  60066. */
  60067. get rgb(): NodeMaterialConnectionPoint;
  60068. /**
  60069. * Gets the r output component
  60070. */
  60071. get r(): NodeMaterialConnectionPoint;
  60072. /**
  60073. * Gets the g output component
  60074. */
  60075. get g(): NodeMaterialConnectionPoint;
  60076. /**
  60077. * Gets the b output component
  60078. */
  60079. get b(): NodeMaterialConnectionPoint;
  60080. /**
  60081. * Gets the a output component
  60082. */
  60083. get a(): NodeMaterialConnectionPoint;
  60084. get target(): NodeMaterialBlockTargets;
  60085. autoConfigure(material: NodeMaterial): void;
  60086. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60088. isReady(): boolean;
  60089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60090. private get _isMixed();
  60091. private _injectVertexCode;
  60092. private _writeTextureRead;
  60093. private _writeOutput;
  60094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60095. protected _dumpPropertiesCode(): string;
  60096. serialize(): any;
  60097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60098. }
  60099. }
  60100. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60103. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60104. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60105. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60106. import { Scene } from "babylonjs/scene";
  60107. /**
  60108. * Class used to store shared data between 2 NodeMaterialBuildState
  60109. */
  60110. export class NodeMaterialBuildStateSharedData {
  60111. /**
  60112. * Gets the list of emitted varyings
  60113. */
  60114. temps: string[];
  60115. /**
  60116. * Gets the list of emitted varyings
  60117. */
  60118. varyings: string[];
  60119. /**
  60120. * Gets the varying declaration string
  60121. */
  60122. varyingDeclaration: string;
  60123. /**
  60124. * Input blocks
  60125. */
  60126. inputBlocks: InputBlock[];
  60127. /**
  60128. * Input blocks
  60129. */
  60130. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60131. /**
  60132. * Bindable blocks (Blocks that need to set data to the effect)
  60133. */
  60134. bindableBlocks: NodeMaterialBlock[];
  60135. /**
  60136. * List of blocks that can provide a compilation fallback
  60137. */
  60138. blocksWithFallbacks: NodeMaterialBlock[];
  60139. /**
  60140. * List of blocks that can provide a define update
  60141. */
  60142. blocksWithDefines: NodeMaterialBlock[];
  60143. /**
  60144. * List of blocks that can provide a repeatable content
  60145. */
  60146. repeatableContentBlocks: NodeMaterialBlock[];
  60147. /**
  60148. * List of blocks that can provide a dynamic list of uniforms
  60149. */
  60150. dynamicUniformBlocks: NodeMaterialBlock[];
  60151. /**
  60152. * List of blocks that can block the isReady function for the material
  60153. */
  60154. blockingBlocks: NodeMaterialBlock[];
  60155. /**
  60156. * Gets the list of animated inputs
  60157. */
  60158. animatedInputs: InputBlock[];
  60159. /**
  60160. * Build Id used to avoid multiple recompilations
  60161. */
  60162. buildId: number;
  60163. /** List of emitted variables */
  60164. variableNames: {
  60165. [key: string]: number;
  60166. };
  60167. /** List of emitted defines */
  60168. defineNames: {
  60169. [key: string]: number;
  60170. };
  60171. /** Should emit comments? */
  60172. emitComments: boolean;
  60173. /** Emit build activity */
  60174. verbose: boolean;
  60175. /** Gets or sets the hosting scene */
  60176. scene: Scene;
  60177. /**
  60178. * Gets the compilation hints emitted at compilation time
  60179. */
  60180. hints: {
  60181. needWorldViewMatrix: boolean;
  60182. needWorldViewProjectionMatrix: boolean;
  60183. needAlphaBlending: boolean;
  60184. needAlphaTesting: boolean;
  60185. };
  60186. /**
  60187. * List of compilation checks
  60188. */
  60189. checks: {
  60190. emitVertex: boolean;
  60191. emitFragment: boolean;
  60192. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60193. };
  60194. /** Creates a new shared data */
  60195. constructor();
  60196. /**
  60197. * Emits console errors and exceptions if there is a failing check
  60198. */
  60199. emitErrors(): void;
  60200. }
  60201. }
  60202. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60203. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60204. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60205. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60206. /**
  60207. * Class used to store node based material build state
  60208. */
  60209. export class NodeMaterialBuildState {
  60210. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60211. supportUniformBuffers: boolean;
  60212. /**
  60213. * Gets the list of emitted attributes
  60214. */
  60215. attributes: string[];
  60216. /**
  60217. * Gets the list of emitted uniforms
  60218. */
  60219. uniforms: string[];
  60220. /**
  60221. * Gets the list of emitted constants
  60222. */
  60223. constants: string[];
  60224. /**
  60225. * Gets the list of emitted samplers
  60226. */
  60227. samplers: string[];
  60228. /**
  60229. * Gets the list of emitted functions
  60230. */
  60231. functions: {
  60232. [key: string]: string;
  60233. };
  60234. /**
  60235. * Gets the list of emitted extensions
  60236. */
  60237. extensions: {
  60238. [key: string]: string;
  60239. };
  60240. /**
  60241. * Gets the target of the compilation state
  60242. */
  60243. target: NodeMaterialBlockTargets;
  60244. /**
  60245. * Gets the list of emitted counters
  60246. */
  60247. counters: {
  60248. [key: string]: number;
  60249. };
  60250. /**
  60251. * Shared data between multiple NodeMaterialBuildState instances
  60252. */
  60253. sharedData: NodeMaterialBuildStateSharedData;
  60254. /** @hidden */
  60255. _vertexState: NodeMaterialBuildState;
  60256. /** @hidden */
  60257. _attributeDeclaration: string;
  60258. /** @hidden */
  60259. _uniformDeclaration: string;
  60260. /** @hidden */
  60261. _constantDeclaration: string;
  60262. /** @hidden */
  60263. _samplerDeclaration: string;
  60264. /** @hidden */
  60265. _varyingTransfer: string;
  60266. private _repeatableContentAnchorIndex;
  60267. /** @hidden */
  60268. _builtCompilationString: string;
  60269. /**
  60270. * Gets the emitted compilation strings
  60271. */
  60272. compilationString: string;
  60273. /**
  60274. * Finalize the compilation strings
  60275. * @param state defines the current compilation state
  60276. */
  60277. finalize(state: NodeMaterialBuildState): void;
  60278. /** @hidden */
  60279. get _repeatableContentAnchor(): string;
  60280. /** @hidden */
  60281. _getFreeVariableName(prefix: string): string;
  60282. /** @hidden */
  60283. _getFreeDefineName(prefix: string): string;
  60284. /** @hidden */
  60285. _excludeVariableName(name: string): void;
  60286. /** @hidden */
  60287. _emit2DSampler(name: string): void;
  60288. /** @hidden */
  60289. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60290. /** @hidden */
  60291. _emitExtension(name: string, extension: string): void;
  60292. /** @hidden */
  60293. _emitFunction(name: string, code: string, comments: string): void;
  60294. /** @hidden */
  60295. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60296. replaceStrings?: {
  60297. search: RegExp;
  60298. replace: string;
  60299. }[];
  60300. repeatKey?: string;
  60301. }): string;
  60302. /** @hidden */
  60303. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60304. repeatKey?: string;
  60305. removeAttributes?: boolean;
  60306. removeUniforms?: boolean;
  60307. removeVaryings?: boolean;
  60308. removeIfDef?: boolean;
  60309. replaceStrings?: {
  60310. search: RegExp;
  60311. replace: string;
  60312. }[];
  60313. }, storeKey?: string): void;
  60314. /** @hidden */
  60315. _registerTempVariable(name: string): boolean;
  60316. /** @hidden */
  60317. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60318. /** @hidden */
  60319. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60320. /** @hidden */
  60321. _emitFloat(value: number): string;
  60322. }
  60323. }
  60324. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60325. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60327. import { Nullable } from "babylonjs/types";
  60328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60329. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60330. import { Effect } from "babylonjs/Materials/effect";
  60331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60332. import { Mesh } from "babylonjs/Meshes/mesh";
  60333. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60334. import { Scene } from "babylonjs/scene";
  60335. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60336. /**
  60337. * Defines a block that can be used inside a node based material
  60338. */
  60339. export class NodeMaterialBlock {
  60340. private _buildId;
  60341. private _buildTarget;
  60342. private _target;
  60343. private _isFinalMerger;
  60344. private _isInput;
  60345. protected _isUnique: boolean;
  60346. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60347. inputsAreExclusive: boolean;
  60348. /** @hidden */
  60349. _codeVariableName: string;
  60350. /** @hidden */
  60351. _inputs: NodeMaterialConnectionPoint[];
  60352. /** @hidden */
  60353. _outputs: NodeMaterialConnectionPoint[];
  60354. /** @hidden */
  60355. _preparationId: number;
  60356. /**
  60357. * Gets or sets the name of the block
  60358. */
  60359. name: string;
  60360. /**
  60361. * Gets or sets the unique id of the node
  60362. */
  60363. uniqueId: number;
  60364. /**
  60365. * Gets or sets the comments associated with this block
  60366. */
  60367. comments: string;
  60368. /**
  60369. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60370. */
  60371. get isUnique(): boolean;
  60372. /**
  60373. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60374. */
  60375. get isFinalMerger(): boolean;
  60376. /**
  60377. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60378. */
  60379. get isInput(): boolean;
  60380. /**
  60381. * Gets or sets the build Id
  60382. */
  60383. get buildId(): number;
  60384. set buildId(value: number);
  60385. /**
  60386. * Gets or sets the target of the block
  60387. */
  60388. get target(): NodeMaterialBlockTargets;
  60389. set target(value: NodeMaterialBlockTargets);
  60390. /**
  60391. * Gets the list of input points
  60392. */
  60393. get inputs(): NodeMaterialConnectionPoint[];
  60394. /** Gets the list of output points */
  60395. get outputs(): NodeMaterialConnectionPoint[];
  60396. /**
  60397. * Find an input by its name
  60398. * @param name defines the name of the input to look for
  60399. * @returns the input or null if not found
  60400. */
  60401. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60402. /**
  60403. * Find an output by its name
  60404. * @param name defines the name of the outputto look for
  60405. * @returns the output or null if not found
  60406. */
  60407. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60408. /**
  60409. * Creates a new NodeMaterialBlock
  60410. * @param name defines the block name
  60411. * @param target defines the target of that block (Vertex by default)
  60412. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60413. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60414. */
  60415. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60416. /**
  60417. * Initialize the block and prepare the context for build
  60418. * @param state defines the state that will be used for the build
  60419. */
  60420. initialize(state: NodeMaterialBuildState): void;
  60421. /**
  60422. * Bind data to effect. Will only be called for blocks with isBindable === true
  60423. * @param effect defines the effect to bind data to
  60424. * @param nodeMaterial defines the hosting NodeMaterial
  60425. * @param mesh defines the mesh that will be rendered
  60426. */
  60427. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60428. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60429. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60430. protected _writeFloat(value: number): string;
  60431. /**
  60432. * Gets the current class name e.g. "NodeMaterialBlock"
  60433. * @returns the class name
  60434. */
  60435. getClassName(): string;
  60436. /**
  60437. * Register a new input. Must be called inside a block constructor
  60438. * @param name defines the connection point name
  60439. * @param type defines the connection point type
  60440. * @param isOptional defines a boolean indicating that this input can be omitted
  60441. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60442. * @returns the current block
  60443. */
  60444. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60445. /**
  60446. * Register a new output. Must be called inside a block constructor
  60447. * @param name defines the connection point name
  60448. * @param type defines the connection point type
  60449. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60450. * @returns the current block
  60451. */
  60452. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60453. /**
  60454. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60455. * @param forOutput defines an optional connection point to check compatibility with
  60456. * @returns the first available input or null
  60457. */
  60458. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60459. /**
  60460. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60461. * @param forBlock defines an optional block to check compatibility with
  60462. * @returns the first available input or null
  60463. */
  60464. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60465. /**
  60466. * Gets the sibling of the given output
  60467. * @param current defines the current output
  60468. * @returns the next output in the list or null
  60469. */
  60470. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60471. /**
  60472. * Connect current block with another block
  60473. * @param other defines the block to connect with
  60474. * @param options define the various options to help pick the right connections
  60475. * @returns the current block
  60476. */
  60477. connectTo(other: NodeMaterialBlock, options?: {
  60478. input?: string;
  60479. output?: string;
  60480. outputSwizzle?: string;
  60481. }): this | undefined;
  60482. protected _buildBlock(state: NodeMaterialBuildState): void;
  60483. /**
  60484. * Add uniforms, samplers and uniform buffers at compilation time
  60485. * @param state defines the state to update
  60486. * @param nodeMaterial defines the node material requesting the update
  60487. * @param defines defines the material defines to update
  60488. * @param uniformBuffers defines the list of uniform buffer names
  60489. */
  60490. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60491. /**
  60492. * Add potential fallbacks if shader compilation fails
  60493. * @param mesh defines the mesh to be rendered
  60494. * @param fallbacks defines the current prioritized list of fallbacks
  60495. */
  60496. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60497. /**
  60498. * Initialize defines for shader compilation
  60499. * @param mesh defines the mesh to be rendered
  60500. * @param nodeMaterial defines the node material requesting the update
  60501. * @param defines defines the material defines to update
  60502. * @param useInstances specifies that instances should be used
  60503. */
  60504. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60505. /**
  60506. * Update defines for shader compilation
  60507. * @param mesh defines the mesh to be rendered
  60508. * @param nodeMaterial defines the node material requesting the update
  60509. * @param defines defines the material defines to update
  60510. * @param useInstances specifies that instances should be used
  60511. */
  60512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60513. /**
  60514. * Lets the block try to connect some inputs automatically
  60515. * @param material defines the hosting NodeMaterial
  60516. */
  60517. autoConfigure(material: NodeMaterial): void;
  60518. /**
  60519. * Function called when a block is declared as repeatable content generator
  60520. * @param vertexShaderState defines the current compilation state for the vertex shader
  60521. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60522. * @param mesh defines the mesh to be rendered
  60523. * @param defines defines the material defines to update
  60524. */
  60525. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60526. /**
  60527. * Checks if the block is ready
  60528. * @param mesh defines the mesh to be rendered
  60529. * @param nodeMaterial defines the node material requesting the update
  60530. * @param defines defines the material defines to update
  60531. * @param useInstances specifies that instances should be used
  60532. * @returns true if the block is ready
  60533. */
  60534. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60535. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60536. private _processBuild;
  60537. /**
  60538. * Compile the current node and generate the shader code
  60539. * @param state defines the current compilation state (uniforms, samplers, current string)
  60540. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60541. * @returns true if already built
  60542. */
  60543. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60544. protected _inputRename(name: string): string;
  60545. protected _outputRename(name: string): string;
  60546. protected _dumpPropertiesCode(): string;
  60547. /** @hidden */
  60548. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60549. /** @hidden */
  60550. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60551. /**
  60552. * Clone the current block to a new identical block
  60553. * @param scene defines the hosting scene
  60554. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60555. * @returns a copy of the current block
  60556. */
  60557. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60558. /**
  60559. * Serializes this block in a JSON representation
  60560. * @returns the serialized block object
  60561. */
  60562. serialize(): any;
  60563. /** @hidden */
  60564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60565. /**
  60566. * Release resources
  60567. */
  60568. dispose(): void;
  60569. }
  60570. }
  60571. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60572. /**
  60573. * Enum defining the type of animations supported by InputBlock
  60574. */
  60575. export enum AnimatedInputBlockTypes {
  60576. /** No animation */
  60577. None = 0,
  60578. /** Time based animation. Will only work for floats */
  60579. Time = 1
  60580. }
  60581. }
  60582. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60584. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60585. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60586. import { Nullable } from "babylonjs/types";
  60587. import { Effect } from "babylonjs/Materials/effect";
  60588. import { Matrix } from "babylonjs/Maths/math.vector";
  60589. import { Scene } from "babylonjs/scene";
  60590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60592. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60593. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60594. import { Observable } from "babylonjs/Misc/observable";
  60595. /**
  60596. * Block used to expose an input value
  60597. */
  60598. export class InputBlock extends NodeMaterialBlock {
  60599. private _mode;
  60600. private _associatedVariableName;
  60601. private _storedValue;
  60602. private _valueCallback;
  60603. private _type;
  60604. private _animationType;
  60605. /** Gets or set a value used to limit the range of float values */
  60606. min: number;
  60607. /** Gets or set a value used to limit the range of float values */
  60608. max: number;
  60609. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60610. isBoolean: boolean;
  60611. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60612. matrixMode: number;
  60613. /** @hidden */
  60614. _systemValue: Nullable<NodeMaterialSystemValues>;
  60615. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60616. visibleInInspector: boolean;
  60617. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60618. isConstant: boolean;
  60619. /** Gets or sets the group to use to display this block in the Inspector */
  60620. groupInInspector: string;
  60621. /** Gets an observable raised when the value is changed */
  60622. onValueChangedObservable: Observable<InputBlock>;
  60623. /**
  60624. * Gets or sets the connection point type (default is float)
  60625. */
  60626. get type(): NodeMaterialBlockConnectionPointTypes;
  60627. /**
  60628. * Creates a new InputBlock
  60629. * @param name defines the block name
  60630. * @param target defines the target of that block (Vertex by default)
  60631. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60632. */
  60633. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60634. /**
  60635. * Gets the output component
  60636. */
  60637. get output(): NodeMaterialConnectionPoint;
  60638. /**
  60639. * Set the source of this connection point to a vertex attribute
  60640. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60641. * @returns the current connection point
  60642. */
  60643. setAsAttribute(attributeName?: string): InputBlock;
  60644. /**
  60645. * Set the source of this connection point to a system value
  60646. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60647. * @returns the current connection point
  60648. */
  60649. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60650. /**
  60651. * Gets or sets the value of that point.
  60652. * Please note that this value will be ignored if valueCallback is defined
  60653. */
  60654. get value(): any;
  60655. set value(value: any);
  60656. /**
  60657. * Gets or sets a callback used to get the value of that point.
  60658. * Please note that setting this value will force the connection point to ignore the value property
  60659. */
  60660. get valueCallback(): () => any;
  60661. set valueCallback(value: () => any);
  60662. /**
  60663. * Gets or sets the associated variable name in the shader
  60664. */
  60665. get associatedVariableName(): string;
  60666. set associatedVariableName(value: string);
  60667. /** Gets or sets the type of animation applied to the input */
  60668. get animationType(): AnimatedInputBlockTypes;
  60669. set animationType(value: AnimatedInputBlockTypes);
  60670. /**
  60671. * Gets a boolean indicating that this connection point not defined yet
  60672. */
  60673. get isUndefined(): boolean;
  60674. /**
  60675. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60676. * In this case the connection point name must be the name of the uniform to use.
  60677. * Can only be set on inputs
  60678. */
  60679. get isUniform(): boolean;
  60680. set isUniform(value: boolean);
  60681. /**
  60682. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60683. * In this case the connection point name must be the name of the attribute to use
  60684. * Can only be set on inputs
  60685. */
  60686. get isAttribute(): boolean;
  60687. set isAttribute(value: boolean);
  60688. /**
  60689. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60690. * Can only be set on exit points
  60691. */
  60692. get isVarying(): boolean;
  60693. set isVarying(value: boolean);
  60694. /**
  60695. * Gets a boolean indicating that the current connection point is a system value
  60696. */
  60697. get isSystemValue(): boolean;
  60698. /**
  60699. * Gets or sets the current well known value or null if not defined as a system value
  60700. */
  60701. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60702. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60703. /**
  60704. * Gets the current class name
  60705. * @returns the class name
  60706. */
  60707. getClassName(): string;
  60708. /**
  60709. * Animate the input if animationType !== None
  60710. * @param scene defines the rendering scene
  60711. */
  60712. animate(scene: Scene): void;
  60713. private _emitDefine;
  60714. initialize(state: NodeMaterialBuildState): void;
  60715. /**
  60716. * Set the input block to its default value (based on its type)
  60717. */
  60718. setDefaultValue(): void;
  60719. private _emitConstant;
  60720. private _emit;
  60721. /** @hidden */
  60722. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60723. /** @hidden */
  60724. _transmit(effect: Effect, scene: Scene): void;
  60725. protected _buildBlock(state: NodeMaterialBuildState): void;
  60726. protected _dumpPropertiesCode(): string;
  60727. dispose(): void;
  60728. serialize(): any;
  60729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60730. }
  60731. }
  60732. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60733. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60734. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60735. import { Nullable } from "babylonjs/types";
  60736. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60737. import { Observable } from "babylonjs/Misc/observable";
  60738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60739. /**
  60740. * Enum used to define the compatibility state between two connection points
  60741. */
  60742. export enum NodeMaterialConnectionPointCompatibilityStates {
  60743. /** Points are compatibles */
  60744. Compatible = 0,
  60745. /** Points are incompatible because of their types */
  60746. TypeIncompatible = 1,
  60747. /** Points are incompatible because of their targets (vertex vs fragment) */
  60748. TargetIncompatible = 2
  60749. }
  60750. /**
  60751. * Defines the direction of a connection point
  60752. */
  60753. export enum NodeMaterialConnectionPointDirection {
  60754. /** Input */
  60755. Input = 0,
  60756. /** Output */
  60757. Output = 1
  60758. }
  60759. /**
  60760. * Defines a connection point for a block
  60761. */
  60762. export class NodeMaterialConnectionPoint {
  60763. /** @hidden */
  60764. _ownerBlock: NodeMaterialBlock;
  60765. /** @hidden */
  60766. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60767. private _endpoints;
  60768. private _associatedVariableName;
  60769. private _direction;
  60770. /** @hidden */
  60771. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60772. /** @hidden */
  60773. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60774. private _type;
  60775. /** @hidden */
  60776. _enforceAssociatedVariableName: boolean;
  60777. /** Gets the direction of the point */
  60778. get direction(): NodeMaterialConnectionPointDirection;
  60779. /**
  60780. * Gets or sets the additional types supported by this connection point
  60781. */
  60782. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60783. /**
  60784. * Gets or sets the additional types excluded by this connection point
  60785. */
  60786. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60787. /**
  60788. * Observable triggered when this point is connected
  60789. */
  60790. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60791. /**
  60792. * Gets or sets the associated variable name in the shader
  60793. */
  60794. get associatedVariableName(): string;
  60795. set associatedVariableName(value: string);
  60796. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60797. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60798. /**
  60799. * Gets or sets the connection point type (default is float)
  60800. */
  60801. get type(): NodeMaterialBlockConnectionPointTypes;
  60802. set type(value: NodeMaterialBlockConnectionPointTypes);
  60803. /**
  60804. * Gets or sets the connection point name
  60805. */
  60806. name: string;
  60807. /**
  60808. * Gets or sets a boolean indicating that this connection point can be omitted
  60809. */
  60810. isOptional: boolean;
  60811. /**
  60812. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60813. */
  60814. define: string;
  60815. /** @hidden */
  60816. _prioritizeVertex: boolean;
  60817. private _target;
  60818. /** Gets or sets the target of that connection point */
  60819. get target(): NodeMaterialBlockTargets;
  60820. set target(value: NodeMaterialBlockTargets);
  60821. /**
  60822. * Gets a boolean indicating that the current point is connected
  60823. */
  60824. get isConnected(): boolean;
  60825. /**
  60826. * Gets a boolean indicating that the current point is connected to an input block
  60827. */
  60828. get isConnectedToInputBlock(): boolean;
  60829. /**
  60830. * Gets a the connected input block (if any)
  60831. */
  60832. get connectInputBlock(): Nullable<InputBlock>;
  60833. /** Get the other side of the connection (if any) */
  60834. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60835. /** Get the block that owns this connection point */
  60836. get ownerBlock(): NodeMaterialBlock;
  60837. /** Get the block connected on the other side of this connection (if any) */
  60838. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60839. /** Get the block connected on the endpoints of this connection (if any) */
  60840. get connectedBlocks(): Array<NodeMaterialBlock>;
  60841. /** Gets the list of connected endpoints */
  60842. get endpoints(): NodeMaterialConnectionPoint[];
  60843. /** Gets a boolean indicating if that output point is connected to at least one input */
  60844. get hasEndpoints(): boolean;
  60845. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60846. get isConnectedInVertexShader(): boolean;
  60847. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60848. get isConnectedInFragmentShader(): boolean;
  60849. /**
  60850. * Creates a new connection point
  60851. * @param name defines the connection point name
  60852. * @param ownerBlock defines the block hosting this connection point
  60853. * @param direction defines the direction of the connection point
  60854. */
  60855. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60856. /**
  60857. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60858. * @returns the class name
  60859. */
  60860. getClassName(): string;
  60861. /**
  60862. * Gets a boolean indicating if the current point can be connected to another point
  60863. * @param connectionPoint defines the other connection point
  60864. * @returns a boolean
  60865. */
  60866. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60867. /**
  60868. * Gets a number indicating if the current point can be connected to another point
  60869. * @param connectionPoint defines the other connection point
  60870. * @returns a number defining the compatibility state
  60871. */
  60872. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60873. /**
  60874. * Connect this point to another connection point
  60875. * @param connectionPoint defines the other connection point
  60876. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60877. * @returns the current connection point
  60878. */
  60879. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60880. /**
  60881. * Disconnect this point from one of his endpoint
  60882. * @param endpoint defines the other connection point
  60883. * @returns the current connection point
  60884. */
  60885. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60886. /**
  60887. * Serializes this point in a JSON representation
  60888. * @returns the serialized point object
  60889. */
  60890. serialize(): any;
  60891. /**
  60892. * Release resources
  60893. */
  60894. dispose(): void;
  60895. }
  60896. }
  60897. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60901. import { Mesh } from "babylonjs/Meshes/mesh";
  60902. import { Effect } from "babylonjs/Materials/effect";
  60903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60904. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60905. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60906. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60907. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60908. /**
  60909. * Block used to add support for vertex skinning (bones)
  60910. */
  60911. export class BonesBlock extends NodeMaterialBlock {
  60912. /**
  60913. * Creates a new BonesBlock
  60914. * @param name defines the block name
  60915. */
  60916. constructor(name: string);
  60917. /**
  60918. * Initialize the block and prepare the context for build
  60919. * @param state defines the state that will be used for the build
  60920. */
  60921. initialize(state: NodeMaterialBuildState): void;
  60922. /**
  60923. * Gets the current class name
  60924. * @returns the class name
  60925. */
  60926. getClassName(): string;
  60927. /**
  60928. * Gets the matrix indices input component
  60929. */
  60930. get matricesIndices(): NodeMaterialConnectionPoint;
  60931. /**
  60932. * Gets the matrix weights input component
  60933. */
  60934. get matricesWeights(): NodeMaterialConnectionPoint;
  60935. /**
  60936. * Gets the extra matrix indices input component
  60937. */
  60938. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60939. /**
  60940. * Gets the extra matrix weights input component
  60941. */
  60942. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60943. /**
  60944. * Gets the world input component
  60945. */
  60946. get world(): NodeMaterialConnectionPoint;
  60947. /**
  60948. * Gets the output component
  60949. */
  60950. get output(): NodeMaterialConnectionPoint;
  60951. autoConfigure(material: NodeMaterial): void;
  60952. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60953. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60955. protected _buildBlock(state: NodeMaterialBuildState): this;
  60956. }
  60957. }
  60958. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60963. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60964. /**
  60965. * Block used to add support for instances
  60966. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60967. */
  60968. export class InstancesBlock extends NodeMaterialBlock {
  60969. /**
  60970. * Creates a new InstancesBlock
  60971. * @param name defines the block name
  60972. */
  60973. constructor(name: string);
  60974. /**
  60975. * Gets the current class name
  60976. * @returns the class name
  60977. */
  60978. getClassName(): string;
  60979. /**
  60980. * Gets the first world row input component
  60981. */
  60982. get world0(): NodeMaterialConnectionPoint;
  60983. /**
  60984. * Gets the second world row input component
  60985. */
  60986. get world1(): NodeMaterialConnectionPoint;
  60987. /**
  60988. * Gets the third world row input component
  60989. */
  60990. get world2(): NodeMaterialConnectionPoint;
  60991. /**
  60992. * Gets the forth world row input component
  60993. */
  60994. get world3(): NodeMaterialConnectionPoint;
  60995. /**
  60996. * Gets the world input component
  60997. */
  60998. get world(): NodeMaterialConnectionPoint;
  60999. /**
  61000. * Gets the output component
  61001. */
  61002. get output(): NodeMaterialConnectionPoint;
  61003. /**
  61004. * Gets the isntanceID component
  61005. */
  61006. get instanceID(): NodeMaterialConnectionPoint;
  61007. autoConfigure(material: NodeMaterial): void;
  61008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61009. protected _buildBlock(state: NodeMaterialBuildState): this;
  61010. }
  61011. }
  61012. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61017. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61018. import { Effect } from "babylonjs/Materials/effect";
  61019. import { Mesh } from "babylonjs/Meshes/mesh";
  61020. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61021. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61022. /**
  61023. * Block used to add morph targets support to vertex shader
  61024. */
  61025. export class MorphTargetsBlock extends NodeMaterialBlock {
  61026. private _repeatableContentAnchor;
  61027. /**
  61028. * Create a new MorphTargetsBlock
  61029. * @param name defines the block name
  61030. */
  61031. constructor(name: string);
  61032. /**
  61033. * Gets the current class name
  61034. * @returns the class name
  61035. */
  61036. getClassName(): string;
  61037. /**
  61038. * Gets the position input component
  61039. */
  61040. get position(): NodeMaterialConnectionPoint;
  61041. /**
  61042. * Gets the normal input component
  61043. */
  61044. get normal(): NodeMaterialConnectionPoint;
  61045. /**
  61046. * Gets the tangent input component
  61047. */
  61048. get tangent(): NodeMaterialConnectionPoint;
  61049. /**
  61050. * Gets the tangent input component
  61051. */
  61052. get uv(): NodeMaterialConnectionPoint;
  61053. /**
  61054. * Gets the position output component
  61055. */
  61056. get positionOutput(): NodeMaterialConnectionPoint;
  61057. /**
  61058. * Gets the normal output component
  61059. */
  61060. get normalOutput(): NodeMaterialConnectionPoint;
  61061. /**
  61062. * Gets the tangent output component
  61063. */
  61064. get tangentOutput(): NodeMaterialConnectionPoint;
  61065. /**
  61066. * Gets the tangent output component
  61067. */
  61068. get uvOutput(): NodeMaterialConnectionPoint;
  61069. initialize(state: NodeMaterialBuildState): void;
  61070. autoConfigure(material: NodeMaterial): void;
  61071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61072. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61073. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61074. protected _buildBlock(state: NodeMaterialBuildState): this;
  61075. }
  61076. }
  61077. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61081. import { Nullable } from "babylonjs/types";
  61082. import { Scene } from "babylonjs/scene";
  61083. import { Effect } from "babylonjs/Materials/effect";
  61084. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61085. import { Mesh } from "babylonjs/Meshes/mesh";
  61086. import { Light } from "babylonjs/Lights/light";
  61087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61088. /**
  61089. * Block used to get data information from a light
  61090. */
  61091. export class LightInformationBlock extends NodeMaterialBlock {
  61092. private _lightDataUniformName;
  61093. private _lightColorUniformName;
  61094. private _lightTypeDefineName;
  61095. /**
  61096. * Gets or sets the light associated with this block
  61097. */
  61098. light: Nullable<Light>;
  61099. /**
  61100. * Creates a new LightInformationBlock
  61101. * @param name defines the block name
  61102. */
  61103. constructor(name: string);
  61104. /**
  61105. * Gets the current class name
  61106. * @returns the class name
  61107. */
  61108. getClassName(): string;
  61109. /**
  61110. * Gets the world position input component
  61111. */
  61112. get worldPosition(): NodeMaterialConnectionPoint;
  61113. /**
  61114. * Gets the direction output component
  61115. */
  61116. get direction(): NodeMaterialConnectionPoint;
  61117. /**
  61118. * Gets the direction output component
  61119. */
  61120. get color(): NodeMaterialConnectionPoint;
  61121. /**
  61122. * Gets the direction output component
  61123. */
  61124. get intensity(): NodeMaterialConnectionPoint;
  61125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61127. protected _buildBlock(state: NodeMaterialBuildState): this;
  61128. serialize(): any;
  61129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61130. }
  61131. }
  61132. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61133. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61134. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61135. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61136. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61137. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61138. }
  61139. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61140. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61144. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61145. import { Effect } from "babylonjs/Materials/effect";
  61146. import { Mesh } from "babylonjs/Meshes/mesh";
  61147. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61148. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61149. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61150. /**
  61151. * Block used to add image processing support to fragment shader
  61152. */
  61153. export class ImageProcessingBlock extends NodeMaterialBlock {
  61154. /**
  61155. * Create a new ImageProcessingBlock
  61156. * @param name defines the block name
  61157. */
  61158. constructor(name: string);
  61159. /**
  61160. * Gets the current class name
  61161. * @returns the class name
  61162. */
  61163. getClassName(): string;
  61164. /**
  61165. * Gets the color input component
  61166. */
  61167. get color(): NodeMaterialConnectionPoint;
  61168. /**
  61169. * Gets the output component
  61170. */
  61171. get output(): NodeMaterialConnectionPoint;
  61172. /**
  61173. * Initialize the block and prepare the context for build
  61174. * @param state defines the state that will be used for the build
  61175. */
  61176. initialize(state: NodeMaterialBuildState): void;
  61177. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61180. protected _buildBlock(state: NodeMaterialBuildState): this;
  61181. }
  61182. }
  61183. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61187. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61189. import { Effect } from "babylonjs/Materials/effect";
  61190. import { Mesh } from "babylonjs/Meshes/mesh";
  61191. import { Scene } from "babylonjs/scene";
  61192. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61193. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61194. /**
  61195. * Block used to pertub normals based on a normal map
  61196. */
  61197. export class PerturbNormalBlock extends NodeMaterialBlock {
  61198. private _tangentSpaceParameterName;
  61199. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61200. invertX: boolean;
  61201. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61202. invertY: boolean;
  61203. /**
  61204. * Create a new PerturbNormalBlock
  61205. * @param name defines the block name
  61206. */
  61207. constructor(name: string);
  61208. /**
  61209. * Gets the current class name
  61210. * @returns the class name
  61211. */
  61212. getClassName(): string;
  61213. /**
  61214. * Gets the world position input component
  61215. */
  61216. get worldPosition(): NodeMaterialConnectionPoint;
  61217. /**
  61218. * Gets the world normal input component
  61219. */
  61220. get worldNormal(): NodeMaterialConnectionPoint;
  61221. /**
  61222. * Gets the world tangent input component
  61223. */
  61224. get worldTangent(): NodeMaterialConnectionPoint;
  61225. /**
  61226. * Gets the uv input component
  61227. */
  61228. get uv(): NodeMaterialConnectionPoint;
  61229. /**
  61230. * Gets the normal map color input component
  61231. */
  61232. get normalMapColor(): NodeMaterialConnectionPoint;
  61233. /**
  61234. * Gets the strength input component
  61235. */
  61236. get strength(): NodeMaterialConnectionPoint;
  61237. /**
  61238. * Gets the output component
  61239. */
  61240. get output(): NodeMaterialConnectionPoint;
  61241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61243. autoConfigure(material: NodeMaterial): void;
  61244. protected _buildBlock(state: NodeMaterialBuildState): this;
  61245. protected _dumpPropertiesCode(): string;
  61246. serialize(): any;
  61247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61248. }
  61249. }
  61250. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61251. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61252. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61253. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61254. /**
  61255. * Block used to discard a pixel if a value is smaller than a cutoff
  61256. */
  61257. export class DiscardBlock extends NodeMaterialBlock {
  61258. /**
  61259. * Create a new DiscardBlock
  61260. * @param name defines the block name
  61261. */
  61262. constructor(name: string);
  61263. /**
  61264. * Gets the current class name
  61265. * @returns the class name
  61266. */
  61267. getClassName(): string;
  61268. /**
  61269. * Gets the color input component
  61270. */
  61271. get value(): NodeMaterialConnectionPoint;
  61272. /**
  61273. * Gets the cutoff input component
  61274. */
  61275. get cutoff(): NodeMaterialConnectionPoint;
  61276. protected _buildBlock(state: NodeMaterialBuildState): this;
  61277. }
  61278. }
  61279. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61283. /**
  61284. * Block used to test if the fragment shader is front facing
  61285. */
  61286. export class FrontFacingBlock extends NodeMaterialBlock {
  61287. /**
  61288. * Creates a new FrontFacingBlock
  61289. * @param name defines the block name
  61290. */
  61291. constructor(name: string);
  61292. /**
  61293. * Gets the current class name
  61294. * @returns the class name
  61295. */
  61296. getClassName(): string;
  61297. /**
  61298. * Gets the output component
  61299. */
  61300. get output(): NodeMaterialConnectionPoint;
  61301. protected _buildBlock(state: NodeMaterialBuildState): this;
  61302. }
  61303. }
  61304. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61308. /**
  61309. * Block used to get the derivative value on x and y of a given input
  61310. */
  61311. export class DerivativeBlock extends NodeMaterialBlock {
  61312. /**
  61313. * Create a new DerivativeBlock
  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 input component
  61324. */
  61325. get input(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the derivative output on x
  61328. */
  61329. get dx(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the derivative output on y
  61332. */
  61333. get dy(): NodeMaterialConnectionPoint;
  61334. protected _buildBlock(state: NodeMaterialBuildState): this;
  61335. }
  61336. }
  61337. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61338. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61339. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61340. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61341. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61342. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61343. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61344. }
  61345. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61348. import { Mesh } from "babylonjs/Meshes/mesh";
  61349. import { Effect } from "babylonjs/Materials/effect";
  61350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61352. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61353. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61354. /**
  61355. * Block used to add support for scene fog
  61356. */
  61357. export class FogBlock extends NodeMaterialBlock {
  61358. private _fogDistanceName;
  61359. private _fogParameters;
  61360. /**
  61361. * Create a new FogBlock
  61362. * @param name defines the block name
  61363. */
  61364. constructor(name: string);
  61365. /**
  61366. * Gets the current class name
  61367. * @returns the class name
  61368. */
  61369. getClassName(): string;
  61370. /**
  61371. * Gets the world position input component
  61372. */
  61373. get worldPosition(): NodeMaterialConnectionPoint;
  61374. /**
  61375. * Gets the view input component
  61376. */
  61377. get view(): NodeMaterialConnectionPoint;
  61378. /**
  61379. * Gets the color input component
  61380. */
  61381. get input(): NodeMaterialConnectionPoint;
  61382. /**
  61383. * Gets the fog color input component
  61384. */
  61385. get fogColor(): NodeMaterialConnectionPoint;
  61386. /**
  61387. * Gets the output component
  61388. */
  61389. get output(): NodeMaterialConnectionPoint;
  61390. autoConfigure(material: NodeMaterial): void;
  61391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61393. protected _buildBlock(state: NodeMaterialBuildState): this;
  61394. }
  61395. }
  61396. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61397. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61401. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61402. import { Effect } from "babylonjs/Materials/effect";
  61403. import { Mesh } from "babylonjs/Meshes/mesh";
  61404. import { Light } from "babylonjs/Lights/light";
  61405. import { Nullable } from "babylonjs/types";
  61406. import { Scene } from "babylonjs/scene";
  61407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61409. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61410. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61411. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61412. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61413. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61414. /**
  61415. * Block used to add light in the fragment shader
  61416. */
  61417. export class LightBlock extends NodeMaterialBlock {
  61418. private _lightId;
  61419. /**
  61420. * Gets or sets the light associated with this block
  61421. */
  61422. light: Nullable<Light>;
  61423. /**
  61424. * Create a new LightBlock
  61425. * @param name defines the block name
  61426. */
  61427. constructor(name: string);
  61428. /**
  61429. * Gets the current class name
  61430. * @returns the class name
  61431. */
  61432. getClassName(): string;
  61433. /**
  61434. * Gets the world position input component
  61435. */
  61436. get worldPosition(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the world normal input component
  61439. */
  61440. get worldNormal(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the camera (or eye) position component
  61443. */
  61444. get cameraPosition(): NodeMaterialConnectionPoint;
  61445. /**
  61446. * Gets the glossiness component
  61447. */
  61448. get glossiness(): NodeMaterialConnectionPoint;
  61449. /**
  61450. * Gets the glossinness power component
  61451. */
  61452. get glossPower(): NodeMaterialConnectionPoint;
  61453. /**
  61454. * Gets the diffuse color component
  61455. */
  61456. get diffuseColor(): NodeMaterialConnectionPoint;
  61457. /**
  61458. * Gets the specular color component
  61459. */
  61460. get specularColor(): NodeMaterialConnectionPoint;
  61461. /**
  61462. * Gets the diffuse output component
  61463. */
  61464. get diffuseOutput(): NodeMaterialConnectionPoint;
  61465. /**
  61466. * Gets the specular output component
  61467. */
  61468. get specularOutput(): NodeMaterialConnectionPoint;
  61469. /**
  61470. * Gets the shadow output component
  61471. */
  61472. get shadow(): NodeMaterialConnectionPoint;
  61473. autoConfigure(material: NodeMaterial): void;
  61474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61475. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61476. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61477. private _injectVertexCode;
  61478. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61479. serialize(): any;
  61480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61481. }
  61482. }
  61483. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61484. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61485. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61486. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61487. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61488. }
  61489. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61490. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61491. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61492. }
  61493. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61497. /**
  61498. * Block used to multiply 2 values
  61499. */
  61500. export class MultiplyBlock extends NodeMaterialBlock {
  61501. /**
  61502. * Creates a new MultiplyBlock
  61503. * @param name defines the block name
  61504. */
  61505. constructor(name: string);
  61506. /**
  61507. * Gets the current class name
  61508. * @returns the class name
  61509. */
  61510. getClassName(): string;
  61511. /**
  61512. * Gets the left operand input component
  61513. */
  61514. get left(): NodeMaterialConnectionPoint;
  61515. /**
  61516. * Gets the right operand input component
  61517. */
  61518. get right(): NodeMaterialConnectionPoint;
  61519. /**
  61520. * Gets the output component
  61521. */
  61522. get output(): NodeMaterialConnectionPoint;
  61523. protected _buildBlock(state: NodeMaterialBuildState): this;
  61524. }
  61525. }
  61526. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61527. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61528. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61529. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61530. /**
  61531. * Block used to add 2 vectors
  61532. */
  61533. export class AddBlock extends NodeMaterialBlock {
  61534. /**
  61535. * Creates a new AddBlock
  61536. * @param name defines the block name
  61537. */
  61538. constructor(name: string);
  61539. /**
  61540. * Gets the current class name
  61541. * @returns the class name
  61542. */
  61543. getClassName(): string;
  61544. /**
  61545. * Gets the left operand input component
  61546. */
  61547. get left(): NodeMaterialConnectionPoint;
  61548. /**
  61549. * Gets the right operand input component
  61550. */
  61551. get right(): NodeMaterialConnectionPoint;
  61552. /**
  61553. * Gets the output component
  61554. */
  61555. get output(): NodeMaterialConnectionPoint;
  61556. protected _buildBlock(state: NodeMaterialBuildState): this;
  61557. }
  61558. }
  61559. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61563. /**
  61564. * Block used to scale a vector by a float
  61565. */
  61566. export class ScaleBlock extends NodeMaterialBlock {
  61567. /**
  61568. * Creates a new ScaleBlock
  61569. * @param name defines the block name
  61570. */
  61571. constructor(name: string);
  61572. /**
  61573. * Gets the current class name
  61574. * @returns the class name
  61575. */
  61576. getClassName(): string;
  61577. /**
  61578. * Gets the input component
  61579. */
  61580. get input(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the factor input component
  61583. */
  61584. get factor(): NodeMaterialConnectionPoint;
  61585. /**
  61586. * Gets the output component
  61587. */
  61588. get output(): NodeMaterialConnectionPoint;
  61589. protected _buildBlock(state: NodeMaterialBuildState): this;
  61590. }
  61591. }
  61592. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61596. import { Scene } from "babylonjs/scene";
  61597. /**
  61598. * Block used to clamp a float
  61599. */
  61600. export class ClampBlock extends NodeMaterialBlock {
  61601. /** Gets or sets the minimum range */
  61602. minimum: number;
  61603. /** Gets or sets the maximum range */
  61604. maximum: number;
  61605. /**
  61606. * Creates a new ClampBlock
  61607. * @param name defines the block name
  61608. */
  61609. constructor(name: string);
  61610. /**
  61611. * Gets the current class name
  61612. * @returns the class name
  61613. */
  61614. getClassName(): string;
  61615. /**
  61616. * Gets the value input component
  61617. */
  61618. get value(): NodeMaterialConnectionPoint;
  61619. /**
  61620. * Gets the output component
  61621. */
  61622. get output(): NodeMaterialConnectionPoint;
  61623. protected _buildBlock(state: NodeMaterialBuildState): this;
  61624. protected _dumpPropertiesCode(): string;
  61625. serialize(): any;
  61626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61627. }
  61628. }
  61629. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61633. /**
  61634. * Block used to apply a cross product between 2 vectors
  61635. */
  61636. export class CrossBlock extends NodeMaterialBlock {
  61637. /**
  61638. * Creates a new CrossBlock
  61639. * @param name defines the block name
  61640. */
  61641. constructor(name: string);
  61642. /**
  61643. * Gets the current class name
  61644. * @returns the class name
  61645. */
  61646. getClassName(): string;
  61647. /**
  61648. * Gets the left operand input component
  61649. */
  61650. get left(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the right operand input component
  61653. */
  61654. get right(): NodeMaterialConnectionPoint;
  61655. /**
  61656. * Gets the output component
  61657. */
  61658. get output(): NodeMaterialConnectionPoint;
  61659. protected _buildBlock(state: NodeMaterialBuildState): this;
  61660. }
  61661. }
  61662. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61666. /**
  61667. * Block used to apply a dot product between 2 vectors
  61668. */
  61669. export class DotBlock extends NodeMaterialBlock {
  61670. /**
  61671. * Creates a new DotBlock
  61672. * @param name defines the block name
  61673. */
  61674. constructor(name: string);
  61675. /**
  61676. * Gets the current class name
  61677. * @returns the class name
  61678. */
  61679. getClassName(): string;
  61680. /**
  61681. * Gets the left operand input component
  61682. */
  61683. get left(): NodeMaterialConnectionPoint;
  61684. /**
  61685. * Gets the right operand input component
  61686. */
  61687. get right(): NodeMaterialConnectionPoint;
  61688. /**
  61689. * Gets the output component
  61690. */
  61691. get output(): NodeMaterialConnectionPoint;
  61692. protected _buildBlock(state: NodeMaterialBuildState): this;
  61693. }
  61694. }
  61695. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61699. import { Vector2 } from "babylonjs/Maths/math.vector";
  61700. import { Scene } from "babylonjs/scene";
  61701. /**
  61702. * Block used to remap a float from a range to a new one
  61703. */
  61704. export class RemapBlock extends NodeMaterialBlock {
  61705. /**
  61706. * Gets or sets the source range
  61707. */
  61708. sourceRange: Vector2;
  61709. /**
  61710. * Gets or sets the target range
  61711. */
  61712. targetRange: Vector2;
  61713. /**
  61714. * Creates a new RemapBlock
  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 source min input component
  61729. */
  61730. get sourceMin(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the source max input component
  61733. */
  61734. get sourceMax(): NodeMaterialConnectionPoint;
  61735. /**
  61736. * Gets the target min input component
  61737. */
  61738. get targetMin(): NodeMaterialConnectionPoint;
  61739. /**
  61740. * Gets the target max input component
  61741. */
  61742. get targetMax(): NodeMaterialConnectionPoint;
  61743. /**
  61744. * Gets the output component
  61745. */
  61746. get output(): NodeMaterialConnectionPoint;
  61747. protected _buildBlock(state: NodeMaterialBuildState): this;
  61748. protected _dumpPropertiesCode(): string;
  61749. serialize(): any;
  61750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61751. }
  61752. }
  61753. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61757. /**
  61758. * Block used to normalize a vector
  61759. */
  61760. export class NormalizeBlock extends NodeMaterialBlock {
  61761. /**
  61762. * Creates a new NormalizeBlock
  61763. * @param name defines the block name
  61764. */
  61765. constructor(name: string);
  61766. /**
  61767. * Gets the current class name
  61768. * @returns the class name
  61769. */
  61770. getClassName(): string;
  61771. /**
  61772. * Gets the input component
  61773. */
  61774. get input(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the output component
  61777. */
  61778. get output(): NodeMaterialConnectionPoint;
  61779. protected _buildBlock(state: NodeMaterialBuildState): this;
  61780. }
  61781. }
  61782. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61784. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61785. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61786. import { Scene } from "babylonjs/scene";
  61787. /**
  61788. * Operations supported by the Trigonometry block
  61789. */
  61790. export enum TrigonometryBlockOperations {
  61791. /** Cos */
  61792. Cos = 0,
  61793. /** Sin */
  61794. Sin = 1,
  61795. /** Abs */
  61796. Abs = 2,
  61797. /** Exp */
  61798. Exp = 3,
  61799. /** Exp2 */
  61800. Exp2 = 4,
  61801. /** Round */
  61802. Round = 5,
  61803. /** Floor */
  61804. Floor = 6,
  61805. /** Ceiling */
  61806. Ceiling = 7,
  61807. /** Square root */
  61808. Sqrt = 8,
  61809. /** Log */
  61810. Log = 9,
  61811. /** Tangent */
  61812. Tan = 10,
  61813. /** Arc tangent */
  61814. ArcTan = 11,
  61815. /** Arc cosinus */
  61816. ArcCos = 12,
  61817. /** Arc sinus */
  61818. ArcSin = 13,
  61819. /** Fraction */
  61820. Fract = 14,
  61821. /** Sign */
  61822. Sign = 15,
  61823. /** To radians (from degrees) */
  61824. Radians = 16,
  61825. /** To degrees (from radians) */
  61826. Degrees = 17
  61827. }
  61828. /**
  61829. * Block used to apply trigonometry operation to floats
  61830. */
  61831. export class TrigonometryBlock extends NodeMaterialBlock {
  61832. /**
  61833. * Gets or sets the operation applied by the block
  61834. */
  61835. operation: TrigonometryBlockOperations;
  61836. /**
  61837. * Creates a new TrigonometryBlock
  61838. * @param name defines the block name
  61839. */
  61840. constructor(name: string);
  61841. /**
  61842. * Gets the current class name
  61843. * @returns the class name
  61844. */
  61845. getClassName(): string;
  61846. /**
  61847. * Gets the input component
  61848. */
  61849. get input(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the output component
  61852. */
  61853. get output(): NodeMaterialConnectionPoint;
  61854. protected _buildBlock(state: NodeMaterialBuildState): this;
  61855. serialize(): any;
  61856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61857. protected _dumpPropertiesCode(): string;
  61858. }
  61859. }
  61860. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61864. /**
  61865. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61866. */
  61867. export class ColorMergerBlock extends NodeMaterialBlock {
  61868. /**
  61869. * Create a new ColorMergerBlock
  61870. * @param name defines the block name
  61871. */
  61872. constructor(name: string);
  61873. /**
  61874. * Gets the current class name
  61875. * @returns the class name
  61876. */
  61877. getClassName(): string;
  61878. /**
  61879. * Gets the rgb component (input)
  61880. */
  61881. get rgbIn(): NodeMaterialConnectionPoint;
  61882. /**
  61883. * Gets the r component (input)
  61884. */
  61885. get r(): NodeMaterialConnectionPoint;
  61886. /**
  61887. * Gets the g component (input)
  61888. */
  61889. get g(): NodeMaterialConnectionPoint;
  61890. /**
  61891. * Gets the b component (input)
  61892. */
  61893. get b(): NodeMaterialConnectionPoint;
  61894. /**
  61895. * Gets the a component (input)
  61896. */
  61897. get a(): NodeMaterialConnectionPoint;
  61898. /**
  61899. * Gets the rgba component (output)
  61900. */
  61901. get rgba(): NodeMaterialConnectionPoint;
  61902. /**
  61903. * Gets the rgb component (output)
  61904. */
  61905. get rgbOut(): NodeMaterialConnectionPoint;
  61906. /**
  61907. * Gets the rgb component (output)
  61908. * @deprecated Please use rgbOut instead.
  61909. */
  61910. get rgb(): NodeMaterialConnectionPoint;
  61911. protected _buildBlock(state: NodeMaterialBuildState): this;
  61912. }
  61913. }
  61914. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61918. /**
  61919. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61920. */
  61921. export class VectorMergerBlock extends NodeMaterialBlock {
  61922. /**
  61923. * Create a new VectorMergerBlock
  61924. * @param name defines the block name
  61925. */
  61926. constructor(name: string);
  61927. /**
  61928. * Gets the current class name
  61929. * @returns the class name
  61930. */
  61931. getClassName(): string;
  61932. /**
  61933. * Gets the xyz component (input)
  61934. */
  61935. get xyzIn(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the xy component (input)
  61938. */
  61939. get xyIn(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the x component (input)
  61942. */
  61943. get x(): NodeMaterialConnectionPoint;
  61944. /**
  61945. * Gets the y component (input)
  61946. */
  61947. get y(): NodeMaterialConnectionPoint;
  61948. /**
  61949. * Gets the z component (input)
  61950. */
  61951. get z(): NodeMaterialConnectionPoint;
  61952. /**
  61953. * Gets the w component (input)
  61954. */
  61955. get w(): NodeMaterialConnectionPoint;
  61956. /**
  61957. * Gets the xyzw component (output)
  61958. */
  61959. get xyzw(): NodeMaterialConnectionPoint;
  61960. /**
  61961. * Gets the xyz component (output)
  61962. */
  61963. get xyzOut(): NodeMaterialConnectionPoint;
  61964. /**
  61965. * Gets the xy component (output)
  61966. */
  61967. get xyOut(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the xy component (output)
  61970. * @deprecated Please use xyOut instead.
  61971. */
  61972. get xy(): NodeMaterialConnectionPoint;
  61973. /**
  61974. * Gets the xyz component (output)
  61975. * @deprecated Please use xyzOut instead.
  61976. */
  61977. get xyz(): NodeMaterialConnectionPoint;
  61978. protected _buildBlock(state: NodeMaterialBuildState): this;
  61979. }
  61980. }
  61981. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61985. /**
  61986. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61987. */
  61988. export class ColorSplitterBlock extends NodeMaterialBlock {
  61989. /**
  61990. * Create a new ColorSplitterBlock
  61991. * @param name defines the block name
  61992. */
  61993. constructor(name: string);
  61994. /**
  61995. * Gets the current class name
  61996. * @returns the class name
  61997. */
  61998. getClassName(): string;
  61999. /**
  62000. * Gets the rgba component (input)
  62001. */
  62002. get rgba(): NodeMaterialConnectionPoint;
  62003. /**
  62004. * Gets the rgb component (input)
  62005. */
  62006. get rgbIn(): NodeMaterialConnectionPoint;
  62007. /**
  62008. * Gets the rgb component (output)
  62009. */
  62010. get rgbOut(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the r component (output)
  62013. */
  62014. get r(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the g component (output)
  62017. */
  62018. get g(): NodeMaterialConnectionPoint;
  62019. /**
  62020. * Gets the b component (output)
  62021. */
  62022. get b(): NodeMaterialConnectionPoint;
  62023. /**
  62024. * Gets the a component (output)
  62025. */
  62026. get a(): NodeMaterialConnectionPoint;
  62027. protected _inputRename(name: string): string;
  62028. protected _outputRename(name: string): string;
  62029. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62030. }
  62031. }
  62032. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62036. /**
  62037. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62038. */
  62039. export class VectorSplitterBlock extends NodeMaterialBlock {
  62040. /**
  62041. * Create a new VectorSplitterBlock
  62042. * @param name defines the block name
  62043. */
  62044. constructor(name: string);
  62045. /**
  62046. * Gets the current class name
  62047. * @returns the class name
  62048. */
  62049. getClassName(): string;
  62050. /**
  62051. * Gets the xyzw component (input)
  62052. */
  62053. get xyzw(): NodeMaterialConnectionPoint;
  62054. /**
  62055. * Gets the xyz component (input)
  62056. */
  62057. get xyzIn(): NodeMaterialConnectionPoint;
  62058. /**
  62059. * Gets the xy component (input)
  62060. */
  62061. get xyIn(): NodeMaterialConnectionPoint;
  62062. /**
  62063. * Gets the xyz component (output)
  62064. */
  62065. get xyzOut(): NodeMaterialConnectionPoint;
  62066. /**
  62067. * Gets the xy component (output)
  62068. */
  62069. get xyOut(): NodeMaterialConnectionPoint;
  62070. /**
  62071. * Gets the x component (output)
  62072. */
  62073. get x(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the y component (output)
  62076. */
  62077. get y(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the z component (output)
  62080. */
  62081. get z(): NodeMaterialConnectionPoint;
  62082. /**
  62083. * Gets the w component (output)
  62084. */
  62085. get w(): NodeMaterialConnectionPoint;
  62086. protected _inputRename(name: string): string;
  62087. protected _outputRename(name: string): string;
  62088. protected _buildBlock(state: NodeMaterialBuildState): this;
  62089. }
  62090. }
  62091. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62095. /**
  62096. * Block used to lerp between 2 values
  62097. */
  62098. export class LerpBlock extends NodeMaterialBlock {
  62099. /**
  62100. * Creates a new LerpBlock
  62101. * @param name defines the block name
  62102. */
  62103. constructor(name: string);
  62104. /**
  62105. * Gets the current class name
  62106. * @returns the class name
  62107. */
  62108. getClassName(): string;
  62109. /**
  62110. * Gets the left operand input component
  62111. */
  62112. get left(): NodeMaterialConnectionPoint;
  62113. /**
  62114. * Gets the right operand input component
  62115. */
  62116. get right(): NodeMaterialConnectionPoint;
  62117. /**
  62118. * Gets the gradient operand input component
  62119. */
  62120. get gradient(): NodeMaterialConnectionPoint;
  62121. /**
  62122. * Gets the output component
  62123. */
  62124. get output(): NodeMaterialConnectionPoint;
  62125. protected _buildBlock(state: NodeMaterialBuildState): this;
  62126. }
  62127. }
  62128. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62132. /**
  62133. * Block used to divide 2 vectors
  62134. */
  62135. export class DivideBlock extends NodeMaterialBlock {
  62136. /**
  62137. * Creates a new DivideBlock
  62138. * @param name defines the block name
  62139. */
  62140. constructor(name: string);
  62141. /**
  62142. * Gets the current class name
  62143. * @returns the class name
  62144. */
  62145. getClassName(): string;
  62146. /**
  62147. * Gets the left operand input component
  62148. */
  62149. get left(): NodeMaterialConnectionPoint;
  62150. /**
  62151. * Gets the right operand input component
  62152. */
  62153. get right(): NodeMaterialConnectionPoint;
  62154. /**
  62155. * Gets the output component
  62156. */
  62157. get output(): NodeMaterialConnectionPoint;
  62158. protected _buildBlock(state: NodeMaterialBuildState): this;
  62159. }
  62160. }
  62161. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62165. /**
  62166. * Block used to subtract 2 vectors
  62167. */
  62168. export class SubtractBlock extends NodeMaterialBlock {
  62169. /**
  62170. * Creates a new SubtractBlock
  62171. * @param name defines the block name
  62172. */
  62173. constructor(name: string);
  62174. /**
  62175. * Gets the current class name
  62176. * @returns the class name
  62177. */
  62178. getClassName(): string;
  62179. /**
  62180. * Gets the left operand input component
  62181. */
  62182. get left(): NodeMaterialConnectionPoint;
  62183. /**
  62184. * Gets the right operand input component
  62185. */
  62186. get right(): NodeMaterialConnectionPoint;
  62187. /**
  62188. * Gets the output component
  62189. */
  62190. get output(): NodeMaterialConnectionPoint;
  62191. protected _buildBlock(state: NodeMaterialBuildState): this;
  62192. }
  62193. }
  62194. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62198. /**
  62199. * Block used to step a value
  62200. */
  62201. export class StepBlock extends NodeMaterialBlock {
  62202. /**
  62203. * Creates a new StepBlock
  62204. * @param name defines the block name
  62205. */
  62206. constructor(name: string);
  62207. /**
  62208. * Gets the current class name
  62209. * @returns the class name
  62210. */
  62211. getClassName(): string;
  62212. /**
  62213. * Gets the value operand input component
  62214. */
  62215. get value(): NodeMaterialConnectionPoint;
  62216. /**
  62217. * Gets the edge operand input component
  62218. */
  62219. get edge(): NodeMaterialConnectionPoint;
  62220. /**
  62221. * Gets the output component
  62222. */
  62223. get output(): NodeMaterialConnectionPoint;
  62224. protected _buildBlock(state: NodeMaterialBuildState): this;
  62225. }
  62226. }
  62227. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62231. /**
  62232. * Block used to get the opposite (1 - x) of a value
  62233. */
  62234. export class OneMinusBlock extends NodeMaterialBlock {
  62235. /**
  62236. * Creates a new OneMinusBlock
  62237. * @param name defines the block name
  62238. */
  62239. constructor(name: string);
  62240. /**
  62241. * Gets the current class name
  62242. * @returns the class name
  62243. */
  62244. getClassName(): string;
  62245. /**
  62246. * Gets the input component
  62247. */
  62248. get input(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the output component
  62251. */
  62252. get output(): NodeMaterialConnectionPoint;
  62253. protected _buildBlock(state: NodeMaterialBuildState): this;
  62254. }
  62255. }
  62256. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62260. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62261. /**
  62262. * Block used to get the view direction
  62263. */
  62264. export class ViewDirectionBlock extends NodeMaterialBlock {
  62265. /**
  62266. * Creates a new ViewDirectionBlock
  62267. * @param name defines the block name
  62268. */
  62269. constructor(name: string);
  62270. /**
  62271. * Gets the current class name
  62272. * @returns the class name
  62273. */
  62274. getClassName(): string;
  62275. /**
  62276. * Gets the world position component
  62277. */
  62278. get worldPosition(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the camera position component
  62281. */
  62282. get cameraPosition(): NodeMaterialConnectionPoint;
  62283. /**
  62284. * Gets the output component
  62285. */
  62286. get output(): NodeMaterialConnectionPoint;
  62287. autoConfigure(material: NodeMaterial): void;
  62288. protected _buildBlock(state: NodeMaterialBuildState): this;
  62289. }
  62290. }
  62291. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62295. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62296. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62297. /**
  62298. * Block used to compute fresnel value
  62299. */
  62300. export class FresnelBlock extends NodeMaterialBlock {
  62301. /**
  62302. * Create a new FresnelBlock
  62303. * @param name defines the block name
  62304. */
  62305. constructor(name: string);
  62306. /**
  62307. * Gets the current class name
  62308. * @returns the class name
  62309. */
  62310. getClassName(): string;
  62311. /**
  62312. * Gets the world normal input component
  62313. */
  62314. get worldNormal(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the view direction input component
  62317. */
  62318. get viewDirection(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the bias input component
  62321. */
  62322. get bias(): NodeMaterialConnectionPoint;
  62323. /**
  62324. * Gets the camera (or eye) position component
  62325. */
  62326. get power(): NodeMaterialConnectionPoint;
  62327. /**
  62328. * Gets the fresnel output component
  62329. */
  62330. get fresnel(): NodeMaterialConnectionPoint;
  62331. autoConfigure(material: NodeMaterial): void;
  62332. protected _buildBlock(state: NodeMaterialBuildState): this;
  62333. }
  62334. }
  62335. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62336. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62337. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62338. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62339. /**
  62340. * Block used to get the max of 2 values
  62341. */
  62342. export class MaxBlock extends NodeMaterialBlock {
  62343. /**
  62344. * Creates a new MaxBlock
  62345. * @param name defines the block name
  62346. */
  62347. constructor(name: string);
  62348. /**
  62349. * Gets the current class name
  62350. * @returns the class name
  62351. */
  62352. getClassName(): string;
  62353. /**
  62354. * Gets the left operand input component
  62355. */
  62356. get left(): NodeMaterialConnectionPoint;
  62357. /**
  62358. * Gets the right operand input component
  62359. */
  62360. get right(): NodeMaterialConnectionPoint;
  62361. /**
  62362. * Gets the output component
  62363. */
  62364. get output(): NodeMaterialConnectionPoint;
  62365. protected _buildBlock(state: NodeMaterialBuildState): this;
  62366. }
  62367. }
  62368. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62372. /**
  62373. * Block used to get the min of 2 values
  62374. */
  62375. export class MinBlock extends NodeMaterialBlock {
  62376. /**
  62377. * Creates a new MinBlock
  62378. * @param name defines the block name
  62379. */
  62380. constructor(name: string);
  62381. /**
  62382. * Gets the current class name
  62383. * @returns the class name
  62384. */
  62385. getClassName(): string;
  62386. /**
  62387. * Gets the left operand input component
  62388. */
  62389. get left(): NodeMaterialConnectionPoint;
  62390. /**
  62391. * Gets the right operand input component
  62392. */
  62393. get right(): NodeMaterialConnectionPoint;
  62394. /**
  62395. * Gets the output component
  62396. */
  62397. get output(): NodeMaterialConnectionPoint;
  62398. protected _buildBlock(state: NodeMaterialBuildState): this;
  62399. }
  62400. }
  62401. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62405. /**
  62406. * Block used to get the distance between 2 values
  62407. */
  62408. export class DistanceBlock extends NodeMaterialBlock {
  62409. /**
  62410. * Creates a new DistanceBlock
  62411. * @param name defines the block name
  62412. */
  62413. constructor(name: string);
  62414. /**
  62415. * Gets the current class name
  62416. * @returns the class name
  62417. */
  62418. getClassName(): string;
  62419. /**
  62420. * Gets the left operand input component
  62421. */
  62422. get left(): NodeMaterialConnectionPoint;
  62423. /**
  62424. * Gets the right operand input component
  62425. */
  62426. get right(): NodeMaterialConnectionPoint;
  62427. /**
  62428. * Gets the output component
  62429. */
  62430. get output(): NodeMaterialConnectionPoint;
  62431. protected _buildBlock(state: NodeMaterialBuildState): this;
  62432. }
  62433. }
  62434. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62438. /**
  62439. * Block used to get the length of a vector
  62440. */
  62441. export class LengthBlock extends NodeMaterialBlock {
  62442. /**
  62443. * Creates a new LengthBlock
  62444. * @param name defines the block name
  62445. */
  62446. constructor(name: string);
  62447. /**
  62448. * Gets the current class name
  62449. * @returns the class name
  62450. */
  62451. getClassName(): string;
  62452. /**
  62453. * Gets the value input component
  62454. */
  62455. get value(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the output component
  62458. */
  62459. get output(): NodeMaterialConnectionPoint;
  62460. protected _buildBlock(state: NodeMaterialBuildState): this;
  62461. }
  62462. }
  62463. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62467. /**
  62468. * Block used to get negative version of a value (i.e. x * -1)
  62469. */
  62470. export class NegateBlock extends NodeMaterialBlock {
  62471. /**
  62472. * Creates a new NegateBlock
  62473. * @param name defines the block name
  62474. */
  62475. constructor(name: string);
  62476. /**
  62477. * Gets the current class name
  62478. * @returns the class name
  62479. */
  62480. getClassName(): string;
  62481. /**
  62482. * Gets the value input component
  62483. */
  62484. get value(): NodeMaterialConnectionPoint;
  62485. /**
  62486. * Gets the output component
  62487. */
  62488. get output(): NodeMaterialConnectionPoint;
  62489. protected _buildBlock(state: NodeMaterialBuildState): this;
  62490. }
  62491. }
  62492. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62496. /**
  62497. * Block used to get the value of the first parameter raised to the power of the second
  62498. */
  62499. export class PowBlock extends NodeMaterialBlock {
  62500. /**
  62501. * Creates a new PowBlock
  62502. * @param name defines the block name
  62503. */
  62504. constructor(name: string);
  62505. /**
  62506. * Gets the current class name
  62507. * @returns the class name
  62508. */
  62509. getClassName(): string;
  62510. /**
  62511. * Gets the value operand input component
  62512. */
  62513. get value(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the power operand input component
  62516. */
  62517. get power(): NodeMaterialConnectionPoint;
  62518. /**
  62519. * Gets the output component
  62520. */
  62521. get output(): NodeMaterialConnectionPoint;
  62522. protected _buildBlock(state: NodeMaterialBuildState): this;
  62523. }
  62524. }
  62525. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62530. /**
  62531. * Block used to get a random number
  62532. */
  62533. export class RandomNumberBlock extends NodeMaterialBlock {
  62534. /**
  62535. * Creates a new RandomNumberBlock
  62536. * @param name defines the block name
  62537. */
  62538. constructor(name: string);
  62539. /**
  62540. * Gets the current class name
  62541. * @returns the class name
  62542. */
  62543. getClassName(): string;
  62544. /**
  62545. * Gets the seed input component
  62546. */
  62547. get seed(): NodeMaterialConnectionPoint;
  62548. /**
  62549. * Gets the output component
  62550. */
  62551. get output(): NodeMaterialConnectionPoint;
  62552. protected _buildBlock(state: NodeMaterialBuildState): this;
  62553. }
  62554. }
  62555. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62559. /**
  62560. * Block used to compute arc tangent of 2 values
  62561. */
  62562. export class ArcTan2Block extends NodeMaterialBlock {
  62563. /**
  62564. * Creates a new ArcTan2Block
  62565. * @param name defines the block name
  62566. */
  62567. constructor(name: string);
  62568. /**
  62569. * Gets the current class name
  62570. * @returns the class name
  62571. */
  62572. getClassName(): string;
  62573. /**
  62574. * Gets the x operand input component
  62575. */
  62576. get x(): NodeMaterialConnectionPoint;
  62577. /**
  62578. * Gets the y operand input component
  62579. */
  62580. get y(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the output component
  62583. */
  62584. get output(): NodeMaterialConnectionPoint;
  62585. protected _buildBlock(state: NodeMaterialBuildState): this;
  62586. }
  62587. }
  62588. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62592. /**
  62593. * Block used to smooth step a value
  62594. */
  62595. export class SmoothStepBlock extends NodeMaterialBlock {
  62596. /**
  62597. * Creates a new SmoothStepBlock
  62598. * @param name defines the block name
  62599. */
  62600. constructor(name: string);
  62601. /**
  62602. * Gets the current class name
  62603. * @returns the class name
  62604. */
  62605. getClassName(): string;
  62606. /**
  62607. * Gets the value operand input component
  62608. */
  62609. get value(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the first edge operand input component
  62612. */
  62613. get edge0(): NodeMaterialConnectionPoint;
  62614. /**
  62615. * Gets the second edge operand input component
  62616. */
  62617. get edge1(): NodeMaterialConnectionPoint;
  62618. /**
  62619. * Gets the output component
  62620. */
  62621. get output(): NodeMaterialConnectionPoint;
  62622. protected _buildBlock(state: NodeMaterialBuildState): this;
  62623. }
  62624. }
  62625. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62629. /**
  62630. * Block used to get the reciprocal (1 / x) of a value
  62631. */
  62632. export class ReciprocalBlock extends NodeMaterialBlock {
  62633. /**
  62634. * Creates a new ReciprocalBlock
  62635. * @param name defines the block name
  62636. */
  62637. constructor(name: string);
  62638. /**
  62639. * Gets the current class name
  62640. * @returns the class name
  62641. */
  62642. getClassName(): string;
  62643. /**
  62644. * Gets the input component
  62645. */
  62646. get input(): NodeMaterialConnectionPoint;
  62647. /**
  62648. * Gets the output component
  62649. */
  62650. get output(): NodeMaterialConnectionPoint;
  62651. protected _buildBlock(state: NodeMaterialBuildState): this;
  62652. }
  62653. }
  62654. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62658. /**
  62659. * Block used to replace a color by another one
  62660. */
  62661. export class ReplaceColorBlock extends NodeMaterialBlock {
  62662. /**
  62663. * Creates a new ReplaceColorBlock
  62664. * @param name defines the block name
  62665. */
  62666. constructor(name: string);
  62667. /**
  62668. * Gets the current class name
  62669. * @returns the class name
  62670. */
  62671. getClassName(): string;
  62672. /**
  62673. * Gets the value input component
  62674. */
  62675. get value(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the reference input component
  62678. */
  62679. get reference(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the distance input component
  62682. */
  62683. get distance(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the replacement input component
  62686. */
  62687. get replacement(): NodeMaterialConnectionPoint;
  62688. /**
  62689. * Gets the output component
  62690. */
  62691. get output(): NodeMaterialConnectionPoint;
  62692. protected _buildBlock(state: NodeMaterialBuildState): this;
  62693. }
  62694. }
  62695. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62699. /**
  62700. * Block used to posterize a value
  62701. * @see https://en.wikipedia.org/wiki/Posterization
  62702. */
  62703. export class PosterizeBlock extends NodeMaterialBlock {
  62704. /**
  62705. * Creates a new PosterizeBlock
  62706. * @param name defines the block name
  62707. */
  62708. constructor(name: string);
  62709. /**
  62710. * Gets the current class name
  62711. * @returns the class name
  62712. */
  62713. getClassName(): string;
  62714. /**
  62715. * Gets the value input component
  62716. */
  62717. get value(): NodeMaterialConnectionPoint;
  62718. /**
  62719. * Gets the steps input component
  62720. */
  62721. get steps(): NodeMaterialConnectionPoint;
  62722. /**
  62723. * Gets the output component
  62724. */
  62725. get output(): NodeMaterialConnectionPoint;
  62726. protected _buildBlock(state: NodeMaterialBuildState): this;
  62727. }
  62728. }
  62729. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62733. import { Scene } from "babylonjs/scene";
  62734. /**
  62735. * Operations supported by the Wave block
  62736. */
  62737. export enum WaveBlockKind {
  62738. /** SawTooth */
  62739. SawTooth = 0,
  62740. /** Square */
  62741. Square = 1,
  62742. /** Triangle */
  62743. Triangle = 2
  62744. }
  62745. /**
  62746. * Block used to apply wave operation to floats
  62747. */
  62748. export class WaveBlock extends NodeMaterialBlock {
  62749. /**
  62750. * Gets or sets the kibnd of wave to be applied by the block
  62751. */
  62752. kind: WaveBlockKind;
  62753. /**
  62754. * Creates a new WaveBlock
  62755. * @param name defines the block name
  62756. */
  62757. constructor(name: string);
  62758. /**
  62759. * Gets the current class name
  62760. * @returns the class name
  62761. */
  62762. getClassName(): string;
  62763. /**
  62764. * Gets the input component
  62765. */
  62766. get input(): NodeMaterialConnectionPoint;
  62767. /**
  62768. * Gets the output component
  62769. */
  62770. get output(): NodeMaterialConnectionPoint;
  62771. protected _buildBlock(state: NodeMaterialBuildState): this;
  62772. serialize(): any;
  62773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62774. }
  62775. }
  62776. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62777. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62778. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62780. import { Color3 } from "babylonjs/Maths/math.color";
  62781. import { Scene } from "babylonjs/scene";
  62782. /**
  62783. * Class used to store a color step for the GradientBlock
  62784. */
  62785. export class GradientBlockColorStep {
  62786. /**
  62787. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62788. */
  62789. step: number;
  62790. /**
  62791. * Gets or sets the color associated with this step
  62792. */
  62793. color: Color3;
  62794. /**
  62795. * Creates a new GradientBlockColorStep
  62796. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62797. * @param color defines the color associated with this step
  62798. */
  62799. constructor(
  62800. /**
  62801. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62802. */
  62803. step: number,
  62804. /**
  62805. * Gets or sets the color associated with this step
  62806. */
  62807. color: Color3);
  62808. }
  62809. /**
  62810. * Block used to return a color from a gradient based on an input value between 0 and 1
  62811. */
  62812. export class GradientBlock extends NodeMaterialBlock {
  62813. /**
  62814. * Gets or sets the list of color steps
  62815. */
  62816. colorSteps: GradientBlockColorStep[];
  62817. /**
  62818. * Creates a new GradientBlock
  62819. * @param name defines the block name
  62820. */
  62821. constructor(name: string);
  62822. /**
  62823. * Gets the current class name
  62824. * @returns the class name
  62825. */
  62826. getClassName(): string;
  62827. /**
  62828. * Gets the gradient input component
  62829. */
  62830. get gradient(): NodeMaterialConnectionPoint;
  62831. /**
  62832. * Gets the output component
  62833. */
  62834. get output(): NodeMaterialConnectionPoint;
  62835. private _writeColorConstant;
  62836. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62837. serialize(): any;
  62838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62839. protected _dumpPropertiesCode(): string;
  62840. }
  62841. }
  62842. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62846. /**
  62847. * Block used to normalize lerp between 2 values
  62848. */
  62849. export class NLerpBlock extends NodeMaterialBlock {
  62850. /**
  62851. * Creates a new NLerpBlock
  62852. * @param name defines the block name
  62853. */
  62854. constructor(name: string);
  62855. /**
  62856. * Gets the current class name
  62857. * @returns the class name
  62858. */
  62859. getClassName(): string;
  62860. /**
  62861. * Gets the left operand input component
  62862. */
  62863. get left(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the right operand input component
  62866. */
  62867. get right(): NodeMaterialConnectionPoint;
  62868. /**
  62869. * Gets the gradient operand input component
  62870. */
  62871. get gradient(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the output component
  62874. */
  62875. get output(): NodeMaterialConnectionPoint;
  62876. protected _buildBlock(state: NodeMaterialBuildState): this;
  62877. }
  62878. }
  62879. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  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. import { Scene } from "babylonjs/scene";
  62884. /**
  62885. * block used to Generate a Worley Noise 3D Noise Pattern
  62886. */
  62887. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62888. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62889. manhattanDistance: boolean;
  62890. /**
  62891. * Creates a new WorleyNoise3DBlock
  62892. * @param name defines the block name
  62893. */
  62894. constructor(name: string);
  62895. /**
  62896. * Gets the current class name
  62897. * @returns the class name
  62898. */
  62899. getClassName(): string;
  62900. /**
  62901. * Gets the seed input component
  62902. */
  62903. get seed(): NodeMaterialConnectionPoint;
  62904. /**
  62905. * Gets the jitter input component
  62906. */
  62907. get jitter(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the output component
  62910. */
  62911. get output(): NodeMaterialConnectionPoint;
  62912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62913. /**
  62914. * Exposes the properties to the UI?
  62915. */
  62916. protected _dumpPropertiesCode(): string;
  62917. /**
  62918. * Exposes the properties to the Seralize?
  62919. */
  62920. serialize(): any;
  62921. /**
  62922. * Exposes the properties to the deseralize?
  62923. */
  62924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62925. }
  62926. }
  62927. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62931. /**
  62932. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62933. */
  62934. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62935. /**
  62936. * Creates a new SimplexPerlin3DBlock
  62937. * @param name defines the block name
  62938. */
  62939. constructor(name: string);
  62940. /**
  62941. * Gets the current class name
  62942. * @returns the class name
  62943. */
  62944. getClassName(): string;
  62945. /**
  62946. * Gets the seed operand input component
  62947. */
  62948. get seed(): NodeMaterialConnectionPoint;
  62949. /**
  62950. * Gets the output component
  62951. */
  62952. get output(): NodeMaterialConnectionPoint;
  62953. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62954. }
  62955. }
  62956. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62960. /**
  62961. * Block used to blend normals
  62962. */
  62963. export class NormalBlendBlock extends NodeMaterialBlock {
  62964. /**
  62965. * Creates a new NormalBlendBlock
  62966. * @param name defines the block name
  62967. */
  62968. constructor(name: string);
  62969. /**
  62970. * Gets the current class name
  62971. * @returns the class name
  62972. */
  62973. getClassName(): string;
  62974. /**
  62975. * Gets the first input component
  62976. */
  62977. get normalMap0(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the second input component
  62980. */
  62981. get normalMap1(): NodeMaterialConnectionPoint;
  62982. /**
  62983. * Gets the output component
  62984. */
  62985. get output(): NodeMaterialConnectionPoint;
  62986. protected _buildBlock(state: NodeMaterialBuildState): this;
  62987. }
  62988. }
  62989. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62993. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62994. /**
  62995. * Block used to rotate a 2d vector by a given angle
  62996. */
  62997. export class Rotate2dBlock extends NodeMaterialBlock {
  62998. /**
  62999. * Creates a new Rotate2dBlock
  63000. * @param name defines the block name
  63001. */
  63002. constructor(name: string);
  63003. /**
  63004. * Gets the current class name
  63005. * @returns the class name
  63006. */
  63007. getClassName(): string;
  63008. /**
  63009. * Gets the input vector
  63010. */
  63011. get input(): NodeMaterialConnectionPoint;
  63012. /**
  63013. * Gets the input angle
  63014. */
  63015. get angle(): NodeMaterialConnectionPoint;
  63016. /**
  63017. * Gets the output component
  63018. */
  63019. get output(): NodeMaterialConnectionPoint;
  63020. autoConfigure(material: NodeMaterial): void;
  63021. protected _buildBlock(state: NodeMaterialBuildState): this;
  63022. }
  63023. }
  63024. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63028. /**
  63029. * Block used to get the reflected vector from a direction and a normal
  63030. */
  63031. export class ReflectBlock extends NodeMaterialBlock {
  63032. /**
  63033. * Creates a new ReflectBlock
  63034. * @param name defines the block name
  63035. */
  63036. constructor(name: string);
  63037. /**
  63038. * Gets the current class name
  63039. * @returns the class name
  63040. */
  63041. getClassName(): string;
  63042. /**
  63043. * Gets the incident component
  63044. */
  63045. get incident(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the normal component
  63048. */
  63049. get normal(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the output component
  63052. */
  63053. get output(): NodeMaterialConnectionPoint;
  63054. protected _buildBlock(state: NodeMaterialBuildState): this;
  63055. }
  63056. }
  63057. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63061. /**
  63062. * Block used to get the refracted vector from a direction and a normal
  63063. */
  63064. export class RefractBlock extends NodeMaterialBlock {
  63065. /**
  63066. * Creates a new RefractBlock
  63067. * @param name defines the block name
  63068. */
  63069. constructor(name: string);
  63070. /**
  63071. * Gets the current class name
  63072. * @returns the class name
  63073. */
  63074. getClassName(): string;
  63075. /**
  63076. * Gets the incident component
  63077. */
  63078. get incident(): NodeMaterialConnectionPoint;
  63079. /**
  63080. * Gets the normal component
  63081. */
  63082. get normal(): NodeMaterialConnectionPoint;
  63083. /**
  63084. * Gets the index of refraction component
  63085. */
  63086. get ior(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the output component
  63089. */
  63090. get output(): NodeMaterialConnectionPoint;
  63091. protected _buildBlock(state: NodeMaterialBuildState): this;
  63092. }
  63093. }
  63094. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63098. /**
  63099. * Block used to desaturate a color
  63100. */
  63101. export class DesaturateBlock extends NodeMaterialBlock {
  63102. /**
  63103. * Creates a new DesaturateBlock
  63104. * @param name defines the block name
  63105. */
  63106. constructor(name: string);
  63107. /**
  63108. * Gets the current class name
  63109. * @returns the class name
  63110. */
  63111. getClassName(): string;
  63112. /**
  63113. * Gets the color operand input component
  63114. */
  63115. get color(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the level operand input component
  63118. */
  63119. get level(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the output component
  63122. */
  63123. get output(): NodeMaterialConnectionPoint;
  63124. protected _buildBlock(state: NodeMaterialBuildState): this;
  63125. }
  63126. }
  63127. declare module "babylonjs/Materials/Node/Blocks/index" {
  63128. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63129. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63130. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63131. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63132. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63133. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63134. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63135. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63136. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63137. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63138. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63139. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63140. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63141. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63142. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63143. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63144. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63145. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63146. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63147. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63148. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63149. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63150. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63151. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63152. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63153. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63154. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63155. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63156. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63157. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63158. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63159. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63160. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63161. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63162. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63163. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63164. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63165. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63166. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63167. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63168. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63169. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63170. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63171. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63172. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63173. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63174. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63175. }
  63176. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63177. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63178. }
  63179. declare module "babylonjs/Materials/Node/index" {
  63180. export * from "babylonjs/Materials/Node/Enums/index";
  63181. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63182. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63183. export * from "babylonjs/Materials/Node/nodeMaterial";
  63184. export * from "babylonjs/Materials/Node/Blocks/index";
  63185. export * from "babylonjs/Materials/Node/Optimizers/index";
  63186. }
  63187. declare module "babylonjs/Materials/effectRenderer" {
  63188. import { Nullable } from "babylonjs/types";
  63189. import { Texture } from "babylonjs/Materials/Textures/texture";
  63190. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63191. import { Viewport } from "babylonjs/Maths/math.viewport";
  63192. import { Observable } from "babylonjs/Misc/observable";
  63193. import { Effect } from "babylonjs/Materials/effect";
  63194. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63195. import "babylonjs/Shaders/postprocess.vertex";
  63196. /**
  63197. * Effect Render Options
  63198. */
  63199. export interface IEffectRendererOptions {
  63200. /**
  63201. * Defines the vertices positions.
  63202. */
  63203. positions?: number[];
  63204. /**
  63205. * Defines the indices.
  63206. */
  63207. indices?: number[];
  63208. }
  63209. /**
  63210. * Helper class to render one or more effects
  63211. */
  63212. export class EffectRenderer {
  63213. private engine;
  63214. private static _DefaultOptions;
  63215. private _vertexBuffers;
  63216. private _indexBuffer;
  63217. private _ringBufferIndex;
  63218. private _ringScreenBuffer;
  63219. private _fullscreenViewport;
  63220. private _getNextFrameBuffer;
  63221. /**
  63222. * Creates an effect renderer
  63223. * @param engine the engine to use for rendering
  63224. * @param options defines the options of the effect renderer
  63225. */
  63226. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63227. /**
  63228. * Sets the current viewport in normalized coordinates 0-1
  63229. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63230. */
  63231. setViewport(viewport?: Viewport): void;
  63232. /**
  63233. * Binds the embedded attributes buffer to the effect.
  63234. * @param effect Defines the effect to bind the attributes for
  63235. */
  63236. bindBuffers(effect: Effect): void;
  63237. /**
  63238. * Sets the current effect wrapper to use during draw.
  63239. * The effect needs to be ready before calling this api.
  63240. * This also sets the default full screen position attribute.
  63241. * @param effectWrapper Defines the effect to draw with
  63242. */
  63243. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63244. /**
  63245. * Draws a full screen quad.
  63246. */
  63247. draw(): void;
  63248. /**
  63249. * renders one or more effects to a specified texture
  63250. * @param effectWrappers list of effects to renderer
  63251. * @param outputTexture texture to draw to, if null it will render to the screen
  63252. */
  63253. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63254. /**
  63255. * Disposes of the effect renderer
  63256. */
  63257. dispose(): void;
  63258. }
  63259. /**
  63260. * Options to create an EffectWrapper
  63261. */
  63262. interface EffectWrapperCreationOptions {
  63263. /**
  63264. * Engine to use to create the effect
  63265. */
  63266. engine: ThinEngine;
  63267. /**
  63268. * Fragment shader for the effect
  63269. */
  63270. fragmentShader: string;
  63271. /**
  63272. * Vertex shader for the effect
  63273. */
  63274. vertexShader?: string;
  63275. /**
  63276. * Attributes to use in the shader
  63277. */
  63278. attributeNames?: Array<string>;
  63279. /**
  63280. * Uniforms to use in the shader
  63281. */
  63282. uniformNames?: Array<string>;
  63283. /**
  63284. * Texture sampler names to use in the shader
  63285. */
  63286. samplerNames?: Array<string>;
  63287. /**
  63288. * The friendly name of the effect displayed in Spector.
  63289. */
  63290. name?: string;
  63291. }
  63292. /**
  63293. * Wraps an effect to be used for rendering
  63294. */
  63295. export class EffectWrapper {
  63296. /**
  63297. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63298. */
  63299. onApplyObservable: Observable<{}>;
  63300. /**
  63301. * The underlying effect
  63302. */
  63303. effect: Effect;
  63304. /**
  63305. * Creates an effect to be renderer
  63306. * @param creationOptions options to create the effect
  63307. */
  63308. constructor(creationOptions: EffectWrapperCreationOptions);
  63309. /**
  63310. * Disposes of the effect wrapper
  63311. */
  63312. dispose(): void;
  63313. }
  63314. }
  63315. declare module "babylonjs/Materials/index" {
  63316. export * from "babylonjs/Materials/Background/index";
  63317. export * from "babylonjs/Materials/colorCurves";
  63318. export * from "babylonjs/Materials/iEffectFallbacks";
  63319. export * from "babylonjs/Materials/effectFallbacks";
  63320. export * from "babylonjs/Materials/effect";
  63321. export * from "babylonjs/Materials/fresnelParameters";
  63322. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63323. export * from "babylonjs/Materials/material";
  63324. export * from "babylonjs/Materials/materialDefines";
  63325. export * from "babylonjs/Materials/materialHelper";
  63326. export * from "babylonjs/Materials/multiMaterial";
  63327. export * from "babylonjs/Materials/PBR/index";
  63328. export * from "babylonjs/Materials/pushMaterial";
  63329. export * from "babylonjs/Materials/shaderMaterial";
  63330. export * from "babylonjs/Materials/standardMaterial";
  63331. export * from "babylonjs/Materials/Textures/index";
  63332. export * from "babylonjs/Materials/uniformBuffer";
  63333. export * from "babylonjs/Materials/materialFlags";
  63334. export * from "babylonjs/Materials/Node/index";
  63335. export * from "babylonjs/Materials/effectRenderer";
  63336. }
  63337. declare module "babylonjs/Maths/index" {
  63338. export * from "babylonjs/Maths/math.scalar";
  63339. export * from "babylonjs/Maths/math";
  63340. export * from "babylonjs/Maths/sphericalPolynomial";
  63341. }
  63342. declare module "babylonjs/Misc/workerPool" {
  63343. import { IDisposable } from "babylonjs/scene";
  63344. /**
  63345. * Helper class to push actions to a pool of workers.
  63346. */
  63347. export class WorkerPool implements IDisposable {
  63348. private _workerInfos;
  63349. private _pendingActions;
  63350. /**
  63351. * Constructor
  63352. * @param workers Array of workers to use for actions
  63353. */
  63354. constructor(workers: Array<Worker>);
  63355. /**
  63356. * Terminates all workers and clears any pending actions.
  63357. */
  63358. dispose(): void;
  63359. /**
  63360. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63361. * pended until a worker has completed its action.
  63362. * @param action The action to perform. Call onComplete when the action is complete.
  63363. */
  63364. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63365. private _execute;
  63366. }
  63367. }
  63368. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63369. import { IDisposable } from "babylonjs/scene";
  63370. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63371. /**
  63372. * Configuration for Draco compression
  63373. */
  63374. export interface IDracoCompressionConfiguration {
  63375. /**
  63376. * Configuration for the decoder.
  63377. */
  63378. decoder: {
  63379. /**
  63380. * The url to the WebAssembly module.
  63381. */
  63382. wasmUrl?: string;
  63383. /**
  63384. * The url to the WebAssembly binary.
  63385. */
  63386. wasmBinaryUrl?: string;
  63387. /**
  63388. * The url to the fallback JavaScript module.
  63389. */
  63390. fallbackUrl?: string;
  63391. };
  63392. }
  63393. /**
  63394. * Draco compression (https://google.github.io/draco/)
  63395. *
  63396. * This class wraps the Draco module.
  63397. *
  63398. * **Encoder**
  63399. *
  63400. * The encoder is not currently implemented.
  63401. *
  63402. * **Decoder**
  63403. *
  63404. * 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.
  63405. *
  63406. * To update the configuration, use the following code:
  63407. * ```javascript
  63408. * DracoCompression.Configuration = {
  63409. * decoder: {
  63410. * wasmUrl: "<url to the WebAssembly library>",
  63411. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63412. * fallbackUrl: "<url to the fallback JavaScript library>",
  63413. * }
  63414. * };
  63415. * ```
  63416. *
  63417. * 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.
  63418. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63419. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63420. *
  63421. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63422. * ```javascript
  63423. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63424. * ```
  63425. *
  63426. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63427. */
  63428. export class DracoCompression implements IDisposable {
  63429. private _workerPoolPromise?;
  63430. private _decoderModulePromise?;
  63431. /**
  63432. * The configuration. Defaults to the following urls:
  63433. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63434. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63435. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63436. */
  63437. static Configuration: IDracoCompressionConfiguration;
  63438. /**
  63439. * Returns true if the decoder configuration is available.
  63440. */
  63441. static get DecoderAvailable(): boolean;
  63442. /**
  63443. * Default number of workers to create when creating the draco compression object.
  63444. */
  63445. static DefaultNumWorkers: number;
  63446. private static GetDefaultNumWorkers;
  63447. private static _Default;
  63448. /**
  63449. * Default instance for the draco compression object.
  63450. */
  63451. static get Default(): DracoCompression;
  63452. /**
  63453. * Constructor
  63454. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63455. */
  63456. constructor(numWorkers?: number);
  63457. /**
  63458. * Stop all async operations and release resources.
  63459. */
  63460. dispose(): void;
  63461. /**
  63462. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63463. * @returns a promise that resolves when ready
  63464. */
  63465. whenReadyAsync(): Promise<void>;
  63466. /**
  63467. * Decode Draco compressed mesh data to vertex data.
  63468. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63469. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63470. * @returns A promise that resolves with the decoded vertex data
  63471. */
  63472. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63473. [kind: string]: number;
  63474. }): Promise<VertexData>;
  63475. }
  63476. }
  63477. declare module "babylonjs/Meshes/Compression/index" {
  63478. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63479. }
  63480. declare module "babylonjs/Meshes/csg" {
  63481. import { Nullable } from "babylonjs/types";
  63482. import { Scene } from "babylonjs/scene";
  63483. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63484. import { Mesh } from "babylonjs/Meshes/mesh";
  63485. import { Material } from "babylonjs/Materials/material";
  63486. /**
  63487. * Class for building Constructive Solid Geometry
  63488. */
  63489. export class CSG {
  63490. private polygons;
  63491. /**
  63492. * The world matrix
  63493. */
  63494. matrix: Matrix;
  63495. /**
  63496. * Stores the position
  63497. */
  63498. position: Vector3;
  63499. /**
  63500. * Stores the rotation
  63501. */
  63502. rotation: Vector3;
  63503. /**
  63504. * Stores the rotation quaternion
  63505. */
  63506. rotationQuaternion: Nullable<Quaternion>;
  63507. /**
  63508. * Stores the scaling vector
  63509. */
  63510. scaling: Vector3;
  63511. /**
  63512. * Convert the Mesh to CSG
  63513. * @param mesh The Mesh to convert to CSG
  63514. * @returns A new CSG from the Mesh
  63515. */
  63516. static FromMesh(mesh: Mesh): CSG;
  63517. /**
  63518. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63519. * @param polygons Polygons used to construct a CSG solid
  63520. */
  63521. private static FromPolygons;
  63522. /**
  63523. * Clones, or makes a deep copy, of the CSG
  63524. * @returns A new CSG
  63525. */
  63526. clone(): CSG;
  63527. /**
  63528. * Unions this CSG with another CSG
  63529. * @param csg The CSG to union against this CSG
  63530. * @returns The unioned CSG
  63531. */
  63532. union(csg: CSG): CSG;
  63533. /**
  63534. * Unions this CSG with another CSG in place
  63535. * @param csg The CSG to union against this CSG
  63536. */
  63537. unionInPlace(csg: CSG): void;
  63538. /**
  63539. * Subtracts this CSG with another CSG
  63540. * @param csg The CSG to subtract against this CSG
  63541. * @returns A new CSG
  63542. */
  63543. subtract(csg: CSG): CSG;
  63544. /**
  63545. * Subtracts this CSG with another CSG in place
  63546. * @param csg The CSG to subtact against this CSG
  63547. */
  63548. subtractInPlace(csg: CSG): void;
  63549. /**
  63550. * Intersect this CSG with another CSG
  63551. * @param csg The CSG to intersect against this CSG
  63552. * @returns A new CSG
  63553. */
  63554. intersect(csg: CSG): CSG;
  63555. /**
  63556. * Intersects this CSG with another CSG in place
  63557. * @param csg The CSG to intersect against this CSG
  63558. */
  63559. intersectInPlace(csg: CSG): void;
  63560. /**
  63561. * Return a new CSG solid with solid and empty space switched. This solid is
  63562. * not modified.
  63563. * @returns A new CSG solid with solid and empty space switched
  63564. */
  63565. inverse(): CSG;
  63566. /**
  63567. * Inverses the CSG in place
  63568. */
  63569. inverseInPlace(): void;
  63570. /**
  63571. * This is used to keep meshes transformations so they can be restored
  63572. * when we build back a Babylon Mesh
  63573. * NB : All CSG operations are performed in world coordinates
  63574. * @param csg The CSG to copy the transform attributes from
  63575. * @returns This CSG
  63576. */
  63577. copyTransformAttributes(csg: CSG): CSG;
  63578. /**
  63579. * Build Raw mesh from CSG
  63580. * Coordinates here are in world space
  63581. * @param name The name of the mesh geometry
  63582. * @param scene The Scene
  63583. * @param keepSubMeshes Specifies if the submeshes should be kept
  63584. * @returns A new Mesh
  63585. */
  63586. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63587. /**
  63588. * Build Mesh from CSG taking material and transforms into account
  63589. * @param name The name of the Mesh
  63590. * @param material The material of the Mesh
  63591. * @param scene The Scene
  63592. * @param keepSubMeshes Specifies if submeshes should be kept
  63593. * @returns The new Mesh
  63594. */
  63595. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63596. }
  63597. }
  63598. declare module "babylonjs/Meshes/trailMesh" {
  63599. import { Mesh } from "babylonjs/Meshes/mesh";
  63600. import { Scene } from "babylonjs/scene";
  63601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63602. /**
  63603. * Class used to create a trail following a mesh
  63604. */
  63605. export class TrailMesh extends Mesh {
  63606. private _generator;
  63607. private _autoStart;
  63608. private _running;
  63609. private _diameter;
  63610. private _length;
  63611. private _sectionPolygonPointsCount;
  63612. private _sectionVectors;
  63613. private _sectionNormalVectors;
  63614. private _beforeRenderObserver;
  63615. /**
  63616. * @constructor
  63617. * @param name The value used by scene.getMeshByName() to do a lookup.
  63618. * @param generator The mesh or transform node to generate a trail.
  63619. * @param scene The scene to add this mesh to.
  63620. * @param diameter Diameter of trailing mesh. Default is 1.
  63621. * @param length Length of trailing mesh. Default is 60.
  63622. * @param autoStart Automatically start trailing mesh. Default true.
  63623. */
  63624. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63625. /**
  63626. * "TrailMesh"
  63627. * @returns "TrailMesh"
  63628. */
  63629. getClassName(): string;
  63630. private _createMesh;
  63631. /**
  63632. * Start trailing mesh.
  63633. */
  63634. start(): void;
  63635. /**
  63636. * Stop trailing mesh.
  63637. */
  63638. stop(): void;
  63639. /**
  63640. * Update trailing mesh geometry.
  63641. */
  63642. update(): void;
  63643. /**
  63644. * Returns a new TrailMesh object.
  63645. * @param name is a string, the name given to the new mesh
  63646. * @param newGenerator use new generator object for cloned trail mesh
  63647. * @returns a new mesh
  63648. */
  63649. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63650. /**
  63651. * Serializes this trail mesh
  63652. * @param serializationObject object to write serialization to
  63653. */
  63654. serialize(serializationObject: any): void;
  63655. /**
  63656. * Parses a serialized trail mesh
  63657. * @param parsedMesh the serialized mesh
  63658. * @param scene the scene to create the trail mesh in
  63659. * @returns the created trail mesh
  63660. */
  63661. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63662. }
  63663. }
  63664. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63665. import { Nullable } from "babylonjs/types";
  63666. import { Scene } from "babylonjs/scene";
  63667. import { Vector4 } from "babylonjs/Maths/math.vector";
  63668. import { Color4 } from "babylonjs/Maths/math.color";
  63669. import { Mesh } from "babylonjs/Meshes/mesh";
  63670. /**
  63671. * Class containing static functions to help procedurally build meshes
  63672. */
  63673. export class TiledBoxBuilder {
  63674. /**
  63675. * Creates a box mesh
  63676. * 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)
  63677. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63681. * @param name defines the name of the mesh
  63682. * @param options defines the options used to create the mesh
  63683. * @param scene defines the hosting scene
  63684. * @returns the box mesh
  63685. */
  63686. static CreateTiledBox(name: string, options: {
  63687. pattern?: number;
  63688. width?: number;
  63689. height?: number;
  63690. depth?: number;
  63691. tileSize?: number;
  63692. tileWidth?: number;
  63693. tileHeight?: number;
  63694. alignHorizontal?: number;
  63695. alignVertical?: number;
  63696. faceUV?: Vector4[];
  63697. faceColors?: Color4[];
  63698. sideOrientation?: number;
  63699. updatable?: boolean;
  63700. }, scene?: Nullable<Scene>): Mesh;
  63701. }
  63702. }
  63703. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63704. import { Vector4 } from "babylonjs/Maths/math.vector";
  63705. import { Mesh } from "babylonjs/Meshes/mesh";
  63706. /**
  63707. * Class containing static functions to help procedurally build meshes
  63708. */
  63709. export class TorusKnotBuilder {
  63710. /**
  63711. * Creates a torus knot mesh
  63712. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63713. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63714. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63715. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63719. * @param name defines the name of the mesh
  63720. * @param options defines the options used to create the mesh
  63721. * @param scene defines the hosting scene
  63722. * @returns the torus knot mesh
  63723. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63724. */
  63725. static CreateTorusKnot(name: string, options: {
  63726. radius?: number;
  63727. tube?: number;
  63728. radialSegments?: number;
  63729. tubularSegments?: number;
  63730. p?: number;
  63731. q?: number;
  63732. updatable?: boolean;
  63733. sideOrientation?: number;
  63734. frontUVs?: Vector4;
  63735. backUVs?: Vector4;
  63736. }, scene: any): Mesh;
  63737. }
  63738. }
  63739. declare module "babylonjs/Meshes/polygonMesh" {
  63740. import { Scene } from "babylonjs/scene";
  63741. import { Vector2 } from "babylonjs/Maths/math.vector";
  63742. import { Mesh } from "babylonjs/Meshes/mesh";
  63743. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63744. import { Path2 } from "babylonjs/Maths/math.path";
  63745. /**
  63746. * Polygon
  63747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63748. */
  63749. export class Polygon {
  63750. /**
  63751. * Creates a rectangle
  63752. * @param xmin bottom X coord
  63753. * @param ymin bottom Y coord
  63754. * @param xmax top X coord
  63755. * @param ymax top Y coord
  63756. * @returns points that make the resulting rectation
  63757. */
  63758. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63759. /**
  63760. * Creates a circle
  63761. * @param radius radius of circle
  63762. * @param cx scale in x
  63763. * @param cy scale in y
  63764. * @param numberOfSides number of sides that make up the circle
  63765. * @returns points that make the resulting circle
  63766. */
  63767. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63768. /**
  63769. * Creates a polygon from input string
  63770. * @param input Input polygon data
  63771. * @returns the parsed points
  63772. */
  63773. static Parse(input: string): Vector2[];
  63774. /**
  63775. * Starts building a polygon from x and y coordinates
  63776. * @param x x coordinate
  63777. * @param y y coordinate
  63778. * @returns the started path2
  63779. */
  63780. static StartingAt(x: number, y: number): Path2;
  63781. }
  63782. /**
  63783. * Builds a polygon
  63784. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63785. */
  63786. export class PolygonMeshBuilder {
  63787. private _points;
  63788. private _outlinepoints;
  63789. private _holes;
  63790. private _name;
  63791. private _scene;
  63792. private _epoints;
  63793. private _eholes;
  63794. private _addToepoint;
  63795. /**
  63796. * Babylon reference to the earcut plugin.
  63797. */
  63798. bjsEarcut: any;
  63799. /**
  63800. * Creates a PolygonMeshBuilder
  63801. * @param name name of the builder
  63802. * @param contours Path of the polygon
  63803. * @param scene scene to add to when creating the mesh
  63804. * @param earcutInjection can be used to inject your own earcut reference
  63805. */
  63806. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63807. /**
  63808. * Adds a whole within the polygon
  63809. * @param hole Array of points defining the hole
  63810. * @returns this
  63811. */
  63812. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63813. /**
  63814. * Creates the polygon
  63815. * @param updatable If the mesh should be updatable
  63816. * @param depth The depth of the mesh created
  63817. * @returns the created mesh
  63818. */
  63819. build(updatable?: boolean, depth?: number): Mesh;
  63820. /**
  63821. * Creates the polygon
  63822. * @param depth The depth of the mesh created
  63823. * @returns the created VertexData
  63824. */
  63825. buildVertexData(depth?: number): VertexData;
  63826. /**
  63827. * Adds a side to the polygon
  63828. * @param positions points that make the polygon
  63829. * @param normals normals of the polygon
  63830. * @param uvs uvs of the polygon
  63831. * @param indices indices of the polygon
  63832. * @param bounds bounds of the polygon
  63833. * @param points points of the polygon
  63834. * @param depth depth of the polygon
  63835. * @param flip flip of the polygon
  63836. */
  63837. private addSide;
  63838. }
  63839. }
  63840. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63841. import { Scene } from "babylonjs/scene";
  63842. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63843. import { Color4 } from "babylonjs/Maths/math.color";
  63844. import { Mesh } from "babylonjs/Meshes/mesh";
  63845. import { Nullable } from "babylonjs/types";
  63846. /**
  63847. * Class containing static functions to help procedurally build meshes
  63848. */
  63849. export class PolygonBuilder {
  63850. /**
  63851. * Creates a polygon mesh
  63852. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63853. * * 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
  63854. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63857. * * Remember you can only change the shape positions, not their number when updating a polygon
  63858. * @param name defines the name of the mesh
  63859. * @param options defines the options used to create the mesh
  63860. * @param scene defines the hosting scene
  63861. * @param earcutInjection can be used to inject your own earcut reference
  63862. * @returns the polygon mesh
  63863. */
  63864. static CreatePolygon(name: string, options: {
  63865. shape: Vector3[];
  63866. holes?: Vector3[][];
  63867. depth?: number;
  63868. faceUV?: Vector4[];
  63869. faceColors?: Color4[];
  63870. updatable?: boolean;
  63871. sideOrientation?: number;
  63872. frontUVs?: Vector4;
  63873. backUVs?: Vector4;
  63874. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63875. /**
  63876. * Creates an extruded polygon mesh, with depth in the Y direction.
  63877. * * 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)
  63878. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63879. * @param name defines the name of the mesh
  63880. * @param options defines the options used to create the mesh
  63881. * @param scene defines the hosting scene
  63882. * @param earcutInjection can be used to inject your own earcut reference
  63883. * @returns the polygon mesh
  63884. */
  63885. static ExtrudePolygon(name: string, options: {
  63886. shape: Vector3[];
  63887. holes?: Vector3[][];
  63888. depth?: number;
  63889. faceUV?: Vector4[];
  63890. faceColors?: Color4[];
  63891. updatable?: boolean;
  63892. sideOrientation?: number;
  63893. frontUVs?: Vector4;
  63894. backUVs?: Vector4;
  63895. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63896. }
  63897. }
  63898. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63899. import { Scene } from "babylonjs/scene";
  63900. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63901. import { Mesh } from "babylonjs/Meshes/mesh";
  63902. import { Nullable } from "babylonjs/types";
  63903. /**
  63904. * Class containing static functions to help procedurally build meshes
  63905. */
  63906. export class LatheBuilder {
  63907. /**
  63908. * Creates lathe mesh.
  63909. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63910. * * 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
  63911. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63912. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63913. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63914. * * 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
  63915. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63916. * * 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
  63917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63921. * @param name defines the name of the mesh
  63922. * @param options defines the options used to create the mesh
  63923. * @param scene defines the hosting scene
  63924. * @returns the lathe mesh
  63925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63926. */
  63927. static CreateLathe(name: string, options: {
  63928. shape: Vector3[];
  63929. radius?: number;
  63930. tessellation?: number;
  63931. clip?: number;
  63932. arc?: number;
  63933. closed?: boolean;
  63934. updatable?: boolean;
  63935. sideOrientation?: number;
  63936. frontUVs?: Vector4;
  63937. backUVs?: Vector4;
  63938. cap?: number;
  63939. invertUV?: boolean;
  63940. }, scene?: Nullable<Scene>): Mesh;
  63941. }
  63942. }
  63943. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63944. import { Nullable } from "babylonjs/types";
  63945. import { Scene } from "babylonjs/scene";
  63946. import { Vector4 } from "babylonjs/Maths/math.vector";
  63947. import { Mesh } from "babylonjs/Meshes/mesh";
  63948. /**
  63949. * Class containing static functions to help procedurally build meshes
  63950. */
  63951. export class TiledPlaneBuilder {
  63952. /**
  63953. * Creates a tiled plane mesh
  63954. * * The parameter `pattern` will, depending on value, do nothing or
  63955. * * * flip (reflect about central vertical) alternate tiles across and up
  63956. * * * flip every tile on alternate rows
  63957. * * * rotate (180 degs) alternate tiles across and up
  63958. * * * rotate every tile on alternate rows
  63959. * * * flip and rotate alternate tiles across and up
  63960. * * * flip and rotate every tile on alternate rows
  63961. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63962. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  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. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63965. * * 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)
  63966. * * 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)
  63967. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63968. * @param name defines the name of the mesh
  63969. * @param options defines the options used to create the mesh
  63970. * @param scene defines the hosting scene
  63971. * @returns the box mesh
  63972. */
  63973. static CreateTiledPlane(name: string, options: {
  63974. pattern?: number;
  63975. tileSize?: number;
  63976. tileWidth?: number;
  63977. tileHeight?: number;
  63978. size?: number;
  63979. width?: number;
  63980. height?: number;
  63981. alignHorizontal?: number;
  63982. alignVertical?: number;
  63983. sideOrientation?: number;
  63984. frontUVs?: Vector4;
  63985. backUVs?: Vector4;
  63986. updatable?: boolean;
  63987. }, scene?: Nullable<Scene>): Mesh;
  63988. }
  63989. }
  63990. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63991. import { Nullable } from "babylonjs/types";
  63992. import { Scene } from "babylonjs/scene";
  63993. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63994. import { Mesh } from "babylonjs/Meshes/mesh";
  63995. /**
  63996. * Class containing static functions to help procedurally build meshes
  63997. */
  63998. export class TubeBuilder {
  63999. /**
  64000. * Creates a tube mesh.
  64001. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64002. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64003. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64004. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64005. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64006. * * 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)
  64007. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64008. * * 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
  64009. * * 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
  64010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64014. * @param name defines the name of the mesh
  64015. * @param options defines the options used to create the mesh
  64016. * @param scene defines the hosting scene
  64017. * @returns the tube mesh
  64018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64019. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64020. */
  64021. static CreateTube(name: string, options: {
  64022. path: Vector3[];
  64023. radius?: number;
  64024. tessellation?: number;
  64025. radiusFunction?: {
  64026. (i: number, distance: number): number;
  64027. };
  64028. cap?: number;
  64029. arc?: number;
  64030. updatable?: boolean;
  64031. sideOrientation?: number;
  64032. frontUVs?: Vector4;
  64033. backUVs?: Vector4;
  64034. instance?: Mesh;
  64035. invertUV?: boolean;
  64036. }, scene?: Nullable<Scene>): Mesh;
  64037. }
  64038. }
  64039. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64040. import { Scene } from "babylonjs/scene";
  64041. import { Vector4 } from "babylonjs/Maths/math.vector";
  64042. import { Mesh } from "babylonjs/Meshes/mesh";
  64043. import { Nullable } from "babylonjs/types";
  64044. /**
  64045. * Class containing static functions to help procedurally build meshes
  64046. */
  64047. export class IcoSphereBuilder {
  64048. /**
  64049. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64050. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64051. * * 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`)
  64052. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64053. * * 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
  64054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64057. * @param name defines the name of the mesh
  64058. * @param options defines the options used to create the mesh
  64059. * @param scene defines the hosting scene
  64060. * @returns the icosahedron mesh
  64061. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64062. */
  64063. static CreateIcoSphere(name: string, options: {
  64064. radius?: number;
  64065. radiusX?: number;
  64066. radiusY?: number;
  64067. radiusZ?: number;
  64068. flat?: boolean;
  64069. subdivisions?: number;
  64070. sideOrientation?: number;
  64071. frontUVs?: Vector4;
  64072. backUVs?: Vector4;
  64073. updatable?: boolean;
  64074. }, scene?: Nullable<Scene>): Mesh;
  64075. }
  64076. }
  64077. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64078. import { Vector3 } from "babylonjs/Maths/math.vector";
  64079. import { Mesh } from "babylonjs/Meshes/mesh";
  64080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64081. /**
  64082. * Class containing static functions to help procedurally build meshes
  64083. */
  64084. export class DecalBuilder {
  64085. /**
  64086. * Creates a decal mesh.
  64087. * 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
  64088. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64089. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64090. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64091. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64092. * @param name defines the name of the mesh
  64093. * @param sourceMesh defines the mesh where the decal must be applied
  64094. * @param options defines the options used to create the mesh
  64095. * @param scene defines the hosting scene
  64096. * @returns the decal mesh
  64097. * @see https://doc.babylonjs.com/how_to/decals
  64098. */
  64099. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64100. position?: Vector3;
  64101. normal?: Vector3;
  64102. size?: Vector3;
  64103. angle?: number;
  64104. }): Mesh;
  64105. }
  64106. }
  64107. declare module "babylonjs/Meshes/meshBuilder" {
  64108. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64109. import { Nullable } from "babylonjs/types";
  64110. import { Scene } from "babylonjs/scene";
  64111. import { Mesh } from "babylonjs/Meshes/mesh";
  64112. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64113. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64115. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64116. import { Plane } from "babylonjs/Maths/math.plane";
  64117. /**
  64118. * Class containing static functions to help procedurally build meshes
  64119. */
  64120. export class MeshBuilder {
  64121. /**
  64122. * Creates a box mesh
  64123. * * The parameter `size` sets the size (float) of each box side (default 1)
  64124. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64125. * * 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)
  64126. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64130. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64131. * @param name defines the name of the mesh
  64132. * @param options defines the options used to create the mesh
  64133. * @param scene defines the hosting scene
  64134. * @returns the box mesh
  64135. */
  64136. static CreateBox(name: string, options: {
  64137. size?: number;
  64138. width?: number;
  64139. height?: number;
  64140. depth?: number;
  64141. faceUV?: Vector4[];
  64142. faceColors?: Color4[];
  64143. sideOrientation?: number;
  64144. frontUVs?: Vector4;
  64145. backUVs?: Vector4;
  64146. updatable?: boolean;
  64147. }, scene?: Nullable<Scene>): Mesh;
  64148. /**
  64149. * Creates a tiled box mesh
  64150. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64152. * @param name defines the name of the mesh
  64153. * @param options defines the options used to create the mesh
  64154. * @param scene defines the hosting scene
  64155. * @returns the tiled box mesh
  64156. */
  64157. static CreateTiledBox(name: string, options: {
  64158. pattern?: number;
  64159. size?: number;
  64160. width?: number;
  64161. height?: number;
  64162. depth: number;
  64163. tileSize?: number;
  64164. tileWidth?: number;
  64165. tileHeight?: number;
  64166. faceUV?: Vector4[];
  64167. faceColors?: Color4[];
  64168. alignHorizontal?: number;
  64169. alignVertical?: number;
  64170. sideOrientation?: number;
  64171. updatable?: boolean;
  64172. }, scene?: Nullable<Scene>): Mesh;
  64173. /**
  64174. * Creates a sphere mesh
  64175. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64176. * * 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`)
  64177. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64178. * * 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
  64179. * * 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)
  64180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64183. * @param name defines the name of the mesh
  64184. * @param options defines the options used to create the mesh
  64185. * @param scene defines the hosting scene
  64186. * @returns the sphere mesh
  64187. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64188. */
  64189. static CreateSphere(name: string, options: {
  64190. segments?: number;
  64191. diameter?: number;
  64192. diameterX?: number;
  64193. diameterY?: number;
  64194. diameterZ?: number;
  64195. arc?: number;
  64196. slice?: number;
  64197. sideOrientation?: number;
  64198. frontUVs?: Vector4;
  64199. backUVs?: Vector4;
  64200. updatable?: boolean;
  64201. }, scene?: Nullable<Scene>): Mesh;
  64202. /**
  64203. * Creates a plane polygonal mesh. By default, this is a disc
  64204. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64205. * * 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
  64206. * * 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
  64207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64210. * @param name defines the name of the mesh
  64211. * @param options defines the options used to create the mesh
  64212. * @param scene defines the hosting scene
  64213. * @returns the plane polygonal mesh
  64214. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64215. */
  64216. static CreateDisc(name: string, options: {
  64217. radius?: number;
  64218. tessellation?: number;
  64219. arc?: number;
  64220. updatable?: boolean;
  64221. sideOrientation?: number;
  64222. frontUVs?: Vector4;
  64223. backUVs?: Vector4;
  64224. }, scene?: Nullable<Scene>): Mesh;
  64225. /**
  64226. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64227. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64228. * * 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`)
  64229. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64230. * * 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
  64231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64234. * @param name defines the name of the mesh
  64235. * @param options defines the options used to create the mesh
  64236. * @param scene defines the hosting scene
  64237. * @returns the icosahedron mesh
  64238. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64239. */
  64240. static CreateIcoSphere(name: string, options: {
  64241. radius?: number;
  64242. radiusX?: number;
  64243. radiusY?: number;
  64244. radiusZ?: number;
  64245. flat?: boolean;
  64246. subdivisions?: number;
  64247. sideOrientation?: number;
  64248. frontUVs?: Vector4;
  64249. backUVs?: Vector4;
  64250. updatable?: boolean;
  64251. }, scene?: Nullable<Scene>): Mesh;
  64252. /**
  64253. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64254. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64255. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64256. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64257. * * 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
  64258. * * 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
  64259. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64263. * * 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
  64264. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64265. * * 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
  64266. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64268. * @param name defines the name of the mesh
  64269. * @param options defines the options used to create the mesh
  64270. * @param scene defines the hosting scene
  64271. * @returns the ribbon mesh
  64272. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64274. */
  64275. static CreateRibbon(name: string, options: {
  64276. pathArray: Vector3[][];
  64277. closeArray?: boolean;
  64278. closePath?: boolean;
  64279. offset?: number;
  64280. updatable?: boolean;
  64281. sideOrientation?: number;
  64282. frontUVs?: Vector4;
  64283. backUVs?: Vector4;
  64284. instance?: Mesh;
  64285. invertUV?: boolean;
  64286. uvs?: Vector2[];
  64287. colors?: Color4[];
  64288. }, scene?: Nullable<Scene>): Mesh;
  64289. /**
  64290. * Creates a cylinder or a cone mesh
  64291. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64292. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64293. * * 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.
  64294. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64295. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64296. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64297. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64298. * * 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).
  64299. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64300. * * 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).
  64301. * * 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
  64302. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64303. * * 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
  64304. * * 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.
  64305. * * If `enclose` is false, a ring surface is one element.
  64306. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64307. * * 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
  64308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64311. * @param name defines the name of the mesh
  64312. * @param options defines the options used to create the mesh
  64313. * @param scene defines the hosting scene
  64314. * @returns the cylinder mesh
  64315. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64316. */
  64317. static CreateCylinder(name: string, options: {
  64318. height?: number;
  64319. diameterTop?: number;
  64320. diameterBottom?: number;
  64321. diameter?: number;
  64322. tessellation?: number;
  64323. subdivisions?: number;
  64324. arc?: number;
  64325. faceColors?: Color4[];
  64326. faceUV?: Vector4[];
  64327. updatable?: boolean;
  64328. hasRings?: boolean;
  64329. enclose?: boolean;
  64330. cap?: number;
  64331. sideOrientation?: number;
  64332. frontUVs?: Vector4;
  64333. backUVs?: Vector4;
  64334. }, scene?: Nullable<Scene>): Mesh;
  64335. /**
  64336. * Creates a torus mesh
  64337. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64338. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64339. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64343. * @param name defines the name of the mesh
  64344. * @param options defines the options used to create the mesh
  64345. * @param scene defines the hosting scene
  64346. * @returns the torus mesh
  64347. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64348. */
  64349. static CreateTorus(name: string, options: {
  64350. diameter?: number;
  64351. thickness?: number;
  64352. tessellation?: number;
  64353. updatable?: boolean;
  64354. sideOrientation?: number;
  64355. frontUVs?: Vector4;
  64356. backUVs?: Vector4;
  64357. }, scene?: Nullable<Scene>): Mesh;
  64358. /**
  64359. * Creates a torus knot mesh
  64360. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64361. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64362. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64363. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64367. * @param name defines the name of the mesh
  64368. * @param options defines the options used to create the mesh
  64369. * @param scene defines the hosting scene
  64370. * @returns the torus knot mesh
  64371. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64372. */
  64373. static CreateTorusKnot(name: string, options: {
  64374. radius?: number;
  64375. tube?: number;
  64376. radialSegments?: number;
  64377. tubularSegments?: number;
  64378. p?: number;
  64379. q?: number;
  64380. updatable?: boolean;
  64381. sideOrientation?: number;
  64382. frontUVs?: Vector4;
  64383. backUVs?: Vector4;
  64384. }, scene?: Nullable<Scene>): Mesh;
  64385. /**
  64386. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64387. * * 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
  64388. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64389. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64390. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64391. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64392. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64393. * * 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
  64394. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64397. * @param name defines the name of the new line system
  64398. * @param options defines the options used to create the line system
  64399. * @param scene defines the hosting scene
  64400. * @returns a new line system mesh
  64401. */
  64402. static CreateLineSystem(name: string, options: {
  64403. lines: Vector3[][];
  64404. updatable?: boolean;
  64405. instance?: Nullable<LinesMesh>;
  64406. colors?: Nullable<Color4[][]>;
  64407. useVertexAlpha?: boolean;
  64408. }, scene: Nullable<Scene>): LinesMesh;
  64409. /**
  64410. * Creates a line mesh
  64411. * 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
  64412. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64413. * * The parameter `points` is an array successive Vector3
  64414. * * 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
  64415. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64416. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64417. * * When updating an instance, remember that only point positions can change, not the number of points
  64418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64420. * @param name defines the name of the new line system
  64421. * @param options defines the options used to create the line system
  64422. * @param scene defines the hosting scene
  64423. * @returns a new line mesh
  64424. */
  64425. static CreateLines(name: string, options: {
  64426. points: Vector3[];
  64427. updatable?: boolean;
  64428. instance?: Nullable<LinesMesh>;
  64429. colors?: Color4[];
  64430. useVertexAlpha?: boolean;
  64431. }, scene?: Nullable<Scene>): LinesMesh;
  64432. /**
  64433. * Creates a dashed line mesh
  64434. * * 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
  64435. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64436. * * The parameter `points` is an array successive Vector3
  64437. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64438. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64439. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64440. * * 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
  64441. * * When updating an instance, remember that only point positions can change, not the number of points
  64442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64443. * @param name defines the name of the mesh
  64444. * @param options defines the options used to create the mesh
  64445. * @param scene defines the hosting scene
  64446. * @returns the dashed line mesh
  64447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64448. */
  64449. static CreateDashedLines(name: string, options: {
  64450. points: Vector3[];
  64451. dashSize?: number;
  64452. gapSize?: number;
  64453. dashNb?: number;
  64454. updatable?: boolean;
  64455. instance?: LinesMesh;
  64456. }, scene?: Nullable<Scene>): LinesMesh;
  64457. /**
  64458. * 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.
  64459. * * 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.
  64460. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64461. * * 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.
  64462. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64463. * * 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
  64464. * * 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
  64465. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64468. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64470. * @param name defines the name of the mesh
  64471. * @param options defines the options used to create the mesh
  64472. * @param scene defines the hosting scene
  64473. * @returns the extruded shape mesh
  64474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64476. */
  64477. static ExtrudeShape(name: string, options: {
  64478. shape: Vector3[];
  64479. path: Vector3[];
  64480. scale?: number;
  64481. rotation?: number;
  64482. cap?: number;
  64483. updatable?: boolean;
  64484. sideOrientation?: number;
  64485. frontUVs?: Vector4;
  64486. backUVs?: Vector4;
  64487. instance?: Mesh;
  64488. invertUV?: boolean;
  64489. }, scene?: Nullable<Scene>): Mesh;
  64490. /**
  64491. * Creates an custom extruded shape mesh.
  64492. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64493. * * 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.
  64494. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64495. * * 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
  64496. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64497. * * 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
  64498. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64499. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64500. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64501. * * 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
  64502. * * 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
  64503. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64506. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64508. * @param name defines the name of the mesh
  64509. * @param options defines the options used to create the mesh
  64510. * @param scene defines the hosting scene
  64511. * @returns the custom extruded shape mesh
  64512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64515. */
  64516. static ExtrudeShapeCustom(name: string, options: {
  64517. shape: Vector3[];
  64518. path: Vector3[];
  64519. scaleFunction?: any;
  64520. rotationFunction?: any;
  64521. ribbonCloseArray?: boolean;
  64522. ribbonClosePath?: boolean;
  64523. cap?: number;
  64524. updatable?: boolean;
  64525. sideOrientation?: number;
  64526. frontUVs?: Vector4;
  64527. backUVs?: Vector4;
  64528. instance?: Mesh;
  64529. invertUV?: boolean;
  64530. }, scene?: Nullable<Scene>): Mesh;
  64531. /**
  64532. * Creates lathe mesh.
  64533. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64534. * * 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
  64535. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64536. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64537. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64538. * * 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
  64539. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64540. * * 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
  64541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64545. * @param name defines the name of the mesh
  64546. * @param options defines the options used to create the mesh
  64547. * @param scene defines the hosting scene
  64548. * @returns the lathe mesh
  64549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64550. */
  64551. static CreateLathe(name: string, options: {
  64552. shape: Vector3[];
  64553. radius?: number;
  64554. tessellation?: number;
  64555. clip?: number;
  64556. arc?: number;
  64557. closed?: boolean;
  64558. updatable?: boolean;
  64559. sideOrientation?: number;
  64560. frontUVs?: Vector4;
  64561. backUVs?: Vector4;
  64562. cap?: number;
  64563. invertUV?: boolean;
  64564. }, scene?: Nullable<Scene>): Mesh;
  64565. /**
  64566. * Creates a tiled plane mesh
  64567. * * You can set a limited pattern arrangement with the tiles
  64568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64571. * @param name defines the name of the mesh
  64572. * @param options defines the options used to create the mesh
  64573. * @param scene defines the hosting scene
  64574. * @returns the plane mesh
  64575. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64576. */
  64577. static CreateTiledPlane(name: string, options: {
  64578. pattern?: number;
  64579. tileSize?: number;
  64580. tileWidth?: number;
  64581. tileHeight?: number;
  64582. size?: number;
  64583. width?: number;
  64584. height?: number;
  64585. alignHorizontal?: number;
  64586. alignVertical?: number;
  64587. sideOrientation?: number;
  64588. frontUVs?: Vector4;
  64589. backUVs?: Vector4;
  64590. updatable?: boolean;
  64591. }, scene?: Nullable<Scene>): Mesh;
  64592. /**
  64593. * Creates a plane mesh
  64594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64600. * @param name defines the name of the mesh
  64601. * @param options defines the options used to create the mesh
  64602. * @param scene defines the hosting scene
  64603. * @returns the plane mesh
  64604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64605. */
  64606. static CreatePlane(name: string, options: {
  64607. size?: number;
  64608. width?: number;
  64609. height?: number;
  64610. sideOrientation?: number;
  64611. frontUVs?: Vector4;
  64612. backUVs?: Vector4;
  64613. updatable?: boolean;
  64614. sourcePlane?: Plane;
  64615. }, scene?: Nullable<Scene>): Mesh;
  64616. /**
  64617. * Creates a ground mesh
  64618. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64619. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64621. * @param name defines the name of the mesh
  64622. * @param options defines the options used to create the mesh
  64623. * @param scene defines the hosting scene
  64624. * @returns the ground mesh
  64625. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64626. */
  64627. static CreateGround(name: string, options: {
  64628. width?: number;
  64629. height?: number;
  64630. subdivisions?: number;
  64631. subdivisionsX?: number;
  64632. subdivisionsY?: number;
  64633. updatable?: boolean;
  64634. }, scene?: Nullable<Scene>): Mesh;
  64635. /**
  64636. * Creates a tiled ground mesh
  64637. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64638. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64639. * * 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
  64640. * * 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
  64641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64642. * @param name defines the name of the mesh
  64643. * @param options defines the options used to create the mesh
  64644. * @param scene defines the hosting scene
  64645. * @returns the tiled ground mesh
  64646. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64647. */
  64648. static CreateTiledGround(name: string, options: {
  64649. xmin: number;
  64650. zmin: number;
  64651. xmax: number;
  64652. zmax: number;
  64653. subdivisions?: {
  64654. w: number;
  64655. h: number;
  64656. };
  64657. precision?: {
  64658. w: number;
  64659. h: number;
  64660. };
  64661. updatable?: boolean;
  64662. }, scene?: Nullable<Scene>): Mesh;
  64663. /**
  64664. * Creates a ground mesh from a height map
  64665. * * The parameter `url` sets the URL of the height map image resource.
  64666. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64667. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64668. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64669. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64670. * * 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.
  64671. * * 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).
  64672. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64674. * @param name defines the name of the mesh
  64675. * @param url defines the url to the height map
  64676. * @param options defines the options used to create the mesh
  64677. * @param scene defines the hosting scene
  64678. * @returns the ground mesh
  64679. * @see https://doc.babylonjs.com/babylon101/height_map
  64680. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64681. */
  64682. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64683. width?: number;
  64684. height?: number;
  64685. subdivisions?: number;
  64686. minHeight?: number;
  64687. maxHeight?: number;
  64688. colorFilter?: Color3;
  64689. alphaFilter?: number;
  64690. updatable?: boolean;
  64691. onReady?: (mesh: GroundMesh) => void;
  64692. }, scene?: Nullable<Scene>): GroundMesh;
  64693. /**
  64694. * Creates a polygon mesh
  64695. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64696. * * 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
  64697. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64700. * * Remember you can only change the shape positions, not their number when updating a polygon
  64701. * @param name defines the name of the mesh
  64702. * @param options defines the options used to create the mesh
  64703. * @param scene defines the hosting scene
  64704. * @param earcutInjection can be used to inject your own earcut reference
  64705. * @returns the polygon mesh
  64706. */
  64707. static CreatePolygon(name: string, options: {
  64708. shape: Vector3[];
  64709. holes?: Vector3[][];
  64710. depth?: number;
  64711. faceUV?: Vector4[];
  64712. faceColors?: Color4[];
  64713. updatable?: boolean;
  64714. sideOrientation?: number;
  64715. frontUVs?: Vector4;
  64716. backUVs?: Vector4;
  64717. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64718. /**
  64719. * Creates an extruded polygon mesh, with depth in the Y direction.
  64720. * * 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)
  64721. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64722. * @param name defines the name of the mesh
  64723. * @param options defines the options used to create the mesh
  64724. * @param scene defines the hosting scene
  64725. * @param earcutInjection can be used to inject your own earcut reference
  64726. * @returns the polygon mesh
  64727. */
  64728. static ExtrudePolygon(name: string, options: {
  64729. shape: Vector3[];
  64730. holes?: Vector3[][];
  64731. depth?: number;
  64732. faceUV?: Vector4[];
  64733. faceColors?: Color4[];
  64734. updatable?: boolean;
  64735. sideOrientation?: number;
  64736. frontUVs?: Vector4;
  64737. backUVs?: Vector4;
  64738. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64739. /**
  64740. * Creates a tube mesh.
  64741. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64742. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64743. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64744. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64745. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64746. * * 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)
  64747. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64748. * * 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
  64749. * * 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
  64750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64754. * @param name defines the name of the mesh
  64755. * @param options defines the options used to create the mesh
  64756. * @param scene defines the hosting scene
  64757. * @returns the tube mesh
  64758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64759. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64760. */
  64761. static CreateTube(name: string, options: {
  64762. path: Vector3[];
  64763. radius?: number;
  64764. tessellation?: number;
  64765. radiusFunction?: {
  64766. (i: number, distance: number): number;
  64767. };
  64768. cap?: number;
  64769. arc?: number;
  64770. updatable?: boolean;
  64771. sideOrientation?: number;
  64772. frontUVs?: Vector4;
  64773. backUVs?: Vector4;
  64774. instance?: Mesh;
  64775. invertUV?: boolean;
  64776. }, scene?: Nullable<Scene>): Mesh;
  64777. /**
  64778. * Creates a polyhedron mesh
  64779. * * 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
  64780. * * The parameter `size` (positive float, default 1) sets the polygon size
  64781. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64782. * * 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`
  64783. * * 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
  64784. * * 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)`)
  64785. * * 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
  64786. * * 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
  64787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64790. * @param name defines the name of the mesh
  64791. * @param options defines the options used to create the mesh
  64792. * @param scene defines the hosting scene
  64793. * @returns the polyhedron mesh
  64794. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64795. */
  64796. static CreatePolyhedron(name: string, options: {
  64797. type?: number;
  64798. size?: number;
  64799. sizeX?: number;
  64800. sizeY?: number;
  64801. sizeZ?: number;
  64802. custom?: any;
  64803. faceUV?: Vector4[];
  64804. faceColors?: Color4[];
  64805. flat?: boolean;
  64806. updatable?: boolean;
  64807. sideOrientation?: number;
  64808. frontUVs?: Vector4;
  64809. backUVs?: Vector4;
  64810. }, scene?: Nullable<Scene>): Mesh;
  64811. /**
  64812. * Creates a decal mesh.
  64813. * 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
  64814. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64815. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64816. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64817. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64818. * @param name defines the name of the mesh
  64819. * @param sourceMesh defines the mesh where the decal must be applied
  64820. * @param options defines the options used to create the mesh
  64821. * @param scene defines the hosting scene
  64822. * @returns the decal mesh
  64823. * @see https://doc.babylonjs.com/how_to/decals
  64824. */
  64825. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64826. position?: Vector3;
  64827. normal?: Vector3;
  64828. size?: Vector3;
  64829. angle?: number;
  64830. }): Mesh;
  64831. }
  64832. }
  64833. declare module "babylonjs/Meshes/meshSimplification" {
  64834. import { Mesh } from "babylonjs/Meshes/mesh";
  64835. /**
  64836. * A simplifier interface for future simplification implementations
  64837. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64838. */
  64839. export interface ISimplifier {
  64840. /**
  64841. * Simplification of a given mesh according to the given settings.
  64842. * Since this requires computation, it is assumed that the function runs async.
  64843. * @param settings The settings of the simplification, including quality and distance
  64844. * @param successCallback A callback that will be called after the mesh was simplified.
  64845. * @param errorCallback in case of an error, this callback will be called. optional.
  64846. */
  64847. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64848. }
  64849. /**
  64850. * Expected simplification settings.
  64851. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64852. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64853. */
  64854. export interface ISimplificationSettings {
  64855. /**
  64856. * Gets or sets the expected quality
  64857. */
  64858. quality: number;
  64859. /**
  64860. * Gets or sets the distance when this optimized version should be used
  64861. */
  64862. distance: number;
  64863. /**
  64864. * Gets an already optimized mesh
  64865. */
  64866. optimizeMesh?: boolean;
  64867. }
  64868. /**
  64869. * Class used to specify simplification options
  64870. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64871. */
  64872. export class SimplificationSettings implements ISimplificationSettings {
  64873. /** expected quality */
  64874. quality: number;
  64875. /** distance when this optimized version should be used */
  64876. distance: number;
  64877. /** already optimized mesh */
  64878. optimizeMesh?: boolean | undefined;
  64879. /**
  64880. * Creates a SimplificationSettings
  64881. * @param quality expected quality
  64882. * @param distance distance when this optimized version should be used
  64883. * @param optimizeMesh already optimized mesh
  64884. */
  64885. constructor(
  64886. /** expected quality */
  64887. quality: number,
  64888. /** distance when this optimized version should be used */
  64889. distance: number,
  64890. /** already optimized mesh */
  64891. optimizeMesh?: boolean | undefined);
  64892. }
  64893. /**
  64894. * Interface used to define a simplification task
  64895. */
  64896. export interface ISimplificationTask {
  64897. /**
  64898. * Array of settings
  64899. */
  64900. settings: Array<ISimplificationSettings>;
  64901. /**
  64902. * Simplification type
  64903. */
  64904. simplificationType: SimplificationType;
  64905. /**
  64906. * Mesh to simplify
  64907. */
  64908. mesh: Mesh;
  64909. /**
  64910. * Callback called on success
  64911. */
  64912. successCallback?: () => void;
  64913. /**
  64914. * Defines if parallel processing can be used
  64915. */
  64916. parallelProcessing: boolean;
  64917. }
  64918. /**
  64919. * Queue used to order the simplification tasks
  64920. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64921. */
  64922. export class SimplificationQueue {
  64923. private _simplificationArray;
  64924. /**
  64925. * Gets a boolean indicating that the process is still running
  64926. */
  64927. running: boolean;
  64928. /**
  64929. * Creates a new queue
  64930. */
  64931. constructor();
  64932. /**
  64933. * Adds a new simplification task
  64934. * @param task defines a task to add
  64935. */
  64936. addTask(task: ISimplificationTask): void;
  64937. /**
  64938. * Execute next task
  64939. */
  64940. executeNext(): void;
  64941. /**
  64942. * Execute a simplification task
  64943. * @param task defines the task to run
  64944. */
  64945. runSimplification(task: ISimplificationTask): void;
  64946. private getSimplifier;
  64947. }
  64948. /**
  64949. * The implemented types of simplification
  64950. * At the moment only Quadratic Error Decimation is implemented
  64951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64952. */
  64953. export enum SimplificationType {
  64954. /** Quadratic error decimation */
  64955. QUADRATIC = 0
  64956. }
  64957. /**
  64958. * An implementation of the Quadratic Error simplification algorithm.
  64959. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64960. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64961. * @author RaananW
  64962. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64963. */
  64964. export class QuadraticErrorSimplification implements ISimplifier {
  64965. private _mesh;
  64966. private triangles;
  64967. private vertices;
  64968. private references;
  64969. private _reconstructedMesh;
  64970. /** Gets or sets the number pf sync interations */
  64971. syncIterations: number;
  64972. /** Gets or sets the aggressiveness of the simplifier */
  64973. aggressiveness: number;
  64974. /** Gets or sets the number of allowed iterations for decimation */
  64975. decimationIterations: number;
  64976. /** Gets or sets the espilon to use for bounding box computation */
  64977. boundingBoxEpsilon: number;
  64978. /**
  64979. * Creates a new QuadraticErrorSimplification
  64980. * @param _mesh defines the target mesh
  64981. */
  64982. constructor(_mesh: Mesh);
  64983. /**
  64984. * Simplification of a given mesh according to the given settings.
  64985. * Since this requires computation, it is assumed that the function runs async.
  64986. * @param settings The settings of the simplification, including quality and distance
  64987. * @param successCallback A callback that will be called after the mesh was simplified.
  64988. */
  64989. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64990. private runDecimation;
  64991. private initWithMesh;
  64992. private init;
  64993. private reconstructMesh;
  64994. private initDecimatedMesh;
  64995. private isFlipped;
  64996. private updateTriangles;
  64997. private identifyBorder;
  64998. private updateMesh;
  64999. private vertexError;
  65000. private calculateError;
  65001. }
  65002. }
  65003. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65004. import { Scene } from "babylonjs/scene";
  65005. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65006. import { ISceneComponent } from "babylonjs/sceneComponent";
  65007. module "babylonjs/scene" {
  65008. interface Scene {
  65009. /** @hidden (Backing field) */
  65010. _simplificationQueue: SimplificationQueue;
  65011. /**
  65012. * Gets or sets the simplification queue attached to the scene
  65013. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65014. */
  65015. simplificationQueue: SimplificationQueue;
  65016. }
  65017. }
  65018. module "babylonjs/Meshes/mesh" {
  65019. interface Mesh {
  65020. /**
  65021. * Simplify the mesh according to the given array of settings.
  65022. * Function will return immediately and will simplify async
  65023. * @param settings a collection of simplification settings
  65024. * @param parallelProcessing should all levels calculate parallel or one after the other
  65025. * @param simplificationType the type of simplification to run
  65026. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65027. * @returns the current mesh
  65028. */
  65029. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65030. }
  65031. }
  65032. /**
  65033. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65034. * created in a scene
  65035. */
  65036. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65037. /**
  65038. * The component name helpfull to identify the component in the list of scene components.
  65039. */
  65040. readonly name: string;
  65041. /**
  65042. * The scene the component belongs to.
  65043. */
  65044. scene: Scene;
  65045. /**
  65046. * Creates a new instance of the component for the given scene
  65047. * @param scene Defines the scene to register the component in
  65048. */
  65049. constructor(scene: Scene);
  65050. /**
  65051. * Registers the component in a given scene
  65052. */
  65053. register(): void;
  65054. /**
  65055. * Rebuilds the elements related to this component in case of
  65056. * context lost for instance.
  65057. */
  65058. rebuild(): void;
  65059. /**
  65060. * Disposes the component and the associated ressources
  65061. */
  65062. dispose(): void;
  65063. private _beforeCameraUpdate;
  65064. }
  65065. }
  65066. declare module "babylonjs/Meshes/Builders/index" {
  65067. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65068. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65069. export * from "babylonjs/Meshes/Builders/discBuilder";
  65070. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65071. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65072. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65073. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65074. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65075. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65076. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65077. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65078. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65079. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65080. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65081. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65082. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65083. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65084. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65085. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65086. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65087. }
  65088. declare module "babylonjs/Meshes/index" {
  65089. export * from "babylonjs/Meshes/abstractMesh";
  65090. export * from "babylonjs/Meshes/buffer";
  65091. export * from "babylonjs/Meshes/Compression/index";
  65092. export * from "babylonjs/Meshes/csg";
  65093. export * from "babylonjs/Meshes/geometry";
  65094. export * from "babylonjs/Meshes/groundMesh";
  65095. export * from "babylonjs/Meshes/trailMesh";
  65096. export * from "babylonjs/Meshes/instancedMesh";
  65097. export * from "babylonjs/Meshes/linesMesh";
  65098. export * from "babylonjs/Meshes/mesh";
  65099. export * from "babylonjs/Meshes/mesh.vertexData";
  65100. export * from "babylonjs/Meshes/meshBuilder";
  65101. export * from "babylonjs/Meshes/meshSimplification";
  65102. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65103. export * from "babylonjs/Meshes/polygonMesh";
  65104. export * from "babylonjs/Meshes/subMesh";
  65105. export * from "babylonjs/Meshes/meshLODLevel";
  65106. export * from "babylonjs/Meshes/transformNode";
  65107. export * from "babylonjs/Meshes/Builders/index";
  65108. export * from "babylonjs/Meshes/dataBuffer";
  65109. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65110. }
  65111. declare module "babylonjs/Morph/index" {
  65112. export * from "babylonjs/Morph/morphTarget";
  65113. export * from "babylonjs/Morph/morphTargetManager";
  65114. }
  65115. declare module "babylonjs/Navigation/INavigationEngine" {
  65116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65117. import { Vector3 } from "babylonjs/Maths/math";
  65118. import { Mesh } from "babylonjs/Meshes/mesh";
  65119. import { Scene } from "babylonjs/scene";
  65120. /**
  65121. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65122. */
  65123. export interface INavigationEnginePlugin {
  65124. /**
  65125. * plugin name
  65126. */
  65127. name: string;
  65128. /**
  65129. * Creates a navigation mesh
  65130. * @param meshes array of all the geometry used to compute the navigatio mesh
  65131. * @param parameters bunch of parameters used to filter geometry
  65132. */
  65133. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65134. /**
  65135. * Create a navigation mesh debug mesh
  65136. * @param scene is where the mesh will be added
  65137. * @returns debug display mesh
  65138. */
  65139. createDebugNavMesh(scene: Scene): Mesh;
  65140. /**
  65141. * Get a navigation mesh constrained position, closest to the parameter position
  65142. * @param position world position
  65143. * @returns the closest point to position constrained by the navigation mesh
  65144. */
  65145. getClosestPoint(position: Vector3): Vector3;
  65146. /**
  65147. * Get a navigation mesh constrained position, within a particular radius
  65148. * @param position world position
  65149. * @param maxRadius the maximum distance to the constrained world position
  65150. * @returns the closest point to position constrained by the navigation mesh
  65151. */
  65152. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65153. /**
  65154. * Compute the final position from a segment made of destination-position
  65155. * @param position world position
  65156. * @param destination world position
  65157. * @returns the resulting point along the navmesh
  65158. */
  65159. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65160. /**
  65161. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65162. * @param start world position
  65163. * @param end world position
  65164. * @returns array containing world position composing the path
  65165. */
  65166. computePath(start: Vector3, end: Vector3): Vector3[];
  65167. /**
  65168. * If this plugin is supported
  65169. * @returns true if plugin is supported
  65170. */
  65171. isSupported(): boolean;
  65172. /**
  65173. * Create a new Crowd so you can add agents
  65174. * @param maxAgents the maximum agent count in the crowd
  65175. * @param maxAgentRadius the maximum radius an agent can have
  65176. * @param scene to attach the crowd to
  65177. * @returns the crowd you can add agents to
  65178. */
  65179. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65180. /**
  65181. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65182. * The queries will try to find a solution within those bounds
  65183. * default is (1,1,1)
  65184. * @param extent x,y,z value that define the extent around the queries point of reference
  65185. */
  65186. setDefaultQueryExtent(extent: Vector3): void;
  65187. /**
  65188. * Get the Bounding box extent specified by setDefaultQueryExtent
  65189. * @returns the box extent values
  65190. */
  65191. getDefaultQueryExtent(): Vector3;
  65192. /**
  65193. * Release all resources
  65194. */
  65195. dispose(): void;
  65196. }
  65197. /**
  65198. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65199. */
  65200. export interface ICrowd {
  65201. /**
  65202. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65203. * You can attach anything to that node. The node position is updated in the scene update tick.
  65204. * @param pos world position that will be constrained by the navigation mesh
  65205. * @param parameters agent parameters
  65206. * @param transform hooked to the agent that will be update by the scene
  65207. * @returns agent index
  65208. */
  65209. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65210. /**
  65211. * Returns the agent position in world space
  65212. * @param index agent index returned by addAgent
  65213. * @returns world space position
  65214. */
  65215. getAgentPosition(index: number): Vector3;
  65216. /**
  65217. * Gets the agent velocity in world space
  65218. * @param index agent index returned by addAgent
  65219. * @returns world space velocity
  65220. */
  65221. getAgentVelocity(index: number): Vector3;
  65222. /**
  65223. * remove a particular agent previously created
  65224. * @param index agent index returned by addAgent
  65225. */
  65226. removeAgent(index: number): void;
  65227. /**
  65228. * get the list of all agents attached to this crowd
  65229. * @returns list of agent indices
  65230. */
  65231. getAgents(): number[];
  65232. /**
  65233. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65234. * @param deltaTime in seconds
  65235. */
  65236. update(deltaTime: number): void;
  65237. /**
  65238. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65239. * @param index agent index returned by addAgent
  65240. * @param destination targeted world position
  65241. */
  65242. agentGoto(index: number, destination: Vector3): void;
  65243. /**
  65244. * Teleport the agent to a new position
  65245. * @param index agent index returned by addAgent
  65246. * @param destination targeted world position
  65247. */
  65248. agentTeleport(index: number, destination: Vector3): void;
  65249. /**
  65250. * Update agent parameters
  65251. * @param index agent index returned by addAgent
  65252. * @param parameters agent parameters
  65253. */
  65254. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65255. /**
  65256. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65257. * The queries will try to find a solution within those bounds
  65258. * default is (1,1,1)
  65259. * @param extent x,y,z value that define the extent around the queries point of reference
  65260. */
  65261. setDefaultQueryExtent(extent: Vector3): void;
  65262. /**
  65263. * Get the Bounding box extent specified by setDefaultQueryExtent
  65264. * @returns the box extent values
  65265. */
  65266. getDefaultQueryExtent(): Vector3;
  65267. /**
  65268. * Release all resources
  65269. */
  65270. dispose(): void;
  65271. }
  65272. /**
  65273. * Configures an agent
  65274. */
  65275. export interface IAgentParameters {
  65276. /**
  65277. * Agent radius. [Limit: >= 0]
  65278. */
  65279. radius: number;
  65280. /**
  65281. * Agent height. [Limit: > 0]
  65282. */
  65283. height: number;
  65284. /**
  65285. * Maximum allowed acceleration. [Limit: >= 0]
  65286. */
  65287. maxAcceleration: number;
  65288. /**
  65289. * Maximum allowed speed. [Limit: >= 0]
  65290. */
  65291. maxSpeed: number;
  65292. /**
  65293. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65294. */
  65295. collisionQueryRange: number;
  65296. /**
  65297. * The path visibility optimization range. [Limit: > 0]
  65298. */
  65299. pathOptimizationRange: number;
  65300. /**
  65301. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65302. */
  65303. separationWeight: number;
  65304. }
  65305. /**
  65306. * Configures the navigation mesh creation
  65307. */
  65308. export interface INavMeshParameters {
  65309. /**
  65310. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65311. */
  65312. cs: number;
  65313. /**
  65314. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65315. */
  65316. ch: number;
  65317. /**
  65318. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65319. */
  65320. walkableSlopeAngle: number;
  65321. /**
  65322. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65323. * be considered walkable. [Limit: >= 3] [Units: vx]
  65324. */
  65325. walkableHeight: number;
  65326. /**
  65327. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65328. */
  65329. walkableClimb: number;
  65330. /**
  65331. * The distance to erode/shrink the walkable area of the heightfield away from
  65332. * obstructions. [Limit: >=0] [Units: vx]
  65333. */
  65334. walkableRadius: number;
  65335. /**
  65336. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65337. */
  65338. maxEdgeLen: number;
  65339. /**
  65340. * The maximum distance a simplfied contour's border edges should deviate
  65341. * the original raw contour. [Limit: >=0] [Units: vx]
  65342. */
  65343. maxSimplificationError: number;
  65344. /**
  65345. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65346. */
  65347. minRegionArea: number;
  65348. /**
  65349. * Any regions with a span count smaller than this value will, if possible,
  65350. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65351. */
  65352. mergeRegionArea: number;
  65353. /**
  65354. * The maximum number of vertices allowed for polygons generated during the
  65355. * contour to polygon conversion process. [Limit: >= 3]
  65356. */
  65357. maxVertsPerPoly: number;
  65358. /**
  65359. * Sets the sampling distance to use when generating the detail mesh.
  65360. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65361. */
  65362. detailSampleDist: number;
  65363. /**
  65364. * The maximum distance the detail mesh surface should deviate from heightfield
  65365. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65366. */
  65367. detailSampleMaxError: number;
  65368. }
  65369. }
  65370. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65371. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65372. import { Mesh } from "babylonjs/Meshes/mesh";
  65373. import { Scene } from "babylonjs/scene";
  65374. import { Vector3 } from "babylonjs/Maths/math";
  65375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65376. /**
  65377. * RecastJS navigation plugin
  65378. */
  65379. export class RecastJSPlugin implements INavigationEnginePlugin {
  65380. /**
  65381. * Reference to the Recast library
  65382. */
  65383. bjsRECAST: any;
  65384. /**
  65385. * plugin name
  65386. */
  65387. name: string;
  65388. /**
  65389. * the first navmesh created. We might extend this to support multiple navmeshes
  65390. */
  65391. navMesh: any;
  65392. /**
  65393. * Initializes the recastJS plugin
  65394. * @param recastInjection can be used to inject your own recast reference
  65395. */
  65396. constructor(recastInjection?: any);
  65397. /**
  65398. * Creates a navigation mesh
  65399. * @param meshes array of all the geometry used to compute the navigatio mesh
  65400. * @param parameters bunch of parameters used to filter geometry
  65401. */
  65402. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65403. /**
  65404. * Create a navigation mesh debug mesh
  65405. * @param scene is where the mesh will be added
  65406. * @returns debug display mesh
  65407. */
  65408. createDebugNavMesh(scene: Scene): Mesh;
  65409. /**
  65410. * Get a navigation mesh constrained position, closest to the parameter position
  65411. * @param position world position
  65412. * @returns the closest point to position constrained by the navigation mesh
  65413. */
  65414. getClosestPoint(position: Vector3): Vector3;
  65415. /**
  65416. * Get a navigation mesh constrained position, within a particular radius
  65417. * @param position world position
  65418. * @param maxRadius the maximum distance to the constrained world position
  65419. * @returns the closest point to position constrained by the navigation mesh
  65420. */
  65421. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65422. /**
  65423. * Compute the final position from a segment made of destination-position
  65424. * @param position world position
  65425. * @param destination world position
  65426. * @returns the resulting point along the navmesh
  65427. */
  65428. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65429. /**
  65430. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65431. * @param start world position
  65432. * @param end world position
  65433. * @returns array containing world position composing the path
  65434. */
  65435. computePath(start: Vector3, end: Vector3): Vector3[];
  65436. /**
  65437. * Create a new Crowd so you can add agents
  65438. * @param maxAgents the maximum agent count in the crowd
  65439. * @param maxAgentRadius the maximum radius an agent can have
  65440. * @param scene to attach the crowd to
  65441. * @returns the crowd you can add agents to
  65442. */
  65443. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65444. /**
  65445. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65446. * The queries will try to find a solution within those bounds
  65447. * default is (1,1,1)
  65448. * @param extent x,y,z value that define the extent around the queries point of reference
  65449. */
  65450. setDefaultQueryExtent(extent: Vector3): void;
  65451. /**
  65452. * Get the Bounding box extent specified by setDefaultQueryExtent
  65453. * @returns the box extent values
  65454. */
  65455. getDefaultQueryExtent(): Vector3;
  65456. /**
  65457. * Disposes
  65458. */
  65459. dispose(): void;
  65460. /**
  65461. * If this plugin is supported
  65462. * @returns true if plugin is supported
  65463. */
  65464. isSupported(): boolean;
  65465. }
  65466. /**
  65467. * Recast detour crowd implementation
  65468. */
  65469. export class RecastJSCrowd implements ICrowd {
  65470. /**
  65471. * Recast/detour plugin
  65472. */
  65473. bjsRECASTPlugin: RecastJSPlugin;
  65474. /**
  65475. * Link to the detour crowd
  65476. */
  65477. recastCrowd: any;
  65478. /**
  65479. * One transform per agent
  65480. */
  65481. transforms: TransformNode[];
  65482. /**
  65483. * All agents created
  65484. */
  65485. agents: number[];
  65486. /**
  65487. * Link to the scene is kept to unregister the crowd from the scene
  65488. */
  65489. private _scene;
  65490. /**
  65491. * Observer for crowd updates
  65492. */
  65493. private _onBeforeAnimationsObserver;
  65494. /**
  65495. * Constructor
  65496. * @param plugin recastJS plugin
  65497. * @param maxAgents the maximum agent count in the crowd
  65498. * @param maxAgentRadius the maximum radius an agent can have
  65499. * @param scene to attach the crowd to
  65500. * @returns the crowd you can add agents to
  65501. */
  65502. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65503. /**
  65504. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65505. * You can attach anything to that node. The node position is updated in the scene update tick.
  65506. * @param pos world position that will be constrained by the navigation mesh
  65507. * @param parameters agent parameters
  65508. * @param transform hooked to the agent that will be update by the scene
  65509. * @returns agent index
  65510. */
  65511. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65512. /**
  65513. * Returns the agent position in world space
  65514. * @param index agent index returned by addAgent
  65515. * @returns world space position
  65516. */
  65517. getAgentPosition(index: number): Vector3;
  65518. /**
  65519. * Returns the agent velocity in world space
  65520. * @param index agent index returned by addAgent
  65521. * @returns world space velocity
  65522. */
  65523. getAgentVelocity(index: number): Vector3;
  65524. /**
  65525. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65526. * @param index agent index returned by addAgent
  65527. * @param destination targeted world position
  65528. */
  65529. agentGoto(index: number, destination: Vector3): void;
  65530. /**
  65531. * Teleport the agent to a new position
  65532. * @param index agent index returned by addAgent
  65533. * @param destination targeted world position
  65534. */
  65535. agentTeleport(index: number, destination: Vector3): void;
  65536. /**
  65537. * Update agent parameters
  65538. * @param index agent index returned by addAgent
  65539. * @param parameters agent parameters
  65540. */
  65541. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65542. /**
  65543. * remove a particular agent previously created
  65544. * @param index agent index returned by addAgent
  65545. */
  65546. removeAgent(index: number): void;
  65547. /**
  65548. * get the list of all agents attached to this crowd
  65549. * @returns list of agent indices
  65550. */
  65551. getAgents(): number[];
  65552. /**
  65553. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65554. * @param deltaTime in seconds
  65555. */
  65556. update(deltaTime: number): void;
  65557. /**
  65558. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65559. * The queries will try to find a solution within those bounds
  65560. * default is (1,1,1)
  65561. * @param extent x,y,z value that define the extent around the queries point of reference
  65562. */
  65563. setDefaultQueryExtent(extent: Vector3): void;
  65564. /**
  65565. * Get the Bounding box extent specified by setDefaultQueryExtent
  65566. * @returns the box extent values
  65567. */
  65568. getDefaultQueryExtent(): Vector3;
  65569. /**
  65570. * Release all resources
  65571. */
  65572. dispose(): void;
  65573. }
  65574. }
  65575. declare module "babylonjs/Navigation/Plugins/index" {
  65576. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65577. }
  65578. declare module "babylonjs/Navigation/index" {
  65579. export * from "babylonjs/Navigation/INavigationEngine";
  65580. export * from "babylonjs/Navigation/Plugins/index";
  65581. }
  65582. declare module "babylonjs/Offline/database" {
  65583. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65584. /**
  65585. * Class used to enable access to IndexedDB
  65586. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65587. */
  65588. export class Database implements IOfflineProvider {
  65589. private _callbackManifestChecked;
  65590. private _currentSceneUrl;
  65591. private _db;
  65592. private _enableSceneOffline;
  65593. private _enableTexturesOffline;
  65594. private _manifestVersionFound;
  65595. private _mustUpdateRessources;
  65596. private _hasReachedQuota;
  65597. private _isSupported;
  65598. private _idbFactory;
  65599. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65600. private static IsUASupportingBlobStorage;
  65601. /**
  65602. * Gets a boolean indicating if Database storate is enabled (off by default)
  65603. */
  65604. static IDBStorageEnabled: boolean;
  65605. /**
  65606. * Gets a boolean indicating if scene must be saved in the database
  65607. */
  65608. get enableSceneOffline(): boolean;
  65609. /**
  65610. * Gets a boolean indicating if textures must be saved in the database
  65611. */
  65612. get enableTexturesOffline(): boolean;
  65613. /**
  65614. * Creates a new Database
  65615. * @param urlToScene defines the url to load the scene
  65616. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65617. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65618. */
  65619. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65620. private static _ParseURL;
  65621. private static _ReturnFullUrlLocation;
  65622. private _checkManifestFile;
  65623. /**
  65624. * Open the database and make it available
  65625. * @param successCallback defines the callback to call on success
  65626. * @param errorCallback defines the callback to call on error
  65627. */
  65628. open(successCallback: () => void, errorCallback: () => void): void;
  65629. /**
  65630. * Loads an image from the database
  65631. * @param url defines the url to load from
  65632. * @param image defines the target DOM image
  65633. */
  65634. loadImage(url: string, image: HTMLImageElement): void;
  65635. private _loadImageFromDBAsync;
  65636. private _saveImageIntoDBAsync;
  65637. private _checkVersionFromDB;
  65638. private _loadVersionFromDBAsync;
  65639. private _saveVersionIntoDBAsync;
  65640. /**
  65641. * Loads a file from database
  65642. * @param url defines the URL to load from
  65643. * @param sceneLoaded defines a callback to call on success
  65644. * @param progressCallBack defines a callback to call when progress changed
  65645. * @param errorCallback defines a callback to call on error
  65646. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65647. */
  65648. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65649. private _loadFileAsync;
  65650. private _saveFileAsync;
  65651. /**
  65652. * Validates if xhr data is correct
  65653. * @param xhr defines the request to validate
  65654. * @param dataType defines the expected data type
  65655. * @returns true if data is correct
  65656. */
  65657. private static _ValidateXHRData;
  65658. }
  65659. }
  65660. declare module "babylonjs/Offline/index" {
  65661. export * from "babylonjs/Offline/database";
  65662. export * from "babylonjs/Offline/IOfflineProvider";
  65663. }
  65664. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65665. /** @hidden */
  65666. export var gpuUpdateParticlesPixelShader: {
  65667. name: string;
  65668. shader: string;
  65669. };
  65670. }
  65671. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65672. /** @hidden */
  65673. export var gpuUpdateParticlesVertexShader: {
  65674. name: string;
  65675. shader: string;
  65676. };
  65677. }
  65678. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65679. /** @hidden */
  65680. export var clipPlaneFragmentDeclaration2: {
  65681. name: string;
  65682. shader: string;
  65683. };
  65684. }
  65685. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65686. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65687. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65689. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65690. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65691. /** @hidden */
  65692. export var gpuRenderParticlesPixelShader: {
  65693. name: string;
  65694. shader: string;
  65695. };
  65696. }
  65697. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65698. /** @hidden */
  65699. export var clipPlaneVertexDeclaration2: {
  65700. name: string;
  65701. shader: string;
  65702. };
  65703. }
  65704. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65705. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65706. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65707. /** @hidden */
  65708. export var gpuRenderParticlesVertexShader: {
  65709. name: string;
  65710. shader: string;
  65711. };
  65712. }
  65713. declare module "babylonjs/Particles/gpuParticleSystem" {
  65714. import { Nullable } from "babylonjs/types";
  65715. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65716. import { Observable } from "babylonjs/Misc/observable";
  65717. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65718. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65719. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65720. import { Scene, IDisposable } from "babylonjs/scene";
  65721. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65722. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65723. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65724. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65725. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65726. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65727. /**
  65728. * This represents a GPU particle system in Babylon
  65729. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65730. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65731. */
  65732. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65733. /**
  65734. * The layer mask we are rendering the particles through.
  65735. */
  65736. layerMask: number;
  65737. private _capacity;
  65738. private _activeCount;
  65739. private _currentActiveCount;
  65740. private _accumulatedCount;
  65741. private _renderEffect;
  65742. private _updateEffect;
  65743. private _buffer0;
  65744. private _buffer1;
  65745. private _spriteBuffer;
  65746. private _updateVAO;
  65747. private _renderVAO;
  65748. private _targetIndex;
  65749. private _sourceBuffer;
  65750. private _targetBuffer;
  65751. private _engine;
  65752. private _currentRenderId;
  65753. private _started;
  65754. private _stopped;
  65755. private _timeDelta;
  65756. private _randomTexture;
  65757. private _randomTexture2;
  65758. private _attributesStrideSize;
  65759. private _updateEffectOptions;
  65760. private _randomTextureSize;
  65761. private _actualFrame;
  65762. private readonly _rawTextureWidth;
  65763. /**
  65764. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65765. */
  65766. static get IsSupported(): boolean;
  65767. /**
  65768. * An event triggered when the system is disposed.
  65769. */
  65770. onDisposeObservable: Observable<GPUParticleSystem>;
  65771. /**
  65772. * Gets the maximum number of particles active at the same time.
  65773. * @returns The max number of active particles.
  65774. */
  65775. getCapacity(): number;
  65776. /**
  65777. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65778. * to override the particles.
  65779. */
  65780. forceDepthWrite: boolean;
  65781. /**
  65782. * Gets or set the number of active particles
  65783. */
  65784. get activeParticleCount(): number;
  65785. set activeParticleCount(value: number);
  65786. private _preWarmDone;
  65787. /**
  65788. * Specifies if the particles are updated in emitter local space or world space.
  65789. * This is always false for GPU particles
  65790. */
  65791. get isLocal(): boolean;
  65792. set isLocal(value: boolean);
  65793. /**
  65794. * Is this system ready to be used/rendered
  65795. * @return true if the system is ready
  65796. */
  65797. isReady(): boolean;
  65798. /**
  65799. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65800. * @returns True if it has been started, otherwise false.
  65801. */
  65802. isStarted(): boolean;
  65803. /**
  65804. * Starts the particle system and begins to emit
  65805. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65806. */
  65807. start(delay?: number): void;
  65808. /**
  65809. * Stops the particle system.
  65810. */
  65811. stop(): void;
  65812. /**
  65813. * Remove all active particles
  65814. */
  65815. reset(): void;
  65816. /**
  65817. * Returns the string "GPUParticleSystem"
  65818. * @returns a string containing the class name
  65819. */
  65820. getClassName(): string;
  65821. private _colorGradientsTexture;
  65822. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65823. /**
  65824. * Adds a new color gradient
  65825. * @param gradient defines the gradient to use (between 0 and 1)
  65826. * @param color1 defines the color to affect to the specified gradient
  65827. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65828. * @returns the current particle system
  65829. */
  65830. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65831. /**
  65832. * Remove a specific color gradient
  65833. * @param gradient defines the gradient to remove
  65834. * @returns the current particle system
  65835. */
  65836. removeColorGradient(gradient: number): GPUParticleSystem;
  65837. private _angularSpeedGradientsTexture;
  65838. private _sizeGradientsTexture;
  65839. private _velocityGradientsTexture;
  65840. private _limitVelocityGradientsTexture;
  65841. private _dragGradientsTexture;
  65842. private _addFactorGradient;
  65843. /**
  65844. * Adds a new size gradient
  65845. * @param gradient defines the gradient to use (between 0 and 1)
  65846. * @param factor defines the size factor to affect to the specified gradient
  65847. * @returns the current particle system
  65848. */
  65849. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65850. /**
  65851. * Remove a specific size gradient
  65852. * @param gradient defines the gradient to remove
  65853. * @returns the current particle system
  65854. */
  65855. removeSizeGradient(gradient: number): GPUParticleSystem;
  65856. /**
  65857. * Adds a new angular speed gradient
  65858. * @param gradient defines the gradient to use (between 0 and 1)
  65859. * @param factor defines the angular speed to affect to the specified gradient
  65860. * @returns the current particle system
  65861. */
  65862. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65863. /**
  65864. * Remove a specific angular speed gradient
  65865. * @param gradient defines the gradient to remove
  65866. * @returns the current particle system
  65867. */
  65868. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65869. /**
  65870. * Adds a new velocity gradient
  65871. * @param gradient defines the gradient to use (between 0 and 1)
  65872. * @param factor defines the velocity to affect to the specified gradient
  65873. * @returns the current particle system
  65874. */
  65875. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65876. /**
  65877. * Remove a specific velocity gradient
  65878. * @param gradient defines the gradient to remove
  65879. * @returns the current particle system
  65880. */
  65881. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65882. /**
  65883. * Adds a new limit velocity gradient
  65884. * @param gradient defines the gradient to use (between 0 and 1)
  65885. * @param factor defines the limit velocity value to affect to the specified gradient
  65886. * @returns the current particle system
  65887. */
  65888. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65889. /**
  65890. * Remove a specific limit velocity gradient
  65891. * @param gradient defines the gradient to remove
  65892. * @returns the current particle system
  65893. */
  65894. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65895. /**
  65896. * Adds a new drag gradient
  65897. * @param gradient defines the gradient to use (between 0 and 1)
  65898. * @param factor defines the drag value to affect to the specified gradient
  65899. * @returns the current particle system
  65900. */
  65901. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65902. /**
  65903. * Remove a specific drag gradient
  65904. * @param gradient defines the gradient to remove
  65905. * @returns the current particle system
  65906. */
  65907. removeDragGradient(gradient: number): GPUParticleSystem;
  65908. /**
  65909. * Not supported by GPUParticleSystem
  65910. * @param gradient defines the gradient to use (between 0 and 1)
  65911. * @param factor defines the emit rate value to affect to the specified gradient
  65912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65913. * @returns the current particle system
  65914. */
  65915. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65916. /**
  65917. * Not supported by GPUParticleSystem
  65918. * @param gradient defines the gradient to remove
  65919. * @returns the current particle system
  65920. */
  65921. removeEmitRateGradient(gradient: number): IParticleSystem;
  65922. /**
  65923. * Not supported by GPUParticleSystem
  65924. * @param gradient defines the gradient to use (between 0 and 1)
  65925. * @param factor defines the start size value to affect to the specified gradient
  65926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65927. * @returns the current particle system
  65928. */
  65929. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65930. /**
  65931. * Not supported by GPUParticleSystem
  65932. * @param gradient defines the gradient to remove
  65933. * @returns the current particle system
  65934. */
  65935. removeStartSizeGradient(gradient: number): IParticleSystem;
  65936. /**
  65937. * Not supported by GPUParticleSystem
  65938. * @param gradient defines the gradient to use (between 0 and 1)
  65939. * @param min defines the color remap minimal range
  65940. * @param max defines the color remap maximal range
  65941. * @returns the current particle system
  65942. */
  65943. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65944. /**
  65945. * Not supported by GPUParticleSystem
  65946. * @param gradient defines the gradient to remove
  65947. * @returns the current particle system
  65948. */
  65949. removeColorRemapGradient(): IParticleSystem;
  65950. /**
  65951. * Not supported by GPUParticleSystem
  65952. * @param gradient defines the gradient to use (between 0 and 1)
  65953. * @param min defines the alpha remap minimal range
  65954. * @param max defines the alpha remap maximal range
  65955. * @returns the current particle system
  65956. */
  65957. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65958. /**
  65959. * Not supported by GPUParticleSystem
  65960. * @param gradient defines the gradient to remove
  65961. * @returns the current particle system
  65962. */
  65963. removeAlphaRemapGradient(): IParticleSystem;
  65964. /**
  65965. * Not supported by GPUParticleSystem
  65966. * @param gradient defines the gradient to use (between 0 and 1)
  65967. * @param color defines the color to affect to the specified gradient
  65968. * @returns the current particle system
  65969. */
  65970. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65971. /**
  65972. * Not supported by GPUParticleSystem
  65973. * @param gradient defines the gradient to remove
  65974. * @returns the current particle system
  65975. */
  65976. removeRampGradient(): IParticleSystem;
  65977. /**
  65978. * Not supported by GPUParticleSystem
  65979. * @returns the list of ramp gradients
  65980. */
  65981. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65982. /**
  65983. * Not supported by GPUParticleSystem
  65984. * Gets or sets a boolean indicating that ramp gradients must be used
  65985. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65986. */
  65987. get useRampGradients(): boolean;
  65988. set useRampGradients(value: boolean);
  65989. /**
  65990. * Not supported by GPUParticleSystem
  65991. * @param gradient defines the gradient to use (between 0 and 1)
  65992. * @param factor defines the life time factor to affect to the specified gradient
  65993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65994. * @returns the current particle system
  65995. */
  65996. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65997. /**
  65998. * Not supported by GPUParticleSystem
  65999. * @param gradient defines the gradient to remove
  66000. * @returns the current particle system
  66001. */
  66002. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66003. /**
  66004. * Instantiates a GPU particle system.
  66005. * 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.
  66006. * @param name The name of the particle system
  66007. * @param options The options used to create the system
  66008. * @param scene The scene the particle system belongs to
  66009. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66010. */
  66011. constructor(name: string, options: Partial<{
  66012. capacity: number;
  66013. randomTextureSize: number;
  66014. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66015. protected _reset(): void;
  66016. private _createUpdateVAO;
  66017. private _createRenderVAO;
  66018. private _initialize;
  66019. /** @hidden */
  66020. _recreateUpdateEffect(): void;
  66021. /** @hidden */
  66022. _recreateRenderEffect(): void;
  66023. /**
  66024. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66025. * @param preWarm defines if we are in the pre-warmimg phase
  66026. */
  66027. animate(preWarm?: boolean): void;
  66028. private _createFactorGradientTexture;
  66029. private _createSizeGradientTexture;
  66030. private _createAngularSpeedGradientTexture;
  66031. private _createVelocityGradientTexture;
  66032. private _createLimitVelocityGradientTexture;
  66033. private _createDragGradientTexture;
  66034. private _createColorGradientTexture;
  66035. /**
  66036. * Renders the particle system in its current state
  66037. * @param preWarm defines if the system should only update the particles but not render them
  66038. * @returns the current number of particles
  66039. */
  66040. render(preWarm?: boolean): number;
  66041. /**
  66042. * Rebuilds the particle system
  66043. */
  66044. rebuild(): void;
  66045. private _releaseBuffers;
  66046. private _releaseVAOs;
  66047. /**
  66048. * Disposes the particle system and free the associated resources
  66049. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66050. */
  66051. dispose(disposeTexture?: boolean): void;
  66052. /**
  66053. * Clones the particle system.
  66054. * @param name The name of the cloned object
  66055. * @param newEmitter The new emitter to use
  66056. * @returns the cloned particle system
  66057. */
  66058. clone(name: string, newEmitter: any): GPUParticleSystem;
  66059. /**
  66060. * Serializes the particle system to a JSON object.
  66061. * @returns the JSON object
  66062. */
  66063. serialize(): any;
  66064. /**
  66065. * Parses a JSON object to create a GPU particle system.
  66066. * @param parsedParticleSystem The JSON object to parse
  66067. * @param scene The scene to create the particle system in
  66068. * @param rootUrl The root url to use to load external dependencies like texture
  66069. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66070. * @returns the parsed GPU particle system
  66071. */
  66072. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66073. }
  66074. }
  66075. declare module "babylonjs/Particles/particleSystemSet" {
  66076. import { Nullable } from "babylonjs/types";
  66077. import { Color3 } from "babylonjs/Maths/math.color";
  66078. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66080. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66081. import { Scene, IDisposable } from "babylonjs/scene";
  66082. /**
  66083. * Represents a set of particle systems working together to create a specific effect
  66084. */
  66085. export class ParticleSystemSet implements IDisposable {
  66086. /**
  66087. * Gets or sets base Assets URL
  66088. */
  66089. static BaseAssetsUrl: string;
  66090. private _emitterCreationOptions;
  66091. private _emitterNode;
  66092. /**
  66093. * Gets the particle system list
  66094. */
  66095. systems: IParticleSystem[];
  66096. /**
  66097. * Gets the emitter node used with this set
  66098. */
  66099. get emitterNode(): Nullable<TransformNode>;
  66100. /**
  66101. * Creates a new emitter mesh as a sphere
  66102. * @param options defines the options used to create the sphere
  66103. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66104. * @param scene defines the hosting scene
  66105. */
  66106. setEmitterAsSphere(options: {
  66107. diameter: number;
  66108. segments: number;
  66109. color: Color3;
  66110. }, renderingGroupId: number, scene: Scene): void;
  66111. /**
  66112. * Starts all particle systems of the set
  66113. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66114. */
  66115. start(emitter?: AbstractMesh): void;
  66116. /**
  66117. * Release all associated resources
  66118. */
  66119. dispose(): void;
  66120. /**
  66121. * Serialize the set into a JSON compatible object
  66122. * @returns a JSON compatible representation of the set
  66123. */
  66124. serialize(): any;
  66125. /**
  66126. * Parse a new ParticleSystemSet from a serialized source
  66127. * @param data defines a JSON compatible representation of the set
  66128. * @param scene defines the hosting scene
  66129. * @param gpu defines if we want GPU particles or CPU particles
  66130. * @returns a new ParticleSystemSet
  66131. */
  66132. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66133. }
  66134. }
  66135. declare module "babylonjs/Particles/particleHelper" {
  66136. import { Nullable } from "babylonjs/types";
  66137. import { Scene } from "babylonjs/scene";
  66138. import { Vector3 } from "babylonjs/Maths/math.vector";
  66139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66140. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66141. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66142. /**
  66143. * This class is made for on one-liner static method to help creating particle system set.
  66144. */
  66145. export class ParticleHelper {
  66146. /**
  66147. * Gets or sets base Assets URL
  66148. */
  66149. static BaseAssetsUrl: string;
  66150. /**
  66151. * Create a default particle system that you can tweak
  66152. * @param emitter defines the emitter to use
  66153. * @param capacity defines the system capacity (default is 500 particles)
  66154. * @param scene defines the hosting scene
  66155. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66156. * @returns the new Particle system
  66157. */
  66158. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66159. /**
  66160. * This is the main static method (one-liner) of this helper to create different particle systems
  66161. * @param type This string represents the type to the particle system to create
  66162. * @param scene The scene where the particle system should live
  66163. * @param gpu If the system will use gpu
  66164. * @returns the ParticleSystemSet created
  66165. */
  66166. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66167. /**
  66168. * Static function used to export a particle system to a ParticleSystemSet variable.
  66169. * Please note that the emitter shape is not exported
  66170. * @param systems defines the particle systems to export
  66171. * @returns the created particle system set
  66172. */
  66173. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66174. }
  66175. }
  66176. declare module "babylonjs/Particles/particleSystemComponent" {
  66177. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66178. import { Effect } from "babylonjs/Materials/effect";
  66179. import "babylonjs/Shaders/particles.vertex";
  66180. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66181. module "babylonjs/Engines/engine" {
  66182. interface Engine {
  66183. /**
  66184. * Create an effect to use with particle systems.
  66185. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66186. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66187. * @param uniformsNames defines a list of attribute names
  66188. * @param samplers defines an array of string used to represent textures
  66189. * @param defines defines the string containing the defines to use to compile the shaders
  66190. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66191. * @param onCompiled defines a function to call when the effect creation is successful
  66192. * @param onError defines a function to call when the effect creation has failed
  66193. * @returns the new Effect
  66194. */
  66195. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66196. }
  66197. }
  66198. module "babylonjs/Meshes/mesh" {
  66199. interface Mesh {
  66200. /**
  66201. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66202. * @returns an array of IParticleSystem
  66203. */
  66204. getEmittedParticleSystems(): IParticleSystem[];
  66205. /**
  66206. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66207. * @returns an array of IParticleSystem
  66208. */
  66209. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66210. }
  66211. }
  66212. /**
  66213. * @hidden
  66214. */
  66215. export var _IDoNeedToBeInTheBuild: number;
  66216. }
  66217. declare module "babylonjs/Particles/pointsCloudSystem" {
  66218. import { Color4 } from "babylonjs/Maths/math";
  66219. import { Mesh } from "babylonjs/Meshes/mesh";
  66220. import { Scene, IDisposable } from "babylonjs/scene";
  66221. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66222. /** Defines the 4 color options */
  66223. export enum PointColor {
  66224. /** color value */
  66225. Color = 2,
  66226. /** uv value */
  66227. UV = 1,
  66228. /** random value */
  66229. Random = 0,
  66230. /** stated value */
  66231. Stated = 3
  66232. }
  66233. /**
  66234. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66235. * 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.
  66236. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66237. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66238. *
  66239. * Full documentation here : TO BE ENTERED
  66240. */
  66241. export class PointsCloudSystem implements IDisposable {
  66242. /**
  66243. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66244. * Example : var p = SPS.particles[i];
  66245. */
  66246. particles: CloudPoint[];
  66247. /**
  66248. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66249. */
  66250. nbParticles: number;
  66251. /**
  66252. * This a counter for your own usage. It's not set by any SPS functions.
  66253. */
  66254. counter: number;
  66255. /**
  66256. * The PCS name. This name is also given to the underlying mesh.
  66257. */
  66258. name: string;
  66259. /**
  66260. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66261. */
  66262. mesh: Mesh;
  66263. /**
  66264. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66265. * Please read :
  66266. */
  66267. vars: any;
  66268. /**
  66269. * @hidden
  66270. */
  66271. _size: number;
  66272. private _scene;
  66273. private _promises;
  66274. private _positions;
  66275. private _indices;
  66276. private _normals;
  66277. private _colors;
  66278. private _uvs;
  66279. private _indices32;
  66280. private _positions32;
  66281. private _colors32;
  66282. private _uvs32;
  66283. private _updatable;
  66284. private _isVisibilityBoxLocked;
  66285. private _alwaysVisible;
  66286. private _groups;
  66287. private _groupCounter;
  66288. private _computeParticleColor;
  66289. private _computeParticleTexture;
  66290. private _computeParticleRotation;
  66291. private _computeBoundingBox;
  66292. private _isReady;
  66293. /**
  66294. * Creates a PCS (Points Cloud System) object
  66295. * @param name (String) is the PCS name, this will be the underlying mesh name
  66296. * @param pointSize (number) is the size for each point
  66297. * @param scene (Scene) is the scene in which the PCS is added
  66298. * @param options defines the options of the PCS e.g.
  66299. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66300. */
  66301. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66302. updatable?: boolean;
  66303. });
  66304. /**
  66305. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66306. * If no points were added to the PCS, the returned mesh is just a single point.
  66307. * @returns a promise for the created mesh
  66308. */
  66309. buildMeshAsync(): Promise<Mesh>;
  66310. /**
  66311. * @hidden
  66312. */
  66313. private _buildMesh;
  66314. private _addParticle;
  66315. private _randomUnitVector;
  66316. private _getColorIndicesForCoord;
  66317. private _setPointsColorOrUV;
  66318. private _colorFromTexture;
  66319. private _calculateDensity;
  66320. /**
  66321. * Adds points to the PCS in random positions within a unit sphere
  66322. * @param nb (positive integer) the number of particles to be created from this model
  66323. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66324. * @returns the number of groups in the system
  66325. */
  66326. addPoints(nb: number, pointFunction?: any): number;
  66327. /**
  66328. * Adds points to the PCS from the surface of the model shape
  66329. * @param mesh is any Mesh object that will be used as a surface model for the points
  66330. * @param nb (positive integer) the number of particles to be created from this model
  66331. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66332. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66333. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66334. * @returns the number of groups in the system
  66335. */
  66336. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66337. /**
  66338. * Adds points to the PCS inside the model shape
  66339. * @param mesh is any Mesh object that will be used as a surface model for the points
  66340. * @param nb (positive integer) the number of particles to be created from this model
  66341. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66342. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66343. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66344. * @returns the number of groups in the system
  66345. */
  66346. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66347. /**
  66348. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66349. * This method calls `updateParticle()` for each particle of the SPS.
  66350. * For an animated SPS, it is usually called within the render loop.
  66351. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66352. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66353. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66354. * @returns the PCS.
  66355. */
  66356. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66357. /**
  66358. * Disposes the PCS.
  66359. */
  66360. dispose(): void;
  66361. /**
  66362. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66363. * doc :
  66364. * @returns the PCS.
  66365. */
  66366. refreshVisibleSize(): PointsCloudSystem;
  66367. /**
  66368. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66369. * @param size the size (float) of the visibility box
  66370. * note : this doesn't lock the PCS mesh bounding box.
  66371. * doc :
  66372. */
  66373. setVisibilityBox(size: number): void;
  66374. /**
  66375. * Gets whether the PCS is always visible or not
  66376. * doc :
  66377. */
  66378. get isAlwaysVisible(): boolean;
  66379. /**
  66380. * Sets the PCS as always visible or not
  66381. * doc :
  66382. */
  66383. set isAlwaysVisible(val: boolean);
  66384. /**
  66385. * Tells to `setParticles()` to compute the particle rotations or not
  66386. * Default value : false. The PCS is faster when it's set to false
  66387. * Note : particle rotations are only applied to parent particles
  66388. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66389. */
  66390. set computeParticleRotation(val: boolean);
  66391. /**
  66392. * Tells to `setParticles()` to compute the particle colors or not.
  66393. * Default value : true. The PCS is faster when it's set to false.
  66394. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66395. */
  66396. set computeParticleColor(val: boolean);
  66397. set computeParticleTexture(val: boolean);
  66398. /**
  66399. * Gets if `setParticles()` computes the particle colors or not.
  66400. * Default value : false. The PCS is faster when it's set to false.
  66401. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66402. */
  66403. get computeParticleColor(): boolean;
  66404. /**
  66405. * Gets if `setParticles()` computes the particle textures or not.
  66406. * Default value : false. The PCS is faster when it's set to false.
  66407. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66408. */
  66409. get computeParticleTexture(): boolean;
  66410. /**
  66411. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66412. */
  66413. set computeBoundingBox(val: boolean);
  66414. /**
  66415. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66416. */
  66417. get computeBoundingBox(): boolean;
  66418. /**
  66419. * This function does nothing. It may be overwritten to set all the particle first values.
  66420. * The PCS doesn't call this function, you may have to call it by your own.
  66421. * doc :
  66422. */
  66423. initParticles(): void;
  66424. /**
  66425. * This function does nothing. It may be overwritten to recycle a particle
  66426. * The PCS doesn't call this function, you can to call it
  66427. * doc :
  66428. * @param particle The particle to recycle
  66429. * @returns the recycled particle
  66430. */
  66431. recycleParticle(particle: CloudPoint): CloudPoint;
  66432. /**
  66433. * Updates a particle : this function should be overwritten by the user.
  66434. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66435. * doc :
  66436. * @example : just set a particle position or velocity and recycle conditions
  66437. * @param particle The particle to update
  66438. * @returns the updated particle
  66439. */
  66440. updateParticle(particle: CloudPoint): CloudPoint;
  66441. /**
  66442. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66443. * This does nothing and may be overwritten by the user.
  66444. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66445. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66446. * @param update the boolean update value actually passed to setParticles()
  66447. */
  66448. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66449. /**
  66450. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66451. * This will be passed three parameters.
  66452. * This does nothing and may be overwritten by the user.
  66453. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66454. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66455. * @param update the boolean update value actually passed to setParticles()
  66456. */
  66457. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66458. }
  66459. }
  66460. declare module "babylonjs/Particles/cloudPoint" {
  66461. import { Nullable } from "babylonjs/types";
  66462. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66463. import { Mesh } from "babylonjs/Meshes/mesh";
  66464. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66465. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66466. /**
  66467. * Represents one particle of a points cloud system.
  66468. */
  66469. export class CloudPoint {
  66470. /**
  66471. * particle global index
  66472. */
  66473. idx: number;
  66474. /**
  66475. * The color of the particle
  66476. */
  66477. color: Nullable<Color4>;
  66478. /**
  66479. * The world space position of the particle.
  66480. */
  66481. position: Vector3;
  66482. /**
  66483. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66484. */
  66485. rotation: Vector3;
  66486. /**
  66487. * The world space rotation quaternion of the particle.
  66488. */
  66489. rotationQuaternion: Nullable<Quaternion>;
  66490. /**
  66491. * The uv of the particle.
  66492. */
  66493. uv: Nullable<Vector2>;
  66494. /**
  66495. * The current speed of the particle.
  66496. */
  66497. velocity: Vector3;
  66498. /**
  66499. * The pivot point in the particle local space.
  66500. */
  66501. pivot: Vector3;
  66502. /**
  66503. * Must the particle be translated from its pivot point in its local space ?
  66504. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66505. * Default : false
  66506. */
  66507. translateFromPivot: boolean;
  66508. /**
  66509. * Index of this particle in the global "positions" array (Internal use)
  66510. * @hidden
  66511. */
  66512. _pos: number;
  66513. /**
  66514. * @hidden Index of this particle in the global "indices" array (Internal use)
  66515. */
  66516. _ind: number;
  66517. /**
  66518. * Group this particle belongs to
  66519. */
  66520. _group: PointsGroup;
  66521. /**
  66522. * Group id of this particle
  66523. */
  66524. groupId: number;
  66525. /**
  66526. * Index of the particle in its group id (Internal use)
  66527. */
  66528. idxInGroup: number;
  66529. /**
  66530. * @hidden Particle BoundingInfo object (Internal use)
  66531. */
  66532. _boundingInfo: BoundingInfo;
  66533. /**
  66534. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66535. */
  66536. _pcs: PointsCloudSystem;
  66537. /**
  66538. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66539. */
  66540. _stillInvisible: boolean;
  66541. /**
  66542. * @hidden Last computed particle rotation matrix
  66543. */
  66544. _rotationMatrix: number[];
  66545. /**
  66546. * Parent particle Id, if any.
  66547. * Default null.
  66548. */
  66549. parentId: Nullable<number>;
  66550. /**
  66551. * @hidden Internal global position in the PCS.
  66552. */
  66553. _globalPosition: Vector3;
  66554. /**
  66555. * Creates a Point Cloud object.
  66556. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66557. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66558. * @param group (PointsGroup) is the group the particle belongs to
  66559. * @param groupId (integer) is the group identifier in the PCS.
  66560. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66561. * @param pcs defines the PCS it is associated to
  66562. */
  66563. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66564. /**
  66565. * get point size
  66566. */
  66567. get size(): Vector3;
  66568. /**
  66569. * Set point size
  66570. */
  66571. set size(scale: Vector3);
  66572. /**
  66573. * Legacy support, changed quaternion to rotationQuaternion
  66574. */
  66575. get quaternion(): Nullable<Quaternion>;
  66576. /**
  66577. * Legacy support, changed quaternion to rotationQuaternion
  66578. */
  66579. set quaternion(q: Nullable<Quaternion>);
  66580. /**
  66581. * Returns a boolean. True if the particle intersects a mesh, else false
  66582. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66583. * @param target is the object (point or mesh) what the intersection is computed against
  66584. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66585. * @returns true if it intersects
  66586. */
  66587. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66588. /**
  66589. * get the rotation matrix of the particle
  66590. * @hidden
  66591. */
  66592. getRotationMatrix(m: Matrix): void;
  66593. }
  66594. /**
  66595. * Represents a group of points in a points cloud system
  66596. * * PCS internal tool, don't use it manually.
  66597. */
  66598. export class PointsGroup {
  66599. /**
  66600. * The group id
  66601. * @hidden
  66602. */
  66603. groupID: number;
  66604. /**
  66605. * image data for group (internal use)
  66606. * @hidden
  66607. */
  66608. _groupImageData: Nullable<ArrayBufferView>;
  66609. /**
  66610. * Image Width (internal use)
  66611. * @hidden
  66612. */
  66613. _groupImgWidth: number;
  66614. /**
  66615. * Image Height (internal use)
  66616. * @hidden
  66617. */
  66618. _groupImgHeight: number;
  66619. /**
  66620. * Custom position function (internal use)
  66621. * @hidden
  66622. */
  66623. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66624. /**
  66625. * density per facet for surface points
  66626. * @hidden
  66627. */
  66628. _groupDensity: number[];
  66629. /**
  66630. * Only when points are colored by texture carries pointer to texture list array
  66631. * @hidden
  66632. */
  66633. _textureNb: number;
  66634. /**
  66635. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66636. * PCS internal tool, don't use it manually.
  66637. * @hidden
  66638. */
  66639. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66640. }
  66641. }
  66642. declare module "babylonjs/Particles/index" {
  66643. export * from "babylonjs/Particles/baseParticleSystem";
  66644. export * from "babylonjs/Particles/EmitterTypes/index";
  66645. export * from "babylonjs/Particles/gpuParticleSystem";
  66646. export * from "babylonjs/Particles/IParticleSystem";
  66647. export * from "babylonjs/Particles/particle";
  66648. export * from "babylonjs/Particles/particleHelper";
  66649. export * from "babylonjs/Particles/particleSystem";
  66650. export * from "babylonjs/Particles/particleSystemComponent";
  66651. export * from "babylonjs/Particles/particleSystemSet";
  66652. export * from "babylonjs/Particles/solidParticle";
  66653. export * from "babylonjs/Particles/solidParticleSystem";
  66654. export * from "babylonjs/Particles/cloudPoint";
  66655. export * from "babylonjs/Particles/pointsCloudSystem";
  66656. export * from "babylonjs/Particles/subEmitter";
  66657. }
  66658. declare module "babylonjs/Physics/physicsEngineComponent" {
  66659. import { Nullable } from "babylonjs/types";
  66660. import { Observable, Observer } from "babylonjs/Misc/observable";
  66661. import { Vector3 } from "babylonjs/Maths/math.vector";
  66662. import { Mesh } from "babylonjs/Meshes/mesh";
  66663. import { ISceneComponent } from "babylonjs/sceneComponent";
  66664. import { Scene } from "babylonjs/scene";
  66665. import { Node } from "babylonjs/node";
  66666. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66667. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66668. module "babylonjs/scene" {
  66669. interface Scene {
  66670. /** @hidden (Backing field) */
  66671. _physicsEngine: Nullable<IPhysicsEngine>;
  66672. /** @hidden */
  66673. _physicsTimeAccumulator: number;
  66674. /**
  66675. * Gets the current physics engine
  66676. * @returns a IPhysicsEngine or null if none attached
  66677. */
  66678. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66679. /**
  66680. * Enables physics to the current scene
  66681. * @param gravity defines the scene's gravity for the physics engine
  66682. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66683. * @return a boolean indicating if the physics engine was initialized
  66684. */
  66685. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66686. /**
  66687. * Disables and disposes the physics engine associated with the scene
  66688. */
  66689. disablePhysicsEngine(): void;
  66690. /**
  66691. * Gets a boolean indicating if there is an active physics engine
  66692. * @returns a boolean indicating if there is an active physics engine
  66693. */
  66694. isPhysicsEnabled(): boolean;
  66695. /**
  66696. * Deletes a physics compound impostor
  66697. * @param compound defines the compound to delete
  66698. */
  66699. deleteCompoundImpostor(compound: any): void;
  66700. /**
  66701. * An event triggered when physic simulation is about to be run
  66702. */
  66703. onBeforePhysicsObservable: Observable<Scene>;
  66704. /**
  66705. * An event triggered when physic simulation has been done
  66706. */
  66707. onAfterPhysicsObservable: Observable<Scene>;
  66708. }
  66709. }
  66710. module "babylonjs/Meshes/abstractMesh" {
  66711. interface AbstractMesh {
  66712. /** @hidden */
  66713. _physicsImpostor: Nullable<PhysicsImpostor>;
  66714. /**
  66715. * Gets or sets impostor used for physic simulation
  66716. * @see http://doc.babylonjs.com/features/physics_engine
  66717. */
  66718. physicsImpostor: Nullable<PhysicsImpostor>;
  66719. /**
  66720. * Gets the current physics impostor
  66721. * @see http://doc.babylonjs.com/features/physics_engine
  66722. * @returns a physics impostor or null
  66723. */
  66724. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66725. /** Apply a physic impulse to the mesh
  66726. * @param force defines the force to apply
  66727. * @param contactPoint defines where to apply the force
  66728. * @returns the current mesh
  66729. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66730. */
  66731. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66732. /**
  66733. * Creates a physic joint between two meshes
  66734. * @param otherMesh defines the other mesh to use
  66735. * @param pivot1 defines the pivot to use on this mesh
  66736. * @param pivot2 defines the pivot to use on the other mesh
  66737. * @param options defines additional options (can be plugin dependent)
  66738. * @returns the current mesh
  66739. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66740. */
  66741. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66742. /** @hidden */
  66743. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66744. }
  66745. }
  66746. /**
  66747. * Defines the physics engine scene component responsible to manage a physics engine
  66748. */
  66749. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66750. /**
  66751. * The component name helpful to identify the component in the list of scene components.
  66752. */
  66753. readonly name: string;
  66754. /**
  66755. * The scene the component belongs to.
  66756. */
  66757. scene: Scene;
  66758. /**
  66759. * Creates a new instance of the component for the given scene
  66760. * @param scene Defines the scene to register the component in
  66761. */
  66762. constructor(scene: Scene);
  66763. /**
  66764. * Registers the component in a given scene
  66765. */
  66766. register(): void;
  66767. /**
  66768. * Rebuilds the elements related to this component in case of
  66769. * context lost for instance.
  66770. */
  66771. rebuild(): void;
  66772. /**
  66773. * Disposes the component and the associated ressources
  66774. */
  66775. dispose(): void;
  66776. }
  66777. }
  66778. declare module "babylonjs/Physics/physicsHelper" {
  66779. import { Nullable } from "babylonjs/types";
  66780. import { Vector3 } from "babylonjs/Maths/math.vector";
  66781. import { Mesh } from "babylonjs/Meshes/mesh";
  66782. import { Scene } from "babylonjs/scene";
  66783. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66784. /**
  66785. * A helper for physics simulations
  66786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66787. */
  66788. export class PhysicsHelper {
  66789. private _scene;
  66790. private _physicsEngine;
  66791. /**
  66792. * Initializes the Physics helper
  66793. * @param scene Babylon.js scene
  66794. */
  66795. constructor(scene: Scene);
  66796. /**
  66797. * Applies a radial explosion impulse
  66798. * @param origin the origin of the explosion
  66799. * @param radiusOrEventOptions the radius or the options of radial explosion
  66800. * @param strength the explosion strength
  66801. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66802. * @returns A physics radial explosion event, or null
  66803. */
  66804. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66805. /**
  66806. * Applies a radial explosion force
  66807. * @param origin the origin of the explosion
  66808. * @param radiusOrEventOptions the radius or the options of radial explosion
  66809. * @param strength the explosion strength
  66810. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66811. * @returns A physics radial explosion event, or null
  66812. */
  66813. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66814. /**
  66815. * Creates a gravitational field
  66816. * @param origin the origin of the explosion
  66817. * @param radiusOrEventOptions the radius or the options of radial explosion
  66818. * @param strength the explosion strength
  66819. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66820. * @returns A physics gravitational field event, or null
  66821. */
  66822. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66823. /**
  66824. * Creates a physics updraft event
  66825. * @param origin the origin of the updraft
  66826. * @param radiusOrEventOptions the radius or the options of the updraft
  66827. * @param strength the strength of the updraft
  66828. * @param height the height of the updraft
  66829. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66830. * @returns A physics updraft event, or null
  66831. */
  66832. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66833. /**
  66834. * Creates a physics vortex event
  66835. * @param origin the of the vortex
  66836. * @param radiusOrEventOptions the radius or the options of the vortex
  66837. * @param strength the strength of the vortex
  66838. * @param height the height of the vortex
  66839. * @returns a Physics vortex event, or null
  66840. * A physics vortex event or null
  66841. */
  66842. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66843. }
  66844. /**
  66845. * Represents a physics radial explosion event
  66846. */
  66847. class PhysicsRadialExplosionEvent {
  66848. private _scene;
  66849. private _options;
  66850. private _sphere;
  66851. private _dataFetched;
  66852. /**
  66853. * Initializes a radial explosioin event
  66854. * @param _scene BabylonJS scene
  66855. * @param _options The options for the vortex event
  66856. */
  66857. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66858. /**
  66859. * Returns the data related to the radial explosion event (sphere).
  66860. * @returns The radial explosion event data
  66861. */
  66862. getData(): PhysicsRadialExplosionEventData;
  66863. /**
  66864. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66865. * @param impostor A physics imposter
  66866. * @param origin the origin of the explosion
  66867. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66868. */
  66869. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66870. /**
  66871. * Triggers affecterd impostors callbacks
  66872. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66873. */
  66874. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66875. /**
  66876. * Disposes the sphere.
  66877. * @param force Specifies if the sphere should be disposed by force
  66878. */
  66879. dispose(force?: boolean): void;
  66880. /*** Helpers ***/
  66881. private _prepareSphere;
  66882. private _intersectsWithSphere;
  66883. }
  66884. /**
  66885. * Represents a gravitational field event
  66886. */
  66887. class PhysicsGravitationalFieldEvent {
  66888. private _physicsHelper;
  66889. private _scene;
  66890. private _origin;
  66891. private _options;
  66892. private _tickCallback;
  66893. private _sphere;
  66894. private _dataFetched;
  66895. /**
  66896. * Initializes the physics gravitational field event
  66897. * @param _physicsHelper A physics helper
  66898. * @param _scene BabylonJS scene
  66899. * @param _origin The origin position of the gravitational field event
  66900. * @param _options The options for the vortex event
  66901. */
  66902. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66903. /**
  66904. * Returns the data related to the gravitational field event (sphere).
  66905. * @returns A gravitational field event
  66906. */
  66907. getData(): PhysicsGravitationalFieldEventData;
  66908. /**
  66909. * Enables the gravitational field.
  66910. */
  66911. enable(): void;
  66912. /**
  66913. * Disables the gravitational field.
  66914. */
  66915. disable(): void;
  66916. /**
  66917. * Disposes the sphere.
  66918. * @param force The force to dispose from the gravitational field event
  66919. */
  66920. dispose(force?: boolean): void;
  66921. private _tick;
  66922. }
  66923. /**
  66924. * Represents a physics updraft event
  66925. */
  66926. class PhysicsUpdraftEvent {
  66927. private _scene;
  66928. private _origin;
  66929. private _options;
  66930. private _physicsEngine;
  66931. private _originTop;
  66932. private _originDirection;
  66933. private _tickCallback;
  66934. private _cylinder;
  66935. private _cylinderPosition;
  66936. private _dataFetched;
  66937. /**
  66938. * Initializes the physics updraft event
  66939. * @param _scene BabylonJS scene
  66940. * @param _origin The origin position of the updraft
  66941. * @param _options The options for the updraft event
  66942. */
  66943. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66944. /**
  66945. * Returns the data related to the updraft event (cylinder).
  66946. * @returns A physics updraft event
  66947. */
  66948. getData(): PhysicsUpdraftEventData;
  66949. /**
  66950. * Enables the updraft.
  66951. */
  66952. enable(): void;
  66953. /**
  66954. * Disables the updraft.
  66955. */
  66956. disable(): void;
  66957. /**
  66958. * Disposes the cylinder.
  66959. * @param force Specifies if the updraft should be disposed by force
  66960. */
  66961. dispose(force?: boolean): void;
  66962. private getImpostorHitData;
  66963. private _tick;
  66964. /*** Helpers ***/
  66965. private _prepareCylinder;
  66966. private _intersectsWithCylinder;
  66967. }
  66968. /**
  66969. * Represents a physics vortex event
  66970. */
  66971. class PhysicsVortexEvent {
  66972. private _scene;
  66973. private _origin;
  66974. private _options;
  66975. private _physicsEngine;
  66976. private _originTop;
  66977. private _tickCallback;
  66978. private _cylinder;
  66979. private _cylinderPosition;
  66980. private _dataFetched;
  66981. /**
  66982. * Initializes the physics vortex event
  66983. * @param _scene The BabylonJS scene
  66984. * @param _origin The origin position of the vortex
  66985. * @param _options The options for the vortex event
  66986. */
  66987. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66988. /**
  66989. * Returns the data related to the vortex event (cylinder).
  66990. * @returns The physics vortex event data
  66991. */
  66992. getData(): PhysicsVortexEventData;
  66993. /**
  66994. * Enables the vortex.
  66995. */
  66996. enable(): void;
  66997. /**
  66998. * Disables the cortex.
  66999. */
  67000. disable(): void;
  67001. /**
  67002. * Disposes the sphere.
  67003. * @param force
  67004. */
  67005. dispose(force?: boolean): void;
  67006. private getImpostorHitData;
  67007. private _tick;
  67008. /*** Helpers ***/
  67009. private _prepareCylinder;
  67010. private _intersectsWithCylinder;
  67011. }
  67012. /**
  67013. * Options fot the radial explosion event
  67014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67015. */
  67016. export class PhysicsRadialExplosionEventOptions {
  67017. /**
  67018. * The radius of the sphere for the radial explosion.
  67019. */
  67020. radius: number;
  67021. /**
  67022. * The strenth of the explosion.
  67023. */
  67024. strength: number;
  67025. /**
  67026. * The strenght of the force in correspondence to the distance of the affected object
  67027. */
  67028. falloff: PhysicsRadialImpulseFalloff;
  67029. /**
  67030. * Sphere options for the radial explosion.
  67031. */
  67032. sphere: {
  67033. segments: number;
  67034. diameter: number;
  67035. };
  67036. /**
  67037. * Sphere options for the radial explosion.
  67038. */
  67039. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67040. }
  67041. /**
  67042. * Options fot the updraft event
  67043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67044. */
  67045. export class PhysicsUpdraftEventOptions {
  67046. /**
  67047. * The radius of the cylinder for the vortex
  67048. */
  67049. radius: number;
  67050. /**
  67051. * The strenth of the updraft.
  67052. */
  67053. strength: number;
  67054. /**
  67055. * The height of the cylinder for the updraft.
  67056. */
  67057. height: number;
  67058. /**
  67059. * The mode for the the updraft.
  67060. */
  67061. updraftMode: PhysicsUpdraftMode;
  67062. }
  67063. /**
  67064. * Options fot the vortex event
  67065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67066. */
  67067. export class PhysicsVortexEventOptions {
  67068. /**
  67069. * The radius of the cylinder for the vortex
  67070. */
  67071. radius: number;
  67072. /**
  67073. * The strenth of the vortex.
  67074. */
  67075. strength: number;
  67076. /**
  67077. * The height of the cylinder for the vortex.
  67078. */
  67079. height: number;
  67080. /**
  67081. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67082. */
  67083. centripetalForceThreshold: number;
  67084. /**
  67085. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67086. */
  67087. centripetalForceMultiplier: number;
  67088. /**
  67089. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67090. */
  67091. centrifugalForceMultiplier: number;
  67092. /**
  67093. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67094. */
  67095. updraftForceMultiplier: number;
  67096. }
  67097. /**
  67098. * The strenght of the force in correspondence to the distance of the affected object
  67099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67100. */
  67101. export enum PhysicsRadialImpulseFalloff {
  67102. /** Defines that impulse is constant in strength across it's whole radius */
  67103. Constant = 0,
  67104. /** Defines that impulse gets weaker if it's further from the origin */
  67105. Linear = 1
  67106. }
  67107. /**
  67108. * The strength of the force in correspondence to the distance of the affected object
  67109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67110. */
  67111. export enum PhysicsUpdraftMode {
  67112. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67113. Center = 0,
  67114. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67115. Perpendicular = 1
  67116. }
  67117. /**
  67118. * Interface for a physics hit data
  67119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67120. */
  67121. export interface PhysicsHitData {
  67122. /**
  67123. * The force applied at the contact point
  67124. */
  67125. force: Vector3;
  67126. /**
  67127. * The contact point
  67128. */
  67129. contactPoint: Vector3;
  67130. /**
  67131. * The distance from the origin to the contact point
  67132. */
  67133. distanceFromOrigin: number;
  67134. }
  67135. /**
  67136. * Interface for radial explosion event data
  67137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67138. */
  67139. export interface PhysicsRadialExplosionEventData {
  67140. /**
  67141. * A sphere used for the radial explosion event
  67142. */
  67143. sphere: Mesh;
  67144. }
  67145. /**
  67146. * Interface for gravitational field event data
  67147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67148. */
  67149. export interface PhysicsGravitationalFieldEventData {
  67150. /**
  67151. * A sphere mesh used for the gravitational field event
  67152. */
  67153. sphere: Mesh;
  67154. }
  67155. /**
  67156. * Interface for updraft event data
  67157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67158. */
  67159. export interface PhysicsUpdraftEventData {
  67160. /**
  67161. * A cylinder used for the updraft event
  67162. */
  67163. cylinder: Mesh;
  67164. }
  67165. /**
  67166. * Interface for vortex event data
  67167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67168. */
  67169. export interface PhysicsVortexEventData {
  67170. /**
  67171. * A cylinder used for the vortex event
  67172. */
  67173. cylinder: Mesh;
  67174. }
  67175. /**
  67176. * Interface for an affected physics impostor
  67177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67178. */
  67179. export interface PhysicsAffectedImpostorWithData {
  67180. /**
  67181. * The impostor affected by the effect
  67182. */
  67183. impostor: PhysicsImpostor;
  67184. /**
  67185. * The data about the hit/horce from the explosion
  67186. */
  67187. hitData: PhysicsHitData;
  67188. }
  67189. }
  67190. declare module "babylonjs/Physics/Plugins/index" {
  67191. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67192. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67193. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67194. }
  67195. declare module "babylonjs/Physics/index" {
  67196. export * from "babylonjs/Physics/IPhysicsEngine";
  67197. export * from "babylonjs/Physics/physicsEngine";
  67198. export * from "babylonjs/Physics/physicsEngineComponent";
  67199. export * from "babylonjs/Physics/physicsHelper";
  67200. export * from "babylonjs/Physics/physicsImpostor";
  67201. export * from "babylonjs/Physics/physicsJoint";
  67202. export * from "babylonjs/Physics/Plugins/index";
  67203. }
  67204. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67205. /** @hidden */
  67206. export var blackAndWhitePixelShader: {
  67207. name: string;
  67208. shader: string;
  67209. };
  67210. }
  67211. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67213. import { Camera } from "babylonjs/Cameras/camera";
  67214. import { Engine } from "babylonjs/Engines/engine";
  67215. import "babylonjs/Shaders/blackAndWhite.fragment";
  67216. /**
  67217. * Post process used to render in black and white
  67218. */
  67219. export class BlackAndWhitePostProcess extends PostProcess {
  67220. /**
  67221. * Linear about to convert he result to black and white (default: 1)
  67222. */
  67223. degree: number;
  67224. /**
  67225. * Creates a black and white post process
  67226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67227. * @param name The name of the effect.
  67228. * @param options The required width/height ratio to downsize to before computing the render pass.
  67229. * @param camera The camera to apply the render pass to.
  67230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67231. * @param engine The engine which the post process will be applied. (default: current engine)
  67232. * @param reusable If the post process can be reused on the same frame. (default: false)
  67233. */
  67234. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67235. }
  67236. }
  67237. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67238. import { Nullable } from "babylonjs/types";
  67239. import { Camera } from "babylonjs/Cameras/camera";
  67240. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67241. import { Engine } from "babylonjs/Engines/engine";
  67242. /**
  67243. * This represents a set of one or more post processes in Babylon.
  67244. * A post process can be used to apply a shader to a texture after it is rendered.
  67245. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67246. */
  67247. export class PostProcessRenderEffect {
  67248. private _postProcesses;
  67249. private _getPostProcesses;
  67250. private _singleInstance;
  67251. private _cameras;
  67252. private _indicesForCamera;
  67253. /**
  67254. * Name of the effect
  67255. * @hidden
  67256. */
  67257. _name: string;
  67258. /**
  67259. * Instantiates a post process render effect.
  67260. * A post process can be used to apply a shader to a texture after it is rendered.
  67261. * @param engine The engine the effect is tied to
  67262. * @param name The name of the effect
  67263. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67264. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67265. */
  67266. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67267. /**
  67268. * Checks if all the post processes in the effect are supported.
  67269. */
  67270. get isSupported(): boolean;
  67271. /**
  67272. * Updates the current state of the effect
  67273. * @hidden
  67274. */
  67275. _update(): void;
  67276. /**
  67277. * Attaches the effect on cameras
  67278. * @param cameras The camera to attach to.
  67279. * @hidden
  67280. */
  67281. _attachCameras(cameras: Camera): void;
  67282. /**
  67283. * Attaches the effect on cameras
  67284. * @param cameras The camera to attach to.
  67285. * @hidden
  67286. */
  67287. _attachCameras(cameras: Camera[]): void;
  67288. /**
  67289. * Detaches the effect on cameras
  67290. * @param cameras The camera to detatch from.
  67291. * @hidden
  67292. */
  67293. _detachCameras(cameras: Camera): void;
  67294. /**
  67295. * Detatches the effect on cameras
  67296. * @param cameras The camera to detatch from.
  67297. * @hidden
  67298. */
  67299. _detachCameras(cameras: Camera[]): void;
  67300. /**
  67301. * Enables the effect on given cameras
  67302. * @param cameras The camera to enable.
  67303. * @hidden
  67304. */
  67305. _enable(cameras: Camera): void;
  67306. /**
  67307. * Enables the effect on given cameras
  67308. * @param cameras The camera to enable.
  67309. * @hidden
  67310. */
  67311. _enable(cameras: Nullable<Camera[]>): void;
  67312. /**
  67313. * Disables the effect on the given cameras
  67314. * @param cameras The camera to disable.
  67315. * @hidden
  67316. */
  67317. _disable(cameras: Camera): void;
  67318. /**
  67319. * Disables the effect on the given cameras
  67320. * @param cameras The camera to disable.
  67321. * @hidden
  67322. */
  67323. _disable(cameras: Nullable<Camera[]>): void;
  67324. /**
  67325. * Gets a list of the post processes contained in the effect.
  67326. * @param camera The camera to get the post processes on.
  67327. * @returns The list of the post processes in the effect.
  67328. */
  67329. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67330. }
  67331. }
  67332. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67334. /** @hidden */
  67335. export var extractHighlightsPixelShader: {
  67336. name: string;
  67337. shader: string;
  67338. };
  67339. }
  67340. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67341. import { Nullable } from "babylonjs/types";
  67342. import { Camera } from "babylonjs/Cameras/camera";
  67343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67344. import { Engine } from "babylonjs/Engines/engine";
  67345. import "babylonjs/Shaders/extractHighlights.fragment";
  67346. /**
  67347. * 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.
  67348. */
  67349. export class ExtractHighlightsPostProcess extends PostProcess {
  67350. /**
  67351. * The luminance threshold, pixels below this value will be set to black.
  67352. */
  67353. threshold: number;
  67354. /** @hidden */
  67355. _exposure: number;
  67356. /**
  67357. * Post process which has the input texture to be used when performing highlight extraction
  67358. * @hidden
  67359. */
  67360. _inputPostProcess: Nullable<PostProcess>;
  67361. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67362. }
  67363. }
  67364. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67365. /** @hidden */
  67366. export var bloomMergePixelShader: {
  67367. name: string;
  67368. shader: string;
  67369. };
  67370. }
  67371. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67373. import { Nullable } from "babylonjs/types";
  67374. import { Engine } from "babylonjs/Engines/engine";
  67375. import { Camera } from "babylonjs/Cameras/camera";
  67376. import "babylonjs/Shaders/bloomMerge.fragment";
  67377. /**
  67378. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67379. */
  67380. export class BloomMergePostProcess extends PostProcess {
  67381. /** Weight of the bloom to be added to the original input. */
  67382. weight: number;
  67383. /**
  67384. * Creates a new instance of @see BloomMergePostProcess
  67385. * @param name The name of the effect.
  67386. * @param originalFromInput Post process which's input will be used for the merge.
  67387. * @param blurred Blurred highlights post process which's output will be used.
  67388. * @param weight Weight of the bloom to be added to the original input.
  67389. * @param options The required width/height ratio to downsize to before computing the render pass.
  67390. * @param camera The camera to apply the render pass to.
  67391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67392. * @param engine The engine which the post process will be applied. (default: current engine)
  67393. * @param reusable If the post process can be reused on the same frame. (default: false)
  67394. * @param textureType Type of textures used when performing the post process. (default: 0)
  67395. * @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)
  67396. */
  67397. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67398. /** Weight of the bloom to be added to the original input. */
  67399. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67400. }
  67401. }
  67402. declare module "babylonjs/PostProcesses/bloomEffect" {
  67403. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67404. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67405. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67406. import { Camera } from "babylonjs/Cameras/camera";
  67407. import { Scene } from "babylonjs/scene";
  67408. /**
  67409. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67410. */
  67411. export class BloomEffect extends PostProcessRenderEffect {
  67412. private bloomScale;
  67413. /**
  67414. * @hidden Internal
  67415. */
  67416. _effects: Array<PostProcess>;
  67417. /**
  67418. * @hidden Internal
  67419. */
  67420. _downscale: ExtractHighlightsPostProcess;
  67421. private _blurX;
  67422. private _blurY;
  67423. private _merge;
  67424. /**
  67425. * The luminance threshold to find bright areas of the image to bloom.
  67426. */
  67427. get threshold(): number;
  67428. set threshold(value: number);
  67429. /**
  67430. * The strength of the bloom.
  67431. */
  67432. get weight(): number;
  67433. set weight(value: number);
  67434. /**
  67435. * Specifies the size of the bloom blur kernel, relative to the final output size
  67436. */
  67437. get kernel(): number;
  67438. set kernel(value: number);
  67439. /**
  67440. * Creates a new instance of @see BloomEffect
  67441. * @param scene The scene the effect belongs to.
  67442. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67443. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67444. * @param bloomWeight The the strength of bloom.
  67445. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67446. * @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)
  67447. */
  67448. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67449. /**
  67450. * Disposes each of the internal effects for a given camera.
  67451. * @param camera The camera to dispose the effect on.
  67452. */
  67453. disposeEffects(camera: Camera): void;
  67454. /**
  67455. * @hidden Internal
  67456. */
  67457. _updateEffects(): void;
  67458. /**
  67459. * Internal
  67460. * @returns if all the contained post processes are ready.
  67461. * @hidden
  67462. */
  67463. _isReady(): boolean;
  67464. }
  67465. }
  67466. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67467. /** @hidden */
  67468. export var chromaticAberrationPixelShader: {
  67469. name: string;
  67470. shader: string;
  67471. };
  67472. }
  67473. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67474. import { Vector2 } from "babylonjs/Maths/math.vector";
  67475. import { Nullable } from "babylonjs/types";
  67476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67477. import { Camera } from "babylonjs/Cameras/camera";
  67478. import { Engine } from "babylonjs/Engines/engine";
  67479. import "babylonjs/Shaders/chromaticAberration.fragment";
  67480. /**
  67481. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67482. */
  67483. export class ChromaticAberrationPostProcess extends PostProcess {
  67484. /**
  67485. * The amount of seperation of rgb channels (default: 30)
  67486. */
  67487. aberrationAmount: number;
  67488. /**
  67489. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67490. */
  67491. radialIntensity: number;
  67492. /**
  67493. * 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))
  67494. */
  67495. direction: Vector2;
  67496. /**
  67497. * 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))
  67498. */
  67499. centerPosition: Vector2;
  67500. /**
  67501. * Creates a new instance ChromaticAberrationPostProcess
  67502. * @param name The name of the effect.
  67503. * @param screenWidth The width of the screen to apply the effect on.
  67504. * @param screenHeight The height of the screen to apply the effect on.
  67505. * @param options The required width/height ratio to downsize to before computing the render pass.
  67506. * @param camera The camera to apply the render pass to.
  67507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67508. * @param engine The engine which the post process will be applied. (default: current engine)
  67509. * @param reusable If the post process can be reused on the same frame. (default: false)
  67510. * @param textureType Type of textures used when performing the post process. (default: 0)
  67511. * @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)
  67512. */
  67513. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67514. }
  67515. }
  67516. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67517. /** @hidden */
  67518. export var circleOfConfusionPixelShader: {
  67519. name: string;
  67520. shader: string;
  67521. };
  67522. }
  67523. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67524. import { Nullable } from "babylonjs/types";
  67525. import { Engine } from "babylonjs/Engines/engine";
  67526. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67527. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67528. import { Camera } from "babylonjs/Cameras/camera";
  67529. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67530. /**
  67531. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67532. */
  67533. export class CircleOfConfusionPostProcess extends PostProcess {
  67534. /**
  67535. * 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.
  67536. */
  67537. lensSize: number;
  67538. /**
  67539. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67540. */
  67541. fStop: number;
  67542. /**
  67543. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67544. */
  67545. focusDistance: number;
  67546. /**
  67547. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67548. */
  67549. focalLength: number;
  67550. private _depthTexture;
  67551. /**
  67552. * Creates a new instance CircleOfConfusionPostProcess
  67553. * @param name The name of the effect.
  67554. * @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.
  67555. * @param options The required width/height ratio to downsize to before computing the render pass.
  67556. * @param camera The camera to apply the render pass to.
  67557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67558. * @param engine The engine which the post process will be applied. (default: current engine)
  67559. * @param reusable If the post process can be reused on the same frame. (default: false)
  67560. * @param textureType Type of textures used when performing the post process. (default: 0)
  67561. * @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)
  67562. */
  67563. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67564. /**
  67565. * 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.
  67566. */
  67567. set depthTexture(value: RenderTargetTexture);
  67568. }
  67569. }
  67570. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67571. /** @hidden */
  67572. export var colorCorrectionPixelShader: {
  67573. name: string;
  67574. shader: string;
  67575. };
  67576. }
  67577. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67579. import { Engine } from "babylonjs/Engines/engine";
  67580. import { Camera } from "babylonjs/Cameras/camera";
  67581. import "babylonjs/Shaders/colorCorrection.fragment";
  67582. /**
  67583. *
  67584. * This post-process allows the modification of rendered colors by using
  67585. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67586. *
  67587. * The object needs to be provided an url to a texture containing the color
  67588. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67589. * Use an image editing software to tweak the LUT to match your needs.
  67590. *
  67591. * For an example of a color LUT, see here:
  67592. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67593. * For explanations on color grading, see here:
  67594. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67595. *
  67596. */
  67597. export class ColorCorrectionPostProcess extends PostProcess {
  67598. private _colorTableTexture;
  67599. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67600. }
  67601. }
  67602. declare module "babylonjs/Shaders/convolution.fragment" {
  67603. /** @hidden */
  67604. export var convolutionPixelShader: {
  67605. name: string;
  67606. shader: string;
  67607. };
  67608. }
  67609. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67611. import { Nullable } from "babylonjs/types";
  67612. import { Camera } from "babylonjs/Cameras/camera";
  67613. import { Engine } from "babylonjs/Engines/engine";
  67614. import "babylonjs/Shaders/convolution.fragment";
  67615. /**
  67616. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67617. * input texture to perform effects such as edge detection or sharpening
  67618. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67619. */
  67620. export class ConvolutionPostProcess extends PostProcess {
  67621. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67622. kernel: number[];
  67623. /**
  67624. * Creates a new instance ConvolutionPostProcess
  67625. * @param name The name of the effect.
  67626. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67627. * @param options The required width/height ratio to downsize to before computing the render pass.
  67628. * @param camera The camera to apply the render pass to.
  67629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67630. * @param engine The engine which the post process will be applied. (default: current engine)
  67631. * @param reusable If the post process can be reused on the same frame. (default: false)
  67632. * @param textureType Type of textures used when performing the post process. (default: 0)
  67633. */
  67634. constructor(name: string,
  67635. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67636. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67637. /**
  67638. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67639. */
  67640. static EdgeDetect0Kernel: number[];
  67641. /**
  67642. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67643. */
  67644. static EdgeDetect1Kernel: number[];
  67645. /**
  67646. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67647. */
  67648. static EdgeDetect2Kernel: number[];
  67649. /**
  67650. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67651. */
  67652. static SharpenKernel: number[];
  67653. /**
  67654. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67655. */
  67656. static EmbossKernel: number[];
  67657. /**
  67658. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67659. */
  67660. static GaussianKernel: number[];
  67661. }
  67662. }
  67663. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67664. import { Nullable } from "babylonjs/types";
  67665. import { Vector2 } from "babylonjs/Maths/math.vector";
  67666. import { Camera } from "babylonjs/Cameras/camera";
  67667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67668. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67669. import { Engine } from "babylonjs/Engines/engine";
  67670. import { Scene } from "babylonjs/scene";
  67671. /**
  67672. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67673. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67674. * based on samples that have a large difference in distance than the center pixel.
  67675. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67676. */
  67677. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67678. direction: Vector2;
  67679. /**
  67680. * Creates a new instance CircleOfConfusionPostProcess
  67681. * @param name The name of the effect.
  67682. * @param scene The scene the effect belongs to.
  67683. * @param direction The direction the blur should be applied.
  67684. * @param kernel The size of the kernel used to blur.
  67685. * @param options The required width/height ratio to downsize to before computing the render pass.
  67686. * @param camera The camera to apply the render pass to.
  67687. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67688. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67690. * @param engine The engine which the post process will be applied. (default: current engine)
  67691. * @param reusable If the post process can be reused on the same frame. (default: false)
  67692. * @param textureType Type of textures used when performing the post process. (default: 0)
  67693. * @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)
  67694. */
  67695. 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);
  67696. }
  67697. }
  67698. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67699. /** @hidden */
  67700. export var depthOfFieldMergePixelShader: {
  67701. name: string;
  67702. shader: string;
  67703. };
  67704. }
  67705. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67706. import { Nullable } from "babylonjs/types";
  67707. import { Camera } from "babylonjs/Cameras/camera";
  67708. import { Effect } from "babylonjs/Materials/effect";
  67709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67710. import { Engine } from "babylonjs/Engines/engine";
  67711. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67712. /**
  67713. * Options to be set when merging outputs from the default pipeline.
  67714. */
  67715. export class DepthOfFieldMergePostProcessOptions {
  67716. /**
  67717. * The original image to merge on top of
  67718. */
  67719. originalFromInput: PostProcess;
  67720. /**
  67721. * Parameters to perform the merge of the depth of field effect
  67722. */
  67723. depthOfField?: {
  67724. circleOfConfusion: PostProcess;
  67725. blurSteps: Array<PostProcess>;
  67726. };
  67727. /**
  67728. * Parameters to perform the merge of bloom effect
  67729. */
  67730. bloom?: {
  67731. blurred: PostProcess;
  67732. weight: number;
  67733. };
  67734. }
  67735. /**
  67736. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67737. */
  67738. export class DepthOfFieldMergePostProcess extends PostProcess {
  67739. private blurSteps;
  67740. /**
  67741. * Creates a new instance of DepthOfFieldMergePostProcess
  67742. * @param name The name of the effect.
  67743. * @param originalFromInput Post process which's input will be used for the merge.
  67744. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67745. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67746. * @param options The required width/height ratio to downsize to before computing the render pass.
  67747. * @param camera The camera to apply the render pass to.
  67748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67749. * @param engine The engine which the post process will be applied. (default: current engine)
  67750. * @param reusable If the post process can be reused on the same frame. (default: false)
  67751. * @param textureType Type of textures used when performing the post process. (default: 0)
  67752. * @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)
  67753. */
  67754. 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);
  67755. /**
  67756. * Updates the effect with the current post process compile time values and recompiles the shader.
  67757. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67758. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67759. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67760. * @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
  67761. * @param onCompiled Called when the shader has been compiled.
  67762. * @param onError Called if there is an error when compiling a shader.
  67763. */
  67764. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67765. }
  67766. }
  67767. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67768. import { Nullable } from "babylonjs/types";
  67769. import { Camera } from "babylonjs/Cameras/camera";
  67770. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67771. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67772. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67773. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67774. import { Scene } from "babylonjs/scene";
  67775. /**
  67776. * Specifies the level of max blur that should be applied when using the depth of field effect
  67777. */
  67778. export enum DepthOfFieldEffectBlurLevel {
  67779. /**
  67780. * Subtle blur
  67781. */
  67782. Low = 0,
  67783. /**
  67784. * Medium blur
  67785. */
  67786. Medium = 1,
  67787. /**
  67788. * Large blur
  67789. */
  67790. High = 2
  67791. }
  67792. /**
  67793. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67794. */
  67795. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67796. private _circleOfConfusion;
  67797. /**
  67798. * @hidden Internal, blurs from high to low
  67799. */
  67800. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67801. private _depthOfFieldBlurY;
  67802. private _dofMerge;
  67803. /**
  67804. * @hidden Internal post processes in depth of field effect
  67805. */
  67806. _effects: Array<PostProcess>;
  67807. /**
  67808. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67809. */
  67810. set focalLength(value: number);
  67811. get focalLength(): number;
  67812. /**
  67813. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67814. */
  67815. set fStop(value: number);
  67816. get fStop(): number;
  67817. /**
  67818. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67819. */
  67820. set focusDistance(value: number);
  67821. get focusDistance(): number;
  67822. /**
  67823. * 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.
  67824. */
  67825. set lensSize(value: number);
  67826. get lensSize(): number;
  67827. /**
  67828. * Creates a new instance DepthOfFieldEffect
  67829. * @param scene The scene the effect belongs to.
  67830. * @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.
  67831. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67832. * @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)
  67833. */
  67834. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67835. /**
  67836. * Get the current class name of the current effet
  67837. * @returns "DepthOfFieldEffect"
  67838. */
  67839. getClassName(): string;
  67840. /**
  67841. * 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.
  67842. */
  67843. set depthTexture(value: RenderTargetTexture);
  67844. /**
  67845. * Disposes each of the internal effects for a given camera.
  67846. * @param camera The camera to dispose the effect on.
  67847. */
  67848. disposeEffects(camera: Camera): void;
  67849. /**
  67850. * @hidden Internal
  67851. */
  67852. _updateEffects(): void;
  67853. /**
  67854. * Internal
  67855. * @returns if all the contained post processes are ready.
  67856. * @hidden
  67857. */
  67858. _isReady(): boolean;
  67859. }
  67860. }
  67861. declare module "babylonjs/Shaders/displayPass.fragment" {
  67862. /** @hidden */
  67863. export var displayPassPixelShader: {
  67864. name: string;
  67865. shader: string;
  67866. };
  67867. }
  67868. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67869. import { Nullable } from "babylonjs/types";
  67870. import { Camera } from "babylonjs/Cameras/camera";
  67871. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67872. import { Engine } from "babylonjs/Engines/engine";
  67873. import "babylonjs/Shaders/displayPass.fragment";
  67874. /**
  67875. * DisplayPassPostProcess which produces an output the same as it's input
  67876. */
  67877. export class DisplayPassPostProcess extends PostProcess {
  67878. /**
  67879. * Creates the DisplayPassPostProcess
  67880. * @param name The name of the effect.
  67881. * @param options The required width/height ratio to downsize to before computing the render pass.
  67882. * @param camera The camera to apply the render pass to.
  67883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67884. * @param engine The engine which the post process will be applied. (default: current engine)
  67885. * @param reusable If the post process can be reused on the same frame. (default: false)
  67886. */
  67887. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67888. }
  67889. }
  67890. declare module "babylonjs/Shaders/filter.fragment" {
  67891. /** @hidden */
  67892. export var filterPixelShader: {
  67893. name: string;
  67894. shader: string;
  67895. };
  67896. }
  67897. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67898. import { Nullable } from "babylonjs/types";
  67899. import { Matrix } from "babylonjs/Maths/math.vector";
  67900. import { Camera } from "babylonjs/Cameras/camera";
  67901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67902. import { Engine } from "babylonjs/Engines/engine";
  67903. import "babylonjs/Shaders/filter.fragment";
  67904. /**
  67905. * Applies a kernel filter to the image
  67906. */
  67907. export class FilterPostProcess extends PostProcess {
  67908. /** The matrix to be applied to the image */
  67909. kernelMatrix: Matrix;
  67910. /**
  67911. *
  67912. * @param name The name of the effect.
  67913. * @param kernelMatrix The matrix to be applied to the image
  67914. * @param options The required width/height ratio to downsize to before computing the render pass.
  67915. * @param camera The camera to apply the render pass to.
  67916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67917. * @param engine The engine which the post process will be applied. (default: current engine)
  67918. * @param reusable If the post process can be reused on the same frame. (default: false)
  67919. */
  67920. constructor(name: string,
  67921. /** The matrix to be applied to the image */
  67922. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67923. }
  67924. }
  67925. declare module "babylonjs/Shaders/fxaa.fragment" {
  67926. /** @hidden */
  67927. export var fxaaPixelShader: {
  67928. name: string;
  67929. shader: string;
  67930. };
  67931. }
  67932. declare module "babylonjs/Shaders/fxaa.vertex" {
  67933. /** @hidden */
  67934. export var fxaaVertexShader: {
  67935. name: string;
  67936. shader: string;
  67937. };
  67938. }
  67939. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67940. import { Nullable } from "babylonjs/types";
  67941. import { Camera } from "babylonjs/Cameras/camera";
  67942. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67943. import { Engine } from "babylonjs/Engines/engine";
  67944. import "babylonjs/Shaders/fxaa.fragment";
  67945. import "babylonjs/Shaders/fxaa.vertex";
  67946. /**
  67947. * Fxaa post process
  67948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67949. */
  67950. export class FxaaPostProcess extends PostProcess {
  67951. /** @hidden */
  67952. texelWidth: number;
  67953. /** @hidden */
  67954. texelHeight: number;
  67955. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67956. private _getDefines;
  67957. }
  67958. }
  67959. declare module "babylonjs/Shaders/grain.fragment" {
  67960. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67961. /** @hidden */
  67962. export var grainPixelShader: {
  67963. name: string;
  67964. shader: string;
  67965. };
  67966. }
  67967. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67968. import { Nullable } from "babylonjs/types";
  67969. import { Camera } from "babylonjs/Cameras/camera";
  67970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67971. import { Engine } from "babylonjs/Engines/engine";
  67972. import "babylonjs/Shaders/grain.fragment";
  67973. /**
  67974. * The GrainPostProcess adds noise to the image at mid luminance levels
  67975. */
  67976. export class GrainPostProcess extends PostProcess {
  67977. /**
  67978. * The intensity of the grain added (default: 30)
  67979. */
  67980. intensity: number;
  67981. /**
  67982. * If the grain should be randomized on every frame
  67983. */
  67984. animated: boolean;
  67985. /**
  67986. * Creates a new instance of @see GrainPostProcess
  67987. * @param name The name of the effect.
  67988. * @param options The required width/height ratio to downsize to before computing the render pass.
  67989. * @param camera The camera to apply the render pass to.
  67990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67991. * @param engine The engine which the post process will be applied. (default: current engine)
  67992. * @param reusable If the post process can be reused on the same frame. (default: false)
  67993. * @param textureType Type of textures used when performing the post process. (default: 0)
  67994. * @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)
  67995. */
  67996. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67997. }
  67998. }
  67999. declare module "babylonjs/Shaders/highlights.fragment" {
  68000. /** @hidden */
  68001. export var highlightsPixelShader: {
  68002. name: string;
  68003. shader: string;
  68004. };
  68005. }
  68006. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68007. import { Nullable } from "babylonjs/types";
  68008. import { Camera } from "babylonjs/Cameras/camera";
  68009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68010. import { Engine } from "babylonjs/Engines/engine";
  68011. import "babylonjs/Shaders/highlights.fragment";
  68012. /**
  68013. * Extracts highlights from the image
  68014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68015. */
  68016. export class HighlightsPostProcess extends PostProcess {
  68017. /**
  68018. * Extracts highlights from the image
  68019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68020. * @param name The name of the effect.
  68021. * @param options The required width/height ratio to downsize to before computing the render pass.
  68022. * @param camera The camera to apply the render pass to.
  68023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68024. * @param engine The engine which the post process will be applied. (default: current engine)
  68025. * @param reusable If the post process can be reused on the same frame. (default: false)
  68026. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68027. */
  68028. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68029. }
  68030. }
  68031. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68032. /** @hidden */
  68033. export var mrtFragmentDeclaration: {
  68034. name: string;
  68035. shader: string;
  68036. };
  68037. }
  68038. declare module "babylonjs/Shaders/geometry.fragment" {
  68039. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68040. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68041. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68042. /** @hidden */
  68043. export var geometryPixelShader: {
  68044. name: string;
  68045. shader: string;
  68046. };
  68047. }
  68048. declare module "babylonjs/Shaders/geometry.vertex" {
  68049. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68050. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68051. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68052. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68053. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68054. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68055. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68056. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68057. /** @hidden */
  68058. export var geometryVertexShader: {
  68059. name: string;
  68060. shader: string;
  68061. };
  68062. }
  68063. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68064. import { Matrix } from "babylonjs/Maths/math.vector";
  68065. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68066. import { Mesh } from "babylonjs/Meshes/mesh";
  68067. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68068. import { Effect } from "babylonjs/Materials/effect";
  68069. import { Scene } from "babylonjs/scene";
  68070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68071. import "babylonjs/Shaders/geometry.fragment";
  68072. import "babylonjs/Shaders/geometry.vertex";
  68073. /** @hidden */
  68074. interface ISavedTransformationMatrix {
  68075. world: Matrix;
  68076. viewProjection: Matrix;
  68077. }
  68078. /**
  68079. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68080. */
  68081. export class GeometryBufferRenderer {
  68082. /**
  68083. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68084. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68085. */
  68086. static readonly POSITION_TEXTURE_TYPE: number;
  68087. /**
  68088. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68089. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68090. */
  68091. static readonly VELOCITY_TEXTURE_TYPE: number;
  68092. /**
  68093. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68094. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68095. */
  68096. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68097. /**
  68098. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68099. * in order to compute objects velocities when enableVelocity is set to "true"
  68100. * @hidden
  68101. */
  68102. _previousTransformationMatrices: {
  68103. [index: number]: ISavedTransformationMatrix;
  68104. };
  68105. /**
  68106. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68107. * in order to compute objects velocities when enableVelocity is set to "true"
  68108. * @hidden
  68109. */
  68110. _previousBonesTransformationMatrices: {
  68111. [index: number]: Float32Array;
  68112. };
  68113. /**
  68114. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68115. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68116. */
  68117. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68118. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68119. renderTransparentMeshes: boolean;
  68120. private _scene;
  68121. private _multiRenderTarget;
  68122. private _ratio;
  68123. private _enablePosition;
  68124. private _enableVelocity;
  68125. private _enableReflectivity;
  68126. private _positionIndex;
  68127. private _velocityIndex;
  68128. private _reflectivityIndex;
  68129. protected _effect: Effect;
  68130. protected _cachedDefines: string;
  68131. /**
  68132. * Set the render list (meshes to be rendered) used in the G buffer.
  68133. */
  68134. set renderList(meshes: Mesh[]);
  68135. /**
  68136. * Gets wether or not G buffer are supported by the running hardware.
  68137. * This requires draw buffer supports
  68138. */
  68139. get isSupported(): boolean;
  68140. /**
  68141. * Returns the index of the given texture type in the G-Buffer textures array
  68142. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68143. * @returns the index of the given texture type in the G-Buffer textures array
  68144. */
  68145. getTextureIndex(textureType: number): number;
  68146. /**
  68147. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68148. */
  68149. get enablePosition(): boolean;
  68150. /**
  68151. * Sets whether or not objects positions are enabled for the G buffer.
  68152. */
  68153. set enablePosition(enable: boolean);
  68154. /**
  68155. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68156. */
  68157. get enableVelocity(): boolean;
  68158. /**
  68159. * Sets wether or not objects velocities are enabled for the G buffer.
  68160. */
  68161. set enableVelocity(enable: boolean);
  68162. /**
  68163. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68164. */
  68165. get enableReflectivity(): boolean;
  68166. /**
  68167. * Sets wether or not objects roughness are enabled for the G buffer.
  68168. */
  68169. set enableReflectivity(enable: boolean);
  68170. /**
  68171. * Gets the scene associated with the buffer.
  68172. */
  68173. get scene(): Scene;
  68174. /**
  68175. * Gets the ratio used by the buffer during its creation.
  68176. * How big is the buffer related to the main canvas.
  68177. */
  68178. get ratio(): number;
  68179. /** @hidden */
  68180. static _SceneComponentInitialization: (scene: Scene) => void;
  68181. /**
  68182. * Creates a new G Buffer for the scene
  68183. * @param scene The scene the buffer belongs to
  68184. * @param ratio How big is the buffer related to the main canvas.
  68185. */
  68186. constructor(scene: Scene, ratio?: number);
  68187. /**
  68188. * Checks wether everything is ready to render a submesh to the G buffer.
  68189. * @param subMesh the submesh to check readiness for
  68190. * @param useInstances is the mesh drawn using instance or not
  68191. * @returns true if ready otherwise false
  68192. */
  68193. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68194. /**
  68195. * Gets the current underlying G Buffer.
  68196. * @returns the buffer
  68197. */
  68198. getGBuffer(): MultiRenderTarget;
  68199. /**
  68200. * Gets the number of samples used to render the buffer (anti aliasing).
  68201. */
  68202. get samples(): number;
  68203. /**
  68204. * Sets the number of samples used to render the buffer (anti aliasing).
  68205. */
  68206. set samples(value: number);
  68207. /**
  68208. * Disposes the renderer and frees up associated resources.
  68209. */
  68210. dispose(): void;
  68211. protected _createRenderTargets(): void;
  68212. private _copyBonesTransformationMatrices;
  68213. }
  68214. }
  68215. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68216. import { Nullable } from "babylonjs/types";
  68217. import { Scene } from "babylonjs/scene";
  68218. import { ISceneComponent } from "babylonjs/sceneComponent";
  68219. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68220. module "babylonjs/scene" {
  68221. interface Scene {
  68222. /** @hidden (Backing field) */
  68223. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68224. /**
  68225. * Gets or Sets the current geometry buffer associated to the scene.
  68226. */
  68227. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68228. /**
  68229. * Enables a GeometryBufferRender and associates it with the scene
  68230. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68231. * @returns the GeometryBufferRenderer
  68232. */
  68233. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68234. /**
  68235. * Disables the GeometryBufferRender associated with the scene
  68236. */
  68237. disableGeometryBufferRenderer(): void;
  68238. }
  68239. }
  68240. /**
  68241. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68242. * in several rendering techniques.
  68243. */
  68244. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68245. /**
  68246. * The component name helpful to identify the component in the list of scene components.
  68247. */
  68248. readonly name: string;
  68249. /**
  68250. * The scene the component belongs to.
  68251. */
  68252. scene: Scene;
  68253. /**
  68254. * Creates a new instance of the component for the given scene
  68255. * @param scene Defines the scene to register the component in
  68256. */
  68257. constructor(scene: Scene);
  68258. /**
  68259. * Registers the component in a given scene
  68260. */
  68261. register(): void;
  68262. /**
  68263. * Rebuilds the elements related to this component in case of
  68264. * context lost for instance.
  68265. */
  68266. rebuild(): void;
  68267. /**
  68268. * Disposes the component and the associated ressources
  68269. */
  68270. dispose(): void;
  68271. private _gatherRenderTargets;
  68272. }
  68273. }
  68274. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68275. /** @hidden */
  68276. export var motionBlurPixelShader: {
  68277. name: string;
  68278. shader: string;
  68279. };
  68280. }
  68281. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68282. import { Nullable } from "babylonjs/types";
  68283. import { Camera } from "babylonjs/Cameras/camera";
  68284. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68285. import { Scene } from "babylonjs/scene";
  68286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68287. import "babylonjs/Animations/animatable";
  68288. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68289. import "babylonjs/Shaders/motionBlur.fragment";
  68290. import { Engine } from "babylonjs/Engines/engine";
  68291. /**
  68292. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68293. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68294. * As an example, all you have to do is to create the post-process:
  68295. * var mb = new BABYLON.MotionBlurPostProcess(
  68296. * 'mb', // The name of the effect.
  68297. * scene, // The scene containing the objects to blur according to their velocity.
  68298. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68299. * camera // The camera to apply the render pass to.
  68300. * );
  68301. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68302. */
  68303. export class MotionBlurPostProcess extends PostProcess {
  68304. /**
  68305. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68306. */
  68307. motionStrength: number;
  68308. /**
  68309. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68310. */
  68311. get motionBlurSamples(): number;
  68312. /**
  68313. * Sets the number of iterations to be used for motion blur quality
  68314. */
  68315. set motionBlurSamples(samples: number);
  68316. private _motionBlurSamples;
  68317. private _geometryBufferRenderer;
  68318. /**
  68319. * Creates a new instance MotionBlurPostProcess
  68320. * @param name The name of the effect.
  68321. * @param scene The scene containing the objects to blur according to their velocity.
  68322. * @param options The required width/height ratio to downsize to before computing the render pass.
  68323. * @param camera The camera to apply the render pass to.
  68324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68325. * @param engine The engine which the post process will be applied. (default: current engine)
  68326. * @param reusable If the post process can be reused on the same frame. (default: false)
  68327. * @param textureType Type of textures used when performing the post process. (default: 0)
  68328. * @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)
  68329. */
  68330. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68331. /**
  68332. * Excludes the given skinned mesh from computing bones velocities.
  68333. * 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.
  68334. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68335. */
  68336. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68337. /**
  68338. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68339. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68340. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68341. */
  68342. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68343. /**
  68344. * Disposes the post process.
  68345. * @param camera The camera to dispose the post process on.
  68346. */
  68347. dispose(camera?: Camera): void;
  68348. }
  68349. }
  68350. declare module "babylonjs/Shaders/refraction.fragment" {
  68351. /** @hidden */
  68352. export var refractionPixelShader: {
  68353. name: string;
  68354. shader: string;
  68355. };
  68356. }
  68357. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68358. import { Color3 } from "babylonjs/Maths/math.color";
  68359. import { Camera } from "babylonjs/Cameras/camera";
  68360. import { Texture } from "babylonjs/Materials/Textures/texture";
  68361. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68362. import { Engine } from "babylonjs/Engines/engine";
  68363. import "babylonjs/Shaders/refraction.fragment";
  68364. /**
  68365. * Post process which applies a refractin texture
  68366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68367. */
  68368. export class RefractionPostProcess extends PostProcess {
  68369. /** the base color of the refraction (used to taint the rendering) */
  68370. color: Color3;
  68371. /** simulated refraction depth */
  68372. depth: number;
  68373. /** the coefficient of the base color (0 to remove base color tainting) */
  68374. colorLevel: number;
  68375. private _refTexture;
  68376. private _ownRefractionTexture;
  68377. /**
  68378. * Gets or sets the refraction texture
  68379. * Please note that you are responsible for disposing the texture if you set it manually
  68380. */
  68381. get refractionTexture(): Texture;
  68382. set refractionTexture(value: Texture);
  68383. /**
  68384. * Initializes the RefractionPostProcess
  68385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68386. * @param name The name of the effect.
  68387. * @param refractionTextureUrl Url of the refraction texture to use
  68388. * @param color the base color of the refraction (used to taint the rendering)
  68389. * @param depth simulated refraction depth
  68390. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68391. * @param camera The camera to apply the render pass to.
  68392. * @param options The required width/height ratio to downsize to before computing the render pass.
  68393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68394. * @param engine The engine which the post process will be applied. (default: current engine)
  68395. * @param reusable If the post process can be reused on the same frame. (default: false)
  68396. */
  68397. constructor(name: string, refractionTextureUrl: string,
  68398. /** the base color of the refraction (used to taint the rendering) */
  68399. color: Color3,
  68400. /** simulated refraction depth */
  68401. depth: number,
  68402. /** the coefficient of the base color (0 to remove base color tainting) */
  68403. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68404. /**
  68405. * Disposes of the post process
  68406. * @param camera Camera to dispose post process on
  68407. */
  68408. dispose(camera: Camera): void;
  68409. }
  68410. }
  68411. declare module "babylonjs/Shaders/sharpen.fragment" {
  68412. /** @hidden */
  68413. export var sharpenPixelShader: {
  68414. name: string;
  68415. shader: string;
  68416. };
  68417. }
  68418. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68419. import { Nullable } from "babylonjs/types";
  68420. import { Camera } from "babylonjs/Cameras/camera";
  68421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68422. import "babylonjs/Shaders/sharpen.fragment";
  68423. import { Engine } from "babylonjs/Engines/engine";
  68424. /**
  68425. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68426. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68427. */
  68428. export class SharpenPostProcess extends PostProcess {
  68429. /**
  68430. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68431. */
  68432. colorAmount: number;
  68433. /**
  68434. * How much sharpness should be applied (default: 0.3)
  68435. */
  68436. edgeAmount: number;
  68437. /**
  68438. * Creates a new instance ConvolutionPostProcess
  68439. * @param name The name of the effect.
  68440. * @param options The required width/height ratio to downsize to before computing the render pass.
  68441. * @param camera The camera to apply the render pass to.
  68442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68443. * @param engine The engine which the post process will be applied. (default: current engine)
  68444. * @param reusable If the post process can be reused on the same frame. (default: false)
  68445. * @param textureType Type of textures used when performing the post process. (default: 0)
  68446. * @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)
  68447. */
  68448. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68449. }
  68450. }
  68451. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68452. import { Nullable } from "babylonjs/types";
  68453. import { Camera } from "babylonjs/Cameras/camera";
  68454. import { Engine } from "babylonjs/Engines/engine";
  68455. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68456. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68457. /**
  68458. * PostProcessRenderPipeline
  68459. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68460. */
  68461. export class PostProcessRenderPipeline {
  68462. private engine;
  68463. private _renderEffects;
  68464. private _renderEffectsForIsolatedPass;
  68465. /**
  68466. * List of inspectable custom properties (used by the Inspector)
  68467. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68468. */
  68469. inspectableCustomProperties: IInspectable[];
  68470. /**
  68471. * @hidden
  68472. */
  68473. protected _cameras: Camera[];
  68474. /** @hidden */
  68475. _name: string;
  68476. /**
  68477. * Gets pipeline name
  68478. */
  68479. get name(): string;
  68480. /** Gets the list of attached cameras */
  68481. get cameras(): Camera[];
  68482. /**
  68483. * Initializes a PostProcessRenderPipeline
  68484. * @param engine engine to add the pipeline to
  68485. * @param name name of the pipeline
  68486. */
  68487. constructor(engine: Engine, name: string);
  68488. /**
  68489. * Gets the class name
  68490. * @returns "PostProcessRenderPipeline"
  68491. */
  68492. getClassName(): string;
  68493. /**
  68494. * If all the render effects in the pipeline are supported
  68495. */
  68496. get isSupported(): boolean;
  68497. /**
  68498. * Adds an effect to the pipeline
  68499. * @param renderEffect the effect to add
  68500. */
  68501. addEffect(renderEffect: PostProcessRenderEffect): void;
  68502. /** @hidden */
  68503. _rebuild(): void;
  68504. /** @hidden */
  68505. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68506. /** @hidden */
  68507. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68508. /** @hidden */
  68509. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68510. /** @hidden */
  68511. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68512. /** @hidden */
  68513. _attachCameras(cameras: Camera, unique: boolean): void;
  68514. /** @hidden */
  68515. _attachCameras(cameras: Camera[], unique: boolean): void;
  68516. /** @hidden */
  68517. _detachCameras(cameras: Camera): void;
  68518. /** @hidden */
  68519. _detachCameras(cameras: Nullable<Camera[]>): void;
  68520. /** @hidden */
  68521. _update(): void;
  68522. /** @hidden */
  68523. _reset(): void;
  68524. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68525. /**
  68526. * Disposes of the pipeline
  68527. */
  68528. dispose(): void;
  68529. }
  68530. }
  68531. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68532. import { Camera } from "babylonjs/Cameras/camera";
  68533. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68534. /**
  68535. * PostProcessRenderPipelineManager class
  68536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68537. */
  68538. export class PostProcessRenderPipelineManager {
  68539. private _renderPipelines;
  68540. /**
  68541. * Initializes a PostProcessRenderPipelineManager
  68542. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68543. */
  68544. constructor();
  68545. /**
  68546. * Gets the list of supported render pipelines
  68547. */
  68548. get supportedPipelines(): PostProcessRenderPipeline[];
  68549. /**
  68550. * Adds a pipeline to the manager
  68551. * @param renderPipeline The pipeline to add
  68552. */
  68553. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68554. /**
  68555. * Attaches a camera to the pipeline
  68556. * @param renderPipelineName The name of the pipeline to attach to
  68557. * @param cameras the camera to attach
  68558. * @param unique if the camera can be attached multiple times to the pipeline
  68559. */
  68560. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68561. /**
  68562. * Detaches a camera from the pipeline
  68563. * @param renderPipelineName The name of the pipeline to detach from
  68564. * @param cameras the camera to detach
  68565. */
  68566. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68567. /**
  68568. * Enables an effect by name on a pipeline
  68569. * @param renderPipelineName the name of the pipeline to enable the effect in
  68570. * @param renderEffectName the name of the effect to enable
  68571. * @param cameras the cameras that the effect should be enabled on
  68572. */
  68573. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68574. /**
  68575. * Disables an effect by name on a pipeline
  68576. * @param renderPipelineName the name of the pipeline to disable the effect in
  68577. * @param renderEffectName the name of the effect to disable
  68578. * @param cameras the cameras that the effect should be disabled on
  68579. */
  68580. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68581. /**
  68582. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68583. */
  68584. update(): void;
  68585. /** @hidden */
  68586. _rebuild(): void;
  68587. /**
  68588. * Disposes of the manager and pipelines
  68589. */
  68590. dispose(): void;
  68591. }
  68592. }
  68593. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68594. import { ISceneComponent } from "babylonjs/sceneComponent";
  68595. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68596. import { Scene } from "babylonjs/scene";
  68597. module "babylonjs/scene" {
  68598. interface Scene {
  68599. /** @hidden (Backing field) */
  68600. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68601. /**
  68602. * Gets the postprocess render pipeline manager
  68603. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68604. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68605. */
  68606. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68607. }
  68608. }
  68609. /**
  68610. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68611. */
  68612. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68613. /**
  68614. * The component name helpfull to identify the component in the list of scene components.
  68615. */
  68616. readonly name: string;
  68617. /**
  68618. * The scene the component belongs to.
  68619. */
  68620. scene: Scene;
  68621. /**
  68622. * Creates a new instance of the component for the given scene
  68623. * @param scene Defines the scene to register the component in
  68624. */
  68625. constructor(scene: Scene);
  68626. /**
  68627. * Registers the component in a given scene
  68628. */
  68629. register(): void;
  68630. /**
  68631. * Rebuilds the elements related to this component in case of
  68632. * context lost for instance.
  68633. */
  68634. rebuild(): void;
  68635. /**
  68636. * Disposes the component and the associated ressources
  68637. */
  68638. dispose(): void;
  68639. private _gatherRenderTargets;
  68640. }
  68641. }
  68642. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68643. import { Nullable } from "babylonjs/types";
  68644. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68645. import { Camera } from "babylonjs/Cameras/camera";
  68646. import { IDisposable } from "babylonjs/scene";
  68647. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68648. import { Scene } from "babylonjs/scene";
  68649. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68650. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68651. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68652. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68653. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68654. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68655. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68656. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68657. import { Animation } from "babylonjs/Animations/animation";
  68658. /**
  68659. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68660. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68661. */
  68662. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68663. private _scene;
  68664. private _camerasToBeAttached;
  68665. /**
  68666. * ID of the sharpen post process,
  68667. */
  68668. private readonly SharpenPostProcessId;
  68669. /**
  68670. * @ignore
  68671. * ID of the image processing post process;
  68672. */
  68673. readonly ImageProcessingPostProcessId: string;
  68674. /**
  68675. * @ignore
  68676. * ID of the Fast Approximate Anti-Aliasing post process;
  68677. */
  68678. readonly FxaaPostProcessId: string;
  68679. /**
  68680. * ID of the chromatic aberration post process,
  68681. */
  68682. private readonly ChromaticAberrationPostProcessId;
  68683. /**
  68684. * ID of the grain post process
  68685. */
  68686. private readonly GrainPostProcessId;
  68687. /**
  68688. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68689. */
  68690. sharpen: SharpenPostProcess;
  68691. private _sharpenEffect;
  68692. private bloom;
  68693. /**
  68694. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68695. */
  68696. depthOfField: DepthOfFieldEffect;
  68697. /**
  68698. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68699. */
  68700. fxaa: FxaaPostProcess;
  68701. /**
  68702. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68703. */
  68704. imageProcessing: ImageProcessingPostProcess;
  68705. /**
  68706. * Chromatic aberration post process which will shift rgb colors in the image
  68707. */
  68708. chromaticAberration: ChromaticAberrationPostProcess;
  68709. private _chromaticAberrationEffect;
  68710. /**
  68711. * Grain post process which add noise to the image
  68712. */
  68713. grain: GrainPostProcess;
  68714. private _grainEffect;
  68715. /**
  68716. * Glow post process which adds a glow to emissive areas of the image
  68717. */
  68718. private _glowLayer;
  68719. /**
  68720. * Animations which can be used to tweak settings over a period of time
  68721. */
  68722. animations: Animation[];
  68723. private _imageProcessingConfigurationObserver;
  68724. private _sharpenEnabled;
  68725. private _bloomEnabled;
  68726. private _depthOfFieldEnabled;
  68727. private _depthOfFieldBlurLevel;
  68728. private _fxaaEnabled;
  68729. private _imageProcessingEnabled;
  68730. private _defaultPipelineTextureType;
  68731. private _bloomScale;
  68732. private _chromaticAberrationEnabled;
  68733. private _grainEnabled;
  68734. private _buildAllowed;
  68735. /**
  68736. * Gets active scene
  68737. */
  68738. get scene(): Scene;
  68739. /**
  68740. * Enable or disable the sharpen process from the pipeline
  68741. */
  68742. set sharpenEnabled(enabled: boolean);
  68743. get sharpenEnabled(): boolean;
  68744. private _resizeObserver;
  68745. private _hardwareScaleLevel;
  68746. private _bloomKernel;
  68747. /**
  68748. * Specifies the size of the bloom blur kernel, relative to the final output size
  68749. */
  68750. get bloomKernel(): number;
  68751. set bloomKernel(value: number);
  68752. /**
  68753. * Specifies the weight of the bloom in the final rendering
  68754. */
  68755. private _bloomWeight;
  68756. /**
  68757. * Specifies the luma threshold for the area that will be blurred by the bloom
  68758. */
  68759. private _bloomThreshold;
  68760. private _hdr;
  68761. /**
  68762. * The strength of the bloom.
  68763. */
  68764. set bloomWeight(value: number);
  68765. get bloomWeight(): number;
  68766. /**
  68767. * The strength of the bloom.
  68768. */
  68769. set bloomThreshold(value: number);
  68770. get bloomThreshold(): number;
  68771. /**
  68772. * The scale of the bloom, lower value will provide better performance.
  68773. */
  68774. set bloomScale(value: number);
  68775. get bloomScale(): number;
  68776. /**
  68777. * Enable or disable the bloom from the pipeline
  68778. */
  68779. set bloomEnabled(enabled: boolean);
  68780. get bloomEnabled(): boolean;
  68781. private _rebuildBloom;
  68782. /**
  68783. * If the depth of field is enabled.
  68784. */
  68785. get depthOfFieldEnabled(): boolean;
  68786. set depthOfFieldEnabled(enabled: boolean);
  68787. /**
  68788. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68789. */
  68790. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68791. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68792. /**
  68793. * If the anti aliasing is enabled.
  68794. */
  68795. set fxaaEnabled(enabled: boolean);
  68796. get fxaaEnabled(): boolean;
  68797. private _samples;
  68798. /**
  68799. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68800. */
  68801. set samples(sampleCount: number);
  68802. get samples(): number;
  68803. /**
  68804. * If image processing is enabled.
  68805. */
  68806. set imageProcessingEnabled(enabled: boolean);
  68807. get imageProcessingEnabled(): boolean;
  68808. /**
  68809. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68810. */
  68811. set glowLayerEnabled(enabled: boolean);
  68812. get glowLayerEnabled(): boolean;
  68813. /**
  68814. * Gets the glow layer (or null if not defined)
  68815. */
  68816. get glowLayer(): Nullable<GlowLayer>;
  68817. /**
  68818. * Enable or disable the chromaticAberration process from the pipeline
  68819. */
  68820. set chromaticAberrationEnabled(enabled: boolean);
  68821. get chromaticAberrationEnabled(): boolean;
  68822. /**
  68823. * Enable or disable the grain process from the pipeline
  68824. */
  68825. set grainEnabled(enabled: boolean);
  68826. get grainEnabled(): boolean;
  68827. /**
  68828. * @constructor
  68829. * @param name - The rendering pipeline name (default: "")
  68830. * @param hdr - If high dynamic range textures should be used (default: true)
  68831. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68832. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68833. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68834. */
  68835. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68836. /**
  68837. * Get the class name
  68838. * @returns "DefaultRenderingPipeline"
  68839. */
  68840. getClassName(): string;
  68841. /**
  68842. * Force the compilation of the entire pipeline.
  68843. */
  68844. prepare(): void;
  68845. private _hasCleared;
  68846. private _prevPostProcess;
  68847. private _prevPrevPostProcess;
  68848. private _setAutoClearAndTextureSharing;
  68849. private _depthOfFieldSceneObserver;
  68850. private _buildPipeline;
  68851. private _disposePostProcesses;
  68852. /**
  68853. * Adds a camera to the pipeline
  68854. * @param camera the camera to be added
  68855. */
  68856. addCamera(camera: Camera): void;
  68857. /**
  68858. * Removes a camera from the pipeline
  68859. * @param camera the camera to remove
  68860. */
  68861. removeCamera(camera: Camera): void;
  68862. /**
  68863. * Dispose of the pipeline and stop all post processes
  68864. */
  68865. dispose(): void;
  68866. /**
  68867. * Serialize the rendering pipeline (Used when exporting)
  68868. * @returns the serialized object
  68869. */
  68870. serialize(): any;
  68871. /**
  68872. * Parse the serialized pipeline
  68873. * @param source Source pipeline.
  68874. * @param scene The scene to load the pipeline to.
  68875. * @param rootUrl The URL of the serialized pipeline.
  68876. * @returns An instantiated pipeline from the serialized object.
  68877. */
  68878. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68879. }
  68880. }
  68881. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68882. /** @hidden */
  68883. export var lensHighlightsPixelShader: {
  68884. name: string;
  68885. shader: string;
  68886. };
  68887. }
  68888. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68889. /** @hidden */
  68890. export var depthOfFieldPixelShader: {
  68891. name: string;
  68892. shader: string;
  68893. };
  68894. }
  68895. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68896. import { Camera } from "babylonjs/Cameras/camera";
  68897. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68898. import { Scene } from "babylonjs/scene";
  68899. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68900. import "babylonjs/Shaders/chromaticAberration.fragment";
  68901. import "babylonjs/Shaders/lensHighlights.fragment";
  68902. import "babylonjs/Shaders/depthOfField.fragment";
  68903. /**
  68904. * BABYLON.JS Chromatic Aberration GLSL Shader
  68905. * Author: Olivier Guyot
  68906. * Separates very slightly R, G and B colors on the edges of the screen
  68907. * Inspired by Francois Tarlier & Martins Upitis
  68908. */
  68909. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68910. /**
  68911. * @ignore
  68912. * The chromatic aberration PostProcess id in the pipeline
  68913. */
  68914. LensChromaticAberrationEffect: string;
  68915. /**
  68916. * @ignore
  68917. * The highlights enhancing PostProcess id in the pipeline
  68918. */
  68919. HighlightsEnhancingEffect: string;
  68920. /**
  68921. * @ignore
  68922. * The depth-of-field PostProcess id in the pipeline
  68923. */
  68924. LensDepthOfFieldEffect: string;
  68925. private _scene;
  68926. private _depthTexture;
  68927. private _grainTexture;
  68928. private _chromaticAberrationPostProcess;
  68929. private _highlightsPostProcess;
  68930. private _depthOfFieldPostProcess;
  68931. private _edgeBlur;
  68932. private _grainAmount;
  68933. private _chromaticAberration;
  68934. private _distortion;
  68935. private _highlightsGain;
  68936. private _highlightsThreshold;
  68937. private _dofDistance;
  68938. private _dofAperture;
  68939. private _dofDarken;
  68940. private _dofPentagon;
  68941. private _blurNoise;
  68942. /**
  68943. * @constructor
  68944. *
  68945. * Effect parameters are as follow:
  68946. * {
  68947. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68948. * edge_blur: number; // from 0 to x (1 for realism)
  68949. * distortion: number; // from 0 to x (1 for realism)
  68950. * grain_amount: number; // from 0 to 1
  68951. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68952. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68953. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68954. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68955. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68956. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68957. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68958. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68959. * }
  68960. * Note: if an effect parameter is unset, effect is disabled
  68961. *
  68962. * @param name The rendering pipeline name
  68963. * @param parameters - An object containing all parameters (see above)
  68964. * @param scene The scene linked to this pipeline
  68965. * @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)
  68966. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68967. */
  68968. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68969. /**
  68970. * Get the class name
  68971. * @returns "LensRenderingPipeline"
  68972. */
  68973. getClassName(): string;
  68974. /**
  68975. * Gets associated scene
  68976. */
  68977. get scene(): Scene;
  68978. /**
  68979. * Gets or sets the edge blur
  68980. */
  68981. get edgeBlur(): number;
  68982. set edgeBlur(value: number);
  68983. /**
  68984. * Gets or sets the grain amount
  68985. */
  68986. get grainAmount(): number;
  68987. set grainAmount(value: number);
  68988. /**
  68989. * Gets or sets the chromatic aberration amount
  68990. */
  68991. get chromaticAberration(): number;
  68992. set chromaticAberration(value: number);
  68993. /**
  68994. * Gets or sets the depth of field aperture
  68995. */
  68996. get dofAperture(): number;
  68997. set dofAperture(value: number);
  68998. /**
  68999. * Gets or sets the edge distortion
  69000. */
  69001. get edgeDistortion(): number;
  69002. set edgeDistortion(value: number);
  69003. /**
  69004. * Gets or sets the depth of field distortion
  69005. */
  69006. get dofDistortion(): number;
  69007. set dofDistortion(value: number);
  69008. /**
  69009. * Gets or sets the darken out of focus amount
  69010. */
  69011. get darkenOutOfFocus(): number;
  69012. set darkenOutOfFocus(value: number);
  69013. /**
  69014. * Gets or sets a boolean indicating if blur noise is enabled
  69015. */
  69016. get blurNoise(): boolean;
  69017. set blurNoise(value: boolean);
  69018. /**
  69019. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69020. */
  69021. get pentagonBokeh(): boolean;
  69022. set pentagonBokeh(value: boolean);
  69023. /**
  69024. * Gets or sets the highlight grain amount
  69025. */
  69026. get highlightsGain(): number;
  69027. set highlightsGain(value: number);
  69028. /**
  69029. * Gets or sets the highlight threshold
  69030. */
  69031. get highlightsThreshold(): number;
  69032. set highlightsThreshold(value: number);
  69033. /**
  69034. * Sets the amount of blur at the edges
  69035. * @param amount blur amount
  69036. */
  69037. setEdgeBlur(amount: number): void;
  69038. /**
  69039. * Sets edge blur to 0
  69040. */
  69041. disableEdgeBlur(): void;
  69042. /**
  69043. * Sets the amout of grain
  69044. * @param amount Amount of grain
  69045. */
  69046. setGrainAmount(amount: number): void;
  69047. /**
  69048. * Set grain amount to 0
  69049. */
  69050. disableGrain(): void;
  69051. /**
  69052. * Sets the chromatic aberration amount
  69053. * @param amount amount of chromatic aberration
  69054. */
  69055. setChromaticAberration(amount: number): void;
  69056. /**
  69057. * Sets chromatic aberration amount to 0
  69058. */
  69059. disableChromaticAberration(): void;
  69060. /**
  69061. * Sets the EdgeDistortion amount
  69062. * @param amount amount of EdgeDistortion
  69063. */
  69064. setEdgeDistortion(amount: number): void;
  69065. /**
  69066. * Sets edge distortion to 0
  69067. */
  69068. disableEdgeDistortion(): void;
  69069. /**
  69070. * Sets the FocusDistance amount
  69071. * @param amount amount of FocusDistance
  69072. */
  69073. setFocusDistance(amount: number): void;
  69074. /**
  69075. * Disables depth of field
  69076. */
  69077. disableDepthOfField(): void;
  69078. /**
  69079. * Sets the Aperture amount
  69080. * @param amount amount of Aperture
  69081. */
  69082. setAperture(amount: number): void;
  69083. /**
  69084. * Sets the DarkenOutOfFocus amount
  69085. * @param amount amount of DarkenOutOfFocus
  69086. */
  69087. setDarkenOutOfFocus(amount: number): void;
  69088. private _pentagonBokehIsEnabled;
  69089. /**
  69090. * Creates a pentagon bokeh effect
  69091. */
  69092. enablePentagonBokeh(): void;
  69093. /**
  69094. * Disables the pentagon bokeh effect
  69095. */
  69096. disablePentagonBokeh(): void;
  69097. /**
  69098. * Enables noise blur
  69099. */
  69100. enableNoiseBlur(): void;
  69101. /**
  69102. * Disables noise blur
  69103. */
  69104. disableNoiseBlur(): void;
  69105. /**
  69106. * Sets the HighlightsGain amount
  69107. * @param amount amount of HighlightsGain
  69108. */
  69109. setHighlightsGain(amount: number): void;
  69110. /**
  69111. * Sets the HighlightsThreshold amount
  69112. * @param amount amount of HighlightsThreshold
  69113. */
  69114. setHighlightsThreshold(amount: number): void;
  69115. /**
  69116. * Disables highlights
  69117. */
  69118. disableHighlights(): void;
  69119. /**
  69120. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69121. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69122. */
  69123. dispose(disableDepthRender?: boolean): void;
  69124. private _createChromaticAberrationPostProcess;
  69125. private _createHighlightsPostProcess;
  69126. private _createDepthOfFieldPostProcess;
  69127. private _createGrainTexture;
  69128. }
  69129. }
  69130. declare module "babylonjs/Shaders/ssao2.fragment" {
  69131. /** @hidden */
  69132. export var ssao2PixelShader: {
  69133. name: string;
  69134. shader: string;
  69135. };
  69136. }
  69137. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69138. /** @hidden */
  69139. export var ssaoCombinePixelShader: {
  69140. name: string;
  69141. shader: string;
  69142. };
  69143. }
  69144. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69145. import { Camera } from "babylonjs/Cameras/camera";
  69146. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69147. import { Scene } from "babylonjs/scene";
  69148. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69149. import "babylonjs/Shaders/ssao2.fragment";
  69150. import "babylonjs/Shaders/ssaoCombine.fragment";
  69151. /**
  69152. * Render pipeline to produce ssao effect
  69153. */
  69154. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69155. /**
  69156. * @ignore
  69157. * The PassPostProcess id in the pipeline that contains the original scene color
  69158. */
  69159. SSAOOriginalSceneColorEffect: string;
  69160. /**
  69161. * @ignore
  69162. * The SSAO PostProcess id in the pipeline
  69163. */
  69164. SSAORenderEffect: string;
  69165. /**
  69166. * @ignore
  69167. * The horizontal blur PostProcess id in the pipeline
  69168. */
  69169. SSAOBlurHRenderEffect: string;
  69170. /**
  69171. * @ignore
  69172. * The vertical blur PostProcess id in the pipeline
  69173. */
  69174. SSAOBlurVRenderEffect: string;
  69175. /**
  69176. * @ignore
  69177. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69178. */
  69179. SSAOCombineRenderEffect: string;
  69180. /**
  69181. * The output strength of the SSAO post-process. Default value is 1.0.
  69182. */
  69183. totalStrength: number;
  69184. /**
  69185. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69186. */
  69187. maxZ: number;
  69188. /**
  69189. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69190. */
  69191. minZAspect: number;
  69192. private _samples;
  69193. /**
  69194. * Number of samples used for the SSAO calculations. Default value is 8
  69195. */
  69196. set samples(n: number);
  69197. get samples(): number;
  69198. private _textureSamples;
  69199. /**
  69200. * Number of samples to use for antialiasing
  69201. */
  69202. set textureSamples(n: number);
  69203. get textureSamples(): number;
  69204. /**
  69205. * Ratio object used for SSAO ratio and blur ratio
  69206. */
  69207. private _ratio;
  69208. /**
  69209. * Dynamically generated sphere sampler.
  69210. */
  69211. private _sampleSphere;
  69212. /**
  69213. * Blur filter offsets
  69214. */
  69215. private _samplerOffsets;
  69216. private _expensiveBlur;
  69217. /**
  69218. * If bilateral blur should be used
  69219. */
  69220. set expensiveBlur(b: boolean);
  69221. get expensiveBlur(): boolean;
  69222. /**
  69223. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69224. */
  69225. radius: number;
  69226. /**
  69227. * The base color of the SSAO post-process
  69228. * The final result is "base + ssao" between [0, 1]
  69229. */
  69230. base: number;
  69231. /**
  69232. * Support test.
  69233. */
  69234. static get IsSupported(): boolean;
  69235. private _scene;
  69236. private _depthTexture;
  69237. private _normalTexture;
  69238. private _randomTexture;
  69239. private _originalColorPostProcess;
  69240. private _ssaoPostProcess;
  69241. private _blurHPostProcess;
  69242. private _blurVPostProcess;
  69243. private _ssaoCombinePostProcess;
  69244. /**
  69245. * Gets active scene
  69246. */
  69247. get scene(): Scene;
  69248. /**
  69249. * @constructor
  69250. * @param name The rendering pipeline name
  69251. * @param scene The scene linked to this pipeline
  69252. * @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 }
  69253. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69254. */
  69255. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69256. /**
  69257. * Get the class name
  69258. * @returns "SSAO2RenderingPipeline"
  69259. */
  69260. getClassName(): string;
  69261. /**
  69262. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69263. */
  69264. dispose(disableGeometryBufferRenderer?: boolean): void;
  69265. private _createBlurPostProcess;
  69266. /** @hidden */
  69267. _rebuild(): void;
  69268. private _bits;
  69269. private _radicalInverse_VdC;
  69270. private _hammersley;
  69271. private _hemisphereSample_uniform;
  69272. private _generateHemisphere;
  69273. private _createSSAOPostProcess;
  69274. private _createSSAOCombinePostProcess;
  69275. private _createRandomTexture;
  69276. /**
  69277. * Serialize the rendering pipeline (Used when exporting)
  69278. * @returns the serialized object
  69279. */
  69280. serialize(): any;
  69281. /**
  69282. * Parse the serialized pipeline
  69283. * @param source Source pipeline.
  69284. * @param scene The scene to load the pipeline to.
  69285. * @param rootUrl The URL of the serialized pipeline.
  69286. * @returns An instantiated pipeline from the serialized object.
  69287. */
  69288. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69289. }
  69290. }
  69291. declare module "babylonjs/Shaders/ssao.fragment" {
  69292. /** @hidden */
  69293. export var ssaoPixelShader: {
  69294. name: string;
  69295. shader: string;
  69296. };
  69297. }
  69298. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69299. import { Camera } from "babylonjs/Cameras/camera";
  69300. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69301. import { Scene } from "babylonjs/scene";
  69302. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69303. import "babylonjs/Shaders/ssao.fragment";
  69304. import "babylonjs/Shaders/ssaoCombine.fragment";
  69305. /**
  69306. * Render pipeline to produce ssao effect
  69307. */
  69308. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69309. /**
  69310. * @ignore
  69311. * The PassPostProcess id in the pipeline that contains the original scene color
  69312. */
  69313. SSAOOriginalSceneColorEffect: string;
  69314. /**
  69315. * @ignore
  69316. * The SSAO PostProcess id in the pipeline
  69317. */
  69318. SSAORenderEffect: string;
  69319. /**
  69320. * @ignore
  69321. * The horizontal blur PostProcess id in the pipeline
  69322. */
  69323. SSAOBlurHRenderEffect: string;
  69324. /**
  69325. * @ignore
  69326. * The vertical blur PostProcess id in the pipeline
  69327. */
  69328. SSAOBlurVRenderEffect: string;
  69329. /**
  69330. * @ignore
  69331. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69332. */
  69333. SSAOCombineRenderEffect: string;
  69334. /**
  69335. * The output strength of the SSAO post-process. Default value is 1.0.
  69336. */
  69337. totalStrength: number;
  69338. /**
  69339. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69340. */
  69341. radius: number;
  69342. /**
  69343. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69344. * Must not be equal to fallOff and superior to fallOff.
  69345. * Default value is 0.0075
  69346. */
  69347. area: number;
  69348. /**
  69349. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69350. * Must not be equal to area and inferior to area.
  69351. * Default value is 0.000001
  69352. */
  69353. fallOff: number;
  69354. /**
  69355. * The base color of the SSAO post-process
  69356. * The final result is "base + ssao" between [0, 1]
  69357. */
  69358. base: number;
  69359. private _scene;
  69360. private _depthTexture;
  69361. private _randomTexture;
  69362. private _originalColorPostProcess;
  69363. private _ssaoPostProcess;
  69364. private _blurHPostProcess;
  69365. private _blurVPostProcess;
  69366. private _ssaoCombinePostProcess;
  69367. private _firstUpdate;
  69368. /**
  69369. * Gets active scene
  69370. */
  69371. get scene(): Scene;
  69372. /**
  69373. * @constructor
  69374. * @param name - The rendering pipeline name
  69375. * @param scene - The scene linked to this pipeline
  69376. * @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 }
  69377. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69378. */
  69379. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69380. /**
  69381. * Get the class name
  69382. * @returns "SSAORenderingPipeline"
  69383. */
  69384. getClassName(): string;
  69385. /**
  69386. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69387. */
  69388. dispose(disableDepthRender?: boolean): void;
  69389. private _createBlurPostProcess;
  69390. /** @hidden */
  69391. _rebuild(): void;
  69392. private _createSSAOPostProcess;
  69393. private _createSSAOCombinePostProcess;
  69394. private _createRandomTexture;
  69395. }
  69396. }
  69397. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69398. /** @hidden */
  69399. export var screenSpaceReflectionPixelShader: {
  69400. name: string;
  69401. shader: string;
  69402. };
  69403. }
  69404. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69405. import { Nullable } from "babylonjs/types";
  69406. import { Camera } from "babylonjs/Cameras/camera";
  69407. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69408. import { Scene } from "babylonjs/scene";
  69409. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69410. import { Engine } from "babylonjs/Engines/engine";
  69411. /**
  69412. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69413. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69414. */
  69415. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69416. /**
  69417. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69418. */
  69419. threshold: number;
  69420. /**
  69421. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69422. */
  69423. strength: number;
  69424. /**
  69425. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69426. */
  69427. reflectionSpecularFalloffExponent: number;
  69428. /**
  69429. * 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]
  69430. */
  69431. step: number;
  69432. /**
  69433. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69434. */
  69435. roughnessFactor: number;
  69436. private _geometryBufferRenderer;
  69437. private _enableSmoothReflections;
  69438. private _reflectionSamples;
  69439. private _smoothSteps;
  69440. /**
  69441. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69442. * @param name The name of the effect.
  69443. * @param scene The scene containing the objects to calculate reflections.
  69444. * @param options The required width/height ratio to downsize to before computing the render pass.
  69445. * @param camera The camera to apply the render pass to.
  69446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69447. * @param engine The engine which the post process will be applied. (default: current engine)
  69448. * @param reusable If the post process can be reused on the same frame. (default: false)
  69449. * @param textureType Type of textures used when performing the post process. (default: 0)
  69450. * @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)
  69451. */
  69452. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69453. /**
  69454. * Gets wether or not smoothing reflections is enabled.
  69455. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69456. */
  69457. get enableSmoothReflections(): boolean;
  69458. /**
  69459. * Sets wether or not smoothing reflections is enabled.
  69460. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69461. */
  69462. set enableSmoothReflections(enabled: boolean);
  69463. /**
  69464. * Gets the number of samples taken while computing reflections. More samples count is high,
  69465. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69466. */
  69467. get reflectionSamples(): number;
  69468. /**
  69469. * Sets the number of samples taken while computing reflections. More samples count is high,
  69470. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69471. */
  69472. set reflectionSamples(samples: number);
  69473. /**
  69474. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69475. * more the post-process will require GPU power and can generate a drop in FPS.
  69476. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69477. */
  69478. get smoothSteps(): number;
  69479. set smoothSteps(steps: number);
  69480. private _updateEffectDefines;
  69481. }
  69482. }
  69483. declare module "babylonjs/Shaders/standard.fragment" {
  69484. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69485. /** @hidden */
  69486. export var standardPixelShader: {
  69487. name: string;
  69488. shader: string;
  69489. };
  69490. }
  69491. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69492. import { Nullable } from "babylonjs/types";
  69493. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69494. import { Camera } from "babylonjs/Cameras/camera";
  69495. import { Texture } from "babylonjs/Materials/Textures/texture";
  69496. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69497. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69498. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69499. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69500. import { IDisposable } from "babylonjs/scene";
  69501. import { SpotLight } from "babylonjs/Lights/spotLight";
  69502. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69503. import { Scene } from "babylonjs/scene";
  69504. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69505. import { Animation } from "babylonjs/Animations/animation";
  69506. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69507. import "babylonjs/Shaders/standard.fragment";
  69508. /**
  69509. * Standard rendering pipeline
  69510. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69511. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69512. */
  69513. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69514. /**
  69515. * Public members
  69516. */
  69517. /**
  69518. * Post-process which contains the original scene color before the pipeline applies all the effects
  69519. */
  69520. originalPostProcess: Nullable<PostProcess>;
  69521. /**
  69522. * Post-process used to down scale an image x4
  69523. */
  69524. downSampleX4PostProcess: Nullable<PostProcess>;
  69525. /**
  69526. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69527. */
  69528. brightPassPostProcess: Nullable<PostProcess>;
  69529. /**
  69530. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69531. */
  69532. blurHPostProcesses: PostProcess[];
  69533. /**
  69534. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69535. */
  69536. blurVPostProcesses: PostProcess[];
  69537. /**
  69538. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69539. */
  69540. textureAdderPostProcess: Nullable<PostProcess>;
  69541. /**
  69542. * Post-process used to create volumetric lighting effect
  69543. */
  69544. volumetricLightPostProcess: Nullable<PostProcess>;
  69545. /**
  69546. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69547. */
  69548. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69549. /**
  69550. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69551. */
  69552. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69553. /**
  69554. * Post-process used to merge the volumetric light effect and the real scene color
  69555. */
  69556. volumetricLightMergePostProces: Nullable<PostProcess>;
  69557. /**
  69558. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69559. */
  69560. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69561. /**
  69562. * Base post-process used to calculate the average luminance of the final image for HDR
  69563. */
  69564. luminancePostProcess: Nullable<PostProcess>;
  69565. /**
  69566. * Post-processes used to create down sample post-processes in order to get
  69567. * the average luminance of the final image for HDR
  69568. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69569. */
  69570. luminanceDownSamplePostProcesses: PostProcess[];
  69571. /**
  69572. * Post-process used to create a HDR effect (light adaptation)
  69573. */
  69574. hdrPostProcess: Nullable<PostProcess>;
  69575. /**
  69576. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69577. */
  69578. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69579. /**
  69580. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69581. */
  69582. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69583. /**
  69584. * Post-process used to merge the final HDR post-process and the real scene color
  69585. */
  69586. hdrFinalPostProcess: Nullable<PostProcess>;
  69587. /**
  69588. * Post-process used to create a lens flare effect
  69589. */
  69590. lensFlarePostProcess: Nullable<PostProcess>;
  69591. /**
  69592. * Post-process that merges the result of the lens flare post-process and the real scene color
  69593. */
  69594. lensFlareComposePostProcess: Nullable<PostProcess>;
  69595. /**
  69596. * Post-process used to create a motion blur effect
  69597. */
  69598. motionBlurPostProcess: Nullable<PostProcess>;
  69599. /**
  69600. * Post-process used to create a depth of field effect
  69601. */
  69602. depthOfFieldPostProcess: Nullable<PostProcess>;
  69603. /**
  69604. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69605. */
  69606. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69607. /**
  69608. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69609. */
  69610. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69611. /**
  69612. * Represents the brightness threshold in order to configure the illuminated surfaces
  69613. */
  69614. brightThreshold: number;
  69615. /**
  69616. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69617. */
  69618. blurWidth: number;
  69619. /**
  69620. * Sets if the blur for highlighted surfaces must be only horizontal
  69621. */
  69622. horizontalBlur: boolean;
  69623. /**
  69624. * Gets the overall exposure used by the pipeline
  69625. */
  69626. get exposure(): number;
  69627. /**
  69628. * Sets the overall exposure used by the pipeline
  69629. */
  69630. set exposure(value: number);
  69631. /**
  69632. * Texture used typically to simulate "dirty" on camera lens
  69633. */
  69634. lensTexture: Nullable<Texture>;
  69635. /**
  69636. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69637. */
  69638. volumetricLightCoefficient: number;
  69639. /**
  69640. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69641. */
  69642. volumetricLightPower: number;
  69643. /**
  69644. * Used the set the blur intensity to smooth the volumetric lights
  69645. */
  69646. volumetricLightBlurScale: number;
  69647. /**
  69648. * Light (spot or directional) used to generate the volumetric lights rays
  69649. * The source light must have a shadow generate so the pipeline can get its
  69650. * depth map
  69651. */
  69652. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69653. /**
  69654. * For eye adaptation, represents the minimum luminance the eye can see
  69655. */
  69656. hdrMinimumLuminance: number;
  69657. /**
  69658. * For eye adaptation, represents the decrease luminance speed
  69659. */
  69660. hdrDecreaseRate: number;
  69661. /**
  69662. * For eye adaptation, represents the increase luminance speed
  69663. */
  69664. hdrIncreaseRate: number;
  69665. /**
  69666. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69667. */
  69668. get hdrAutoExposure(): boolean;
  69669. /**
  69670. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69671. */
  69672. set hdrAutoExposure(value: boolean);
  69673. /**
  69674. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69675. */
  69676. lensColorTexture: Nullable<Texture>;
  69677. /**
  69678. * The overall strengh for the lens flare effect
  69679. */
  69680. lensFlareStrength: number;
  69681. /**
  69682. * Dispersion coefficient for lens flare ghosts
  69683. */
  69684. lensFlareGhostDispersal: number;
  69685. /**
  69686. * Main lens flare halo width
  69687. */
  69688. lensFlareHaloWidth: number;
  69689. /**
  69690. * Based on the lens distortion effect, defines how much the lens flare result
  69691. * is distorted
  69692. */
  69693. lensFlareDistortionStrength: number;
  69694. /**
  69695. * Configures the blur intensity used for for lens flare (halo)
  69696. */
  69697. lensFlareBlurWidth: number;
  69698. /**
  69699. * Lens star texture must be used to simulate rays on the flares and is available
  69700. * in the documentation
  69701. */
  69702. lensStarTexture: Nullable<Texture>;
  69703. /**
  69704. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69705. * flare effect by taking account of the dirt texture
  69706. */
  69707. lensFlareDirtTexture: Nullable<Texture>;
  69708. /**
  69709. * Represents the focal length for the depth of field effect
  69710. */
  69711. depthOfFieldDistance: number;
  69712. /**
  69713. * Represents the blur intensity for the blurred part of the depth of field effect
  69714. */
  69715. depthOfFieldBlurWidth: number;
  69716. /**
  69717. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69718. */
  69719. get motionStrength(): number;
  69720. /**
  69721. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69722. */
  69723. set motionStrength(strength: number);
  69724. /**
  69725. * Gets wether or not the motion blur post-process is object based or screen based.
  69726. */
  69727. get objectBasedMotionBlur(): boolean;
  69728. /**
  69729. * Sets wether or not the motion blur post-process should be object based or screen based
  69730. */
  69731. set objectBasedMotionBlur(value: boolean);
  69732. /**
  69733. * List of animations for the pipeline (IAnimatable implementation)
  69734. */
  69735. animations: Animation[];
  69736. /**
  69737. * Private members
  69738. */
  69739. private _scene;
  69740. private _currentDepthOfFieldSource;
  69741. private _basePostProcess;
  69742. private _fixedExposure;
  69743. private _currentExposure;
  69744. private _hdrAutoExposure;
  69745. private _hdrCurrentLuminance;
  69746. private _motionStrength;
  69747. private _isObjectBasedMotionBlur;
  69748. private _floatTextureType;
  69749. private _camerasToBeAttached;
  69750. private _ratio;
  69751. private _bloomEnabled;
  69752. private _depthOfFieldEnabled;
  69753. private _vlsEnabled;
  69754. private _lensFlareEnabled;
  69755. private _hdrEnabled;
  69756. private _motionBlurEnabled;
  69757. private _fxaaEnabled;
  69758. private _screenSpaceReflectionsEnabled;
  69759. private _motionBlurSamples;
  69760. private _volumetricLightStepsCount;
  69761. private _samples;
  69762. /**
  69763. * @ignore
  69764. * Specifies if the bloom pipeline is enabled
  69765. */
  69766. get BloomEnabled(): boolean;
  69767. set BloomEnabled(enabled: boolean);
  69768. /**
  69769. * @ignore
  69770. * Specifies if the depth of field pipeline is enabed
  69771. */
  69772. get DepthOfFieldEnabled(): boolean;
  69773. set DepthOfFieldEnabled(enabled: boolean);
  69774. /**
  69775. * @ignore
  69776. * Specifies if the lens flare pipeline is enabed
  69777. */
  69778. get LensFlareEnabled(): boolean;
  69779. set LensFlareEnabled(enabled: boolean);
  69780. /**
  69781. * @ignore
  69782. * Specifies if the HDR pipeline is enabled
  69783. */
  69784. get HDREnabled(): boolean;
  69785. set HDREnabled(enabled: boolean);
  69786. /**
  69787. * @ignore
  69788. * Specifies if the volumetric lights scattering effect is enabled
  69789. */
  69790. get VLSEnabled(): boolean;
  69791. set VLSEnabled(enabled: boolean);
  69792. /**
  69793. * @ignore
  69794. * Specifies if the motion blur effect is enabled
  69795. */
  69796. get MotionBlurEnabled(): boolean;
  69797. set MotionBlurEnabled(enabled: boolean);
  69798. /**
  69799. * Specifies if anti-aliasing is enabled
  69800. */
  69801. get fxaaEnabled(): boolean;
  69802. set fxaaEnabled(enabled: boolean);
  69803. /**
  69804. * Specifies if screen space reflections are enabled.
  69805. */
  69806. get screenSpaceReflectionsEnabled(): boolean;
  69807. set screenSpaceReflectionsEnabled(enabled: boolean);
  69808. /**
  69809. * Specifies the number of steps used to calculate the volumetric lights
  69810. * Typically in interval [50, 200]
  69811. */
  69812. get volumetricLightStepsCount(): number;
  69813. set volumetricLightStepsCount(count: number);
  69814. /**
  69815. * Specifies the number of samples used for the motion blur effect
  69816. * Typically in interval [16, 64]
  69817. */
  69818. get motionBlurSamples(): number;
  69819. set motionBlurSamples(samples: number);
  69820. /**
  69821. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69822. */
  69823. get samples(): number;
  69824. set samples(sampleCount: number);
  69825. /**
  69826. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69827. * @constructor
  69828. * @param name The rendering pipeline name
  69829. * @param scene The scene linked to this pipeline
  69830. * @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)
  69831. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69832. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69833. */
  69834. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69835. private _buildPipeline;
  69836. private _createDownSampleX4PostProcess;
  69837. private _createBrightPassPostProcess;
  69838. private _createBlurPostProcesses;
  69839. private _createTextureAdderPostProcess;
  69840. private _createVolumetricLightPostProcess;
  69841. private _createLuminancePostProcesses;
  69842. private _createHdrPostProcess;
  69843. private _createLensFlarePostProcess;
  69844. private _createDepthOfFieldPostProcess;
  69845. private _createMotionBlurPostProcess;
  69846. private _getDepthTexture;
  69847. private _disposePostProcesses;
  69848. /**
  69849. * Dispose of the pipeline and stop all post processes
  69850. */
  69851. dispose(): void;
  69852. /**
  69853. * Serialize the rendering pipeline (Used when exporting)
  69854. * @returns the serialized object
  69855. */
  69856. serialize(): any;
  69857. /**
  69858. * Parse the serialized pipeline
  69859. * @param source Source pipeline.
  69860. * @param scene The scene to load the pipeline to.
  69861. * @param rootUrl The URL of the serialized pipeline.
  69862. * @returns An instantiated pipeline from the serialized object.
  69863. */
  69864. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69865. /**
  69866. * Luminance steps
  69867. */
  69868. static LuminanceSteps: number;
  69869. }
  69870. }
  69871. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69872. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69873. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69874. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69875. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69876. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69877. }
  69878. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69879. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69880. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69881. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69882. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69883. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69884. }
  69885. declare module "babylonjs/Shaders/tonemap.fragment" {
  69886. /** @hidden */
  69887. export var tonemapPixelShader: {
  69888. name: string;
  69889. shader: string;
  69890. };
  69891. }
  69892. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69893. import { Camera } from "babylonjs/Cameras/camera";
  69894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69895. import "babylonjs/Shaders/tonemap.fragment";
  69896. import { Engine } from "babylonjs/Engines/engine";
  69897. /** Defines operator used for tonemapping */
  69898. export enum TonemappingOperator {
  69899. /** Hable */
  69900. Hable = 0,
  69901. /** Reinhard */
  69902. Reinhard = 1,
  69903. /** HejiDawson */
  69904. HejiDawson = 2,
  69905. /** Photographic */
  69906. Photographic = 3
  69907. }
  69908. /**
  69909. * Defines a post process to apply tone mapping
  69910. */
  69911. export class TonemapPostProcess extends PostProcess {
  69912. private _operator;
  69913. /** Defines the required exposure adjustement */
  69914. exposureAdjustment: number;
  69915. /**
  69916. * Creates a new TonemapPostProcess
  69917. * @param name defines the name of the postprocess
  69918. * @param _operator defines the operator to use
  69919. * @param exposureAdjustment defines the required exposure adjustement
  69920. * @param camera defines the camera to use (can be null)
  69921. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69922. * @param engine defines the hosting engine (can be ignore if camera is set)
  69923. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69924. */
  69925. constructor(name: string, _operator: TonemappingOperator,
  69926. /** Defines the required exposure adjustement */
  69927. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69928. }
  69929. }
  69930. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69931. /** @hidden */
  69932. export var volumetricLightScatteringPixelShader: {
  69933. name: string;
  69934. shader: string;
  69935. };
  69936. }
  69937. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69938. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69941. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69943. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69944. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69945. /** @hidden */
  69946. export var volumetricLightScatteringPassVertexShader: {
  69947. name: string;
  69948. shader: string;
  69949. };
  69950. }
  69951. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69952. /** @hidden */
  69953. export var volumetricLightScatteringPassPixelShader: {
  69954. name: string;
  69955. shader: string;
  69956. };
  69957. }
  69958. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69959. import { Vector3 } from "babylonjs/Maths/math.vector";
  69960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69961. import { Mesh } from "babylonjs/Meshes/mesh";
  69962. import { Camera } from "babylonjs/Cameras/camera";
  69963. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69965. import { Scene } from "babylonjs/scene";
  69966. import "babylonjs/Meshes/Builders/planeBuilder";
  69967. import "babylonjs/Shaders/depth.vertex";
  69968. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69969. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69970. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69971. import { Engine } from "babylonjs/Engines/engine";
  69972. /**
  69973. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69974. */
  69975. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69976. private _volumetricLightScatteringPass;
  69977. private _volumetricLightScatteringRTT;
  69978. private _viewPort;
  69979. private _screenCoordinates;
  69980. private _cachedDefines;
  69981. /**
  69982. * If not undefined, the mesh position is computed from the attached node position
  69983. */
  69984. attachedNode: {
  69985. position: Vector3;
  69986. };
  69987. /**
  69988. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69989. */
  69990. customMeshPosition: Vector3;
  69991. /**
  69992. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69993. */
  69994. useCustomMeshPosition: boolean;
  69995. /**
  69996. * If the post-process should inverse the light scattering direction
  69997. */
  69998. invert: boolean;
  69999. /**
  70000. * The internal mesh used by the post-process
  70001. */
  70002. mesh: Mesh;
  70003. /**
  70004. * @hidden
  70005. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70006. */
  70007. get useDiffuseColor(): boolean;
  70008. set useDiffuseColor(useDiffuseColor: boolean);
  70009. /**
  70010. * Array containing the excluded meshes not rendered in the internal pass
  70011. */
  70012. excludedMeshes: AbstractMesh[];
  70013. /**
  70014. * Controls the overall intensity of the post-process
  70015. */
  70016. exposure: number;
  70017. /**
  70018. * Dissipates each sample's contribution in range [0, 1]
  70019. */
  70020. decay: number;
  70021. /**
  70022. * Controls the overall intensity of each sample
  70023. */
  70024. weight: number;
  70025. /**
  70026. * Controls the density of each sample
  70027. */
  70028. density: number;
  70029. /**
  70030. * @constructor
  70031. * @param name The post-process name
  70032. * @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)
  70033. * @param camera The camera that the post-process will be attached to
  70034. * @param mesh The mesh used to create the light scattering
  70035. * @param samples The post-process quality, default 100
  70036. * @param samplingModeThe post-process filtering mode
  70037. * @param engine The babylon engine
  70038. * @param reusable If the post-process is reusable
  70039. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70040. */
  70041. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70042. /**
  70043. * Returns the string "VolumetricLightScatteringPostProcess"
  70044. * @returns "VolumetricLightScatteringPostProcess"
  70045. */
  70046. getClassName(): string;
  70047. private _isReady;
  70048. /**
  70049. * Sets the new light position for light scattering effect
  70050. * @param position The new custom light position
  70051. */
  70052. setCustomMeshPosition(position: Vector3): void;
  70053. /**
  70054. * Returns the light position for light scattering effect
  70055. * @return Vector3 The custom light position
  70056. */
  70057. getCustomMeshPosition(): Vector3;
  70058. /**
  70059. * Disposes the internal assets and detaches the post-process from the camera
  70060. */
  70061. dispose(camera: Camera): void;
  70062. /**
  70063. * Returns the render target texture used by the post-process
  70064. * @return the render target texture used by the post-process
  70065. */
  70066. getPass(): RenderTargetTexture;
  70067. private _meshExcluded;
  70068. private _createPass;
  70069. private _updateMeshScreenCoordinates;
  70070. /**
  70071. * Creates a default mesh for the Volumeric Light Scattering post-process
  70072. * @param name The mesh name
  70073. * @param scene The scene where to create the mesh
  70074. * @return the default mesh
  70075. */
  70076. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70077. }
  70078. }
  70079. declare module "babylonjs/PostProcesses/index" {
  70080. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70081. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70082. export * from "babylonjs/PostProcesses/bloomEffect";
  70083. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70084. export * from "babylonjs/PostProcesses/blurPostProcess";
  70085. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70086. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70087. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70088. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70089. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70090. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70091. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70092. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70093. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70094. export * from "babylonjs/PostProcesses/filterPostProcess";
  70095. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70096. export * from "babylonjs/PostProcesses/grainPostProcess";
  70097. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70098. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70099. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70100. export * from "babylonjs/PostProcesses/passPostProcess";
  70101. export * from "babylonjs/PostProcesses/postProcess";
  70102. export * from "babylonjs/PostProcesses/postProcessManager";
  70103. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70104. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70105. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70106. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70107. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70108. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70109. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70110. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70111. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70112. }
  70113. declare module "babylonjs/Probes/index" {
  70114. export * from "babylonjs/Probes/reflectionProbe";
  70115. }
  70116. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70117. import { Scene } from "babylonjs/scene";
  70118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70119. import { SmartArray } from "babylonjs/Misc/smartArray";
  70120. import { ISceneComponent } from "babylonjs/sceneComponent";
  70121. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70122. import "babylonjs/Meshes/Builders/boxBuilder";
  70123. import "babylonjs/Shaders/color.fragment";
  70124. import "babylonjs/Shaders/color.vertex";
  70125. import { Color3 } from "babylonjs/Maths/math.color";
  70126. module "babylonjs/scene" {
  70127. interface Scene {
  70128. /** @hidden (Backing field) */
  70129. _boundingBoxRenderer: BoundingBoxRenderer;
  70130. /** @hidden (Backing field) */
  70131. _forceShowBoundingBoxes: boolean;
  70132. /**
  70133. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70134. */
  70135. forceShowBoundingBoxes: boolean;
  70136. /**
  70137. * Gets the bounding box renderer associated with the scene
  70138. * @returns a BoundingBoxRenderer
  70139. */
  70140. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70141. }
  70142. }
  70143. module "babylonjs/Meshes/abstractMesh" {
  70144. interface AbstractMesh {
  70145. /** @hidden (Backing field) */
  70146. _showBoundingBox: boolean;
  70147. /**
  70148. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70149. */
  70150. showBoundingBox: boolean;
  70151. }
  70152. }
  70153. /**
  70154. * Component responsible of rendering the bounding box of the meshes in a scene.
  70155. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70156. */
  70157. export class BoundingBoxRenderer implements ISceneComponent {
  70158. /**
  70159. * The component name helpfull to identify the component in the list of scene components.
  70160. */
  70161. readonly name: string;
  70162. /**
  70163. * The scene the component belongs to.
  70164. */
  70165. scene: Scene;
  70166. /**
  70167. * Color of the bounding box lines placed in front of an object
  70168. */
  70169. frontColor: Color3;
  70170. /**
  70171. * Color of the bounding box lines placed behind an object
  70172. */
  70173. backColor: Color3;
  70174. /**
  70175. * Defines if the renderer should show the back lines or not
  70176. */
  70177. showBackLines: boolean;
  70178. /**
  70179. * @hidden
  70180. */
  70181. renderList: SmartArray<BoundingBox>;
  70182. private _colorShader;
  70183. private _vertexBuffers;
  70184. private _indexBuffer;
  70185. private _fillIndexBuffer;
  70186. private _fillIndexData;
  70187. /**
  70188. * Instantiates a new bounding box renderer in a scene.
  70189. * @param scene the scene the renderer renders in
  70190. */
  70191. constructor(scene: Scene);
  70192. /**
  70193. * Registers the component in a given scene
  70194. */
  70195. register(): void;
  70196. private _evaluateSubMesh;
  70197. private _activeMesh;
  70198. private _prepareRessources;
  70199. private _createIndexBuffer;
  70200. /**
  70201. * Rebuilds the elements related to this component in case of
  70202. * context lost for instance.
  70203. */
  70204. rebuild(): void;
  70205. /**
  70206. * @hidden
  70207. */
  70208. reset(): void;
  70209. /**
  70210. * Render the bounding boxes of a specific rendering group
  70211. * @param renderingGroupId defines the rendering group to render
  70212. */
  70213. render(renderingGroupId: number): void;
  70214. /**
  70215. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70216. * @param mesh Define the mesh to render the occlusion bounding box for
  70217. */
  70218. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70219. /**
  70220. * Dispose and release the resources attached to this renderer.
  70221. */
  70222. dispose(): void;
  70223. }
  70224. }
  70225. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70226. import { Nullable } from "babylonjs/types";
  70227. import { Scene } from "babylonjs/scene";
  70228. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70229. import { Camera } from "babylonjs/Cameras/camera";
  70230. import { ISceneComponent } from "babylonjs/sceneComponent";
  70231. module "babylonjs/scene" {
  70232. interface Scene {
  70233. /** @hidden (Backing field) */
  70234. _depthRenderer: {
  70235. [id: string]: DepthRenderer;
  70236. };
  70237. /**
  70238. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70239. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70240. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70241. * @returns the created depth renderer
  70242. */
  70243. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70244. /**
  70245. * Disables a depth renderer for a given camera
  70246. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70247. */
  70248. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70249. }
  70250. }
  70251. /**
  70252. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70253. * in several rendering techniques.
  70254. */
  70255. export class DepthRendererSceneComponent implements ISceneComponent {
  70256. /**
  70257. * The component name helpfull to identify the component in the list of scene components.
  70258. */
  70259. readonly name: string;
  70260. /**
  70261. * The scene the component belongs to.
  70262. */
  70263. scene: Scene;
  70264. /**
  70265. * Creates a new instance of the component for the given scene
  70266. * @param scene Defines the scene to register the component in
  70267. */
  70268. constructor(scene: Scene);
  70269. /**
  70270. * Registers the component in a given scene
  70271. */
  70272. register(): void;
  70273. /**
  70274. * Rebuilds the elements related to this component in case of
  70275. * context lost for instance.
  70276. */
  70277. rebuild(): void;
  70278. /**
  70279. * Disposes the component and the associated ressources
  70280. */
  70281. dispose(): void;
  70282. private _gatherRenderTargets;
  70283. private _gatherActiveCameraRenderTargets;
  70284. }
  70285. }
  70286. declare module "babylonjs/Shaders/outline.fragment" {
  70287. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70288. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70289. /** @hidden */
  70290. export var outlinePixelShader: {
  70291. name: string;
  70292. shader: string;
  70293. };
  70294. }
  70295. declare module "babylonjs/Shaders/outline.vertex" {
  70296. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70299. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70300. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70301. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70302. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70303. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70304. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70305. /** @hidden */
  70306. export var outlineVertexShader: {
  70307. name: string;
  70308. shader: string;
  70309. };
  70310. }
  70311. declare module "babylonjs/Rendering/outlineRenderer" {
  70312. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70313. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70314. import { Scene } from "babylonjs/scene";
  70315. import { ISceneComponent } from "babylonjs/sceneComponent";
  70316. import "babylonjs/Shaders/outline.fragment";
  70317. import "babylonjs/Shaders/outline.vertex";
  70318. module "babylonjs/scene" {
  70319. interface Scene {
  70320. /** @hidden */
  70321. _outlineRenderer: OutlineRenderer;
  70322. /**
  70323. * Gets the outline renderer associated with the scene
  70324. * @returns a OutlineRenderer
  70325. */
  70326. getOutlineRenderer(): OutlineRenderer;
  70327. }
  70328. }
  70329. module "babylonjs/Meshes/abstractMesh" {
  70330. interface AbstractMesh {
  70331. /** @hidden (Backing field) */
  70332. _renderOutline: boolean;
  70333. /**
  70334. * Gets or sets a boolean indicating if the outline must be rendered as well
  70335. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70336. */
  70337. renderOutline: boolean;
  70338. /** @hidden (Backing field) */
  70339. _renderOverlay: boolean;
  70340. /**
  70341. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70342. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70343. */
  70344. renderOverlay: boolean;
  70345. }
  70346. }
  70347. /**
  70348. * This class is responsible to draw bothe outline/overlay of meshes.
  70349. * It should not be used directly but through the available method on mesh.
  70350. */
  70351. export class OutlineRenderer implements ISceneComponent {
  70352. /**
  70353. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70354. */
  70355. private static _StencilReference;
  70356. /**
  70357. * The name of the component. Each component must have a unique name.
  70358. */
  70359. name: string;
  70360. /**
  70361. * The scene the component belongs to.
  70362. */
  70363. scene: Scene;
  70364. /**
  70365. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70366. */
  70367. zOffset: number;
  70368. private _engine;
  70369. private _effect;
  70370. private _cachedDefines;
  70371. private _savedDepthWrite;
  70372. /**
  70373. * Instantiates a new outline renderer. (There could be only one per scene).
  70374. * @param scene Defines the scene it belongs to
  70375. */
  70376. constructor(scene: Scene);
  70377. /**
  70378. * Register the component to one instance of a scene.
  70379. */
  70380. register(): void;
  70381. /**
  70382. * Rebuilds the elements related to this component in case of
  70383. * context lost for instance.
  70384. */
  70385. rebuild(): void;
  70386. /**
  70387. * Disposes the component and the associated ressources.
  70388. */
  70389. dispose(): void;
  70390. /**
  70391. * Renders the outline in the canvas.
  70392. * @param subMesh Defines the sumesh to render
  70393. * @param batch Defines the batch of meshes in case of instances
  70394. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70395. */
  70396. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70397. /**
  70398. * Returns whether or not the outline renderer is ready for a given submesh.
  70399. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70400. * @param subMesh Defines the submesh to check readyness for
  70401. * @param useInstances Defines wheter wee are trying to render instances or not
  70402. * @returns true if ready otherwise false
  70403. */
  70404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70405. private _beforeRenderingMesh;
  70406. private _afterRenderingMesh;
  70407. }
  70408. }
  70409. declare module "babylonjs/Rendering/index" {
  70410. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70411. export * from "babylonjs/Rendering/depthRenderer";
  70412. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70413. export * from "babylonjs/Rendering/edgesRenderer";
  70414. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70415. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70416. export * from "babylonjs/Rendering/outlineRenderer";
  70417. export * from "babylonjs/Rendering/renderingGroup";
  70418. export * from "babylonjs/Rendering/renderingManager";
  70419. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70420. }
  70421. declare module "babylonjs/Sprites/ISprites" {
  70422. /**
  70423. * Defines the basic options interface of a Sprite Frame Source Size.
  70424. */
  70425. export interface ISpriteJSONSpriteSourceSize {
  70426. /**
  70427. * number of the original width of the Frame
  70428. */
  70429. w: number;
  70430. /**
  70431. * number of the original height of the Frame
  70432. */
  70433. h: number;
  70434. }
  70435. /**
  70436. * Defines the basic options interface of a Sprite Frame Data.
  70437. */
  70438. export interface ISpriteJSONSpriteFrameData {
  70439. /**
  70440. * number of the x offset of the Frame
  70441. */
  70442. x: number;
  70443. /**
  70444. * number of the y offset of the Frame
  70445. */
  70446. y: number;
  70447. /**
  70448. * number of the width of the Frame
  70449. */
  70450. w: number;
  70451. /**
  70452. * number of the height of the Frame
  70453. */
  70454. h: number;
  70455. }
  70456. /**
  70457. * Defines the basic options interface of a JSON Sprite.
  70458. */
  70459. export interface ISpriteJSONSprite {
  70460. /**
  70461. * string name of the Frame
  70462. */
  70463. filename: string;
  70464. /**
  70465. * ISpriteJSONSpriteFrame basic object of the frame data
  70466. */
  70467. frame: ISpriteJSONSpriteFrameData;
  70468. /**
  70469. * boolean to flag is the frame was rotated.
  70470. */
  70471. rotated: boolean;
  70472. /**
  70473. * boolean to flag is the frame was trimmed.
  70474. */
  70475. trimmed: boolean;
  70476. /**
  70477. * ISpriteJSONSpriteFrame basic object of the source data
  70478. */
  70479. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70480. /**
  70481. * ISpriteJSONSpriteFrame basic object of the source data
  70482. */
  70483. sourceSize: ISpriteJSONSpriteSourceSize;
  70484. }
  70485. /**
  70486. * Defines the basic options interface of a JSON atlas.
  70487. */
  70488. export interface ISpriteJSONAtlas {
  70489. /**
  70490. * Array of objects that contain the frame data.
  70491. */
  70492. frames: Array<ISpriteJSONSprite>;
  70493. /**
  70494. * object basic object containing the sprite meta data.
  70495. */
  70496. meta?: object;
  70497. }
  70498. }
  70499. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70500. /** @hidden */
  70501. export var spriteMapPixelShader: {
  70502. name: string;
  70503. shader: string;
  70504. };
  70505. }
  70506. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70507. /** @hidden */
  70508. export var spriteMapVertexShader: {
  70509. name: string;
  70510. shader: string;
  70511. };
  70512. }
  70513. declare module "babylonjs/Sprites/spriteMap" {
  70514. import { IDisposable, Scene } from "babylonjs/scene";
  70515. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70516. import { Texture } from "babylonjs/Materials/Textures/texture";
  70517. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70518. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70519. import "babylonjs/Meshes/Builders/planeBuilder";
  70520. import "babylonjs/Shaders/spriteMap.fragment";
  70521. import "babylonjs/Shaders/spriteMap.vertex";
  70522. /**
  70523. * Defines the basic options interface of a SpriteMap
  70524. */
  70525. export interface ISpriteMapOptions {
  70526. /**
  70527. * Vector2 of the number of cells in the grid.
  70528. */
  70529. stageSize?: Vector2;
  70530. /**
  70531. * Vector2 of the size of the output plane in World Units.
  70532. */
  70533. outputSize?: Vector2;
  70534. /**
  70535. * Vector3 of the position of the output plane in World Units.
  70536. */
  70537. outputPosition?: Vector3;
  70538. /**
  70539. * Vector3 of the rotation of the output plane.
  70540. */
  70541. outputRotation?: Vector3;
  70542. /**
  70543. * number of layers that the system will reserve in resources.
  70544. */
  70545. layerCount?: number;
  70546. /**
  70547. * number of max animation frames a single cell will reserve in resources.
  70548. */
  70549. maxAnimationFrames?: number;
  70550. /**
  70551. * number cell index of the base tile when the system compiles.
  70552. */
  70553. baseTile?: number;
  70554. /**
  70555. * boolean flip the sprite after its been repositioned by the framing data.
  70556. */
  70557. flipU?: boolean;
  70558. /**
  70559. * Vector3 scalar of the global RGB values of the SpriteMap.
  70560. */
  70561. colorMultiply?: Vector3;
  70562. }
  70563. /**
  70564. * Defines the IDisposable interface in order to be cleanable from resources.
  70565. */
  70566. export interface ISpriteMap extends IDisposable {
  70567. /**
  70568. * String name of the SpriteMap.
  70569. */
  70570. name: string;
  70571. /**
  70572. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70573. */
  70574. atlasJSON: ISpriteJSONAtlas;
  70575. /**
  70576. * Texture of the SpriteMap.
  70577. */
  70578. spriteSheet: Texture;
  70579. /**
  70580. * The parameters to initialize the SpriteMap with.
  70581. */
  70582. options: ISpriteMapOptions;
  70583. }
  70584. /**
  70585. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70586. */
  70587. export class SpriteMap implements ISpriteMap {
  70588. /** The Name of the spriteMap */
  70589. name: string;
  70590. /** The JSON file with the frame and meta data */
  70591. atlasJSON: ISpriteJSONAtlas;
  70592. /** The systems Sprite Sheet Texture */
  70593. spriteSheet: Texture;
  70594. /** Arguments passed with the Constructor */
  70595. options: ISpriteMapOptions;
  70596. /** Public Sprite Storage array, parsed from atlasJSON */
  70597. sprites: Array<ISpriteJSONSprite>;
  70598. /** Returns the Number of Sprites in the System */
  70599. get spriteCount(): number;
  70600. /** Returns the Position of Output Plane*/
  70601. get position(): Vector3;
  70602. /** Returns the Position of Output Plane*/
  70603. set position(v: Vector3);
  70604. /** Returns the Rotation of Output Plane*/
  70605. get rotation(): Vector3;
  70606. /** Returns the Rotation of Output Plane*/
  70607. set rotation(v: Vector3);
  70608. /** Sets the AnimationMap*/
  70609. get animationMap(): RawTexture;
  70610. /** Sets the AnimationMap*/
  70611. set animationMap(v: RawTexture);
  70612. /** Scene that the SpriteMap was created in */
  70613. private _scene;
  70614. /** Texture Buffer of Float32 that holds tile frame data*/
  70615. private _frameMap;
  70616. /** Texture Buffers of Float32 that holds tileMap data*/
  70617. private _tileMaps;
  70618. /** Texture Buffer of Float32 that holds Animation Data*/
  70619. private _animationMap;
  70620. /** Custom ShaderMaterial Central to the System*/
  70621. private _material;
  70622. /** Custom ShaderMaterial Central to the System*/
  70623. private _output;
  70624. /** Systems Time Ticker*/
  70625. private _time;
  70626. /**
  70627. * Creates a new SpriteMap
  70628. * @param name defines the SpriteMaps Name
  70629. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70630. * @param spriteSheet is the Texture that the Sprites are on.
  70631. * @param options a basic deployment configuration
  70632. * @param scene The Scene that the map is deployed on
  70633. */
  70634. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70635. /**
  70636. * Returns tileID location
  70637. * @returns Vector2 the cell position ID
  70638. */
  70639. getTileID(): Vector2;
  70640. /**
  70641. * Gets the UV location of the mouse over the SpriteMap.
  70642. * @returns Vector2 the UV position of the mouse interaction
  70643. */
  70644. getMousePosition(): Vector2;
  70645. /**
  70646. * Creates the "frame" texture Buffer
  70647. * -------------------------------------
  70648. * Structure of frames
  70649. * "filename": "Falling-Water-2.png",
  70650. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70651. * "rotated": true,
  70652. * "trimmed": true,
  70653. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70654. * "sourceSize": {"w":32,"h":32}
  70655. * @returns RawTexture of the frameMap
  70656. */
  70657. private _createFrameBuffer;
  70658. /**
  70659. * Creates the tileMap texture Buffer
  70660. * @param buffer normally and array of numbers, or a false to generate from scratch
  70661. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70662. * @returns RawTexture of the tileMap
  70663. */
  70664. private _createTileBuffer;
  70665. /**
  70666. * Modifies the data of the tileMaps
  70667. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70668. * @param pos is the iVector2 Coordinates of the Tile
  70669. * @param tile The SpriteIndex of the new Tile
  70670. */
  70671. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70672. /**
  70673. * Creates the animationMap texture Buffer
  70674. * @param buffer normally and array of numbers, or a false to generate from scratch
  70675. * @returns RawTexture of the animationMap
  70676. */
  70677. private _createTileAnimationBuffer;
  70678. /**
  70679. * Modifies the data of the animationMap
  70680. * @param cellID is the Index of the Sprite
  70681. * @param _frame is the target Animation frame
  70682. * @param toCell is the Target Index of the next frame of the animation
  70683. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70684. * @param speed is a global scalar of the time variable on the map.
  70685. */
  70686. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70687. /**
  70688. * Exports the .tilemaps file
  70689. */
  70690. saveTileMaps(): void;
  70691. /**
  70692. * Imports the .tilemaps file
  70693. * @param url of the .tilemaps file
  70694. */
  70695. loadTileMaps(url: string): void;
  70696. /**
  70697. * Release associated resources
  70698. */
  70699. dispose(): void;
  70700. }
  70701. }
  70702. declare module "babylonjs/Sprites/spritePackedManager" {
  70703. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70704. import { Scene } from "babylonjs/scene";
  70705. /**
  70706. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70707. * @see http://doc.babylonjs.com/babylon101/sprites
  70708. */
  70709. export class SpritePackedManager extends SpriteManager {
  70710. /** defines the packed manager's name */
  70711. name: string;
  70712. /**
  70713. * Creates a new sprite manager from a packed sprite sheet
  70714. * @param name defines the manager's name
  70715. * @param imgUrl defines the sprite sheet url
  70716. * @param capacity defines the maximum allowed number of sprites
  70717. * @param scene defines the hosting scene
  70718. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70719. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70720. * @param samplingMode defines the smapling mode to use with spritesheet
  70721. * @param fromPacked set to true; do not alter
  70722. */
  70723. constructor(
  70724. /** defines the packed manager's name */
  70725. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70726. }
  70727. }
  70728. declare module "babylonjs/Sprites/index" {
  70729. export * from "babylonjs/Sprites/sprite";
  70730. export * from "babylonjs/Sprites/ISprites";
  70731. export * from "babylonjs/Sprites/spriteManager";
  70732. export * from "babylonjs/Sprites/spriteMap";
  70733. export * from "babylonjs/Sprites/spritePackedManager";
  70734. export * from "babylonjs/Sprites/spriteSceneComponent";
  70735. }
  70736. declare module "babylonjs/States/index" {
  70737. export * from "babylonjs/States/alphaCullingState";
  70738. export * from "babylonjs/States/depthCullingState";
  70739. export * from "babylonjs/States/stencilState";
  70740. }
  70741. declare module "babylonjs/Misc/assetsManager" {
  70742. import { Scene } from "babylonjs/scene";
  70743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70744. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70745. import { Skeleton } from "babylonjs/Bones/skeleton";
  70746. import { Observable } from "babylonjs/Misc/observable";
  70747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70748. import { Texture } from "babylonjs/Materials/Textures/texture";
  70749. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70750. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70751. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70752. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70753. /**
  70754. * Defines the list of states available for a task inside a AssetsManager
  70755. */
  70756. export enum AssetTaskState {
  70757. /**
  70758. * Initialization
  70759. */
  70760. INIT = 0,
  70761. /**
  70762. * Running
  70763. */
  70764. RUNNING = 1,
  70765. /**
  70766. * Done
  70767. */
  70768. DONE = 2,
  70769. /**
  70770. * Error
  70771. */
  70772. ERROR = 3
  70773. }
  70774. /**
  70775. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70776. */
  70777. export abstract class AbstractAssetTask {
  70778. /**
  70779. * Task name
  70780. */ name: string;
  70781. /**
  70782. * Callback called when the task is successful
  70783. */
  70784. onSuccess: (task: any) => void;
  70785. /**
  70786. * Callback called when the task is not successful
  70787. */
  70788. onError: (task: any, message?: string, exception?: any) => void;
  70789. /**
  70790. * Creates a new AssetsManager
  70791. * @param name defines the name of the task
  70792. */
  70793. constructor(
  70794. /**
  70795. * Task name
  70796. */ name: string);
  70797. private _isCompleted;
  70798. private _taskState;
  70799. private _errorObject;
  70800. /**
  70801. * Get if the task is completed
  70802. */
  70803. get isCompleted(): boolean;
  70804. /**
  70805. * Gets the current state of the task
  70806. */
  70807. get taskState(): AssetTaskState;
  70808. /**
  70809. * Gets the current error object (if task is in error)
  70810. */
  70811. get errorObject(): {
  70812. message?: string;
  70813. exception?: any;
  70814. };
  70815. /**
  70816. * Internal only
  70817. * @hidden
  70818. */
  70819. _setErrorObject(message?: string, exception?: any): void;
  70820. /**
  70821. * Execute the current task
  70822. * @param scene defines the scene where you want your assets to be loaded
  70823. * @param onSuccess is a callback called when the task is successfully executed
  70824. * @param onError is a callback called if an error occurs
  70825. */
  70826. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70827. /**
  70828. * Execute the current task
  70829. * @param scene defines the scene where you want your assets to be loaded
  70830. * @param onSuccess is a callback called when the task is successfully executed
  70831. * @param onError is a callback called if an error occurs
  70832. */
  70833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70834. /**
  70835. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70836. * This can be used with failed tasks that have the reason for failure fixed.
  70837. */
  70838. reset(): void;
  70839. private onErrorCallback;
  70840. private onDoneCallback;
  70841. }
  70842. /**
  70843. * Define the interface used by progress events raised during assets loading
  70844. */
  70845. export interface IAssetsProgressEvent {
  70846. /**
  70847. * Defines the number of remaining tasks to process
  70848. */
  70849. remainingCount: number;
  70850. /**
  70851. * Defines the total number of tasks
  70852. */
  70853. totalCount: number;
  70854. /**
  70855. * Defines the task that was just processed
  70856. */
  70857. task: AbstractAssetTask;
  70858. }
  70859. /**
  70860. * Class used to share progress information about assets loading
  70861. */
  70862. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70863. /**
  70864. * Defines the number of remaining tasks to process
  70865. */
  70866. remainingCount: number;
  70867. /**
  70868. * Defines the total number of tasks
  70869. */
  70870. totalCount: number;
  70871. /**
  70872. * Defines the task that was just processed
  70873. */
  70874. task: AbstractAssetTask;
  70875. /**
  70876. * Creates a AssetsProgressEvent
  70877. * @param remainingCount defines the number of remaining tasks to process
  70878. * @param totalCount defines the total number of tasks
  70879. * @param task defines the task that was just processed
  70880. */
  70881. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70882. }
  70883. /**
  70884. * Define a task used by AssetsManager to load meshes
  70885. */
  70886. export class MeshAssetTask extends AbstractAssetTask {
  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. * Gets the list of loaded meshes
  70905. */
  70906. loadedMeshes: Array<AbstractMesh>;
  70907. /**
  70908. * Gets the list of loaded particle systems
  70909. */
  70910. loadedParticleSystems: Array<IParticleSystem>;
  70911. /**
  70912. * Gets the list of loaded skeletons
  70913. */
  70914. loadedSkeletons: Array<Skeleton>;
  70915. /**
  70916. * Gets the list of loaded animation groups
  70917. */
  70918. loadedAnimationGroups: Array<AnimationGroup>;
  70919. /**
  70920. * Callback called when the task is successful
  70921. */
  70922. onSuccess: (task: MeshAssetTask) => void;
  70923. /**
  70924. * Callback called when the task is successful
  70925. */
  70926. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70927. /**
  70928. * Creates a new MeshAssetTask
  70929. * @param name defines the name of the task
  70930. * @param meshesNames defines the list of mesh's names you want to load
  70931. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70932. * @param sceneFilename defines the filename of the scene to load from
  70933. */
  70934. constructor(
  70935. /**
  70936. * Defines the name of the task
  70937. */
  70938. name: string,
  70939. /**
  70940. * Defines the list of mesh's names you want to load
  70941. */
  70942. meshesNames: any,
  70943. /**
  70944. * Defines the root url to use as a base to load your meshes and associated resources
  70945. */
  70946. rootUrl: string,
  70947. /**
  70948. * Defines the filename of the scene to load from
  70949. */
  70950. sceneFilename: string);
  70951. /**
  70952. * Execute the current task
  70953. * @param scene defines the scene where you want your assets to be loaded
  70954. * @param onSuccess is a callback called when the task is successfully executed
  70955. * @param onError is a callback called if an error occurs
  70956. */
  70957. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70958. }
  70959. /**
  70960. * Define a task used by AssetsManager to load text content
  70961. */
  70962. export class TextFileAssetTask extends AbstractAssetTask {
  70963. /**
  70964. * Defines the name of the task
  70965. */
  70966. name: string;
  70967. /**
  70968. * Defines the location of the file to load
  70969. */
  70970. url: string;
  70971. /**
  70972. * Gets the loaded text string
  70973. */
  70974. text: string;
  70975. /**
  70976. * Callback called when the task is successful
  70977. */
  70978. onSuccess: (task: TextFileAssetTask) => void;
  70979. /**
  70980. * Callback called when the task is successful
  70981. */
  70982. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70983. /**
  70984. * Creates a new TextFileAssetTask object
  70985. * @param name defines the name of the task
  70986. * @param url defines the location of the file to load
  70987. */
  70988. constructor(
  70989. /**
  70990. * Defines the name of the task
  70991. */
  70992. name: string,
  70993. /**
  70994. * Defines the location of the file to load
  70995. */
  70996. url: string);
  70997. /**
  70998. * Execute the current task
  70999. * @param scene defines the scene where you want your assets to be loaded
  71000. * @param onSuccess is a callback called when the task is successfully executed
  71001. * @param onError is a callback called if an error occurs
  71002. */
  71003. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71004. }
  71005. /**
  71006. * Define a task used by AssetsManager to load binary data
  71007. */
  71008. export class BinaryFileAssetTask extends AbstractAssetTask {
  71009. /**
  71010. * Defines the name of the task
  71011. */
  71012. name: string;
  71013. /**
  71014. * Defines the location of the file to load
  71015. */
  71016. url: string;
  71017. /**
  71018. * Gets the lodaded data (as an array buffer)
  71019. */
  71020. data: ArrayBuffer;
  71021. /**
  71022. * Callback called when the task is successful
  71023. */
  71024. onSuccess: (task: BinaryFileAssetTask) => void;
  71025. /**
  71026. * Callback called when the task is successful
  71027. */
  71028. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71029. /**
  71030. * Creates a new BinaryFileAssetTask object
  71031. * @param name defines the name of the new task
  71032. * @param url defines the location of the file to load
  71033. */
  71034. constructor(
  71035. /**
  71036. * Defines the name of the task
  71037. */
  71038. name: string,
  71039. /**
  71040. * Defines the location of the file to load
  71041. */
  71042. url: string);
  71043. /**
  71044. * Execute the current task
  71045. * @param scene defines the scene where you want your assets to be loaded
  71046. * @param onSuccess is a callback called when the task is successfully executed
  71047. * @param onError is a callback called if an error occurs
  71048. */
  71049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71050. }
  71051. /**
  71052. * Define a task used by AssetsManager to load images
  71053. */
  71054. export class ImageAssetTask extends AbstractAssetTask {
  71055. /**
  71056. * Defines the name of the task
  71057. */
  71058. name: string;
  71059. /**
  71060. * Defines the location of the image to load
  71061. */
  71062. url: string;
  71063. /**
  71064. * Gets the loaded images
  71065. */
  71066. image: HTMLImageElement;
  71067. /**
  71068. * Callback called when the task is successful
  71069. */
  71070. onSuccess: (task: ImageAssetTask) => void;
  71071. /**
  71072. * Callback called when the task is successful
  71073. */
  71074. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71075. /**
  71076. * Creates a new ImageAssetTask
  71077. * @param name defines the name of the task
  71078. * @param url defines the location of the image to load
  71079. */
  71080. constructor(
  71081. /**
  71082. * Defines the name of the task
  71083. */
  71084. name: string,
  71085. /**
  71086. * Defines the location of the image to load
  71087. */
  71088. url: string);
  71089. /**
  71090. * Execute the current task
  71091. * @param scene defines the scene where you want your assets to be loaded
  71092. * @param onSuccess is a callback called when the task is successfully executed
  71093. * @param onError is a callback called if an error occurs
  71094. */
  71095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71096. }
  71097. /**
  71098. * Defines the interface used by texture loading tasks
  71099. */
  71100. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71101. /**
  71102. * Gets the loaded texture
  71103. */
  71104. texture: TEX;
  71105. }
  71106. /**
  71107. * Define a task used by AssetsManager to load 2D textures
  71108. */
  71109. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71110. /**
  71111. * Defines the name of the task
  71112. */
  71113. name: string;
  71114. /**
  71115. * Defines the location of the file to load
  71116. */
  71117. url: string;
  71118. /**
  71119. * Defines if mipmap should not be generated (default is false)
  71120. */
  71121. noMipmap?: boolean | undefined;
  71122. /**
  71123. * Defines if texture must be inverted on Y axis (default is false)
  71124. */
  71125. invertY?: boolean | undefined;
  71126. /**
  71127. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71128. */
  71129. samplingMode: number;
  71130. /**
  71131. * Gets the loaded texture
  71132. */
  71133. texture: Texture;
  71134. /**
  71135. * Callback called when the task is successful
  71136. */
  71137. onSuccess: (task: TextureAssetTask) => void;
  71138. /**
  71139. * Callback called when the task is successful
  71140. */
  71141. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71142. /**
  71143. * Creates a new TextureAssetTask object
  71144. * @param name defines the name of the task
  71145. * @param url defines the location of the file to load
  71146. * @param noMipmap defines if mipmap should not be generated (default is false)
  71147. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71148. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71149. */
  71150. constructor(
  71151. /**
  71152. * Defines the name of the task
  71153. */
  71154. name: string,
  71155. /**
  71156. * Defines the location of the file to load
  71157. */
  71158. url: string,
  71159. /**
  71160. * Defines if mipmap should not be generated (default is false)
  71161. */
  71162. noMipmap?: boolean | undefined,
  71163. /**
  71164. * Defines if texture must be inverted on Y axis (default is false)
  71165. */
  71166. invertY?: boolean | undefined,
  71167. /**
  71168. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71169. */
  71170. samplingMode?: number);
  71171. /**
  71172. * Execute the current task
  71173. * @param scene defines the scene where you want your assets to be loaded
  71174. * @param onSuccess is a callback called when the task is successfully executed
  71175. * @param onError is a callback called if an error occurs
  71176. */
  71177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71178. }
  71179. /**
  71180. * Define a task used by AssetsManager to load cube textures
  71181. */
  71182. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71183. /**
  71184. * Defines the name of the task
  71185. */
  71186. name: string;
  71187. /**
  71188. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71189. */
  71190. url: string;
  71191. /**
  71192. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71193. */
  71194. extensions?: string[] | undefined;
  71195. /**
  71196. * Defines if mipmaps should not be generated (default is false)
  71197. */
  71198. noMipmap?: boolean | undefined;
  71199. /**
  71200. * Defines the explicit list of files (undefined by default)
  71201. */
  71202. files?: string[] | undefined;
  71203. /**
  71204. * Gets the loaded texture
  71205. */
  71206. texture: CubeTexture;
  71207. /**
  71208. * Callback called when the task is successful
  71209. */
  71210. onSuccess: (task: CubeTextureAssetTask) => void;
  71211. /**
  71212. * Callback called when the task is successful
  71213. */
  71214. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71215. /**
  71216. * Creates a new CubeTextureAssetTask
  71217. * @param name defines the name of the task
  71218. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71219. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71220. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71221. * @param files defines the explicit list of files (undefined by default)
  71222. */
  71223. constructor(
  71224. /**
  71225. * Defines the name of the task
  71226. */
  71227. name: string,
  71228. /**
  71229. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71230. */
  71231. url: string,
  71232. /**
  71233. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71234. */
  71235. extensions?: string[] | undefined,
  71236. /**
  71237. * Defines if mipmaps should not be generated (default is false)
  71238. */
  71239. noMipmap?: boolean | undefined,
  71240. /**
  71241. * Defines the explicit list of files (undefined by default)
  71242. */
  71243. files?: string[] | undefined);
  71244. /**
  71245. * Execute the current task
  71246. * @param scene defines the scene where you want your assets to be loaded
  71247. * @param onSuccess is a callback called when the task is successfully executed
  71248. * @param onError is a callback called if an error occurs
  71249. */
  71250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71251. }
  71252. /**
  71253. * Define a task used by AssetsManager to load HDR cube textures
  71254. */
  71255. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71256. /**
  71257. * Defines the name of the task
  71258. */
  71259. name: string;
  71260. /**
  71261. * Defines the location of the file to load
  71262. */
  71263. url: string;
  71264. /**
  71265. * Defines the desired size (the more it increases the longer the generation will be)
  71266. */
  71267. size: number;
  71268. /**
  71269. * Defines if mipmaps should not be generated (default is false)
  71270. */
  71271. noMipmap: boolean;
  71272. /**
  71273. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71274. */
  71275. generateHarmonics: boolean;
  71276. /**
  71277. * 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)
  71278. */
  71279. gammaSpace: boolean;
  71280. /**
  71281. * Internal Use Only
  71282. */
  71283. reserved: boolean;
  71284. /**
  71285. * Gets the loaded texture
  71286. */
  71287. texture: HDRCubeTexture;
  71288. /**
  71289. * Callback called when the task is successful
  71290. */
  71291. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71292. /**
  71293. * Callback called when the task is successful
  71294. */
  71295. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71296. /**
  71297. * Creates a new HDRCubeTextureAssetTask object
  71298. * @param name defines the name of the task
  71299. * @param url defines the location of the file to load
  71300. * @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.
  71301. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71302. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71303. * @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)
  71304. * @param reserved Internal use only
  71305. */
  71306. constructor(
  71307. /**
  71308. * Defines the name of the task
  71309. */
  71310. name: string,
  71311. /**
  71312. * Defines the location of the file to load
  71313. */
  71314. url: string,
  71315. /**
  71316. * Defines the desired size (the more it increases the longer the generation will be)
  71317. */
  71318. size: number,
  71319. /**
  71320. * Defines if mipmaps should not be generated (default is false)
  71321. */
  71322. noMipmap?: boolean,
  71323. /**
  71324. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71325. */
  71326. generateHarmonics?: boolean,
  71327. /**
  71328. * 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)
  71329. */
  71330. gammaSpace?: boolean,
  71331. /**
  71332. * Internal Use Only
  71333. */
  71334. reserved?: boolean);
  71335. /**
  71336. * Execute the current task
  71337. * @param scene defines the scene where you want your assets to be loaded
  71338. * @param onSuccess is a callback called when the task is successfully executed
  71339. * @param onError is a callback called if an error occurs
  71340. */
  71341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71342. }
  71343. /**
  71344. * Define a task used by AssetsManager to load Equirectangular cube textures
  71345. */
  71346. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71347. /**
  71348. * Defines the name of the task
  71349. */
  71350. name: string;
  71351. /**
  71352. * Defines the location of the file to load
  71353. */
  71354. url: string;
  71355. /**
  71356. * Defines the desired size (the more it increases the longer the generation will be)
  71357. */
  71358. size: number;
  71359. /**
  71360. * Defines if mipmaps should not be generated (default is false)
  71361. */
  71362. noMipmap: boolean;
  71363. /**
  71364. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71365. * but the standard material would require them in Gamma space) (default is true)
  71366. */
  71367. gammaSpace: boolean;
  71368. /**
  71369. * Gets the loaded texture
  71370. */
  71371. texture: EquiRectangularCubeTexture;
  71372. /**
  71373. * Callback called when the task is successful
  71374. */
  71375. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71376. /**
  71377. * Callback called when the task is successful
  71378. */
  71379. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71380. /**
  71381. * Creates a new EquiRectangularCubeTextureAssetTask object
  71382. * @param name defines the name of the task
  71383. * @param url defines the location of the file to load
  71384. * @param size defines the desired size (the more it increases the longer the generation will be)
  71385. * If the size is omitted this implies you are using a preprocessed cubemap.
  71386. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71387. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71388. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71389. * (default is true)
  71390. */
  71391. constructor(
  71392. /**
  71393. * Defines the name of the task
  71394. */
  71395. name: string,
  71396. /**
  71397. * Defines the location of the file to load
  71398. */
  71399. url: string,
  71400. /**
  71401. * Defines the desired size (the more it increases the longer the generation will be)
  71402. */
  71403. size: number,
  71404. /**
  71405. * Defines if mipmaps should not be generated (default is false)
  71406. */
  71407. noMipmap?: boolean,
  71408. /**
  71409. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71410. * but the standard material would require them in Gamma space) (default is true)
  71411. */
  71412. gammaSpace?: boolean);
  71413. /**
  71414. * Execute the current task
  71415. * @param scene defines the scene where you want your assets to be loaded
  71416. * @param onSuccess is a callback called when the task is successfully executed
  71417. * @param onError is a callback called if an error occurs
  71418. */
  71419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71420. }
  71421. /**
  71422. * This class can be used to easily import assets into a scene
  71423. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71424. */
  71425. export class AssetsManager {
  71426. private _scene;
  71427. private _isLoading;
  71428. protected _tasks: AbstractAssetTask[];
  71429. protected _waitingTasksCount: number;
  71430. protected _totalTasksCount: number;
  71431. /**
  71432. * Callback called when all tasks are processed
  71433. */
  71434. onFinish: (tasks: AbstractAssetTask[]) => void;
  71435. /**
  71436. * Callback called when a task is successful
  71437. */
  71438. onTaskSuccess: (task: AbstractAssetTask) => void;
  71439. /**
  71440. * Callback called when a task had an error
  71441. */
  71442. onTaskError: (task: AbstractAssetTask) => void;
  71443. /**
  71444. * Callback called when a task is done (whatever the result is)
  71445. */
  71446. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71447. /**
  71448. * Observable called when all tasks are processed
  71449. */
  71450. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71451. /**
  71452. * Observable called when a task had an error
  71453. */
  71454. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71455. /**
  71456. * Observable called when all tasks were executed
  71457. */
  71458. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71459. /**
  71460. * Observable called when a task is done (whatever the result is)
  71461. */
  71462. onProgressObservable: Observable<IAssetsProgressEvent>;
  71463. /**
  71464. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71465. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71466. */
  71467. useDefaultLoadingScreen: boolean;
  71468. /**
  71469. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71470. * when all assets have been downloaded.
  71471. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71472. */
  71473. autoHideLoadingUI: boolean;
  71474. /**
  71475. * Creates a new AssetsManager
  71476. * @param scene defines the scene to work on
  71477. */
  71478. constructor(scene: Scene);
  71479. /**
  71480. * Add a MeshAssetTask to the list of active tasks
  71481. * @param taskName defines the name of the new task
  71482. * @param meshesNames defines the name of meshes to load
  71483. * @param rootUrl defines the root url to use to locate files
  71484. * @param sceneFilename defines the filename of the scene file
  71485. * @returns a new MeshAssetTask object
  71486. */
  71487. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71488. /**
  71489. * Add a TextFileAssetTask to the list of active tasks
  71490. * @param taskName defines the name of the new task
  71491. * @param url defines the url of the file to load
  71492. * @returns a new TextFileAssetTask object
  71493. */
  71494. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71495. /**
  71496. * Add a BinaryFileAssetTask 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. * @returns a new BinaryFileAssetTask object
  71500. */
  71501. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71502. /**
  71503. * Add a ImageAssetTask to the list of active tasks
  71504. * @param taskName defines the name of the new task
  71505. * @param url defines the url of the file to load
  71506. * @returns a new ImageAssetTask object
  71507. */
  71508. addImageTask(taskName: string, url: string): ImageAssetTask;
  71509. /**
  71510. * Add a TextureAssetTask to the list of active tasks
  71511. * @param taskName defines the name of the new task
  71512. * @param url defines the url of the file to load
  71513. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71514. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71515. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71516. * @returns a new TextureAssetTask object
  71517. */
  71518. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71519. /**
  71520. * Add a CubeTextureAssetTask to the list of active tasks
  71521. * @param taskName defines the name of the new task
  71522. * @param url defines the url of the file to load
  71523. * @param extensions defines the extension to use to load the cube map (can be null)
  71524. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71525. * @param files defines the list of files to load (can be null)
  71526. * @returns a new CubeTextureAssetTask object
  71527. */
  71528. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71529. /**
  71530. *
  71531. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71532. * @param taskName defines the name of the new task
  71533. * @param url defines the url of the file to load
  71534. * @param size defines the size you want for the cubemap (can be null)
  71535. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71536. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71537. * @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)
  71538. * @param reserved Internal use only
  71539. * @returns a new HDRCubeTextureAssetTask object
  71540. */
  71541. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71542. /**
  71543. *
  71544. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71545. * @param taskName defines the name of the new task
  71546. * @param url defines the url of the file to load
  71547. * @param size defines the size you want for the cubemap (can be null)
  71548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71549. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71550. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71551. * @returns a new EquiRectangularCubeTextureAssetTask object
  71552. */
  71553. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71554. /**
  71555. * Remove a task from the assets manager.
  71556. * @param task the task to remove
  71557. */
  71558. removeTask(task: AbstractAssetTask): void;
  71559. private _decreaseWaitingTasksCount;
  71560. private _runTask;
  71561. /**
  71562. * Reset the AssetsManager and remove all tasks
  71563. * @return the current instance of the AssetsManager
  71564. */
  71565. reset(): AssetsManager;
  71566. /**
  71567. * Start the loading process
  71568. * @return the current instance of the AssetsManager
  71569. */
  71570. load(): AssetsManager;
  71571. /**
  71572. * Start the loading process as an async operation
  71573. * @return a promise returning the list of failed tasks
  71574. */
  71575. loadAsync(): Promise<void>;
  71576. }
  71577. }
  71578. declare module "babylonjs/Misc/deferred" {
  71579. /**
  71580. * Wrapper class for promise with external resolve and reject.
  71581. */
  71582. export class Deferred<T> {
  71583. /**
  71584. * The promise associated with this deferred object.
  71585. */
  71586. readonly promise: Promise<T>;
  71587. private _resolve;
  71588. private _reject;
  71589. /**
  71590. * The resolve method of the promise associated with this deferred object.
  71591. */
  71592. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71593. /**
  71594. * The reject method of the promise associated with this deferred object.
  71595. */
  71596. get reject(): (reason?: any) => void;
  71597. /**
  71598. * Constructor for this deferred object.
  71599. */
  71600. constructor();
  71601. }
  71602. }
  71603. declare module "babylonjs/Misc/meshExploder" {
  71604. import { Mesh } from "babylonjs/Meshes/mesh";
  71605. /**
  71606. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71607. */
  71608. export class MeshExploder {
  71609. private _centerMesh;
  71610. private _meshes;
  71611. private _meshesOrigins;
  71612. private _toCenterVectors;
  71613. private _scaledDirection;
  71614. private _newPosition;
  71615. private _centerPosition;
  71616. /**
  71617. * Explodes meshes from a center mesh.
  71618. * @param meshes The meshes to explode.
  71619. * @param centerMesh The mesh to be center of explosion.
  71620. */
  71621. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71622. private _setCenterMesh;
  71623. /**
  71624. * Get class name
  71625. * @returns "MeshExploder"
  71626. */
  71627. getClassName(): string;
  71628. /**
  71629. * "Exploded meshes"
  71630. * @returns Array of meshes with the centerMesh at index 0.
  71631. */
  71632. getMeshes(): Array<Mesh>;
  71633. /**
  71634. * Explodes meshes giving a specific direction
  71635. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71636. */
  71637. explode(direction?: number): void;
  71638. }
  71639. }
  71640. declare module "babylonjs/Misc/filesInput" {
  71641. import { Engine } from "babylonjs/Engines/engine";
  71642. import { Scene } from "babylonjs/scene";
  71643. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71644. /**
  71645. * Class used to help managing file picking and drag'n'drop
  71646. */
  71647. export class FilesInput {
  71648. /**
  71649. * List of files ready to be loaded
  71650. */
  71651. static get FilesToLoad(): {
  71652. [key: string]: File;
  71653. };
  71654. /**
  71655. * Callback called when a file is processed
  71656. */
  71657. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71658. private _engine;
  71659. private _currentScene;
  71660. private _sceneLoadedCallback;
  71661. private _progressCallback;
  71662. private _additionalRenderLoopLogicCallback;
  71663. private _textureLoadingCallback;
  71664. private _startingProcessingFilesCallback;
  71665. private _onReloadCallback;
  71666. private _errorCallback;
  71667. private _elementToMonitor;
  71668. private _sceneFileToLoad;
  71669. private _filesToLoad;
  71670. /**
  71671. * Creates a new FilesInput
  71672. * @param engine defines the rendering engine
  71673. * @param scene defines the hosting scene
  71674. * @param sceneLoadedCallback callback called when scene is loaded
  71675. * @param progressCallback callback called to track progress
  71676. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71677. * @param textureLoadingCallback callback called when a texture is loading
  71678. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71679. * @param onReloadCallback callback called when a reload is requested
  71680. * @param errorCallback callback call if an error occurs
  71681. */
  71682. 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);
  71683. private _dragEnterHandler;
  71684. private _dragOverHandler;
  71685. private _dropHandler;
  71686. /**
  71687. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71688. * @param elementToMonitor defines the DOM element to track
  71689. */
  71690. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71691. /**
  71692. * Release all associated resources
  71693. */
  71694. dispose(): void;
  71695. private renderFunction;
  71696. private drag;
  71697. private drop;
  71698. private _traverseFolder;
  71699. private _processFiles;
  71700. /**
  71701. * Load files from a drop event
  71702. * @param event defines the drop event to use as source
  71703. */
  71704. loadFiles(event: any): void;
  71705. private _processReload;
  71706. /**
  71707. * Reload the current scene from the loaded files
  71708. */
  71709. reload(): void;
  71710. }
  71711. }
  71712. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71713. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71714. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71715. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71716. }
  71717. declare module "babylonjs/Misc/sceneOptimizer" {
  71718. import { Scene, IDisposable } from "babylonjs/scene";
  71719. import { Observable } from "babylonjs/Misc/observable";
  71720. /**
  71721. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71723. */
  71724. export class SceneOptimization {
  71725. /**
  71726. * Defines the priority of this optimization (0 by default which means first in the list)
  71727. */
  71728. priority: number;
  71729. /**
  71730. * Gets a string describing the action executed by the current optimization
  71731. * @returns description string
  71732. */
  71733. getDescription(): string;
  71734. /**
  71735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71736. * @param scene defines the current scene where to apply this optimization
  71737. * @param optimizer defines the current optimizer
  71738. * @returns true if everything that can be done was applied
  71739. */
  71740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71741. /**
  71742. * Creates the SceneOptimization object
  71743. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71744. * @param desc defines the description associated with the optimization
  71745. */
  71746. constructor(
  71747. /**
  71748. * Defines the priority of this optimization (0 by default which means first in the list)
  71749. */
  71750. priority?: number);
  71751. }
  71752. /**
  71753. * Defines an optimization used to reduce the size of render target textures
  71754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71755. */
  71756. export class TextureOptimization extends SceneOptimization {
  71757. /**
  71758. * Defines the priority of this optimization (0 by default which means first in the list)
  71759. */
  71760. priority: number;
  71761. /**
  71762. * 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
  71763. */
  71764. maximumSize: number;
  71765. /**
  71766. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71767. */
  71768. step: number;
  71769. /**
  71770. * Gets a string describing the action executed by the current optimization
  71771. * @returns description string
  71772. */
  71773. getDescription(): string;
  71774. /**
  71775. * Creates the TextureOptimization object
  71776. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71777. * @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
  71778. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71779. */
  71780. constructor(
  71781. /**
  71782. * Defines the priority of this optimization (0 by default which means first in the list)
  71783. */
  71784. priority?: number,
  71785. /**
  71786. * 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
  71787. */
  71788. maximumSize?: number,
  71789. /**
  71790. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71791. */
  71792. step?: number);
  71793. /**
  71794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71795. * @param scene defines the current scene where to apply this optimization
  71796. * @param optimizer defines the current optimizer
  71797. * @returns true if everything that can be done was applied
  71798. */
  71799. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71800. }
  71801. /**
  71802. * Defines an optimization used to increase or decrease the rendering resolution
  71803. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71804. */
  71805. export class HardwareScalingOptimization extends SceneOptimization {
  71806. /**
  71807. * Defines the priority of this optimization (0 by default which means first in the list)
  71808. */
  71809. priority: number;
  71810. /**
  71811. * Defines the maximum scale to use (2 by default)
  71812. */
  71813. maximumScale: number;
  71814. /**
  71815. * Defines the step to use between two passes (0.5 by default)
  71816. */
  71817. step: number;
  71818. private _currentScale;
  71819. private _directionOffset;
  71820. /**
  71821. * Gets a string describing the action executed by the current optimization
  71822. * @return description string
  71823. */
  71824. getDescription(): string;
  71825. /**
  71826. * Creates the HardwareScalingOptimization object
  71827. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71828. * @param maximumScale defines the maximum scale to use (2 by default)
  71829. * @param step defines the step to use between two passes (0.5 by default)
  71830. */
  71831. constructor(
  71832. /**
  71833. * Defines the priority of this optimization (0 by default which means first in the list)
  71834. */
  71835. priority?: number,
  71836. /**
  71837. * Defines the maximum scale to use (2 by default)
  71838. */
  71839. maximumScale?: number,
  71840. /**
  71841. * Defines the step to use between two passes (0.5 by default)
  71842. */
  71843. step?: number);
  71844. /**
  71845. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71846. * @param scene defines the current scene where to apply this optimization
  71847. * @param optimizer defines the current optimizer
  71848. * @returns true if everything that can be done was applied
  71849. */
  71850. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71851. }
  71852. /**
  71853. * Defines an optimization used to remove shadows
  71854. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71855. */
  71856. export class ShadowsOptimization extends SceneOptimization {
  71857. /**
  71858. * Gets a string describing the action executed by the current optimization
  71859. * @return description string
  71860. */
  71861. getDescription(): string;
  71862. /**
  71863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71864. * @param scene defines the current scene where to apply this optimization
  71865. * @param optimizer defines the current optimizer
  71866. * @returns true if everything that can be done was applied
  71867. */
  71868. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71869. }
  71870. /**
  71871. * Defines an optimization used to turn post-processes off
  71872. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71873. */
  71874. export class PostProcessesOptimization extends SceneOptimization {
  71875. /**
  71876. * Gets a string describing the action executed by the current optimization
  71877. * @return description string
  71878. */
  71879. getDescription(): string;
  71880. /**
  71881. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71882. * @param scene defines the current scene where to apply this optimization
  71883. * @param optimizer defines the current optimizer
  71884. * @returns true if everything that can be done was applied
  71885. */
  71886. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71887. }
  71888. /**
  71889. * Defines an optimization used to turn lens flares off
  71890. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71891. */
  71892. export class LensFlaresOptimization extends SceneOptimization {
  71893. /**
  71894. * Gets a string describing the action executed by the current optimization
  71895. * @return description string
  71896. */
  71897. getDescription(): string;
  71898. /**
  71899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71900. * @param scene defines the current scene where to apply this optimization
  71901. * @param optimizer defines the current optimizer
  71902. * @returns true if everything that can be done was applied
  71903. */
  71904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71905. }
  71906. /**
  71907. * Defines an optimization based on user defined callback.
  71908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71909. */
  71910. export class CustomOptimization extends SceneOptimization {
  71911. /**
  71912. * Callback called to apply the custom optimization.
  71913. */
  71914. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71915. /**
  71916. * Callback called to get custom description
  71917. */
  71918. onGetDescription: () => string;
  71919. /**
  71920. * Gets a string describing the action executed by the current optimization
  71921. * @returns description string
  71922. */
  71923. getDescription(): string;
  71924. /**
  71925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71926. * @param scene defines the current scene where to apply this optimization
  71927. * @param optimizer defines the current optimizer
  71928. * @returns true if everything that can be done was applied
  71929. */
  71930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71931. }
  71932. /**
  71933. * Defines an optimization used to turn particles off
  71934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71935. */
  71936. export class ParticlesOptimization extends SceneOptimization {
  71937. /**
  71938. * Gets a string describing the action executed by the current optimization
  71939. * @return description string
  71940. */
  71941. getDescription(): string;
  71942. /**
  71943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71944. * @param scene defines the current scene where to apply this optimization
  71945. * @param optimizer defines the current optimizer
  71946. * @returns true if everything that can be done was applied
  71947. */
  71948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71949. }
  71950. /**
  71951. * Defines an optimization used to turn render targets off
  71952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71953. */
  71954. export class RenderTargetsOptimization extends SceneOptimization {
  71955. /**
  71956. * Gets a string describing the action executed by the current optimization
  71957. * @return description string
  71958. */
  71959. getDescription(): string;
  71960. /**
  71961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71962. * @param scene defines the current scene where to apply this optimization
  71963. * @param optimizer defines the current optimizer
  71964. * @returns true if everything that can be done was applied
  71965. */
  71966. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71967. }
  71968. /**
  71969. * Defines an optimization used to merge meshes with compatible materials
  71970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71971. */
  71972. export class MergeMeshesOptimization extends SceneOptimization {
  71973. private static _UpdateSelectionTree;
  71974. /**
  71975. * Gets or sets a boolean which defines if optimization octree has to be updated
  71976. */
  71977. static get UpdateSelectionTree(): boolean;
  71978. /**
  71979. * Gets or sets a boolean which defines if optimization octree has to be updated
  71980. */
  71981. static set UpdateSelectionTree(value: boolean);
  71982. /**
  71983. * Gets a string describing the action executed by the current optimization
  71984. * @return description string
  71985. */
  71986. getDescription(): string;
  71987. private _canBeMerged;
  71988. /**
  71989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71990. * @param scene defines the current scene where to apply this optimization
  71991. * @param optimizer defines the current optimizer
  71992. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71993. * @returns true if everything that can be done was applied
  71994. */
  71995. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71996. }
  71997. /**
  71998. * Defines a list of options used by SceneOptimizer
  71999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72000. */
  72001. export class SceneOptimizerOptions {
  72002. /**
  72003. * Defines the target frame rate to reach (60 by default)
  72004. */
  72005. targetFrameRate: number;
  72006. /**
  72007. * Defines the interval between two checkes (2000ms by default)
  72008. */
  72009. trackerDuration: number;
  72010. /**
  72011. * Gets the list of optimizations to apply
  72012. */
  72013. optimizations: SceneOptimization[];
  72014. /**
  72015. * Creates a new list of options used by SceneOptimizer
  72016. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72017. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72018. */
  72019. constructor(
  72020. /**
  72021. * Defines the target frame rate to reach (60 by default)
  72022. */
  72023. targetFrameRate?: number,
  72024. /**
  72025. * Defines the interval between two checkes (2000ms by default)
  72026. */
  72027. trackerDuration?: number);
  72028. /**
  72029. * Add a new optimization
  72030. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72031. * @returns the current SceneOptimizerOptions
  72032. */
  72033. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72034. /**
  72035. * Add a new custom optimization
  72036. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72037. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72039. * @returns the current SceneOptimizerOptions
  72040. */
  72041. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72042. /**
  72043. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72044. * @param targetFrameRate defines the target frame rate (60 by default)
  72045. * @returns a SceneOptimizerOptions object
  72046. */
  72047. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72048. /**
  72049. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72050. * @param targetFrameRate defines the target frame rate (60 by default)
  72051. * @returns a SceneOptimizerOptions object
  72052. */
  72053. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72054. /**
  72055. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72056. * @param targetFrameRate defines the target frame rate (60 by default)
  72057. * @returns a SceneOptimizerOptions object
  72058. */
  72059. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72060. }
  72061. /**
  72062. * Class used to run optimizations in order to reach a target frame rate
  72063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72064. */
  72065. export class SceneOptimizer implements IDisposable {
  72066. private _isRunning;
  72067. private _options;
  72068. private _scene;
  72069. private _currentPriorityLevel;
  72070. private _targetFrameRate;
  72071. private _trackerDuration;
  72072. private _currentFrameRate;
  72073. private _sceneDisposeObserver;
  72074. private _improvementMode;
  72075. /**
  72076. * Defines an observable called when the optimizer reaches the target frame rate
  72077. */
  72078. onSuccessObservable: Observable<SceneOptimizer>;
  72079. /**
  72080. * Defines an observable called when the optimizer enables an optimization
  72081. */
  72082. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72083. /**
  72084. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72085. */
  72086. onFailureObservable: Observable<SceneOptimizer>;
  72087. /**
  72088. * Gets a boolean indicating if the optimizer is in improvement mode
  72089. */
  72090. get isInImprovementMode(): boolean;
  72091. /**
  72092. * Gets the current priority level (0 at start)
  72093. */
  72094. get currentPriorityLevel(): number;
  72095. /**
  72096. * Gets the current frame rate checked by the SceneOptimizer
  72097. */
  72098. get currentFrameRate(): number;
  72099. /**
  72100. * Gets or sets the current target frame rate (60 by default)
  72101. */
  72102. get targetFrameRate(): number;
  72103. /**
  72104. * Gets or sets the current target frame rate (60 by default)
  72105. */
  72106. set targetFrameRate(value: number);
  72107. /**
  72108. * Gets or sets the current interval between two checks (every 2000ms by default)
  72109. */
  72110. get trackerDuration(): number;
  72111. /**
  72112. * Gets or sets the current interval between two checks (every 2000ms by default)
  72113. */
  72114. set trackerDuration(value: number);
  72115. /**
  72116. * Gets the list of active optimizations
  72117. */
  72118. get optimizations(): SceneOptimization[];
  72119. /**
  72120. * Creates a new SceneOptimizer
  72121. * @param scene defines the scene to work on
  72122. * @param options defines the options to use with the SceneOptimizer
  72123. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72124. * @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)
  72125. */
  72126. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72127. /**
  72128. * Stops the current optimizer
  72129. */
  72130. stop(): void;
  72131. /**
  72132. * Reset the optimizer to initial step (current priority level = 0)
  72133. */
  72134. reset(): void;
  72135. /**
  72136. * Start the optimizer. By default it will try to reach a specific framerate
  72137. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72138. */
  72139. start(): void;
  72140. private _checkCurrentState;
  72141. /**
  72142. * Release all resources
  72143. */
  72144. dispose(): void;
  72145. /**
  72146. * Helper function to create a SceneOptimizer with one single line of code
  72147. * @param scene defines the scene to work on
  72148. * @param options defines the options to use with the SceneOptimizer
  72149. * @param onSuccess defines a callback to call on success
  72150. * @param onFailure defines a callback to call on failure
  72151. * @returns the new SceneOptimizer object
  72152. */
  72153. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72154. }
  72155. }
  72156. declare module "babylonjs/Misc/sceneSerializer" {
  72157. import { Scene } from "babylonjs/scene";
  72158. /**
  72159. * Class used to serialize a scene into a string
  72160. */
  72161. export class SceneSerializer {
  72162. /**
  72163. * Clear cache used by a previous serialization
  72164. */
  72165. static ClearCache(): void;
  72166. /**
  72167. * Serialize a scene into a JSON compatible object
  72168. * @param scene defines the scene to serialize
  72169. * @returns a JSON compatible object
  72170. */
  72171. static Serialize(scene: Scene): any;
  72172. /**
  72173. * Serialize a mesh into a JSON compatible object
  72174. * @param toSerialize defines the mesh to serialize
  72175. * @param withParents defines if parents must be serialized as well
  72176. * @param withChildren defines if children must be serialized as well
  72177. * @returns a JSON compatible object
  72178. */
  72179. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72180. }
  72181. }
  72182. declare module "babylonjs/Misc/textureTools" {
  72183. import { Texture } from "babylonjs/Materials/Textures/texture";
  72184. /**
  72185. * Class used to host texture specific utilities
  72186. */
  72187. export class TextureTools {
  72188. /**
  72189. * Uses the GPU to create a copy texture rescaled at a given size
  72190. * @param texture Texture to copy from
  72191. * @param width defines the desired width
  72192. * @param height defines the desired height
  72193. * @param useBilinearMode defines if bilinear mode has to be used
  72194. * @return the generated texture
  72195. */
  72196. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72197. }
  72198. }
  72199. declare module "babylonjs/Misc/videoRecorder" {
  72200. import { Nullable } from "babylonjs/types";
  72201. import { Engine } from "babylonjs/Engines/engine";
  72202. /**
  72203. * This represents the different options available for the video capture.
  72204. */
  72205. export interface VideoRecorderOptions {
  72206. /** Defines the mime type of the video. */
  72207. mimeType: string;
  72208. /** Defines the FPS the video should be recorded at. */
  72209. fps: number;
  72210. /** Defines the chunk size for the recording data. */
  72211. recordChunckSize: number;
  72212. /** The audio tracks to attach to the recording. */
  72213. audioTracks?: MediaStreamTrack[];
  72214. }
  72215. /**
  72216. * This can help with recording videos from BabylonJS.
  72217. * This is based on the available WebRTC functionalities of the browser.
  72218. *
  72219. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72220. */
  72221. export class VideoRecorder {
  72222. private static readonly _defaultOptions;
  72223. /**
  72224. * Returns whether or not the VideoRecorder is available in your browser.
  72225. * @param engine Defines the Babylon Engine.
  72226. * @returns true if supported otherwise false.
  72227. */
  72228. static IsSupported(engine: Engine): boolean;
  72229. private readonly _options;
  72230. private _canvas;
  72231. private _mediaRecorder;
  72232. private _recordedChunks;
  72233. private _fileName;
  72234. private _resolve;
  72235. private _reject;
  72236. /**
  72237. * True when a recording is already in progress.
  72238. */
  72239. get isRecording(): boolean;
  72240. /**
  72241. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72242. * @param engine Defines the BabylonJS Engine you wish to record.
  72243. * @param options Defines options that can be used to customize the capture.
  72244. */
  72245. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72246. /**
  72247. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72248. */
  72249. stopRecording(): void;
  72250. /**
  72251. * Starts recording the canvas for a max duration specified in parameters.
  72252. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72253. * If null no automatic download will start and you can rely on the promise to get the data back.
  72254. * @param maxDuration Defines the maximum recording time in seconds.
  72255. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72256. * @return A promise callback at the end of the recording with the video data in Blob.
  72257. */
  72258. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72259. /**
  72260. * Releases internal resources used during the recording.
  72261. */
  72262. dispose(): void;
  72263. private _handleDataAvailable;
  72264. private _handleError;
  72265. private _handleStop;
  72266. }
  72267. }
  72268. declare module "babylonjs/Misc/screenshotTools" {
  72269. import { Camera } from "babylonjs/Cameras/camera";
  72270. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72271. import { Engine } from "babylonjs/Engines/engine";
  72272. /**
  72273. * Class containing a set of static utilities functions for screenshots
  72274. */
  72275. export class ScreenshotTools {
  72276. /**
  72277. * Captures a screenshot of the current rendering
  72278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72279. * @param engine defines the rendering engine
  72280. * @param camera defines the source camera
  72281. * @param size This parameter can be set to a single number or to an object with the
  72282. * following (optional) properties: precision, width, height. If a single number is passed,
  72283. * it will be used for both width and height. If an object is passed, the screenshot size
  72284. * will be derived from the parameters. The precision property is a multiplier allowing
  72285. * rendering at a higher or lower resolution
  72286. * @param successCallback defines the callback receives a single parameter which contains the
  72287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72288. * src parameter of an <img> to display it
  72289. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72290. * Check your browser for supported MIME types
  72291. */
  72292. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72293. /**
  72294. * Captures a screenshot of the current rendering
  72295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72296. * @param engine defines the rendering engine
  72297. * @param camera defines the source camera
  72298. * @param size This parameter can be set to a single number or to an object with the
  72299. * following (optional) properties: precision, width, height. If a single number is passed,
  72300. * it will be used for both width and height. If an object is passed, the screenshot size
  72301. * will be derived from the parameters. The precision property is a multiplier allowing
  72302. * rendering at a higher or lower resolution
  72303. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72304. * Check your browser for supported MIME types
  72305. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72306. * to the src parameter of an <img> to display it
  72307. */
  72308. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72309. /**
  72310. * Generates an image screenshot from the specified camera.
  72311. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72312. * @param engine The engine to use for rendering
  72313. * @param camera The camera to use for rendering
  72314. * @param size This parameter can be set to a single number or to an object with the
  72315. * following (optional) properties: precision, width, height. If a single number is passed,
  72316. * it will be used for both width and height. If an object is passed, the screenshot size
  72317. * will be derived from the parameters. The precision property is a multiplier allowing
  72318. * rendering at a higher or lower resolution
  72319. * @param successCallback The callback receives a single parameter which contains the
  72320. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72321. * src parameter of an <img> to display it
  72322. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72323. * Check your browser for supported MIME types
  72324. * @param samples Texture samples (default: 1)
  72325. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72326. * @param fileName A name for for the downloaded file.
  72327. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72328. */
  72329. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72330. /**
  72331. * Generates an image screenshot from the specified camera.
  72332. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72333. * @param engine The engine to use for rendering
  72334. * @param camera The camera to use for rendering
  72335. * @param size This parameter can be set to a single number or to an object with the
  72336. * following (optional) properties: precision, width, height. If a single number is passed,
  72337. * it will be used for both width and height. If an object is passed, the screenshot size
  72338. * will be derived from the parameters. The precision property is a multiplier allowing
  72339. * rendering at a higher or lower resolution
  72340. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72341. * Check your browser for supported MIME types
  72342. * @param samples Texture samples (default: 1)
  72343. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72344. * @param fileName A name for for the downloaded file.
  72345. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72346. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72347. * to the src parameter of an <img> to display it
  72348. */
  72349. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72350. /**
  72351. * Gets height and width for screenshot size
  72352. * @private
  72353. */
  72354. private static _getScreenshotSize;
  72355. }
  72356. }
  72357. declare module "babylonjs/Misc/dataReader" {
  72358. /**
  72359. * Interface for a data buffer
  72360. */
  72361. export interface IDataBuffer {
  72362. /**
  72363. * Reads bytes from the data buffer.
  72364. * @param byteOffset The byte offset to read
  72365. * @param byteLength The byte length to read
  72366. * @returns A promise that resolves when the bytes are read
  72367. */
  72368. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72369. /**
  72370. * The byte length of the buffer.
  72371. */
  72372. readonly byteLength: number;
  72373. }
  72374. /**
  72375. * Utility class for reading from a data buffer
  72376. */
  72377. export class DataReader {
  72378. /**
  72379. * The data buffer associated with this data reader.
  72380. */
  72381. readonly buffer: IDataBuffer;
  72382. /**
  72383. * The current byte offset from the beginning of the data buffer.
  72384. */
  72385. byteOffset: number;
  72386. private _dataView;
  72387. private _dataByteOffset;
  72388. /**
  72389. * Constructor
  72390. * @param buffer The buffer to read
  72391. */
  72392. constructor(buffer: IDataBuffer);
  72393. /**
  72394. * Loads the given byte length.
  72395. * @param byteLength The byte length to load
  72396. * @returns A promise that resolves when the load is complete
  72397. */
  72398. loadAsync(byteLength: number): Promise<void>;
  72399. /**
  72400. * Read a unsigned 32-bit integer from the currently loaded data range.
  72401. * @returns The 32-bit integer read
  72402. */
  72403. readUint32(): number;
  72404. /**
  72405. * Read a byte array from the currently loaded data range.
  72406. * @param byteLength The byte length to read
  72407. * @returns The byte array read
  72408. */
  72409. readUint8Array(byteLength: number): Uint8Array;
  72410. /**
  72411. * Read a string from the currently loaded data range.
  72412. * @param byteLength The byte length to read
  72413. * @returns The string read
  72414. */
  72415. readString(byteLength: number): string;
  72416. /**
  72417. * Skips the given byte length the currently loaded data range.
  72418. * @param byteLength The byte length to skip
  72419. */
  72420. skipBytes(byteLength: number): void;
  72421. }
  72422. }
  72423. declare module "babylonjs/Misc/dataStorage" {
  72424. /**
  72425. * Class for storing data to local storage if available or in-memory storage otherwise
  72426. */
  72427. export class DataStorage {
  72428. private static _Storage;
  72429. private static _GetStorage;
  72430. /**
  72431. * Reads a string from the data storage
  72432. * @param key The key to read
  72433. * @param defaultValue The value if the key doesn't exist
  72434. * @returns The string value
  72435. */
  72436. static ReadString(key: string, defaultValue: string): string;
  72437. /**
  72438. * Writes a string to the data storage
  72439. * @param key The key to write
  72440. * @param value The value to write
  72441. */
  72442. static WriteString(key: string, value: string): void;
  72443. /**
  72444. * Reads a boolean from the data storage
  72445. * @param key The key to read
  72446. * @param defaultValue The value if the key doesn't exist
  72447. * @returns The boolean value
  72448. */
  72449. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72450. /**
  72451. * Writes a boolean to the data storage
  72452. * @param key The key to write
  72453. * @param value The value to write
  72454. */
  72455. static WriteBoolean(key: string, value: boolean): void;
  72456. /**
  72457. * Reads a number from the data storage
  72458. * @param key The key to read
  72459. * @param defaultValue The value if the key doesn't exist
  72460. * @returns The number value
  72461. */
  72462. static ReadNumber(key: string, defaultValue: number): number;
  72463. /**
  72464. * Writes a number to the data storage
  72465. * @param key The key to write
  72466. * @param value The value to write
  72467. */
  72468. static WriteNumber(key: string, value: number): void;
  72469. }
  72470. }
  72471. declare module "babylonjs/Misc/index" {
  72472. export * from "babylonjs/Misc/andOrNotEvaluator";
  72473. export * from "babylonjs/Misc/assetsManager";
  72474. export * from "babylonjs/Misc/basis";
  72475. export * from "babylonjs/Misc/dds";
  72476. export * from "babylonjs/Misc/decorators";
  72477. export * from "babylonjs/Misc/deferred";
  72478. export * from "babylonjs/Misc/environmentTextureTools";
  72479. export * from "babylonjs/Misc/meshExploder";
  72480. export * from "babylonjs/Misc/filesInput";
  72481. export * from "babylonjs/Misc/HighDynamicRange/index";
  72482. export * from "babylonjs/Misc/khronosTextureContainer";
  72483. export * from "babylonjs/Misc/observable";
  72484. export * from "babylonjs/Misc/performanceMonitor";
  72485. export * from "babylonjs/Misc/promise";
  72486. export * from "babylonjs/Misc/sceneOptimizer";
  72487. export * from "babylonjs/Misc/sceneSerializer";
  72488. export * from "babylonjs/Misc/smartArray";
  72489. export * from "babylonjs/Misc/stringDictionary";
  72490. export * from "babylonjs/Misc/tags";
  72491. export * from "babylonjs/Misc/textureTools";
  72492. export * from "babylonjs/Misc/tga";
  72493. export * from "babylonjs/Misc/tools";
  72494. export * from "babylonjs/Misc/videoRecorder";
  72495. export * from "babylonjs/Misc/virtualJoystick";
  72496. export * from "babylonjs/Misc/workerPool";
  72497. export * from "babylonjs/Misc/logger";
  72498. export * from "babylonjs/Misc/typeStore";
  72499. export * from "babylonjs/Misc/filesInputStore";
  72500. export * from "babylonjs/Misc/deepCopier";
  72501. export * from "babylonjs/Misc/pivotTools";
  72502. export * from "babylonjs/Misc/precisionDate";
  72503. export * from "babylonjs/Misc/screenshotTools";
  72504. export * from "babylonjs/Misc/typeStore";
  72505. export * from "babylonjs/Misc/webRequest";
  72506. export * from "babylonjs/Misc/iInspectable";
  72507. export * from "babylonjs/Misc/brdfTextureTools";
  72508. export * from "babylonjs/Misc/rgbdTextureTools";
  72509. export * from "babylonjs/Misc/gradients";
  72510. export * from "babylonjs/Misc/perfCounter";
  72511. export * from "babylonjs/Misc/fileRequest";
  72512. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72513. export * from "babylonjs/Misc/retryStrategy";
  72514. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72515. export * from "babylonjs/Misc/canvasGenerator";
  72516. export * from "babylonjs/Misc/fileTools";
  72517. export * from "babylonjs/Misc/stringTools";
  72518. export * from "babylonjs/Misc/dataReader";
  72519. export * from "babylonjs/Misc/minMaxReducer";
  72520. export * from "babylonjs/Misc/depthReducer";
  72521. export * from "babylonjs/Misc/dataStorage";
  72522. }
  72523. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72524. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72525. import { Observable } from "babylonjs/Misc/observable";
  72526. import { Matrix } from "babylonjs/Maths/math.vector";
  72527. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72528. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72529. /**
  72530. * Options used for hit testing
  72531. */
  72532. export interface IWebXRHitTestOptions {
  72533. /**
  72534. * Only test when user interacted with the scene. Default - hit test every frame
  72535. */
  72536. testOnPointerDownOnly?: boolean;
  72537. /**
  72538. * The node to use to transform the local results to world coordinates
  72539. */
  72540. worldParentNode?: TransformNode;
  72541. }
  72542. /**
  72543. * Interface defining the babylon result of raycasting/hit-test
  72544. */
  72545. export interface IWebXRHitResult {
  72546. /**
  72547. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72548. */
  72549. transformationMatrix: Matrix;
  72550. /**
  72551. * The native hit test result
  72552. */
  72553. xrHitResult: XRHitResult;
  72554. }
  72555. /**
  72556. * The currently-working hit-test module.
  72557. * Hit test (or Ray-casting) is used to interact with the real world.
  72558. * For further information read here - https://github.com/immersive-web/hit-test
  72559. */
  72560. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72561. /**
  72562. * options to use when constructing this feature
  72563. */
  72564. readonly options: IWebXRHitTestOptions;
  72565. private _direction;
  72566. private _mat;
  72567. private _onSelectEnabled;
  72568. private _origin;
  72569. /**
  72570. * The module's name
  72571. */
  72572. static readonly Name: string;
  72573. /**
  72574. * The (Babylon) version of this module.
  72575. * This is an integer representing the implementation version.
  72576. * This number does not correspond to the WebXR specs version
  72577. */
  72578. static readonly Version: number;
  72579. /**
  72580. * Populated with the last native XR Hit Results
  72581. */
  72582. lastNativeXRHitResults: XRHitResult[];
  72583. /**
  72584. * Triggered when new babylon (transformed) hit test results are available
  72585. */
  72586. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72587. /**
  72588. * Creates a new instance of the (legacy version) hit test feature
  72589. * @param _xrSessionManager an instance of WebXRSessionManager
  72590. * @param options options to use when constructing this feature
  72591. */
  72592. constructor(_xrSessionManager: WebXRSessionManager,
  72593. /**
  72594. * options to use when constructing this feature
  72595. */
  72596. options?: IWebXRHitTestOptions);
  72597. /**
  72598. * execute a hit test with an XR Ray
  72599. *
  72600. * @param xrSession a native xrSession that will execute this hit test
  72601. * @param xrRay the ray (position and direction) to use for ray-casting
  72602. * @param referenceSpace native XR reference space to use for the hit-test
  72603. * @param filter filter function that will filter the results
  72604. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72605. */
  72606. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72607. /**
  72608. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72609. * @param event the (select) event to use to select with
  72610. * @param referenceSpace the reference space to use for this hit test
  72611. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72612. */
  72613. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72614. /**
  72615. * attach this feature
  72616. * Will usually be called by the features manager
  72617. *
  72618. * @returns true if successful.
  72619. */
  72620. attach(): boolean;
  72621. /**
  72622. * detach this feature.
  72623. * Will usually be called by the features manager
  72624. *
  72625. * @returns true if successful.
  72626. */
  72627. detach(): boolean;
  72628. /**
  72629. * Dispose this feature and all of the resources attached
  72630. */
  72631. dispose(): void;
  72632. protected _onXRFrame(frame: XRFrame): void;
  72633. private _onHitTestResults;
  72634. private _onSelect;
  72635. }
  72636. }
  72637. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72638. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72639. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72640. import { Observable } from "babylonjs/Misc/observable";
  72641. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72642. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72643. /**
  72644. * Options used in the plane detector module
  72645. */
  72646. export interface IWebXRPlaneDetectorOptions {
  72647. /**
  72648. * The node to use to transform the local results to world coordinates
  72649. */
  72650. worldParentNode?: TransformNode;
  72651. }
  72652. /**
  72653. * A babylon interface for a WebXR plane.
  72654. * A Plane is actually a polygon, built from N points in space
  72655. *
  72656. * Supported in chrome 79, not supported in canary 81 ATM
  72657. */
  72658. export interface IWebXRPlane {
  72659. /**
  72660. * a babylon-assigned ID for this polygon
  72661. */
  72662. id: number;
  72663. /**
  72664. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72665. */
  72666. polygonDefinition: Array<Vector3>;
  72667. /**
  72668. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72669. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72670. */
  72671. transformationMatrix: Matrix;
  72672. /**
  72673. * the native xr-plane object
  72674. */
  72675. xrPlane: XRPlane;
  72676. }
  72677. /**
  72678. * The plane detector is used to detect planes in the real world when in AR
  72679. * For more information see https://github.com/immersive-web/real-world-geometry/
  72680. */
  72681. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72682. private _options;
  72683. private _detectedPlanes;
  72684. private _enabled;
  72685. private _lastFrameDetected;
  72686. /**
  72687. * The module's name
  72688. */
  72689. static readonly Name: string;
  72690. /**
  72691. * The (Babylon) version of this module.
  72692. * This is an integer representing the implementation version.
  72693. * This number does not correspond to the WebXR specs version
  72694. */
  72695. static readonly Version: number;
  72696. /**
  72697. * Observers registered here will be executed when a new plane was added to the session
  72698. */
  72699. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72700. /**
  72701. * Observers registered here will be executed when a plane is no longer detected in the session
  72702. */
  72703. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72704. /**
  72705. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72706. * This can execute N times every frame
  72707. */
  72708. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72709. /**
  72710. * construct a new Plane Detector
  72711. * @param _xrSessionManager an instance of xr Session manager
  72712. * @param _options configuration to use when constructing this feature
  72713. */
  72714. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72715. /**
  72716. * Dispose this feature and all of the resources attached
  72717. */
  72718. dispose(): void;
  72719. protected _onXRFrame(frame: XRFrame): void;
  72720. private _init;
  72721. private _updatePlaneWithXRPlane;
  72722. /**
  72723. * avoiding using Array.find for global support.
  72724. * @param xrPlane the plane to find in the array
  72725. */
  72726. private findIndexInPlaneArray;
  72727. }
  72728. }
  72729. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72730. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72731. import { Observable } from "babylonjs/Misc/observable";
  72732. import { Matrix } from "babylonjs/Maths/math.vector";
  72733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72734. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72735. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72736. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72737. /**
  72738. * Configuration options of the anchor system
  72739. */
  72740. export interface IWebXRAnchorSystemOptions {
  72741. /**
  72742. * Should a new anchor be added every time a select event is triggered
  72743. */
  72744. addAnchorOnSelect?: boolean;
  72745. /**
  72746. * should the anchor system use plane detection.
  72747. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72748. */
  72749. usePlaneDetection?: boolean;
  72750. /**
  72751. * a node that will be used to convert local to world coordinates
  72752. */
  72753. worldParentNode?: TransformNode;
  72754. }
  72755. /**
  72756. * A babylon container for an XR Anchor
  72757. */
  72758. export interface IWebXRAnchor {
  72759. /**
  72760. * A babylon-assigned ID for this anchor
  72761. */
  72762. id: number;
  72763. /**
  72764. * Transformation matrix to apply to an object attached to this anchor
  72765. */
  72766. transformationMatrix: Matrix;
  72767. /**
  72768. * The native anchor object
  72769. */
  72770. xrAnchor: XRAnchor;
  72771. }
  72772. /**
  72773. * An implementation of the anchor system of WebXR.
  72774. * Note that the current documented implementation is not available in any browser. Future implementations
  72775. * will use the frame to create an anchor and not the session or a detected plane
  72776. * For further information see https://github.com/immersive-web/anchors/
  72777. */
  72778. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72779. private _options;
  72780. private _enabled;
  72781. private _hitTestModule;
  72782. private _lastFrameDetected;
  72783. private _onSelect;
  72784. private _planeDetector;
  72785. private _trackedAnchors;
  72786. /**
  72787. * The module's name
  72788. */
  72789. static readonly Name: string;
  72790. /**
  72791. * The (Babylon) version of this module.
  72792. * This is an integer representing the implementation version.
  72793. * This number does not correspond to the WebXR specs version
  72794. */
  72795. static readonly Version: number;
  72796. /**
  72797. * Observers registered here will be executed when a new anchor was added to the session
  72798. */
  72799. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72800. /**
  72801. * Observers registered here will be executed when an anchor was removed from the session
  72802. */
  72803. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72804. /**
  72805. * Observers registered here will be executed when an existing anchor updates
  72806. * This can execute N times every frame
  72807. */
  72808. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72809. /**
  72810. * constructs a new anchor system
  72811. * @param _xrSessionManager an instance of WebXRSessionManager
  72812. * @param _options configuration object for this feature
  72813. */
  72814. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72815. /**
  72816. * Add anchor at a specific XR point.
  72817. *
  72818. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72819. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72820. * @returns a promise the fulfills when the anchor was created
  72821. */
  72822. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72823. /**
  72824. * attach this feature
  72825. * Will usually be called by the features manager
  72826. *
  72827. * @returns true if successful.
  72828. */
  72829. attach(): boolean;
  72830. /**
  72831. * detach this feature.
  72832. * Will usually be called by the features manager
  72833. *
  72834. * @returns true if successful.
  72835. */
  72836. detach(): boolean;
  72837. /**
  72838. * Dispose this feature and all of the resources attached
  72839. */
  72840. dispose(): void;
  72841. /**
  72842. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72843. * @param hitTestModule the hit-test module to use.
  72844. */
  72845. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72846. /**
  72847. * set the plane detector to use in order to create anchors from frames
  72848. * @param planeDetector the plane-detector module to use
  72849. * @param enable enable plane-anchors. default is true
  72850. */
  72851. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72852. protected _onXRFrame(frame: XRFrame): void;
  72853. /**
  72854. * avoiding using Array.find for global support.
  72855. * @param xrAnchor the plane to find in the array
  72856. */
  72857. private _findIndexInAnchorArray;
  72858. private _updateAnchorWithXRFrame;
  72859. }
  72860. }
  72861. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72862. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72864. import { Observable } from "babylonjs/Misc/observable";
  72865. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72866. /**
  72867. * Options interface for the background remover plugin
  72868. */
  72869. export interface IWebXRBackgroundRemoverOptions {
  72870. /**
  72871. * Further background meshes to disable when entering AR
  72872. */
  72873. backgroundMeshes?: AbstractMesh[];
  72874. /**
  72875. * flags to configure the removal of the environment helper.
  72876. * If not set, the entire background will be removed. If set, flags should be set as well.
  72877. */
  72878. environmentHelperRemovalFlags?: {
  72879. /**
  72880. * Should the skybox be removed (default false)
  72881. */
  72882. skyBox?: boolean;
  72883. /**
  72884. * Should the ground be removed (default false)
  72885. */
  72886. ground?: boolean;
  72887. };
  72888. /**
  72889. * don't disable the environment helper
  72890. */
  72891. ignoreEnvironmentHelper?: boolean;
  72892. }
  72893. /**
  72894. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72895. */
  72896. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72897. /**
  72898. * read-only options to be used in this module
  72899. */
  72900. readonly options: IWebXRBackgroundRemoverOptions;
  72901. /**
  72902. * The module's name
  72903. */
  72904. static readonly Name: string;
  72905. /**
  72906. * The (Babylon) version of this module.
  72907. * This is an integer representing the implementation version.
  72908. * This number does not correspond to the WebXR specs version
  72909. */
  72910. static readonly Version: number;
  72911. /**
  72912. * registered observers will be triggered when the background state changes
  72913. */
  72914. onBackgroundStateChangedObservable: Observable<boolean>;
  72915. /**
  72916. * constructs a new background remover module
  72917. * @param _xrSessionManager the session manager for this module
  72918. * @param options read-only options to be used in this module
  72919. */
  72920. constructor(_xrSessionManager: WebXRSessionManager,
  72921. /**
  72922. * read-only options to be used in this module
  72923. */
  72924. options?: IWebXRBackgroundRemoverOptions);
  72925. /**
  72926. * attach this feature
  72927. * Will usually be called by the features manager
  72928. *
  72929. * @returns true if successful.
  72930. */
  72931. attach(): boolean;
  72932. /**
  72933. * detach this feature.
  72934. * Will usually be called by the features manager
  72935. *
  72936. * @returns true if successful.
  72937. */
  72938. detach(): boolean;
  72939. /**
  72940. * Dispose this feature and all of the resources attached
  72941. */
  72942. dispose(): void;
  72943. protected _onXRFrame(_xrFrame: XRFrame): void;
  72944. private _setBackgroundState;
  72945. }
  72946. }
  72947. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72948. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72949. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72950. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72951. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72952. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72953. import { Nullable } from "babylonjs/types";
  72954. /**
  72955. * Options for the controller physics feature
  72956. */
  72957. export class IWebXRControllerPhysicsOptions {
  72958. /**
  72959. * Should the headset get its own impostor
  72960. */
  72961. enableHeadsetImpostor?: boolean;
  72962. /**
  72963. * Optional parameters for the headset impostor
  72964. */
  72965. headsetImpostorParams?: {
  72966. /**
  72967. * The type of impostor to create. Default is sphere
  72968. */
  72969. impostorType: number;
  72970. /**
  72971. * the size of the impostor. Defaults to 10cm
  72972. */
  72973. impostorSize?: number | {
  72974. width: number;
  72975. height: number;
  72976. depth: number;
  72977. };
  72978. /**
  72979. * Friction definitions
  72980. */
  72981. friction?: number;
  72982. /**
  72983. * Restitution
  72984. */
  72985. restitution?: number;
  72986. };
  72987. /**
  72988. * The physics properties of the future impostors
  72989. */
  72990. physicsProperties?: {
  72991. /**
  72992. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72993. * Note that this requires a physics engine that supports mesh impostors!
  72994. */
  72995. useControllerMesh?: boolean;
  72996. /**
  72997. * The type of impostor to create. Default is sphere
  72998. */
  72999. impostorType?: number;
  73000. /**
  73001. * the size of the impostor. Defaults to 10cm
  73002. */
  73003. impostorSize?: number | {
  73004. width: number;
  73005. height: number;
  73006. depth: number;
  73007. };
  73008. /**
  73009. * Friction definitions
  73010. */
  73011. friction?: number;
  73012. /**
  73013. * Restitution
  73014. */
  73015. restitution?: number;
  73016. };
  73017. /**
  73018. * the xr input to use with this pointer selection
  73019. */
  73020. xrInput: WebXRInput;
  73021. }
  73022. /**
  73023. * Add physics impostor to your webxr controllers,
  73024. * including naive calculation of their linear and angular velocity
  73025. */
  73026. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73027. private readonly _options;
  73028. private _attachController;
  73029. private _controllers;
  73030. private _debugMode;
  73031. private _delta;
  73032. private _headsetImpostor?;
  73033. private _headsetMesh?;
  73034. private _lastTimestamp;
  73035. private _tmpQuaternion;
  73036. private _tmpVector;
  73037. /**
  73038. * The module's name
  73039. */
  73040. static readonly Name: string;
  73041. /**
  73042. * The (Babylon) version of this module.
  73043. * This is an integer representing the implementation version.
  73044. * This number does not correspond to the webxr specs version
  73045. */
  73046. static readonly Version: number;
  73047. /**
  73048. * Construct a new Controller Physics Feature
  73049. * @param _xrSessionManager the corresponding xr session manager
  73050. * @param _options options to create this feature with
  73051. */
  73052. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73053. /**
  73054. * @hidden
  73055. * enable debugging - will show console outputs and the impostor mesh
  73056. */
  73057. _enablePhysicsDebug(): void;
  73058. /**
  73059. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73060. * @param xrController the controller to add
  73061. */
  73062. addController(xrController: WebXRInputSource): void;
  73063. /**
  73064. * attach this feature
  73065. * Will usually be called by the features manager
  73066. *
  73067. * @returns true if successful.
  73068. */
  73069. attach(): boolean;
  73070. /**
  73071. * detach this feature.
  73072. * Will usually be called by the features manager
  73073. *
  73074. * @returns true if successful.
  73075. */
  73076. detach(): boolean;
  73077. /**
  73078. * Get the headset impostor, if enabled
  73079. * @returns the impostor
  73080. */
  73081. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73082. /**
  73083. * Get the physics impostor of a specific controller.
  73084. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73085. * @param controller the controller or the controller id of which to get the impostor
  73086. * @returns the impostor or null
  73087. */
  73088. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73089. /**
  73090. * Update the physics properties provided in the constructor
  73091. * @param newProperties the new properties object
  73092. */
  73093. setPhysicsProperties(newProperties: {
  73094. impostorType?: number;
  73095. impostorSize?: number | {
  73096. width: number;
  73097. height: number;
  73098. depth: number;
  73099. };
  73100. friction?: number;
  73101. restitution?: number;
  73102. }): void;
  73103. protected _onXRFrame(_xrFrame: any): void;
  73104. private _detachController;
  73105. }
  73106. }
  73107. declare module "babylonjs/XR/features/index" {
  73108. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73109. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73110. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73111. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73112. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73113. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73114. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73115. }
  73116. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73117. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73119. import { Scene } from "babylonjs/scene";
  73120. /**
  73121. * The motion controller class for all microsoft mixed reality controllers
  73122. */
  73123. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73124. protected readonly _mapping: {
  73125. defaultButton: {
  73126. "valueNodeName": string;
  73127. "unpressedNodeName": string;
  73128. "pressedNodeName": string;
  73129. };
  73130. defaultAxis: {
  73131. "valueNodeName": string;
  73132. "minNodeName": string;
  73133. "maxNodeName": string;
  73134. };
  73135. buttons: {
  73136. "xr-standard-trigger": {
  73137. "rootNodeName": string;
  73138. "componentProperty": string;
  73139. "states": string[];
  73140. };
  73141. "xr-standard-squeeze": {
  73142. "rootNodeName": string;
  73143. "componentProperty": string;
  73144. "states": string[];
  73145. };
  73146. "xr-standard-touchpad": {
  73147. "rootNodeName": string;
  73148. "labelAnchorNodeName": string;
  73149. "touchPointNodeName": string;
  73150. };
  73151. "xr-standard-thumbstick": {
  73152. "rootNodeName": string;
  73153. "componentProperty": string;
  73154. "states": string[];
  73155. };
  73156. };
  73157. axes: {
  73158. "xr-standard-touchpad": {
  73159. "x-axis": {
  73160. "rootNodeName": string;
  73161. };
  73162. "y-axis": {
  73163. "rootNodeName": string;
  73164. };
  73165. };
  73166. "xr-standard-thumbstick": {
  73167. "x-axis": {
  73168. "rootNodeName": string;
  73169. };
  73170. "y-axis": {
  73171. "rootNodeName": string;
  73172. };
  73173. };
  73174. };
  73175. };
  73176. /**
  73177. * The base url used to load the left and right controller models
  73178. */
  73179. static MODEL_BASE_URL: string;
  73180. /**
  73181. * The name of the left controller model file
  73182. */
  73183. static MODEL_LEFT_FILENAME: string;
  73184. /**
  73185. * The name of the right controller model file
  73186. */
  73187. static MODEL_RIGHT_FILENAME: string;
  73188. profileId: string;
  73189. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73190. protected _getFilenameAndPath(): {
  73191. filename: string;
  73192. path: string;
  73193. };
  73194. protected _getModelLoadingConstraints(): boolean;
  73195. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73196. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73197. protected _updateModel(): void;
  73198. }
  73199. }
  73200. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73201. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73203. import { Scene } from "babylonjs/scene";
  73204. /**
  73205. * The motion controller class for oculus touch (quest, rift).
  73206. * This class supports legacy mapping as well the standard xr mapping
  73207. */
  73208. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73209. private _forceLegacyControllers;
  73210. private _modelRootNode;
  73211. /**
  73212. * The base url used to load the left and right controller models
  73213. */
  73214. static MODEL_BASE_URL: string;
  73215. /**
  73216. * The name of the left controller model file
  73217. */
  73218. static MODEL_LEFT_FILENAME: string;
  73219. /**
  73220. * The name of the right controller model file
  73221. */
  73222. static MODEL_RIGHT_FILENAME: string;
  73223. /**
  73224. * Base Url for the Quest controller model.
  73225. */
  73226. static QUEST_MODEL_BASE_URL: string;
  73227. profileId: string;
  73228. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73229. protected _getFilenameAndPath(): {
  73230. filename: string;
  73231. path: string;
  73232. };
  73233. protected _getModelLoadingConstraints(): boolean;
  73234. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73235. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73236. protected _updateModel(): void;
  73237. /**
  73238. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73239. * between the touch and touch 2.
  73240. */
  73241. private _isQuest;
  73242. }
  73243. }
  73244. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73245. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73246. import { Scene } from "babylonjs/scene";
  73247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73248. /**
  73249. * The motion controller class for the standard HTC-Vive controllers
  73250. */
  73251. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73252. private _modelRootNode;
  73253. /**
  73254. * The base url used to load the left and right controller models
  73255. */
  73256. static MODEL_BASE_URL: string;
  73257. /**
  73258. * File name for the controller model.
  73259. */
  73260. static MODEL_FILENAME: string;
  73261. profileId: string;
  73262. /**
  73263. * Create a new Vive motion controller object
  73264. * @param scene the scene to use to create this controller
  73265. * @param gamepadObject the corresponding gamepad object
  73266. * @param handness the handness of the controller
  73267. */
  73268. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73269. protected _getFilenameAndPath(): {
  73270. filename: string;
  73271. path: string;
  73272. };
  73273. protected _getModelLoadingConstraints(): boolean;
  73274. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73275. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73276. protected _updateModel(): void;
  73277. }
  73278. }
  73279. declare module "babylonjs/XR/motionController/index" {
  73280. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73281. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73282. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73283. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73284. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73285. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73286. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73287. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73288. }
  73289. declare module "babylonjs/XR/index" {
  73290. export * from "babylonjs/XR/webXRCamera";
  73291. export * from "babylonjs/XR/webXREnterExitUI";
  73292. export * from "babylonjs/XR/webXRExperienceHelper";
  73293. export * from "babylonjs/XR/webXRInput";
  73294. export * from "babylonjs/XR/webXRInputSource";
  73295. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73296. export * from "babylonjs/XR/webXRTypes";
  73297. export * from "babylonjs/XR/webXRSessionManager";
  73298. export * from "babylonjs/XR/webXRDefaultExperience";
  73299. export * from "babylonjs/XR/webXRFeaturesManager";
  73300. export * from "babylonjs/XR/features/index";
  73301. export * from "babylonjs/XR/motionController/index";
  73302. }
  73303. declare module "babylonjs/index" {
  73304. export * from "babylonjs/abstractScene";
  73305. export * from "babylonjs/Actions/index";
  73306. export * from "babylonjs/Animations/index";
  73307. export * from "babylonjs/assetContainer";
  73308. export * from "babylonjs/Audio/index";
  73309. export * from "babylonjs/Behaviors/index";
  73310. export * from "babylonjs/Bones/index";
  73311. export * from "babylonjs/Cameras/index";
  73312. export * from "babylonjs/Collisions/index";
  73313. export * from "babylonjs/Culling/index";
  73314. export * from "babylonjs/Debug/index";
  73315. export * from "babylonjs/Engines/index";
  73316. export * from "babylonjs/Events/index";
  73317. export * from "babylonjs/Gamepads/index";
  73318. export * from "babylonjs/Gizmos/index";
  73319. export * from "babylonjs/Helpers/index";
  73320. export * from "babylonjs/Instrumentation/index";
  73321. export * from "babylonjs/Layers/index";
  73322. export * from "babylonjs/LensFlares/index";
  73323. export * from "babylonjs/Lights/index";
  73324. export * from "babylonjs/Loading/index";
  73325. export * from "babylonjs/Materials/index";
  73326. export * from "babylonjs/Maths/index";
  73327. export * from "babylonjs/Meshes/index";
  73328. export * from "babylonjs/Morph/index";
  73329. export * from "babylonjs/Navigation/index";
  73330. export * from "babylonjs/node";
  73331. export * from "babylonjs/Offline/index";
  73332. export * from "babylonjs/Particles/index";
  73333. export * from "babylonjs/Physics/index";
  73334. export * from "babylonjs/PostProcesses/index";
  73335. export * from "babylonjs/Probes/index";
  73336. export * from "babylonjs/Rendering/index";
  73337. export * from "babylonjs/scene";
  73338. export * from "babylonjs/sceneComponent";
  73339. export * from "babylonjs/Sprites/index";
  73340. export * from "babylonjs/States/index";
  73341. export * from "babylonjs/Misc/index";
  73342. export * from "babylonjs/XR/index";
  73343. export * from "babylonjs/types";
  73344. }
  73345. declare module "babylonjs/Animations/pathCursor" {
  73346. import { Vector3 } from "babylonjs/Maths/math.vector";
  73347. import { Path2 } from "babylonjs/Maths/math.path";
  73348. /**
  73349. * A cursor which tracks a point on a path
  73350. */
  73351. export class PathCursor {
  73352. private path;
  73353. /**
  73354. * Stores path cursor callbacks for when an onchange event is triggered
  73355. */
  73356. private _onchange;
  73357. /**
  73358. * The value of the path cursor
  73359. */
  73360. value: number;
  73361. /**
  73362. * The animation array of the path cursor
  73363. */
  73364. animations: Animation[];
  73365. /**
  73366. * Initializes the path cursor
  73367. * @param path The path to track
  73368. */
  73369. constructor(path: Path2);
  73370. /**
  73371. * Gets the cursor point on the path
  73372. * @returns A point on the path cursor at the cursor location
  73373. */
  73374. getPoint(): Vector3;
  73375. /**
  73376. * Moves the cursor ahead by the step amount
  73377. * @param step The amount to move the cursor forward
  73378. * @returns This path cursor
  73379. */
  73380. moveAhead(step?: number): PathCursor;
  73381. /**
  73382. * Moves the cursor behind by the step amount
  73383. * @param step The amount to move the cursor back
  73384. * @returns This path cursor
  73385. */
  73386. moveBack(step?: number): PathCursor;
  73387. /**
  73388. * Moves the cursor by the step amount
  73389. * If the step amount is greater than one, an exception is thrown
  73390. * @param step The amount to move the cursor
  73391. * @returns This path cursor
  73392. */
  73393. move(step: number): PathCursor;
  73394. /**
  73395. * Ensures that the value is limited between zero and one
  73396. * @returns This path cursor
  73397. */
  73398. private ensureLimits;
  73399. /**
  73400. * Runs onchange callbacks on change (used by the animation engine)
  73401. * @returns This path cursor
  73402. */
  73403. private raiseOnChange;
  73404. /**
  73405. * Executes a function on change
  73406. * @param f A path cursor onchange callback
  73407. * @returns This path cursor
  73408. */
  73409. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73410. }
  73411. }
  73412. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73413. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73414. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73415. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73416. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73417. }
  73418. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73419. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73420. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73421. }
  73422. declare module "babylonjs/Engines/Processors/index" {
  73423. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73424. export * from "babylonjs/Engines/Processors/Expressions/index";
  73425. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73426. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73427. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73428. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73429. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73430. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73431. }
  73432. declare module "babylonjs/Legacy/legacy" {
  73433. import * as Babylon from "babylonjs/index";
  73434. export * from "babylonjs/index";
  73435. }
  73436. declare module "babylonjs/Shaders/blur.fragment" {
  73437. /** @hidden */
  73438. export var blurPixelShader: {
  73439. name: string;
  73440. shader: string;
  73441. };
  73442. }
  73443. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73444. /** @hidden */
  73445. export var pointCloudVertexDeclaration: {
  73446. name: string;
  73447. shader: string;
  73448. };
  73449. }
  73450. declare module "babylonjs" {
  73451. export * from "babylonjs/Legacy/legacy";
  73452. }
  73453. declare module BABYLON {
  73454. /** Alias type for value that can be null */
  73455. export type Nullable<T> = T | null;
  73456. /**
  73457. * Alias type for number that are floats
  73458. * @ignorenaming
  73459. */
  73460. export type float = number;
  73461. /**
  73462. * Alias type for number that are doubles.
  73463. * @ignorenaming
  73464. */
  73465. export type double = number;
  73466. /**
  73467. * Alias type for number that are integer
  73468. * @ignorenaming
  73469. */
  73470. export type int = number;
  73471. /** Alias type for number array or Float32Array */
  73472. export type FloatArray = number[] | Float32Array;
  73473. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73474. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73475. /**
  73476. * Alias for types that can be used by a Buffer or VertexBuffer.
  73477. */
  73478. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73479. /**
  73480. * Alias type for primitive types
  73481. * @ignorenaming
  73482. */
  73483. type Primitive = undefined | null | boolean | string | number | Function;
  73484. /**
  73485. * Type modifier to make all the properties of an object Readonly
  73486. */
  73487. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73488. /**
  73489. * Type modifier to make all the properties of an object Readonly recursively
  73490. */
  73491. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73492. /**
  73493. * Type modifier to make object properties readonly.
  73494. */
  73495. export type DeepImmutableObject<T> = {
  73496. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73497. };
  73498. /** @hidden */
  73499. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73500. }
  73501. }
  73502. declare module BABYLON {
  73503. /**
  73504. * A class serves as a medium between the observable and its observers
  73505. */
  73506. export class EventState {
  73507. /**
  73508. * Create a new EventState
  73509. * @param mask defines the mask associated with this state
  73510. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73511. * @param target defines the original target of the state
  73512. * @param currentTarget defines the current target of the state
  73513. */
  73514. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73515. /**
  73516. * Initialize the current event state
  73517. * @param mask defines the mask associated with this state
  73518. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73519. * @param target defines the original target of the state
  73520. * @param currentTarget defines the current target of the state
  73521. * @returns the current event state
  73522. */
  73523. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73524. /**
  73525. * An Observer can set this property to true to prevent subsequent observers of being notified
  73526. */
  73527. skipNextObservers: boolean;
  73528. /**
  73529. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73530. */
  73531. mask: number;
  73532. /**
  73533. * The object that originally notified the event
  73534. */
  73535. target?: any;
  73536. /**
  73537. * The current object in the bubbling phase
  73538. */
  73539. currentTarget?: any;
  73540. /**
  73541. * This will be populated with the return value of the last function that was executed.
  73542. * If it is the first function in the callback chain it will be the event data.
  73543. */
  73544. lastReturnValue?: any;
  73545. }
  73546. /**
  73547. * Represent an Observer registered to a given Observable object.
  73548. */
  73549. export class Observer<T> {
  73550. /**
  73551. * Defines the callback to call when the observer is notified
  73552. */
  73553. callback: (eventData: T, eventState: EventState) => void;
  73554. /**
  73555. * Defines the mask of the observer (used to filter notifications)
  73556. */
  73557. mask: number;
  73558. /**
  73559. * Defines the current scope used to restore the JS context
  73560. */
  73561. scope: any;
  73562. /** @hidden */
  73563. _willBeUnregistered: boolean;
  73564. /**
  73565. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73566. */
  73567. unregisterOnNextCall: boolean;
  73568. /**
  73569. * Creates a new observer
  73570. * @param callback defines the callback to call when the observer is notified
  73571. * @param mask defines the mask of the observer (used to filter notifications)
  73572. * @param scope defines the current scope used to restore the JS context
  73573. */
  73574. constructor(
  73575. /**
  73576. * Defines the callback to call when the observer is notified
  73577. */
  73578. callback: (eventData: T, eventState: EventState) => void,
  73579. /**
  73580. * Defines the mask of the observer (used to filter notifications)
  73581. */
  73582. mask: number,
  73583. /**
  73584. * Defines the current scope used to restore the JS context
  73585. */
  73586. scope?: any);
  73587. }
  73588. /**
  73589. * Represent a list of observers registered to multiple Observables object.
  73590. */
  73591. export class MultiObserver<T> {
  73592. private _observers;
  73593. private _observables;
  73594. /**
  73595. * Release associated resources
  73596. */
  73597. dispose(): void;
  73598. /**
  73599. * Raise a callback when one of the observable will notify
  73600. * @param observables defines a list of observables to watch
  73601. * @param callback defines the callback to call on notification
  73602. * @param mask defines the mask used to filter notifications
  73603. * @param scope defines the current scope used to restore the JS context
  73604. * @returns the new MultiObserver
  73605. */
  73606. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73607. }
  73608. /**
  73609. * The Observable class is a simple implementation of the Observable pattern.
  73610. *
  73611. * 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.
  73612. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73613. * 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).
  73614. * 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.
  73615. */
  73616. export class Observable<T> {
  73617. private _observers;
  73618. private _eventState;
  73619. private _onObserverAdded;
  73620. /**
  73621. * Gets the list of observers
  73622. */
  73623. get observers(): Array<Observer<T>>;
  73624. /**
  73625. * Creates a new observable
  73626. * @param onObserverAdded defines a callback to call when a new observer is added
  73627. */
  73628. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73629. /**
  73630. * Create a new Observer with the specified callback
  73631. * @param callback the callback that will be executed for that Observer
  73632. * @param mask the mask used to filter observers
  73633. * @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.
  73634. * @param scope optional scope for the callback to be called from
  73635. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73636. * @returns the new observer created for the callback
  73637. */
  73638. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73639. /**
  73640. * Create a new Observer with the specified callback and unregisters after the next notification
  73641. * @param callback the callback that will be executed for that Observer
  73642. * @returns the new observer created for the callback
  73643. */
  73644. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73645. /**
  73646. * Remove an Observer from the Observable object
  73647. * @param observer the instance of the Observer to remove
  73648. * @returns false if it doesn't belong to this Observable
  73649. */
  73650. remove(observer: Nullable<Observer<T>>): boolean;
  73651. /**
  73652. * Remove a callback from the Observable object
  73653. * @param callback the callback to remove
  73654. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73655. * @returns false if it doesn't belong to this Observable
  73656. */
  73657. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73658. private _deferUnregister;
  73659. private _remove;
  73660. /**
  73661. * Moves the observable to the top of the observer list making it get called first when notified
  73662. * @param observer the observer to move
  73663. */
  73664. makeObserverTopPriority(observer: Observer<T>): void;
  73665. /**
  73666. * Moves the observable to the bottom of the observer list making it get called last when notified
  73667. * @param observer the observer to move
  73668. */
  73669. makeObserverBottomPriority(observer: Observer<T>): void;
  73670. /**
  73671. * Notify all Observers by calling their respective callback with the given data
  73672. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73673. * @param eventData defines the data to send to all observers
  73674. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73675. * @param target defines the original target of the state
  73676. * @param currentTarget defines the current target of the state
  73677. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73678. */
  73679. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73680. /**
  73681. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73682. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73683. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73684. * and it is crucial that all callbacks will be executed.
  73685. * The order of the callbacks is kept, callbacks are not executed parallel.
  73686. *
  73687. * @param eventData The data to be sent to each callback
  73688. * @param mask is used to filter observers defaults to -1
  73689. * @param target defines the callback target (see EventState)
  73690. * @param currentTarget defines he current object in the bubbling phase
  73691. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73692. */
  73693. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73694. /**
  73695. * Notify a specific observer
  73696. * @param observer defines the observer to notify
  73697. * @param eventData defines the data to be sent to each callback
  73698. * @param mask is used to filter observers defaults to -1
  73699. */
  73700. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73701. /**
  73702. * Gets a boolean indicating if the observable has at least one observer
  73703. * @returns true is the Observable has at least one Observer registered
  73704. */
  73705. hasObservers(): boolean;
  73706. /**
  73707. * Clear the list of observers
  73708. */
  73709. clear(): void;
  73710. /**
  73711. * Clone the current observable
  73712. * @returns a new observable
  73713. */
  73714. clone(): Observable<T>;
  73715. /**
  73716. * Does this observable handles observer registered with a given mask
  73717. * @param mask defines the mask to be tested
  73718. * @return whether or not one observer registered with the given mask is handeled
  73719. **/
  73720. hasSpecificMask(mask?: number): boolean;
  73721. }
  73722. }
  73723. declare module BABYLON {
  73724. /**
  73725. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73726. * Babylon.js
  73727. */
  73728. export class DomManagement {
  73729. /**
  73730. * Checks if the window object exists
  73731. * @returns true if the window object exists
  73732. */
  73733. static IsWindowObjectExist(): boolean;
  73734. /**
  73735. * Checks if the navigator object exists
  73736. * @returns true if the navigator object exists
  73737. */
  73738. static IsNavigatorAvailable(): boolean;
  73739. /**
  73740. * Extracts text content from a DOM element hierarchy
  73741. * @param element defines the root element
  73742. * @returns a string
  73743. */
  73744. static GetDOMTextContent(element: HTMLElement): string;
  73745. }
  73746. }
  73747. declare module BABYLON {
  73748. /**
  73749. * Logger used througouht the application to allow configuration of
  73750. * the log level required for the messages.
  73751. */
  73752. export class Logger {
  73753. /**
  73754. * No log
  73755. */
  73756. static readonly NoneLogLevel: number;
  73757. /**
  73758. * Only message logs
  73759. */
  73760. static readonly MessageLogLevel: number;
  73761. /**
  73762. * Only warning logs
  73763. */
  73764. static readonly WarningLogLevel: number;
  73765. /**
  73766. * Only error logs
  73767. */
  73768. static readonly ErrorLogLevel: number;
  73769. /**
  73770. * All logs
  73771. */
  73772. static readonly AllLogLevel: number;
  73773. private static _LogCache;
  73774. /**
  73775. * Gets a value indicating the number of loading errors
  73776. * @ignorenaming
  73777. */
  73778. static errorsCount: number;
  73779. /**
  73780. * Callback called when a new log is added
  73781. */
  73782. static OnNewCacheEntry: (entry: string) => void;
  73783. private static _AddLogEntry;
  73784. private static _FormatMessage;
  73785. private static _LogDisabled;
  73786. private static _LogEnabled;
  73787. private static _WarnDisabled;
  73788. private static _WarnEnabled;
  73789. private static _ErrorDisabled;
  73790. private static _ErrorEnabled;
  73791. /**
  73792. * Log a message to the console
  73793. */
  73794. static Log: (message: string) => void;
  73795. /**
  73796. * Write a warning message to the console
  73797. */
  73798. static Warn: (message: string) => void;
  73799. /**
  73800. * Write an error message to the console
  73801. */
  73802. static Error: (message: string) => void;
  73803. /**
  73804. * Gets current log cache (list of logs)
  73805. */
  73806. static get LogCache(): string;
  73807. /**
  73808. * Clears the log cache
  73809. */
  73810. static ClearLogCache(): void;
  73811. /**
  73812. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73813. */
  73814. static set LogLevels(level: number);
  73815. }
  73816. }
  73817. declare module BABYLON {
  73818. /** @hidden */
  73819. export class _TypeStore {
  73820. /** @hidden */
  73821. static RegisteredTypes: {
  73822. [key: string]: Object;
  73823. };
  73824. /** @hidden */
  73825. static GetClass(fqdn: string): any;
  73826. }
  73827. }
  73828. declare module BABYLON {
  73829. /**
  73830. * Helper to manipulate strings
  73831. */
  73832. export class StringTools {
  73833. /**
  73834. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73835. * @param str Source string
  73836. * @param suffix Suffix to search for in the source string
  73837. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73838. */
  73839. static EndsWith(str: string, suffix: string): boolean;
  73840. /**
  73841. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73842. * @param str Source string
  73843. * @param suffix Suffix to search for in the source string
  73844. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73845. */
  73846. static StartsWith(str: string, suffix: string): boolean;
  73847. /**
  73848. * Decodes a buffer into a string
  73849. * @param buffer The buffer to decode
  73850. * @returns The decoded string
  73851. */
  73852. static Decode(buffer: Uint8Array | Uint16Array): string;
  73853. /**
  73854. * Encode a buffer to a base64 string
  73855. * @param buffer defines the buffer to encode
  73856. * @returns the encoded string
  73857. */
  73858. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73859. /**
  73860. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  73861. * @param num the number to convert and pad
  73862. * @param length the expected length of the string
  73863. * @returns the padded string
  73864. */
  73865. static PadNumber(num: number, length: number): string;
  73866. }
  73867. }
  73868. declare module BABYLON {
  73869. /**
  73870. * Class containing a set of static utilities functions for deep copy.
  73871. */
  73872. export class DeepCopier {
  73873. /**
  73874. * Tries to copy an object by duplicating every property
  73875. * @param source defines the source object
  73876. * @param destination defines the target object
  73877. * @param doNotCopyList defines a list of properties to avoid
  73878. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73879. */
  73880. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73881. }
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * Class containing a set of static utilities functions for precision date
  73886. */
  73887. export class PrecisionDate {
  73888. /**
  73889. * Gets either window.performance.now() if supported or Date.now() else
  73890. */
  73891. static get Now(): number;
  73892. }
  73893. }
  73894. declare module BABYLON {
  73895. /** @hidden */
  73896. export class _DevTools {
  73897. static WarnImport(name: string): string;
  73898. }
  73899. }
  73900. declare module BABYLON {
  73901. /**
  73902. * Interface used to define the mechanism to get data from the network
  73903. */
  73904. export interface IWebRequest {
  73905. /**
  73906. * Returns client's response url
  73907. */
  73908. responseURL: string;
  73909. /**
  73910. * Returns client's status
  73911. */
  73912. status: number;
  73913. /**
  73914. * Returns client's status as a text
  73915. */
  73916. statusText: string;
  73917. }
  73918. }
  73919. declare module BABYLON {
  73920. /**
  73921. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73922. */
  73923. export class WebRequest implements IWebRequest {
  73924. private _xhr;
  73925. /**
  73926. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73927. * i.e. when loading files, where the server/service expects an Authorization header
  73928. */
  73929. static CustomRequestHeaders: {
  73930. [key: string]: string;
  73931. };
  73932. /**
  73933. * Add callback functions in this array to update all the requests before they get sent to the network
  73934. */
  73935. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73936. private _injectCustomRequestHeaders;
  73937. /**
  73938. * Gets or sets a function to be called when loading progress changes
  73939. */
  73940. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73941. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73942. /**
  73943. * Returns client's state
  73944. */
  73945. get readyState(): number;
  73946. /**
  73947. * Returns client's status
  73948. */
  73949. get status(): number;
  73950. /**
  73951. * Returns client's status as a text
  73952. */
  73953. get statusText(): string;
  73954. /**
  73955. * Returns client's response
  73956. */
  73957. get response(): any;
  73958. /**
  73959. * Returns client's response url
  73960. */
  73961. get responseURL(): string;
  73962. /**
  73963. * Returns client's response as text
  73964. */
  73965. get responseText(): string;
  73966. /**
  73967. * Gets or sets the expected response type
  73968. */
  73969. get responseType(): XMLHttpRequestResponseType;
  73970. set responseType(value: XMLHttpRequestResponseType);
  73971. /** @hidden */
  73972. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73973. /** @hidden */
  73974. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73975. /**
  73976. * Cancels any network activity
  73977. */
  73978. abort(): void;
  73979. /**
  73980. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73981. * @param body defines an optional request body
  73982. */
  73983. send(body?: Document | BodyInit | null): void;
  73984. /**
  73985. * Sets the request method, request URL
  73986. * @param method defines the method to use (GET, POST, etc..)
  73987. * @param url defines the url to connect with
  73988. */
  73989. open(method: string, url: string): void;
  73990. /**
  73991. * Sets the value of a request header.
  73992. * @param name The name of the header whose value is to be set
  73993. * @param value The value to set as the body of the header
  73994. */
  73995. setRequestHeader(name: string, value: string): void;
  73996. /**
  73997. * Get the string containing the text of a particular header's value.
  73998. * @param name The name of the header
  73999. * @returns The string containing the text of the given header name
  74000. */
  74001. getResponseHeader(name: string): Nullable<string>;
  74002. }
  74003. }
  74004. declare module BABYLON {
  74005. /**
  74006. * File request interface
  74007. */
  74008. export interface IFileRequest {
  74009. /**
  74010. * Raised when the request is complete (success or error).
  74011. */
  74012. onCompleteObservable: Observable<IFileRequest>;
  74013. /**
  74014. * Aborts the request for a file.
  74015. */
  74016. abort: () => void;
  74017. }
  74018. }
  74019. declare module BABYLON {
  74020. /**
  74021. * Define options used to create a render target texture
  74022. */
  74023. export class RenderTargetCreationOptions {
  74024. /**
  74025. * Specifies is mipmaps must be generated
  74026. */
  74027. generateMipMaps?: boolean;
  74028. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74029. generateDepthBuffer?: boolean;
  74030. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74031. generateStencilBuffer?: boolean;
  74032. /** Defines texture type (int by default) */
  74033. type?: number;
  74034. /** Defines sampling mode (trilinear by default) */
  74035. samplingMode?: number;
  74036. /** Defines format (RGBA by default) */
  74037. format?: number;
  74038. }
  74039. }
  74040. declare module BABYLON {
  74041. /** Defines the cross module used constants to avoid circular dependncies */
  74042. export class Constants {
  74043. /** Defines that alpha blending is disabled */
  74044. static readonly ALPHA_DISABLE: number;
  74045. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74046. static readonly ALPHA_ADD: number;
  74047. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74048. static readonly ALPHA_COMBINE: number;
  74049. /** Defines that alpha blending is DEST - SRC * DEST */
  74050. static readonly ALPHA_SUBTRACT: number;
  74051. /** Defines that alpha blending is SRC * DEST */
  74052. static readonly ALPHA_MULTIPLY: number;
  74053. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74054. static readonly ALPHA_MAXIMIZED: number;
  74055. /** Defines that alpha blending is SRC + DEST */
  74056. static readonly ALPHA_ONEONE: number;
  74057. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74058. static readonly ALPHA_PREMULTIPLIED: number;
  74059. /**
  74060. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74061. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74062. */
  74063. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74064. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74065. static readonly ALPHA_INTERPOLATE: number;
  74066. /**
  74067. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74068. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74069. */
  74070. static readonly ALPHA_SCREENMODE: number;
  74071. /**
  74072. * Defines that alpha blending is SRC + DST
  74073. * Alpha will be set to SRC ALPHA + DST ALPHA
  74074. */
  74075. static readonly ALPHA_ONEONE_ONEONE: number;
  74076. /**
  74077. * Defines that alpha blending is SRC * DST ALPHA + DST
  74078. * Alpha will be set to 0
  74079. */
  74080. static readonly ALPHA_ALPHATOCOLOR: number;
  74081. /**
  74082. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74083. */
  74084. static readonly ALPHA_REVERSEONEMINUS: number;
  74085. /**
  74086. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74087. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74088. */
  74089. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74090. /**
  74091. * Defines that alpha blending is SRC + DST
  74092. * Alpha will be set to SRC ALPHA
  74093. */
  74094. static readonly ALPHA_ONEONE_ONEZERO: number;
  74095. /**
  74096. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74097. * Alpha will be set to DST ALPHA
  74098. */
  74099. static readonly ALPHA_EXCLUSION: number;
  74100. /** Defines that alpha blending equation a SUM */
  74101. static readonly ALPHA_EQUATION_ADD: number;
  74102. /** Defines that alpha blending equation a SUBSTRACTION */
  74103. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74104. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74105. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74106. /** Defines that alpha blending equation a MAX operation */
  74107. static readonly ALPHA_EQUATION_MAX: number;
  74108. /** Defines that alpha blending equation a MIN operation */
  74109. static readonly ALPHA_EQUATION_MIN: number;
  74110. /**
  74111. * Defines that alpha blending equation a DARKEN operation:
  74112. * It takes the min of the src and sums the alpha channels.
  74113. */
  74114. static readonly ALPHA_EQUATION_DARKEN: number;
  74115. /** Defines that the ressource is not delayed*/
  74116. static readonly DELAYLOADSTATE_NONE: number;
  74117. /** Defines that the ressource was successfully delay loaded */
  74118. static readonly DELAYLOADSTATE_LOADED: number;
  74119. /** Defines that the ressource is currently delay loading */
  74120. static readonly DELAYLOADSTATE_LOADING: number;
  74121. /** Defines that the ressource is delayed and has not started loading */
  74122. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74124. static readonly NEVER: number;
  74125. /** 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 */
  74126. static readonly ALWAYS: number;
  74127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74128. static readonly LESS: number;
  74129. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74130. static readonly EQUAL: number;
  74131. /** 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 */
  74132. static readonly LEQUAL: number;
  74133. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74134. static readonly GREATER: number;
  74135. /** 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 */
  74136. static readonly GEQUAL: number;
  74137. /** 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 */
  74138. static readonly NOTEQUAL: number;
  74139. /** Passed to stencilOperation to specify that stencil value must be kept */
  74140. static readonly KEEP: number;
  74141. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74142. static readonly REPLACE: number;
  74143. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74144. static readonly INCR: number;
  74145. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74146. static readonly DECR: number;
  74147. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74148. static readonly INVERT: number;
  74149. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74150. static readonly INCR_WRAP: number;
  74151. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74152. static readonly DECR_WRAP: number;
  74153. /** Texture is not repeating outside of 0..1 UVs */
  74154. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74155. /** Texture is repeating outside of 0..1 UVs */
  74156. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74157. /** Texture is repeating and mirrored */
  74158. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74159. /** ALPHA */
  74160. static readonly TEXTUREFORMAT_ALPHA: number;
  74161. /** LUMINANCE */
  74162. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74163. /** LUMINANCE_ALPHA */
  74164. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74165. /** RGB */
  74166. static readonly TEXTUREFORMAT_RGB: number;
  74167. /** RGBA */
  74168. static readonly TEXTUREFORMAT_RGBA: number;
  74169. /** RED */
  74170. static readonly TEXTUREFORMAT_RED: number;
  74171. /** RED (2nd reference) */
  74172. static readonly TEXTUREFORMAT_R: number;
  74173. /** RG */
  74174. static readonly TEXTUREFORMAT_RG: number;
  74175. /** RED_INTEGER */
  74176. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74177. /** RED_INTEGER (2nd reference) */
  74178. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74179. /** RG_INTEGER */
  74180. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74181. /** RGB_INTEGER */
  74182. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74183. /** RGBA_INTEGER */
  74184. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74185. /** UNSIGNED_BYTE */
  74186. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74187. /** UNSIGNED_BYTE (2nd reference) */
  74188. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74189. /** FLOAT */
  74190. static readonly TEXTURETYPE_FLOAT: number;
  74191. /** HALF_FLOAT */
  74192. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74193. /** BYTE */
  74194. static readonly TEXTURETYPE_BYTE: number;
  74195. /** SHORT */
  74196. static readonly TEXTURETYPE_SHORT: number;
  74197. /** UNSIGNED_SHORT */
  74198. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74199. /** INT */
  74200. static readonly TEXTURETYPE_INT: number;
  74201. /** UNSIGNED_INT */
  74202. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74203. /** UNSIGNED_SHORT_4_4_4_4 */
  74204. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74205. /** UNSIGNED_SHORT_5_5_5_1 */
  74206. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74207. /** UNSIGNED_SHORT_5_6_5 */
  74208. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74209. /** UNSIGNED_INT_2_10_10_10_REV */
  74210. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74211. /** UNSIGNED_INT_24_8 */
  74212. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74213. /** UNSIGNED_INT_10F_11F_11F_REV */
  74214. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74215. /** UNSIGNED_INT_5_9_9_9_REV */
  74216. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74217. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74218. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74219. /** nearest is mag = nearest and min = nearest and no mip */
  74220. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74221. /** mag = nearest and min = nearest and mip = none */
  74222. static readonly TEXTURE_NEAREST_NEAREST: number;
  74223. /** Bilinear is mag = linear and min = linear and no mip */
  74224. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74225. /** mag = linear and min = linear and mip = none */
  74226. static readonly TEXTURE_LINEAR_LINEAR: number;
  74227. /** Trilinear is mag = linear and min = linear and mip = linear */
  74228. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74229. /** Trilinear is mag = linear and min = linear and mip = linear */
  74230. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74231. /** mag = nearest and min = nearest and mip = nearest */
  74232. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74233. /** mag = nearest and min = linear and mip = nearest */
  74234. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74235. /** mag = nearest and min = linear and mip = linear */
  74236. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74237. /** mag = nearest and min = linear and mip = none */
  74238. static readonly TEXTURE_NEAREST_LINEAR: number;
  74239. /** nearest is mag = nearest and min = nearest and mip = linear */
  74240. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74241. /** mag = linear and min = nearest and mip = nearest */
  74242. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74243. /** mag = linear and min = nearest and mip = linear */
  74244. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74245. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74246. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74247. /** mag = linear and min = nearest and mip = none */
  74248. static readonly TEXTURE_LINEAR_NEAREST: number;
  74249. /** Explicit coordinates mode */
  74250. static readonly TEXTURE_EXPLICIT_MODE: number;
  74251. /** Spherical coordinates mode */
  74252. static readonly TEXTURE_SPHERICAL_MODE: number;
  74253. /** Planar coordinates mode */
  74254. static readonly TEXTURE_PLANAR_MODE: number;
  74255. /** Cubic coordinates mode */
  74256. static readonly TEXTURE_CUBIC_MODE: number;
  74257. /** Projection coordinates mode */
  74258. static readonly TEXTURE_PROJECTION_MODE: number;
  74259. /** Skybox coordinates mode */
  74260. static readonly TEXTURE_SKYBOX_MODE: number;
  74261. /** Inverse Cubic coordinates mode */
  74262. static readonly TEXTURE_INVCUBIC_MODE: number;
  74263. /** Equirectangular coordinates mode */
  74264. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74265. /** Equirectangular Fixed coordinates mode */
  74266. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74267. /** Equirectangular Fixed Mirrored coordinates mode */
  74268. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74269. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74270. static readonly SCALEMODE_FLOOR: number;
  74271. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74272. static readonly SCALEMODE_NEAREST: number;
  74273. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74274. static readonly SCALEMODE_CEILING: number;
  74275. /**
  74276. * The dirty texture flag value
  74277. */
  74278. static readonly MATERIAL_TextureDirtyFlag: number;
  74279. /**
  74280. * The dirty light flag value
  74281. */
  74282. static readonly MATERIAL_LightDirtyFlag: number;
  74283. /**
  74284. * The dirty fresnel flag value
  74285. */
  74286. static readonly MATERIAL_FresnelDirtyFlag: number;
  74287. /**
  74288. * The dirty attribute flag value
  74289. */
  74290. static readonly MATERIAL_AttributesDirtyFlag: number;
  74291. /**
  74292. * The dirty misc flag value
  74293. */
  74294. static readonly MATERIAL_MiscDirtyFlag: number;
  74295. /**
  74296. * The all dirty flag value
  74297. */
  74298. static readonly MATERIAL_AllDirtyFlag: number;
  74299. /**
  74300. * Returns the triangle fill mode
  74301. */
  74302. static readonly MATERIAL_TriangleFillMode: number;
  74303. /**
  74304. * Returns the wireframe mode
  74305. */
  74306. static readonly MATERIAL_WireFrameFillMode: number;
  74307. /**
  74308. * Returns the point fill mode
  74309. */
  74310. static readonly MATERIAL_PointFillMode: number;
  74311. /**
  74312. * Returns the point list draw mode
  74313. */
  74314. static readonly MATERIAL_PointListDrawMode: number;
  74315. /**
  74316. * Returns the line list draw mode
  74317. */
  74318. static readonly MATERIAL_LineListDrawMode: number;
  74319. /**
  74320. * Returns the line loop draw mode
  74321. */
  74322. static readonly MATERIAL_LineLoopDrawMode: number;
  74323. /**
  74324. * Returns the line strip draw mode
  74325. */
  74326. static readonly MATERIAL_LineStripDrawMode: number;
  74327. /**
  74328. * Returns the triangle strip draw mode
  74329. */
  74330. static readonly MATERIAL_TriangleStripDrawMode: number;
  74331. /**
  74332. * Returns the triangle fan draw mode
  74333. */
  74334. static readonly MATERIAL_TriangleFanDrawMode: number;
  74335. /**
  74336. * Stores the clock-wise side orientation
  74337. */
  74338. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74339. /**
  74340. * Stores the counter clock-wise side orientation
  74341. */
  74342. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74343. /**
  74344. * Nothing
  74345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74346. */
  74347. static readonly ACTION_NothingTrigger: number;
  74348. /**
  74349. * On pick
  74350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74351. */
  74352. static readonly ACTION_OnPickTrigger: number;
  74353. /**
  74354. * On left pick
  74355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74356. */
  74357. static readonly ACTION_OnLeftPickTrigger: number;
  74358. /**
  74359. * On right pick
  74360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74361. */
  74362. static readonly ACTION_OnRightPickTrigger: number;
  74363. /**
  74364. * On center pick
  74365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74366. */
  74367. static readonly ACTION_OnCenterPickTrigger: number;
  74368. /**
  74369. * On pick down
  74370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74371. */
  74372. static readonly ACTION_OnPickDownTrigger: number;
  74373. /**
  74374. * On double pick
  74375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74376. */
  74377. static readonly ACTION_OnDoublePickTrigger: number;
  74378. /**
  74379. * On pick up
  74380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74381. */
  74382. static readonly ACTION_OnPickUpTrigger: number;
  74383. /**
  74384. * On pick out.
  74385. * This trigger will only be raised if you also declared a OnPickDown
  74386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74387. */
  74388. static readonly ACTION_OnPickOutTrigger: number;
  74389. /**
  74390. * On long press
  74391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74392. */
  74393. static readonly ACTION_OnLongPressTrigger: number;
  74394. /**
  74395. * On pointer over
  74396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74397. */
  74398. static readonly ACTION_OnPointerOverTrigger: number;
  74399. /**
  74400. * On pointer out
  74401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74402. */
  74403. static readonly ACTION_OnPointerOutTrigger: number;
  74404. /**
  74405. * On every frame
  74406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74407. */
  74408. static readonly ACTION_OnEveryFrameTrigger: number;
  74409. /**
  74410. * On intersection enter
  74411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74412. */
  74413. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74414. /**
  74415. * On intersection exit
  74416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74417. */
  74418. static readonly ACTION_OnIntersectionExitTrigger: number;
  74419. /**
  74420. * On key down
  74421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74422. */
  74423. static readonly ACTION_OnKeyDownTrigger: number;
  74424. /**
  74425. * On key up
  74426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74427. */
  74428. static readonly ACTION_OnKeyUpTrigger: number;
  74429. /**
  74430. * Billboard mode will only apply to Y axis
  74431. */
  74432. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74433. /**
  74434. * Billboard mode will apply to all axes
  74435. */
  74436. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74437. /**
  74438. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74439. */
  74440. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74441. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74442. * Test order :
  74443. * Is the bounding sphere outside the frustum ?
  74444. * If not, are the bounding box vertices outside the frustum ?
  74445. * It not, then the cullable object is in the frustum.
  74446. */
  74447. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74448. /** Culling strategy : Bounding Sphere Only.
  74449. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74450. * It's also less accurate than the standard because some not visible objects can still be selected.
  74451. * Test : is the bounding sphere outside the frustum ?
  74452. * If not, then the cullable object is in the frustum.
  74453. */
  74454. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74455. /** Culling strategy : Optimistic Inclusion.
  74456. * This in an inclusion test first, then the standard exclusion test.
  74457. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74458. * 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.
  74459. * Anyway, it's as accurate as the standard strategy.
  74460. * Test :
  74461. * Is the cullable object bounding sphere center in the frustum ?
  74462. * If not, apply the default culling strategy.
  74463. */
  74464. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74465. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74466. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74467. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74468. * 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.
  74469. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74470. * Test :
  74471. * Is the cullable object bounding sphere center in the frustum ?
  74472. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74473. */
  74474. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74475. /**
  74476. * No logging while loading
  74477. */
  74478. static readonly SCENELOADER_NO_LOGGING: number;
  74479. /**
  74480. * Minimal logging while loading
  74481. */
  74482. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74483. /**
  74484. * Summary logging while loading
  74485. */
  74486. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74487. /**
  74488. * Detailled logging while loading
  74489. */
  74490. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74491. }
  74492. }
  74493. declare module BABYLON {
  74494. /**
  74495. * This represents the required contract to create a new type of texture loader.
  74496. */
  74497. export interface IInternalTextureLoader {
  74498. /**
  74499. * Defines wether the loader supports cascade loading the different faces.
  74500. */
  74501. supportCascades: boolean;
  74502. /**
  74503. * This returns if the loader support the current file information.
  74504. * @param extension defines the file extension of the file being loaded
  74505. * @returns true if the loader can load the specified file
  74506. */
  74507. canLoad(extension: string): boolean;
  74508. /**
  74509. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74510. * @param data contains the texture data
  74511. * @param texture defines the BabylonJS internal texture
  74512. * @param createPolynomials will be true if polynomials have been requested
  74513. * @param onLoad defines the callback to trigger once the texture is ready
  74514. * @param onError defines the callback to trigger in case of error
  74515. */
  74516. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74517. /**
  74518. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74519. * @param data contains the texture data
  74520. * @param texture defines the BabylonJS internal texture
  74521. * @param callback defines the method to call once ready to upload
  74522. */
  74523. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74524. }
  74525. }
  74526. declare module BABYLON {
  74527. /**
  74528. * Class used to store and describe the pipeline context associated with an effect
  74529. */
  74530. export interface IPipelineContext {
  74531. /**
  74532. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74533. */
  74534. isAsync: boolean;
  74535. /**
  74536. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74537. */
  74538. isReady: boolean;
  74539. /** @hidden */
  74540. _getVertexShaderCode(): string | null;
  74541. /** @hidden */
  74542. _getFragmentShaderCode(): string | null;
  74543. /** @hidden */
  74544. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74545. }
  74546. }
  74547. declare module BABYLON {
  74548. /**
  74549. * Class used to store gfx data (like WebGLBuffer)
  74550. */
  74551. export class DataBuffer {
  74552. /**
  74553. * Gets or sets the number of objects referencing this buffer
  74554. */
  74555. references: number;
  74556. /** Gets or sets the size of the underlying buffer */
  74557. capacity: number;
  74558. /**
  74559. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74560. */
  74561. is32Bits: boolean;
  74562. /**
  74563. * Gets the underlying buffer
  74564. */
  74565. get underlyingResource(): any;
  74566. }
  74567. }
  74568. declare module BABYLON {
  74569. /** @hidden */
  74570. export interface IShaderProcessor {
  74571. attributeProcessor?: (attribute: string) => string;
  74572. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74573. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74574. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74575. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74576. lineProcessor?: (line: string, isFragment: boolean) => string;
  74577. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74578. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74579. }
  74580. }
  74581. declare module BABYLON {
  74582. /** @hidden */
  74583. export interface ProcessingOptions {
  74584. defines: string[];
  74585. indexParameters: any;
  74586. isFragment: boolean;
  74587. shouldUseHighPrecisionShader: boolean;
  74588. supportsUniformBuffers: boolean;
  74589. shadersRepository: string;
  74590. includesShadersStore: {
  74591. [key: string]: string;
  74592. };
  74593. processor?: IShaderProcessor;
  74594. version: string;
  74595. platformName: string;
  74596. lookForClosingBracketForUniformBuffer?: boolean;
  74597. }
  74598. }
  74599. declare module BABYLON {
  74600. /** @hidden */
  74601. export class ShaderCodeNode {
  74602. line: string;
  74603. children: ShaderCodeNode[];
  74604. additionalDefineKey?: string;
  74605. additionalDefineValue?: string;
  74606. isValid(preprocessors: {
  74607. [key: string]: string;
  74608. }): boolean;
  74609. process(preprocessors: {
  74610. [key: string]: string;
  74611. }, options: ProcessingOptions): string;
  74612. }
  74613. }
  74614. declare module BABYLON {
  74615. /** @hidden */
  74616. export class ShaderCodeCursor {
  74617. private _lines;
  74618. lineIndex: number;
  74619. get currentLine(): string;
  74620. get canRead(): boolean;
  74621. set lines(value: string[]);
  74622. }
  74623. }
  74624. declare module BABYLON {
  74625. /** @hidden */
  74626. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74627. process(preprocessors: {
  74628. [key: string]: string;
  74629. }, options: ProcessingOptions): string;
  74630. }
  74631. }
  74632. declare module BABYLON {
  74633. /** @hidden */
  74634. export class ShaderDefineExpression {
  74635. isTrue(preprocessors: {
  74636. [key: string]: string;
  74637. }): boolean;
  74638. }
  74639. }
  74640. declare module BABYLON {
  74641. /** @hidden */
  74642. export class ShaderCodeTestNode extends ShaderCodeNode {
  74643. testExpression: ShaderDefineExpression;
  74644. isValid(preprocessors: {
  74645. [key: string]: string;
  74646. }): boolean;
  74647. }
  74648. }
  74649. declare module BABYLON {
  74650. /** @hidden */
  74651. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74652. define: string;
  74653. not: boolean;
  74654. constructor(define: string, not?: boolean);
  74655. isTrue(preprocessors: {
  74656. [key: string]: string;
  74657. }): boolean;
  74658. }
  74659. }
  74660. declare module BABYLON {
  74661. /** @hidden */
  74662. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74663. leftOperand: ShaderDefineExpression;
  74664. rightOperand: ShaderDefineExpression;
  74665. isTrue(preprocessors: {
  74666. [key: string]: string;
  74667. }): boolean;
  74668. }
  74669. }
  74670. declare module BABYLON {
  74671. /** @hidden */
  74672. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74673. leftOperand: ShaderDefineExpression;
  74674. rightOperand: ShaderDefineExpression;
  74675. isTrue(preprocessors: {
  74676. [key: string]: string;
  74677. }): boolean;
  74678. }
  74679. }
  74680. declare module BABYLON {
  74681. /** @hidden */
  74682. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74683. define: string;
  74684. operand: string;
  74685. testValue: string;
  74686. constructor(define: string, operand: string, testValue: string);
  74687. isTrue(preprocessors: {
  74688. [key: string]: string;
  74689. }): boolean;
  74690. }
  74691. }
  74692. declare module BABYLON {
  74693. /**
  74694. * Class used to enable access to offline support
  74695. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74696. */
  74697. export interface IOfflineProvider {
  74698. /**
  74699. * Gets a boolean indicating if scene must be saved in the database
  74700. */
  74701. enableSceneOffline: boolean;
  74702. /**
  74703. * Gets a boolean indicating if textures must be saved in the database
  74704. */
  74705. enableTexturesOffline: boolean;
  74706. /**
  74707. * Open the offline support and make it available
  74708. * @param successCallback defines the callback to call on success
  74709. * @param errorCallback defines the callback to call on error
  74710. */
  74711. open(successCallback: () => void, errorCallback: () => void): void;
  74712. /**
  74713. * Loads an image from the offline support
  74714. * @param url defines the url to load from
  74715. * @param image defines the target DOM image
  74716. */
  74717. loadImage(url: string, image: HTMLImageElement): void;
  74718. /**
  74719. * Loads a file from offline support
  74720. * @param url defines the URL to load from
  74721. * @param sceneLoaded defines a callback to call on success
  74722. * @param progressCallBack defines a callback to call when progress changed
  74723. * @param errorCallback defines a callback to call on error
  74724. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74725. */
  74726. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74727. }
  74728. }
  74729. declare module BABYLON {
  74730. /**
  74731. * Class used to help managing file picking and drag'n'drop
  74732. * File Storage
  74733. */
  74734. export class FilesInputStore {
  74735. /**
  74736. * List of files ready to be loaded
  74737. */
  74738. static FilesToLoad: {
  74739. [key: string]: File;
  74740. };
  74741. }
  74742. }
  74743. declare module BABYLON {
  74744. /**
  74745. * Class used to define a retry strategy when error happens while loading assets
  74746. */
  74747. export class RetryStrategy {
  74748. /**
  74749. * Function used to defines an exponential back off strategy
  74750. * @param maxRetries defines the maximum number of retries (3 by default)
  74751. * @param baseInterval defines the interval between retries
  74752. * @returns the strategy function to use
  74753. */
  74754. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74755. }
  74756. }
  74757. declare module BABYLON {
  74758. /**
  74759. * @ignore
  74760. * Application error to support additional information when loading a file
  74761. */
  74762. export abstract class BaseError extends Error {
  74763. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74764. }
  74765. }
  74766. declare module BABYLON {
  74767. /** @ignore */
  74768. export class LoadFileError extends BaseError {
  74769. request?: WebRequest;
  74770. file?: File;
  74771. /**
  74772. * Creates a new LoadFileError
  74773. * @param message defines the message of the error
  74774. * @param request defines the optional web request
  74775. * @param file defines the optional file
  74776. */
  74777. constructor(message: string, object?: WebRequest | File);
  74778. }
  74779. /** @ignore */
  74780. export class RequestFileError extends BaseError {
  74781. request: WebRequest;
  74782. /**
  74783. * Creates a new LoadFileError
  74784. * @param message defines the message of the error
  74785. * @param request defines the optional web request
  74786. */
  74787. constructor(message: string, request: WebRequest);
  74788. }
  74789. /** @ignore */
  74790. export class ReadFileError extends BaseError {
  74791. file: File;
  74792. /**
  74793. * Creates a new ReadFileError
  74794. * @param message defines the message of the error
  74795. * @param file defines the optional file
  74796. */
  74797. constructor(message: string, file: File);
  74798. }
  74799. /**
  74800. * @hidden
  74801. */
  74802. export class FileTools {
  74803. /**
  74804. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74805. */
  74806. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74807. /**
  74808. * Gets or sets the base URL to use to load assets
  74809. */
  74810. static BaseUrl: string;
  74811. /**
  74812. * Default behaviour for cors in the application.
  74813. * It can be a string if the expected behavior is identical in the entire app.
  74814. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74815. */
  74816. static CorsBehavior: string | ((url: string | string[]) => string);
  74817. /**
  74818. * Gets or sets a function used to pre-process url before using them to load assets
  74819. */
  74820. static PreprocessUrl: (url: string) => string;
  74821. /**
  74822. * Removes unwanted characters from an url
  74823. * @param url defines the url to clean
  74824. * @returns the cleaned url
  74825. */
  74826. private static _CleanUrl;
  74827. /**
  74828. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74829. * @param url define the url we are trying
  74830. * @param element define the dom element where to configure the cors policy
  74831. */
  74832. static SetCorsBehavior(url: string | string[], element: {
  74833. crossOrigin: string | null;
  74834. }): void;
  74835. /**
  74836. * Loads an image as an HTMLImageElement.
  74837. * @param input url string, ArrayBuffer, or Blob to load
  74838. * @param onLoad callback called when the image successfully loads
  74839. * @param onError callback called when the image fails to load
  74840. * @param offlineProvider offline provider for caching
  74841. * @param mimeType optional mime type
  74842. * @returns the HTMLImageElement of the loaded image
  74843. */
  74844. 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>;
  74845. /**
  74846. * Reads a file from a File object
  74847. * @param file defines the file to load
  74848. * @param onSuccess defines the callback to call when data is loaded
  74849. * @param onProgress defines the callback to call during loading process
  74850. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74851. * @param onError defines the callback to call when an error occurs
  74852. * @returns a file request object
  74853. */
  74854. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74855. /**
  74856. * Loads a file from a url
  74857. * @param url url to load
  74858. * @param onSuccess callback called when the file successfully loads
  74859. * @param onProgress callback called while file is loading (if the server supports this mode)
  74860. * @param offlineProvider defines the offline provider for caching
  74861. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74862. * @param onError callback called when the file fails to load
  74863. * @returns a file request object
  74864. */
  74865. 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;
  74866. /**
  74867. * Loads a file
  74868. * @param url url to load
  74869. * @param onSuccess callback called when the file successfully loads
  74870. * @param onProgress callback called while file is loading (if the server supports this mode)
  74871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74872. * @param onError callback called when the file fails to load
  74873. * @param onOpened callback called when the web request is opened
  74874. * @returns a file request object
  74875. */
  74876. 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;
  74877. /**
  74878. * Checks if the loaded document was accessed via `file:`-Protocol.
  74879. * @returns boolean
  74880. */
  74881. static IsFileURL(): boolean;
  74882. }
  74883. }
  74884. declare module BABYLON {
  74885. /** @hidden */
  74886. export class ShaderProcessor {
  74887. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74888. private static _ProcessPrecision;
  74889. private static _ExtractOperation;
  74890. private static _BuildSubExpression;
  74891. private static _BuildExpression;
  74892. private static _MoveCursorWithinIf;
  74893. private static _MoveCursor;
  74894. private static _EvaluatePreProcessors;
  74895. private static _PreparePreProcessors;
  74896. private static _ProcessShaderConversion;
  74897. private static _ProcessIncludes;
  74898. /**
  74899. * Loads a file from a url
  74900. * @param url url to load
  74901. * @param onSuccess callback called when the file successfully loads
  74902. * @param onProgress callback called while file is loading (if the server supports this mode)
  74903. * @param offlineProvider defines the offline provider for caching
  74904. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74905. * @param onError callback called when the file fails to load
  74906. * @returns a file request object
  74907. * @hidden
  74908. */
  74909. 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;
  74910. }
  74911. }
  74912. declare module BABYLON {
  74913. /**
  74914. * @hidden
  74915. */
  74916. export interface IColor4Like {
  74917. r: float;
  74918. g: float;
  74919. b: float;
  74920. a: float;
  74921. }
  74922. /**
  74923. * @hidden
  74924. */
  74925. export interface IColor3Like {
  74926. r: float;
  74927. g: float;
  74928. b: float;
  74929. }
  74930. /**
  74931. * @hidden
  74932. */
  74933. export interface IVector4Like {
  74934. x: float;
  74935. y: float;
  74936. z: float;
  74937. w: float;
  74938. }
  74939. /**
  74940. * @hidden
  74941. */
  74942. export interface IVector3Like {
  74943. x: float;
  74944. y: float;
  74945. z: float;
  74946. }
  74947. /**
  74948. * @hidden
  74949. */
  74950. export interface IVector2Like {
  74951. x: float;
  74952. y: float;
  74953. }
  74954. /**
  74955. * @hidden
  74956. */
  74957. export interface IMatrixLike {
  74958. toArray(): DeepImmutable<Float32Array>;
  74959. updateFlag: int;
  74960. }
  74961. /**
  74962. * @hidden
  74963. */
  74964. export interface IViewportLike {
  74965. x: float;
  74966. y: float;
  74967. width: float;
  74968. height: float;
  74969. }
  74970. /**
  74971. * @hidden
  74972. */
  74973. export interface IPlaneLike {
  74974. normal: IVector3Like;
  74975. d: float;
  74976. normalize(): void;
  74977. }
  74978. }
  74979. declare module BABYLON {
  74980. /**
  74981. * Interface used to define common properties for effect fallbacks
  74982. */
  74983. export interface IEffectFallbacks {
  74984. /**
  74985. * Removes the defines that should be removed when falling back.
  74986. * @param currentDefines defines the current define statements for the shader.
  74987. * @param effect defines the current effect we try to compile
  74988. * @returns The resulting defines with defines of the current rank removed.
  74989. */
  74990. reduce(currentDefines: string, effect: Effect): string;
  74991. /**
  74992. * Removes the fallback from the bound mesh.
  74993. */
  74994. unBindMesh(): void;
  74995. /**
  74996. * Checks to see if more fallbacks are still availible.
  74997. */
  74998. hasMoreFallbacks: boolean;
  74999. }
  75000. }
  75001. declare module BABYLON {
  75002. /**
  75003. * Class used to evalaute queries containing `and` and `or` operators
  75004. */
  75005. export class AndOrNotEvaluator {
  75006. /**
  75007. * Evaluate a query
  75008. * @param query defines the query to evaluate
  75009. * @param evaluateCallback defines the callback used to filter result
  75010. * @returns true if the query matches
  75011. */
  75012. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75013. private static _HandleParenthesisContent;
  75014. private static _SimplifyNegation;
  75015. }
  75016. }
  75017. declare module BABYLON {
  75018. /**
  75019. * Class used to store custom tags
  75020. */
  75021. export class Tags {
  75022. /**
  75023. * Adds support for tags on the given object
  75024. * @param obj defines the object to use
  75025. */
  75026. static EnableFor(obj: any): void;
  75027. /**
  75028. * Removes tags support
  75029. * @param obj defines the object to use
  75030. */
  75031. static DisableFor(obj: any): void;
  75032. /**
  75033. * Gets a boolean indicating if the given object has tags
  75034. * @param obj defines the object to use
  75035. * @returns a boolean
  75036. */
  75037. static HasTags(obj: any): boolean;
  75038. /**
  75039. * Gets the tags available on a given object
  75040. * @param obj defines the object to use
  75041. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75042. * @returns the tags
  75043. */
  75044. static GetTags(obj: any, asString?: boolean): any;
  75045. /**
  75046. * Adds tags to an object
  75047. * @param obj defines the object to use
  75048. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75049. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75050. */
  75051. static AddTagsTo(obj: any, tagsString: string): void;
  75052. /**
  75053. * @hidden
  75054. */
  75055. static _AddTagTo(obj: any, tag: string): void;
  75056. /**
  75057. * Removes specific tags from a specific object
  75058. * @param obj defines the object to use
  75059. * @param tagsString defines the tags to remove
  75060. */
  75061. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75062. /**
  75063. * @hidden
  75064. */
  75065. static _RemoveTagFrom(obj: any, tag: string): void;
  75066. /**
  75067. * Defines if tags hosted on an object match a given query
  75068. * @param obj defines the object to use
  75069. * @param tagsQuery defines the tag query
  75070. * @returns a boolean
  75071. */
  75072. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75073. }
  75074. }
  75075. declare module BABYLON {
  75076. /**
  75077. * Scalar computation library
  75078. */
  75079. export class Scalar {
  75080. /**
  75081. * Two pi constants convenient for computation.
  75082. */
  75083. static TwoPi: number;
  75084. /**
  75085. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75086. * @param a number
  75087. * @param b number
  75088. * @param epsilon (default = 1.401298E-45)
  75089. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75090. */
  75091. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75092. /**
  75093. * Returns a string : the upper case translation of the number i to hexadecimal.
  75094. * @param i number
  75095. * @returns the upper case translation of the number i to hexadecimal.
  75096. */
  75097. static ToHex(i: number): string;
  75098. /**
  75099. * Returns -1 if value is negative and +1 is value is positive.
  75100. * @param value the value
  75101. * @returns the value itself if it's equal to zero.
  75102. */
  75103. static Sign(value: number): number;
  75104. /**
  75105. * Returns the value itself if it's between min and max.
  75106. * Returns min if the value is lower than min.
  75107. * Returns max if the value is greater than max.
  75108. * @param value the value to clmap
  75109. * @param min the min value to clamp to (default: 0)
  75110. * @param max the max value to clamp to (default: 1)
  75111. * @returns the clamped value
  75112. */
  75113. static Clamp(value: number, min?: number, max?: number): number;
  75114. /**
  75115. * the log2 of value.
  75116. * @param value the value to compute log2 of
  75117. * @returns the log2 of value.
  75118. */
  75119. static Log2(value: number): number;
  75120. /**
  75121. * Loops the value, so that it is never larger than length and never smaller than 0.
  75122. *
  75123. * This is similar to the modulo operator but it works with floating point numbers.
  75124. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75125. * With t = 5 and length = 2.5, the result would be 0.0.
  75126. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75127. * @param value the value
  75128. * @param length the length
  75129. * @returns the looped value
  75130. */
  75131. static Repeat(value: number, length: number): number;
  75132. /**
  75133. * Normalize the value between 0.0 and 1.0 using min and max values
  75134. * @param value value to normalize
  75135. * @param min max to normalize between
  75136. * @param max min to normalize between
  75137. * @returns the normalized value
  75138. */
  75139. static Normalize(value: number, min: number, max: number): number;
  75140. /**
  75141. * Denormalize the value from 0.0 and 1.0 using min and max values
  75142. * @param normalized value to denormalize
  75143. * @param min max to denormalize between
  75144. * @param max min to denormalize between
  75145. * @returns the denormalized value
  75146. */
  75147. static Denormalize(normalized: number, min: number, max: number): number;
  75148. /**
  75149. * Calculates the shortest difference between two given angles given in degrees.
  75150. * @param current current angle in degrees
  75151. * @param target target angle in degrees
  75152. * @returns the delta
  75153. */
  75154. static DeltaAngle(current: number, target: number): number;
  75155. /**
  75156. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75157. * @param tx value
  75158. * @param length length
  75159. * @returns The returned value will move back and forth between 0 and length
  75160. */
  75161. static PingPong(tx: number, length: number): number;
  75162. /**
  75163. * Interpolates between min and max with smoothing at the limits.
  75164. *
  75165. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75166. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75167. * @param from from
  75168. * @param to to
  75169. * @param tx value
  75170. * @returns the smooth stepped value
  75171. */
  75172. static SmoothStep(from: number, to: number, tx: number): number;
  75173. /**
  75174. * Moves a value current towards target.
  75175. *
  75176. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75177. * Negative values of maxDelta pushes the value away from target.
  75178. * @param current current value
  75179. * @param target target value
  75180. * @param maxDelta max distance to move
  75181. * @returns resulting value
  75182. */
  75183. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75184. /**
  75185. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75186. *
  75187. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75188. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75189. * @param current current value
  75190. * @param target target value
  75191. * @param maxDelta max distance to move
  75192. * @returns resulting angle
  75193. */
  75194. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75195. /**
  75196. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75197. * @param start start value
  75198. * @param end target value
  75199. * @param amount amount to lerp between
  75200. * @returns the lerped value
  75201. */
  75202. static Lerp(start: number, end: number, amount: number): number;
  75203. /**
  75204. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75205. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75206. * @param start start value
  75207. * @param end target value
  75208. * @param amount amount to lerp between
  75209. * @returns the lerped value
  75210. */
  75211. static LerpAngle(start: number, end: number, amount: number): number;
  75212. /**
  75213. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75214. * @param a start value
  75215. * @param b target value
  75216. * @param value value between a and b
  75217. * @returns the inverseLerp value
  75218. */
  75219. static InverseLerp(a: number, b: number, value: number): number;
  75220. /**
  75221. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75222. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75223. * @param value1 spline value
  75224. * @param tangent1 spline value
  75225. * @param value2 spline value
  75226. * @param tangent2 spline value
  75227. * @param amount input value
  75228. * @returns hermite result
  75229. */
  75230. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75231. /**
  75232. * Returns a random float number between and min and max values
  75233. * @param min min value of random
  75234. * @param max max value of random
  75235. * @returns random value
  75236. */
  75237. static RandomRange(min: number, max: number): number;
  75238. /**
  75239. * This function returns percentage of a number in a given range.
  75240. *
  75241. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75242. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75243. * @param number to convert to percentage
  75244. * @param min min range
  75245. * @param max max range
  75246. * @returns the percentage
  75247. */
  75248. static RangeToPercent(number: number, min: number, max: number): number;
  75249. /**
  75250. * This function returns number that corresponds to the percentage in a given range.
  75251. *
  75252. * PercentToRange(0.34,0,100) will return 34.
  75253. * @param percent to convert to number
  75254. * @param min min range
  75255. * @param max max range
  75256. * @returns the number
  75257. */
  75258. static PercentToRange(percent: number, min: number, max: number): number;
  75259. /**
  75260. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75261. * @param angle The angle to normalize in radian.
  75262. * @return The converted angle.
  75263. */
  75264. static NormalizeRadians(angle: number): number;
  75265. }
  75266. }
  75267. declare module BABYLON {
  75268. /**
  75269. * Constant used to convert a value to gamma space
  75270. * @ignorenaming
  75271. */
  75272. export const ToGammaSpace: number;
  75273. /**
  75274. * Constant used to convert a value to linear space
  75275. * @ignorenaming
  75276. */
  75277. export const ToLinearSpace = 2.2;
  75278. /**
  75279. * Constant used to define the minimal number value in Babylon.js
  75280. * @ignorenaming
  75281. */
  75282. let Epsilon: number;
  75283. }
  75284. declare module BABYLON {
  75285. /**
  75286. * Class used to represent a viewport on screen
  75287. */
  75288. export class Viewport {
  75289. /** viewport left coordinate */
  75290. x: number;
  75291. /** viewport top coordinate */
  75292. y: number;
  75293. /**viewport width */
  75294. width: number;
  75295. /** viewport height */
  75296. height: number;
  75297. /**
  75298. * Creates a Viewport object located at (x, y) and sized (width, height)
  75299. * @param x defines viewport left coordinate
  75300. * @param y defines viewport top coordinate
  75301. * @param width defines the viewport width
  75302. * @param height defines the viewport height
  75303. */
  75304. constructor(
  75305. /** viewport left coordinate */
  75306. x: number,
  75307. /** viewport top coordinate */
  75308. y: number,
  75309. /**viewport width */
  75310. width: number,
  75311. /** viewport height */
  75312. height: number);
  75313. /**
  75314. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75315. * @param renderWidth defines the rendering width
  75316. * @param renderHeight defines the rendering height
  75317. * @returns a new Viewport
  75318. */
  75319. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75320. /**
  75321. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75322. * @param renderWidth defines the rendering width
  75323. * @param renderHeight defines the rendering height
  75324. * @param ref defines the target viewport
  75325. * @returns the current viewport
  75326. */
  75327. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75328. /**
  75329. * Returns a new Viewport copied from the current one
  75330. * @returns a new Viewport
  75331. */
  75332. clone(): Viewport;
  75333. }
  75334. }
  75335. declare module BABYLON {
  75336. /**
  75337. * Class containing a set of static utilities functions for arrays.
  75338. */
  75339. export class ArrayTools {
  75340. /**
  75341. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75342. * @param size the number of element to construct and put in the array
  75343. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75344. * @returns a new array filled with new objects
  75345. */
  75346. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75347. }
  75348. }
  75349. declare module BABYLON {
  75350. /**
  75351. * Class representing a vector containing 2 coordinates
  75352. */
  75353. export class Vector2 {
  75354. /** defines the first coordinate */
  75355. x: number;
  75356. /** defines the second coordinate */
  75357. y: number;
  75358. /**
  75359. * Creates a new Vector2 from the given x and y coordinates
  75360. * @param x defines the first coordinate
  75361. * @param y defines the second coordinate
  75362. */
  75363. constructor(
  75364. /** defines the first coordinate */
  75365. x?: number,
  75366. /** defines the second coordinate */
  75367. y?: number);
  75368. /**
  75369. * Gets a string with the Vector2 coordinates
  75370. * @returns a string with the Vector2 coordinates
  75371. */
  75372. toString(): string;
  75373. /**
  75374. * Gets class name
  75375. * @returns the string "Vector2"
  75376. */
  75377. getClassName(): string;
  75378. /**
  75379. * Gets current vector hash code
  75380. * @returns the Vector2 hash code as a number
  75381. */
  75382. getHashCode(): number;
  75383. /**
  75384. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75385. * @param array defines the source array
  75386. * @param index defines the offset in source array
  75387. * @returns the current Vector2
  75388. */
  75389. toArray(array: FloatArray, index?: number): Vector2;
  75390. /**
  75391. * Copy the current vector to an array
  75392. * @returns a new array with 2 elements: the Vector2 coordinates.
  75393. */
  75394. asArray(): number[];
  75395. /**
  75396. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75397. * @param source defines the source Vector2
  75398. * @returns the current updated Vector2
  75399. */
  75400. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75401. /**
  75402. * Sets the Vector2 coordinates with the given floats
  75403. * @param x defines the first coordinate
  75404. * @param y defines the second coordinate
  75405. * @returns the current updated Vector2
  75406. */
  75407. copyFromFloats(x: number, y: number): Vector2;
  75408. /**
  75409. * Sets the Vector2 coordinates with the given floats
  75410. * @param x defines the first coordinate
  75411. * @param y defines the second coordinate
  75412. * @returns the current updated Vector2
  75413. */
  75414. set(x: number, y: number): Vector2;
  75415. /**
  75416. * Add another vector with the current one
  75417. * @param otherVector defines the other vector
  75418. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75419. */
  75420. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75421. /**
  75422. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75423. * @param otherVector defines the other vector
  75424. * @param result defines the target vector
  75425. * @returns the unmodified current Vector2
  75426. */
  75427. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75428. /**
  75429. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75430. * @param otherVector defines the other vector
  75431. * @returns the current updated Vector2
  75432. */
  75433. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75434. /**
  75435. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75436. * @param otherVector defines the other vector
  75437. * @returns a new Vector2
  75438. */
  75439. addVector3(otherVector: Vector3): Vector2;
  75440. /**
  75441. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75442. * @param otherVector defines the other vector
  75443. * @returns a new Vector2
  75444. */
  75445. subtract(otherVector: Vector2): Vector2;
  75446. /**
  75447. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75448. * @param otherVector defines the other vector
  75449. * @param result defines the target vector
  75450. * @returns the unmodified current Vector2
  75451. */
  75452. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75453. /**
  75454. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75455. * @param otherVector defines the other vector
  75456. * @returns the current updated Vector2
  75457. */
  75458. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75459. /**
  75460. * Multiplies in place the current Vector2 coordinates by the given ones
  75461. * @param otherVector defines the other vector
  75462. * @returns the current updated Vector2
  75463. */
  75464. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75465. /**
  75466. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75467. * @param otherVector defines the other vector
  75468. * @returns a new Vector2
  75469. */
  75470. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75471. /**
  75472. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75473. * @param otherVector defines the other vector
  75474. * @param result defines the target vector
  75475. * @returns the unmodified current Vector2
  75476. */
  75477. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75478. /**
  75479. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75480. * @param x defines the first coordinate
  75481. * @param y defines the second coordinate
  75482. * @returns a new Vector2
  75483. */
  75484. multiplyByFloats(x: number, y: number): Vector2;
  75485. /**
  75486. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75487. * @param otherVector defines the other vector
  75488. * @returns a new Vector2
  75489. */
  75490. divide(otherVector: Vector2): Vector2;
  75491. /**
  75492. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75493. * @param otherVector defines the other vector
  75494. * @param result defines the target vector
  75495. * @returns the unmodified current Vector2
  75496. */
  75497. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75498. /**
  75499. * Divides the current Vector2 coordinates by the given ones
  75500. * @param otherVector defines the other vector
  75501. * @returns the current updated Vector2
  75502. */
  75503. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75504. /**
  75505. * Gets a new Vector2 with current Vector2 negated coordinates
  75506. * @returns a new Vector2
  75507. */
  75508. negate(): Vector2;
  75509. /**
  75510. * Negate this vector in place
  75511. * @returns this
  75512. */
  75513. negateInPlace(): Vector2;
  75514. /**
  75515. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75516. * @param result defines the Vector3 object where to store the result
  75517. * @returns the current Vector2
  75518. */
  75519. negateToRef(result: Vector2): Vector2;
  75520. /**
  75521. * Multiply the Vector2 coordinates by scale
  75522. * @param scale defines the scaling factor
  75523. * @returns the current updated Vector2
  75524. */
  75525. scaleInPlace(scale: number): Vector2;
  75526. /**
  75527. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75528. * @param scale defines the scaling factor
  75529. * @returns a new Vector2
  75530. */
  75531. scale(scale: number): Vector2;
  75532. /**
  75533. * Scale the current Vector2 values by a factor to a given Vector2
  75534. * @param scale defines the scale factor
  75535. * @param result defines the Vector2 object where to store the result
  75536. * @returns the unmodified current Vector2
  75537. */
  75538. scaleToRef(scale: number, result: Vector2): Vector2;
  75539. /**
  75540. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75541. * @param scale defines the scale factor
  75542. * @param result defines the Vector2 object where to store the result
  75543. * @returns the unmodified current Vector2
  75544. */
  75545. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75546. /**
  75547. * Gets a boolean if two vectors are equals
  75548. * @param otherVector defines the other vector
  75549. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75550. */
  75551. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75552. /**
  75553. * Gets a boolean if two vectors are equals (using an epsilon value)
  75554. * @param otherVector defines the other vector
  75555. * @param epsilon defines the minimal distance to consider equality
  75556. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75557. */
  75558. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75559. /**
  75560. * Gets a new Vector2 from current Vector2 floored values
  75561. * @returns a new Vector2
  75562. */
  75563. floor(): Vector2;
  75564. /**
  75565. * Gets a new Vector2 from current Vector2 floored values
  75566. * @returns a new Vector2
  75567. */
  75568. fract(): Vector2;
  75569. /**
  75570. * Gets the length of the vector
  75571. * @returns the vector length (float)
  75572. */
  75573. length(): number;
  75574. /**
  75575. * Gets the vector squared length
  75576. * @returns the vector squared length (float)
  75577. */
  75578. lengthSquared(): number;
  75579. /**
  75580. * Normalize the vector
  75581. * @returns the current updated Vector2
  75582. */
  75583. normalize(): Vector2;
  75584. /**
  75585. * Gets a new Vector2 copied from the Vector2
  75586. * @returns a new Vector2
  75587. */
  75588. clone(): Vector2;
  75589. /**
  75590. * Gets a new Vector2(0, 0)
  75591. * @returns a new Vector2
  75592. */
  75593. static Zero(): Vector2;
  75594. /**
  75595. * Gets a new Vector2(1, 1)
  75596. * @returns a new Vector2
  75597. */
  75598. static One(): Vector2;
  75599. /**
  75600. * Gets a new Vector2 set from the given index element of the given array
  75601. * @param array defines the data source
  75602. * @param offset defines the offset in the data source
  75603. * @returns a new Vector2
  75604. */
  75605. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75606. /**
  75607. * Sets "result" from the given index element of the given array
  75608. * @param array defines the data source
  75609. * @param offset defines the offset in the data source
  75610. * @param result defines the target vector
  75611. */
  75612. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75613. /**
  75614. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75615. * @param value1 defines 1st point of control
  75616. * @param value2 defines 2nd point of control
  75617. * @param value3 defines 3rd point of control
  75618. * @param value4 defines 4th point of control
  75619. * @param amount defines the interpolation factor
  75620. * @returns a new Vector2
  75621. */
  75622. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75623. /**
  75624. * 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".
  75625. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75626. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75627. * @param value defines the value to clamp
  75628. * @param min defines the lower limit
  75629. * @param max defines the upper limit
  75630. * @returns a new Vector2
  75631. */
  75632. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75633. /**
  75634. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75635. * @param value1 defines the 1st control point
  75636. * @param tangent1 defines the outgoing tangent
  75637. * @param value2 defines the 2nd control point
  75638. * @param tangent2 defines the incoming tangent
  75639. * @param amount defines the interpolation factor
  75640. * @returns a new Vector2
  75641. */
  75642. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75643. /**
  75644. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75645. * @param start defines the start vector
  75646. * @param end defines the end vector
  75647. * @param amount defines the interpolation factor
  75648. * @returns a new Vector2
  75649. */
  75650. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75651. /**
  75652. * Gets the dot product of the vector "left" and the vector "right"
  75653. * @param left defines first vector
  75654. * @param right defines second vector
  75655. * @returns the dot product (float)
  75656. */
  75657. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75658. /**
  75659. * Returns a new Vector2 equal to the normalized given vector
  75660. * @param vector defines the vector to normalize
  75661. * @returns a new Vector2
  75662. */
  75663. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75664. /**
  75665. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75666. * @param left defines 1st vector
  75667. * @param right defines 2nd vector
  75668. * @returns a new Vector2
  75669. */
  75670. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75671. /**
  75672. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75673. * @param left defines 1st vector
  75674. * @param right defines 2nd vector
  75675. * @returns a new Vector2
  75676. */
  75677. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75678. /**
  75679. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75680. * @param vector defines the vector to transform
  75681. * @param transformation defines the matrix to apply
  75682. * @returns a new Vector2
  75683. */
  75684. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75685. /**
  75686. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75687. * @param vector defines the vector to transform
  75688. * @param transformation defines the matrix to apply
  75689. * @param result defines the target vector
  75690. */
  75691. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75692. /**
  75693. * Determines if a given vector is included in a triangle
  75694. * @param p defines the vector to test
  75695. * @param p0 defines 1st triangle point
  75696. * @param p1 defines 2nd triangle point
  75697. * @param p2 defines 3rd triangle point
  75698. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75699. */
  75700. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75701. /**
  75702. * Gets the distance between the vectors "value1" and "value2"
  75703. * @param value1 defines first vector
  75704. * @param value2 defines second vector
  75705. * @returns the distance between vectors
  75706. */
  75707. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75708. /**
  75709. * Returns the squared distance between the vectors "value1" and "value2"
  75710. * @param value1 defines first vector
  75711. * @param value2 defines second vector
  75712. * @returns the squared distance between vectors
  75713. */
  75714. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75715. /**
  75716. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75717. * @param value1 defines first vector
  75718. * @param value2 defines second vector
  75719. * @returns a new Vector2
  75720. */
  75721. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75722. /**
  75723. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75724. * @param p defines the middle point
  75725. * @param segA defines one point of the segment
  75726. * @param segB defines the other point of the segment
  75727. * @returns the shortest distance
  75728. */
  75729. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75730. }
  75731. /**
  75732. * Class used to store (x,y,z) vector representation
  75733. * A Vector3 is the main object used in 3D geometry
  75734. * It can represent etiher the coordinates of a point the space, either a direction
  75735. * Reminder: js uses a left handed forward facing system
  75736. */
  75737. export class Vector3 {
  75738. /**
  75739. * Defines the first coordinates (on X axis)
  75740. */
  75741. x: number;
  75742. /**
  75743. * Defines the second coordinates (on Y axis)
  75744. */
  75745. y: number;
  75746. /**
  75747. * Defines the third coordinates (on Z axis)
  75748. */
  75749. z: number;
  75750. private static _UpReadOnly;
  75751. private static _ZeroReadOnly;
  75752. /**
  75753. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75754. * @param x defines the first coordinates (on X axis)
  75755. * @param y defines the second coordinates (on Y axis)
  75756. * @param z defines the third coordinates (on Z axis)
  75757. */
  75758. constructor(
  75759. /**
  75760. * Defines the first coordinates (on X axis)
  75761. */
  75762. x?: number,
  75763. /**
  75764. * Defines the second coordinates (on Y axis)
  75765. */
  75766. y?: number,
  75767. /**
  75768. * Defines the third coordinates (on Z axis)
  75769. */
  75770. z?: number);
  75771. /**
  75772. * Creates a string representation of the Vector3
  75773. * @returns a string with the Vector3 coordinates.
  75774. */
  75775. toString(): string;
  75776. /**
  75777. * Gets the class name
  75778. * @returns the string "Vector3"
  75779. */
  75780. getClassName(): string;
  75781. /**
  75782. * Creates the Vector3 hash code
  75783. * @returns a number which tends to be unique between Vector3 instances
  75784. */
  75785. getHashCode(): number;
  75786. /**
  75787. * Creates an array containing three elements : the coordinates of the Vector3
  75788. * @returns a new array of numbers
  75789. */
  75790. asArray(): number[];
  75791. /**
  75792. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75793. * @param array defines the destination array
  75794. * @param index defines the offset in the destination array
  75795. * @returns the current Vector3
  75796. */
  75797. toArray(array: FloatArray, index?: number): Vector3;
  75798. /**
  75799. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75800. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75801. */
  75802. toQuaternion(): Quaternion;
  75803. /**
  75804. * Adds the given vector to the current Vector3
  75805. * @param otherVector defines the second operand
  75806. * @returns the current updated Vector3
  75807. */
  75808. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75809. /**
  75810. * Adds the given coordinates to the current Vector3
  75811. * @param x defines the x coordinate of the operand
  75812. * @param y defines the y coordinate of the operand
  75813. * @param z defines the z coordinate of the operand
  75814. * @returns the current updated Vector3
  75815. */
  75816. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75817. /**
  75818. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75819. * @param otherVector defines the second operand
  75820. * @returns the resulting Vector3
  75821. */
  75822. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75823. /**
  75824. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75825. * @param otherVector defines the second operand
  75826. * @param result defines the Vector3 object where to store the result
  75827. * @returns the current Vector3
  75828. */
  75829. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75830. /**
  75831. * Subtract the given vector from the current Vector3
  75832. * @param otherVector defines the second operand
  75833. * @returns the current updated Vector3
  75834. */
  75835. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75836. /**
  75837. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75838. * @param otherVector defines the second operand
  75839. * @returns the resulting Vector3
  75840. */
  75841. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75842. /**
  75843. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75844. * @param otherVector defines the second operand
  75845. * @param result defines the Vector3 object where to store the result
  75846. * @returns the current Vector3
  75847. */
  75848. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75849. /**
  75850. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75851. * @param x defines the x coordinate of the operand
  75852. * @param y defines the y coordinate of the operand
  75853. * @param z defines the z coordinate of the operand
  75854. * @returns the resulting Vector3
  75855. */
  75856. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75857. /**
  75858. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75859. * @param x defines the x coordinate of the operand
  75860. * @param y defines the y coordinate of the operand
  75861. * @param z defines the z coordinate of the operand
  75862. * @param result defines the Vector3 object where to store the result
  75863. * @returns the current Vector3
  75864. */
  75865. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75866. /**
  75867. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75868. * @returns a new Vector3
  75869. */
  75870. negate(): Vector3;
  75871. /**
  75872. * Negate this vector in place
  75873. * @returns this
  75874. */
  75875. negateInPlace(): Vector3;
  75876. /**
  75877. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75878. * @param result defines the Vector3 object where to store the result
  75879. * @returns the current Vector3
  75880. */
  75881. negateToRef(result: Vector3): Vector3;
  75882. /**
  75883. * Multiplies the Vector3 coordinates by the float "scale"
  75884. * @param scale defines the multiplier factor
  75885. * @returns the current updated Vector3
  75886. */
  75887. scaleInPlace(scale: number): Vector3;
  75888. /**
  75889. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75890. * @param scale defines the multiplier factor
  75891. * @returns a new Vector3
  75892. */
  75893. scale(scale: number): Vector3;
  75894. /**
  75895. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75896. * @param scale defines the multiplier factor
  75897. * @param result defines the Vector3 object where to store the result
  75898. * @returns the current Vector3
  75899. */
  75900. scaleToRef(scale: number, result: Vector3): Vector3;
  75901. /**
  75902. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75903. * @param scale defines the scale factor
  75904. * @param result defines the Vector3 object where to store the result
  75905. * @returns the unmodified current Vector3
  75906. */
  75907. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75908. /**
  75909. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75910. * @param otherVector defines the second operand
  75911. * @returns true if both vectors are equals
  75912. */
  75913. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75914. /**
  75915. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75916. * @param otherVector defines the second operand
  75917. * @param epsilon defines the minimal distance to define values as equals
  75918. * @returns true if both vectors are distant less than epsilon
  75919. */
  75920. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75921. /**
  75922. * Returns true if the current Vector3 coordinates equals the given floats
  75923. * @param x defines the x coordinate of the operand
  75924. * @param y defines the y coordinate of the operand
  75925. * @param z defines the z coordinate of the operand
  75926. * @returns true if both vectors are equals
  75927. */
  75928. equalsToFloats(x: number, y: number, z: number): boolean;
  75929. /**
  75930. * Multiplies the current Vector3 coordinates by the given ones
  75931. * @param otherVector defines the second operand
  75932. * @returns the current updated Vector3
  75933. */
  75934. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75935. /**
  75936. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75937. * @param otherVector defines the second operand
  75938. * @returns the new Vector3
  75939. */
  75940. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75941. /**
  75942. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75943. * @param otherVector defines the second operand
  75944. * @param result defines the Vector3 object where to store the result
  75945. * @returns the current Vector3
  75946. */
  75947. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75948. /**
  75949. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75950. * @param x defines the x coordinate of the operand
  75951. * @param y defines the y coordinate of the operand
  75952. * @param z defines the z coordinate of the operand
  75953. * @returns the new Vector3
  75954. */
  75955. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75956. /**
  75957. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75958. * @param otherVector defines the second operand
  75959. * @returns the new Vector3
  75960. */
  75961. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75962. /**
  75963. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75964. * @param otherVector defines the second operand
  75965. * @param result defines the Vector3 object where to store the result
  75966. * @returns the current Vector3
  75967. */
  75968. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75969. /**
  75970. * Divides the current Vector3 coordinates by the given ones.
  75971. * @param otherVector defines the second operand
  75972. * @returns the current updated Vector3
  75973. */
  75974. divideInPlace(otherVector: Vector3): Vector3;
  75975. /**
  75976. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75977. * @param other defines the second operand
  75978. * @returns the current updated Vector3
  75979. */
  75980. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75981. /**
  75982. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75983. * @param other defines the second operand
  75984. * @returns the current updated Vector3
  75985. */
  75986. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75987. /**
  75988. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75989. * @param x defines the x coordinate of the operand
  75990. * @param y defines the y coordinate of the operand
  75991. * @param z defines the z coordinate of the operand
  75992. * @returns the current updated Vector3
  75993. */
  75994. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75995. /**
  75996. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75997. * @param x defines the x coordinate of the operand
  75998. * @param y defines the y coordinate of the operand
  75999. * @param z defines the z coordinate of the operand
  76000. * @returns the current updated Vector3
  76001. */
  76002. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76003. /**
  76004. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76005. * Check if is non uniform within a certain amount of decimal places to account for this
  76006. * @param epsilon the amount the values can differ
  76007. * @returns if the the vector is non uniform to a certain number of decimal places
  76008. */
  76009. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76010. /**
  76011. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76012. */
  76013. get isNonUniform(): boolean;
  76014. /**
  76015. * Gets a new Vector3 from current Vector3 floored values
  76016. * @returns a new Vector3
  76017. */
  76018. floor(): Vector3;
  76019. /**
  76020. * Gets a new Vector3 from current Vector3 floored values
  76021. * @returns a new Vector3
  76022. */
  76023. fract(): Vector3;
  76024. /**
  76025. * Gets the length of the Vector3
  76026. * @returns the length of the Vector3
  76027. */
  76028. length(): number;
  76029. /**
  76030. * Gets the squared length of the Vector3
  76031. * @returns squared length of the Vector3
  76032. */
  76033. lengthSquared(): number;
  76034. /**
  76035. * Normalize the current Vector3.
  76036. * Please note that this is an in place operation.
  76037. * @returns the current updated Vector3
  76038. */
  76039. normalize(): Vector3;
  76040. /**
  76041. * Reorders the x y z properties of the vector in place
  76042. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76043. * @returns the current updated vector
  76044. */
  76045. reorderInPlace(order: string): this;
  76046. /**
  76047. * Rotates the vector around 0,0,0 by a quaternion
  76048. * @param quaternion the rotation quaternion
  76049. * @param result vector to store the result
  76050. * @returns the resulting vector
  76051. */
  76052. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76053. /**
  76054. * Rotates a vector around a given point
  76055. * @param quaternion the rotation quaternion
  76056. * @param point the point to rotate around
  76057. * @param result vector to store the result
  76058. * @returns the resulting vector
  76059. */
  76060. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76061. /**
  76062. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76063. * The cross product is then orthogonal to both current and "other"
  76064. * @param other defines the right operand
  76065. * @returns the cross product
  76066. */
  76067. cross(other: Vector3): Vector3;
  76068. /**
  76069. * Normalize the current Vector3 with the given input length.
  76070. * Please note that this is an in place operation.
  76071. * @param len the length of the vector
  76072. * @returns the current updated Vector3
  76073. */
  76074. normalizeFromLength(len: number): Vector3;
  76075. /**
  76076. * Normalize the current Vector3 to a new vector
  76077. * @returns the new Vector3
  76078. */
  76079. normalizeToNew(): Vector3;
  76080. /**
  76081. * Normalize the current Vector3 to the reference
  76082. * @param reference define the Vector3 to update
  76083. * @returns the updated Vector3
  76084. */
  76085. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76086. /**
  76087. * Creates a new Vector3 copied from the current Vector3
  76088. * @returns the new Vector3
  76089. */
  76090. clone(): Vector3;
  76091. /**
  76092. * Copies the given vector coordinates to the current Vector3 ones
  76093. * @param source defines the source Vector3
  76094. * @returns the current updated Vector3
  76095. */
  76096. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76097. /**
  76098. * Copies the given floats to the current Vector3 coordinates
  76099. * @param x defines the x coordinate of the operand
  76100. * @param y defines the y coordinate of the operand
  76101. * @param z defines the z coordinate of the operand
  76102. * @returns the current updated Vector3
  76103. */
  76104. copyFromFloats(x: number, y: number, z: number): Vector3;
  76105. /**
  76106. * Copies the given floats to the current Vector3 coordinates
  76107. * @param x defines the x coordinate of the operand
  76108. * @param y defines the y coordinate of the operand
  76109. * @param z defines the z coordinate of the operand
  76110. * @returns the current updated Vector3
  76111. */
  76112. set(x: number, y: number, z: number): Vector3;
  76113. /**
  76114. * Copies the given float to the current Vector3 coordinates
  76115. * @param v defines the x, y and z coordinates of the operand
  76116. * @returns the current updated Vector3
  76117. */
  76118. setAll(v: number): Vector3;
  76119. /**
  76120. * Get the clip factor between two vectors
  76121. * @param vector0 defines the first operand
  76122. * @param vector1 defines the second operand
  76123. * @param axis defines the axis to use
  76124. * @param size defines the size along the axis
  76125. * @returns the clip factor
  76126. */
  76127. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76128. /**
  76129. * Get angle between two vectors
  76130. * @param vector0 angle between vector0 and vector1
  76131. * @param vector1 angle between vector0 and vector1
  76132. * @param normal direction of the normal
  76133. * @return the angle between vector0 and vector1
  76134. */
  76135. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76136. /**
  76137. * Returns a new Vector3 set from the index "offset" of the given array
  76138. * @param array defines the source array
  76139. * @param offset defines the offset in the source array
  76140. * @returns the new Vector3
  76141. */
  76142. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76143. /**
  76144. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76145. * @param array defines the source array
  76146. * @param offset defines the offset in the source array
  76147. * @returns the new Vector3
  76148. * @deprecated Please use FromArray instead.
  76149. */
  76150. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76151. /**
  76152. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76153. * @param array defines the source array
  76154. * @param offset defines the offset in the source array
  76155. * @param result defines the Vector3 where to store the result
  76156. */
  76157. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76158. /**
  76159. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76160. * @param array defines the source array
  76161. * @param offset defines the offset in the source array
  76162. * @param result defines the Vector3 where to store the result
  76163. * @deprecated Please use FromArrayToRef instead.
  76164. */
  76165. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76166. /**
  76167. * Sets the given vector "result" with the given floats.
  76168. * @param x defines the x coordinate of the source
  76169. * @param y defines the y coordinate of the source
  76170. * @param z defines the z coordinate of the source
  76171. * @param result defines the Vector3 where to store the result
  76172. */
  76173. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76174. /**
  76175. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76176. * @returns a new empty Vector3
  76177. */
  76178. static Zero(): Vector3;
  76179. /**
  76180. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76181. * @returns a new unit Vector3
  76182. */
  76183. static One(): Vector3;
  76184. /**
  76185. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76186. * @returns a new up Vector3
  76187. */
  76188. static Up(): Vector3;
  76189. /**
  76190. * Gets a up Vector3 that must not be updated
  76191. */
  76192. static get UpReadOnly(): DeepImmutable<Vector3>;
  76193. /**
  76194. * Gets a zero Vector3 that must not be updated
  76195. */
  76196. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76197. /**
  76198. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76199. * @returns a new down Vector3
  76200. */
  76201. static Down(): Vector3;
  76202. /**
  76203. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76204. * @returns a new forward Vector3
  76205. */
  76206. static Forward(): Vector3;
  76207. /**
  76208. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76209. * @returns a new forward Vector3
  76210. */
  76211. static Backward(): Vector3;
  76212. /**
  76213. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76214. * @returns a new right Vector3
  76215. */
  76216. static Right(): Vector3;
  76217. /**
  76218. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76219. * @returns a new left Vector3
  76220. */
  76221. static Left(): Vector3;
  76222. /**
  76223. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76224. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76225. * @param vector defines the Vector3 to transform
  76226. * @param transformation defines the transformation matrix
  76227. * @returns the transformed Vector3
  76228. */
  76229. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76230. /**
  76231. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76232. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76233. * @param vector defines the Vector3 to transform
  76234. * @param transformation defines the transformation matrix
  76235. * @param result defines the Vector3 where to store the result
  76236. */
  76237. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76238. /**
  76239. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76240. * This method computes tranformed coordinates only, not transformed direction vectors
  76241. * @param x define the x coordinate of the source vector
  76242. * @param y define the y coordinate of the source vector
  76243. * @param z define the z coordinate of the source vector
  76244. * @param transformation defines the transformation matrix
  76245. * @param result defines the Vector3 where to store the result
  76246. */
  76247. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76248. /**
  76249. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76250. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76251. * @param vector defines the Vector3 to transform
  76252. * @param transformation defines the transformation matrix
  76253. * @returns the new Vector3
  76254. */
  76255. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76256. /**
  76257. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76258. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76259. * @param vector defines the Vector3 to transform
  76260. * @param transformation defines the transformation matrix
  76261. * @param result defines the Vector3 where to store the result
  76262. */
  76263. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76264. /**
  76265. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76266. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76267. * @param x define the x coordinate of the source vector
  76268. * @param y define the y coordinate of the source vector
  76269. * @param z define the z coordinate of the source vector
  76270. * @param transformation defines the transformation matrix
  76271. * @param result defines the Vector3 where to store the result
  76272. */
  76273. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76274. /**
  76275. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76276. * @param value1 defines the first control point
  76277. * @param value2 defines the second control point
  76278. * @param value3 defines the third control point
  76279. * @param value4 defines the fourth control point
  76280. * @param amount defines the amount on the spline to use
  76281. * @returns the new Vector3
  76282. */
  76283. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76284. /**
  76285. * 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"
  76286. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76287. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76288. * @param value defines the current value
  76289. * @param min defines the lower range value
  76290. * @param max defines the upper range value
  76291. * @returns the new Vector3
  76292. */
  76293. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76294. /**
  76295. * 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"
  76296. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76297. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76298. * @param value defines the current value
  76299. * @param min defines the lower range value
  76300. * @param max defines the upper range value
  76301. * @param result defines the Vector3 where to store the result
  76302. */
  76303. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76304. /**
  76305. * Checks if a given vector is inside a specific range
  76306. * @param v defines the vector to test
  76307. * @param min defines the minimum range
  76308. * @param max defines the maximum range
  76309. */
  76310. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76311. /**
  76312. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76313. * @param value1 defines the first control point
  76314. * @param tangent1 defines the first tangent vector
  76315. * @param value2 defines the second control point
  76316. * @param tangent2 defines the second tangent vector
  76317. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76318. * @returns the new Vector3
  76319. */
  76320. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76321. /**
  76322. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76323. * @param start defines the start value
  76324. * @param end defines the end value
  76325. * @param amount max defines amount between both (between 0 and 1)
  76326. * @returns the new Vector3
  76327. */
  76328. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76329. /**
  76330. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76331. * @param start defines the start value
  76332. * @param end defines the end value
  76333. * @param amount max defines amount between both (between 0 and 1)
  76334. * @param result defines the Vector3 where to store the result
  76335. */
  76336. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76337. /**
  76338. * Returns the dot product (float) between the vectors "left" and "right"
  76339. * @param left defines the left operand
  76340. * @param right defines the right operand
  76341. * @returns the dot product
  76342. */
  76343. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76344. /**
  76345. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76346. * The cross product is then orthogonal to both "left" and "right"
  76347. * @param left defines the left operand
  76348. * @param right defines the right operand
  76349. * @returns the cross product
  76350. */
  76351. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76352. /**
  76353. * Sets the given vector "result" with the cross product of "left" and "right"
  76354. * The cross product is then orthogonal to both "left" and "right"
  76355. * @param left defines the left operand
  76356. * @param right defines the right operand
  76357. * @param result defines the Vector3 where to store the result
  76358. */
  76359. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76360. /**
  76361. * Returns a new Vector3 as the normalization of the given vector
  76362. * @param vector defines the Vector3 to normalize
  76363. * @returns the new Vector3
  76364. */
  76365. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76366. /**
  76367. * Sets the given vector "result" with the normalization of the given first vector
  76368. * @param vector defines the Vector3 to normalize
  76369. * @param result defines the Vector3 where to store the result
  76370. */
  76371. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76372. /**
  76373. * Project a Vector3 onto screen space
  76374. * @param vector defines the Vector3 to project
  76375. * @param world defines the world matrix to use
  76376. * @param transform defines the transform (view x projection) matrix to use
  76377. * @param viewport defines the screen viewport to use
  76378. * @returns the new Vector3
  76379. */
  76380. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76381. /** @hidden */
  76382. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76383. /**
  76384. * Unproject from screen space to object space
  76385. * @param source defines the screen space Vector3 to use
  76386. * @param viewportWidth defines the current width of the viewport
  76387. * @param viewportHeight defines the current height of the viewport
  76388. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76389. * @param transform defines the transform (view x projection) matrix to use
  76390. * @returns the new Vector3
  76391. */
  76392. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76393. /**
  76394. * Unproject from screen space to object space
  76395. * @param source defines the screen space Vector3 to use
  76396. * @param viewportWidth defines the current width of the viewport
  76397. * @param viewportHeight defines the current height of the viewport
  76398. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76399. * @param view defines the view matrix to use
  76400. * @param projection defines the projection matrix to use
  76401. * @returns the new Vector3
  76402. */
  76403. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76404. /**
  76405. * Unproject from screen space to object space
  76406. * @param source defines the screen space Vector3 to use
  76407. * @param viewportWidth defines the current width of the viewport
  76408. * @param viewportHeight defines the current height of the viewport
  76409. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76410. * @param view defines the view matrix to use
  76411. * @param projection defines the projection matrix to use
  76412. * @param result defines the Vector3 where to store the result
  76413. */
  76414. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76415. /**
  76416. * Unproject from screen space to object space
  76417. * @param sourceX defines the screen space x coordinate to use
  76418. * @param sourceY defines the screen space y coordinate to use
  76419. * @param sourceZ defines the screen space z coordinate to use
  76420. * @param viewportWidth defines the current width of the viewport
  76421. * @param viewportHeight defines the current height of the viewport
  76422. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76423. * @param view defines the view matrix to use
  76424. * @param projection defines the projection matrix to use
  76425. * @param result defines the Vector3 where to store the result
  76426. */
  76427. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76428. /**
  76429. * Gets the minimal coordinate values between two Vector3
  76430. * @param left defines the first operand
  76431. * @param right defines the second operand
  76432. * @returns the new Vector3
  76433. */
  76434. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76435. /**
  76436. * Gets the maximal coordinate values between two Vector3
  76437. * @param left defines the first operand
  76438. * @param right defines the second operand
  76439. * @returns the new Vector3
  76440. */
  76441. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76442. /**
  76443. * Returns the distance between the vectors "value1" and "value2"
  76444. * @param value1 defines the first operand
  76445. * @param value2 defines the second operand
  76446. * @returns the distance
  76447. */
  76448. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76449. /**
  76450. * Returns the squared distance between the vectors "value1" and "value2"
  76451. * @param value1 defines the first operand
  76452. * @param value2 defines the second operand
  76453. * @returns the squared distance
  76454. */
  76455. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76456. /**
  76457. * Returns a new Vector3 located at the center between "value1" and "value2"
  76458. * @param value1 defines the first operand
  76459. * @param value2 defines the second operand
  76460. * @returns the new Vector3
  76461. */
  76462. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76463. /**
  76464. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76465. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76466. * to something in order to rotate it from its local system to the given target system
  76467. * Note: axis1, axis2 and axis3 are normalized during this operation
  76468. * @param axis1 defines the first axis
  76469. * @param axis2 defines the second axis
  76470. * @param axis3 defines the third axis
  76471. * @returns a new Vector3
  76472. */
  76473. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76474. /**
  76475. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76476. * @param axis1 defines the first axis
  76477. * @param axis2 defines the second axis
  76478. * @param axis3 defines the third axis
  76479. * @param ref defines the Vector3 where to store the result
  76480. */
  76481. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76482. }
  76483. /**
  76484. * Vector4 class created for EulerAngle class conversion to Quaternion
  76485. */
  76486. export class Vector4 {
  76487. /** x value of the vector */
  76488. x: number;
  76489. /** y value of the vector */
  76490. y: number;
  76491. /** z value of the vector */
  76492. z: number;
  76493. /** w value of the vector */
  76494. w: number;
  76495. /**
  76496. * Creates a Vector4 object from the given floats.
  76497. * @param x x value of the vector
  76498. * @param y y value of the vector
  76499. * @param z z value of the vector
  76500. * @param w w value of the vector
  76501. */
  76502. constructor(
  76503. /** x value of the vector */
  76504. x: number,
  76505. /** y value of the vector */
  76506. y: number,
  76507. /** z value of the vector */
  76508. z: number,
  76509. /** w value of the vector */
  76510. w: number);
  76511. /**
  76512. * Returns the string with the Vector4 coordinates.
  76513. * @returns a string containing all the vector values
  76514. */
  76515. toString(): string;
  76516. /**
  76517. * Returns the string "Vector4".
  76518. * @returns "Vector4"
  76519. */
  76520. getClassName(): string;
  76521. /**
  76522. * Returns the Vector4 hash code.
  76523. * @returns a unique hash code
  76524. */
  76525. getHashCode(): number;
  76526. /**
  76527. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76528. * @returns the resulting array
  76529. */
  76530. asArray(): number[];
  76531. /**
  76532. * Populates the given array from the given index with the Vector4 coordinates.
  76533. * @param array array to populate
  76534. * @param index index of the array to start at (default: 0)
  76535. * @returns the Vector4.
  76536. */
  76537. toArray(array: FloatArray, index?: number): Vector4;
  76538. /**
  76539. * Adds the given vector to the current Vector4.
  76540. * @param otherVector the vector to add
  76541. * @returns the updated Vector4.
  76542. */
  76543. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76544. /**
  76545. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76546. * @param otherVector the vector to add
  76547. * @returns the resulting vector
  76548. */
  76549. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76550. /**
  76551. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76552. * @param otherVector the vector to add
  76553. * @param result the vector to store the result
  76554. * @returns the current Vector4.
  76555. */
  76556. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76557. /**
  76558. * Subtract in place the given vector from the current Vector4.
  76559. * @param otherVector the vector to subtract
  76560. * @returns the updated Vector4.
  76561. */
  76562. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76563. /**
  76564. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76565. * @param otherVector the vector to add
  76566. * @returns the new vector with the result
  76567. */
  76568. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76569. /**
  76570. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76571. * @param otherVector the vector to subtract
  76572. * @param result the vector to store the result
  76573. * @returns the current Vector4.
  76574. */
  76575. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76576. /**
  76577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76578. */
  76579. /**
  76580. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76581. * @param x value to subtract
  76582. * @param y value to subtract
  76583. * @param z value to subtract
  76584. * @param w value to subtract
  76585. * @returns new vector containing the result
  76586. */
  76587. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76588. /**
  76589. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76590. * @param x value to subtract
  76591. * @param y value to subtract
  76592. * @param z value to subtract
  76593. * @param w value to subtract
  76594. * @param result the vector to store the result in
  76595. * @returns the current Vector4.
  76596. */
  76597. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76598. /**
  76599. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76600. * @returns a new vector with the negated values
  76601. */
  76602. negate(): Vector4;
  76603. /**
  76604. * Negate this vector in place
  76605. * @returns this
  76606. */
  76607. negateInPlace(): Vector4;
  76608. /**
  76609. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76610. * @param result defines the Vector3 object where to store the result
  76611. * @returns the current Vector4
  76612. */
  76613. negateToRef(result: Vector4): Vector4;
  76614. /**
  76615. * Multiplies the current Vector4 coordinates by scale (float).
  76616. * @param scale the number to scale with
  76617. * @returns the updated Vector4.
  76618. */
  76619. scaleInPlace(scale: number): Vector4;
  76620. /**
  76621. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76622. * @param scale the number to scale with
  76623. * @returns a new vector with the result
  76624. */
  76625. scale(scale: number): Vector4;
  76626. /**
  76627. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76628. * @param scale the number to scale with
  76629. * @param result a vector to store the result in
  76630. * @returns the current Vector4.
  76631. */
  76632. scaleToRef(scale: number, result: Vector4): Vector4;
  76633. /**
  76634. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76635. * @param scale defines the scale factor
  76636. * @param result defines the Vector4 object where to store the result
  76637. * @returns the unmodified current Vector4
  76638. */
  76639. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76640. /**
  76641. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76642. * @param otherVector the vector to compare against
  76643. * @returns true if they are equal
  76644. */
  76645. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76646. /**
  76647. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76648. * @param otherVector vector to compare against
  76649. * @param epsilon (Default: very small number)
  76650. * @returns true if they are equal
  76651. */
  76652. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76653. /**
  76654. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76655. * @param x x value to compare against
  76656. * @param y y value to compare against
  76657. * @param z z value to compare against
  76658. * @param w w value to compare against
  76659. * @returns true if equal
  76660. */
  76661. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76662. /**
  76663. * Multiplies in place the current Vector4 by the given one.
  76664. * @param otherVector vector to multiple with
  76665. * @returns the updated Vector4.
  76666. */
  76667. multiplyInPlace(otherVector: Vector4): Vector4;
  76668. /**
  76669. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76670. * @param otherVector vector to multiple with
  76671. * @returns resulting new vector
  76672. */
  76673. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76674. /**
  76675. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76676. * @param otherVector vector to multiple with
  76677. * @param result vector to store the result
  76678. * @returns the current Vector4.
  76679. */
  76680. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76681. /**
  76682. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76683. * @param x x value multiply with
  76684. * @param y y value multiply with
  76685. * @param z z value multiply with
  76686. * @param w w value multiply with
  76687. * @returns resulting new vector
  76688. */
  76689. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76690. /**
  76691. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76692. * @param otherVector vector to devide with
  76693. * @returns resulting new vector
  76694. */
  76695. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76696. /**
  76697. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76698. * @param otherVector vector to devide with
  76699. * @param result vector to store the result
  76700. * @returns the current Vector4.
  76701. */
  76702. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76703. /**
  76704. * Divides the current Vector3 coordinates by the given ones.
  76705. * @param otherVector vector to devide with
  76706. * @returns the updated Vector3.
  76707. */
  76708. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76709. /**
  76710. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76711. * @param other defines the second operand
  76712. * @returns the current updated Vector4
  76713. */
  76714. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76715. /**
  76716. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76717. * @param other defines the second operand
  76718. * @returns the current updated Vector4
  76719. */
  76720. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76721. /**
  76722. * Gets a new Vector4 from current Vector4 floored values
  76723. * @returns a new Vector4
  76724. */
  76725. floor(): Vector4;
  76726. /**
  76727. * Gets a new Vector4 from current Vector3 floored values
  76728. * @returns a new Vector4
  76729. */
  76730. fract(): Vector4;
  76731. /**
  76732. * Returns the Vector4 length (float).
  76733. * @returns the length
  76734. */
  76735. length(): number;
  76736. /**
  76737. * Returns the Vector4 squared length (float).
  76738. * @returns the length squared
  76739. */
  76740. lengthSquared(): number;
  76741. /**
  76742. * Normalizes in place the Vector4.
  76743. * @returns the updated Vector4.
  76744. */
  76745. normalize(): Vector4;
  76746. /**
  76747. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76748. * @returns this converted to a new vector3
  76749. */
  76750. toVector3(): Vector3;
  76751. /**
  76752. * Returns a new Vector4 copied from the current one.
  76753. * @returns the new cloned vector
  76754. */
  76755. clone(): Vector4;
  76756. /**
  76757. * Updates the current Vector4 with the given one coordinates.
  76758. * @param source the source vector to copy from
  76759. * @returns the updated Vector4.
  76760. */
  76761. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76762. /**
  76763. * Updates the current Vector4 coordinates with the given floats.
  76764. * @param x float to copy from
  76765. * @param y float to copy from
  76766. * @param z float to copy from
  76767. * @param w float to copy from
  76768. * @returns the updated Vector4.
  76769. */
  76770. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76771. /**
  76772. * Updates the current Vector4 coordinates with the given floats.
  76773. * @param x float to set from
  76774. * @param y float to set from
  76775. * @param z float to set from
  76776. * @param w float to set from
  76777. * @returns the updated Vector4.
  76778. */
  76779. set(x: number, y: number, z: number, w: number): Vector4;
  76780. /**
  76781. * Copies the given float to the current Vector3 coordinates
  76782. * @param v defines the x, y, z and w coordinates of the operand
  76783. * @returns the current updated Vector3
  76784. */
  76785. setAll(v: number): Vector4;
  76786. /**
  76787. * Returns a new Vector4 set from the starting index of the given array.
  76788. * @param array the array to pull values from
  76789. * @param offset the offset into the array to start at
  76790. * @returns the new vector
  76791. */
  76792. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76793. /**
  76794. * Updates the given vector "result" from the starting index of the given array.
  76795. * @param array the array to pull values from
  76796. * @param offset the offset into the array to start at
  76797. * @param result the vector to store the result in
  76798. */
  76799. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76800. /**
  76801. * Updates the given vector "result" from the starting index of the given Float32Array.
  76802. * @param array the array to pull values from
  76803. * @param offset the offset into the array to start at
  76804. * @param result the vector to store the result in
  76805. */
  76806. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76807. /**
  76808. * Updates the given vector "result" coordinates from the given floats.
  76809. * @param x float to set from
  76810. * @param y float to set from
  76811. * @param z float to set from
  76812. * @param w float to set from
  76813. * @param result the vector to the floats in
  76814. */
  76815. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76816. /**
  76817. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76818. * @returns the new vector
  76819. */
  76820. static Zero(): Vector4;
  76821. /**
  76822. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76823. * @returns the new vector
  76824. */
  76825. static One(): Vector4;
  76826. /**
  76827. * Returns a new normalized Vector4 from the given one.
  76828. * @param vector the vector to normalize
  76829. * @returns the vector
  76830. */
  76831. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76832. /**
  76833. * Updates the given vector "result" from the normalization of the given one.
  76834. * @param vector the vector to normalize
  76835. * @param result the vector to store the result in
  76836. */
  76837. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76838. /**
  76839. * Returns a vector with the minimum values from the left and right vectors
  76840. * @param left left vector to minimize
  76841. * @param right right vector to minimize
  76842. * @returns a new vector with the minimum of the left and right vector values
  76843. */
  76844. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76845. /**
  76846. * Returns a vector with the maximum values from the left and right vectors
  76847. * @param left left vector to maximize
  76848. * @param right right vector to maximize
  76849. * @returns a new vector with the maximum of the left and right vector values
  76850. */
  76851. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76852. /**
  76853. * Returns the distance (float) between the vectors "value1" and "value2".
  76854. * @param value1 value to calulate the distance between
  76855. * @param value2 value to calulate the distance between
  76856. * @return the distance between the two vectors
  76857. */
  76858. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76859. /**
  76860. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76861. * @param value1 value to calulate the distance between
  76862. * @param value2 value to calulate the distance between
  76863. * @return the distance between the two vectors squared
  76864. */
  76865. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76866. /**
  76867. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76868. * @param value1 value to calulate the center between
  76869. * @param value2 value to calulate the center between
  76870. * @return the center between the two vectors
  76871. */
  76872. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76873. /**
  76874. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76875. * This methods computes transformed normalized direction vectors only.
  76876. * @param vector the vector to transform
  76877. * @param transformation the transformation matrix to apply
  76878. * @returns the new vector
  76879. */
  76880. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76881. /**
  76882. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76883. * This methods computes transformed normalized direction vectors only.
  76884. * @param vector the vector to transform
  76885. * @param transformation the transformation matrix to apply
  76886. * @param result the vector to store the result in
  76887. */
  76888. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76889. /**
  76890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76891. * This methods computes transformed normalized direction vectors only.
  76892. * @param x value to transform
  76893. * @param y value to transform
  76894. * @param z value to transform
  76895. * @param w value to transform
  76896. * @param transformation the transformation matrix to apply
  76897. * @param result the vector to store the results in
  76898. */
  76899. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76900. /**
  76901. * Creates a new Vector4 from a Vector3
  76902. * @param source defines the source data
  76903. * @param w defines the 4th component (default is 0)
  76904. * @returns a new Vector4
  76905. */
  76906. static FromVector3(source: Vector3, w?: number): Vector4;
  76907. }
  76908. /**
  76909. * Class used to store quaternion data
  76910. * @see https://en.wikipedia.org/wiki/Quaternion
  76911. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76912. */
  76913. export class Quaternion {
  76914. /** defines the first component (0 by default) */
  76915. x: number;
  76916. /** defines the second component (0 by default) */
  76917. y: number;
  76918. /** defines the third component (0 by default) */
  76919. z: number;
  76920. /** defines the fourth component (1.0 by default) */
  76921. w: number;
  76922. /**
  76923. * Creates a new Quaternion from the given floats
  76924. * @param x defines the first component (0 by default)
  76925. * @param y defines the second component (0 by default)
  76926. * @param z defines the third component (0 by default)
  76927. * @param w defines the fourth component (1.0 by default)
  76928. */
  76929. constructor(
  76930. /** defines the first component (0 by default) */
  76931. x?: number,
  76932. /** defines the second component (0 by default) */
  76933. y?: number,
  76934. /** defines the third component (0 by default) */
  76935. z?: number,
  76936. /** defines the fourth component (1.0 by default) */
  76937. w?: number);
  76938. /**
  76939. * Gets a string representation for the current quaternion
  76940. * @returns a string with the Quaternion coordinates
  76941. */
  76942. toString(): string;
  76943. /**
  76944. * Gets the class name of the quaternion
  76945. * @returns the string "Quaternion"
  76946. */
  76947. getClassName(): string;
  76948. /**
  76949. * Gets a hash code for this quaternion
  76950. * @returns the quaternion hash code
  76951. */
  76952. getHashCode(): number;
  76953. /**
  76954. * Copy the quaternion to an array
  76955. * @returns a new array populated with 4 elements from the quaternion coordinates
  76956. */
  76957. asArray(): number[];
  76958. /**
  76959. * Check if two quaternions are equals
  76960. * @param otherQuaternion defines the second operand
  76961. * @return true if the current quaternion and the given one coordinates are strictly equals
  76962. */
  76963. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76964. /**
  76965. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76966. * @param otherQuaternion defines the other quaternion
  76967. * @param epsilon defines the minimal distance to consider equality
  76968. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76969. */
  76970. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76971. /**
  76972. * Clone the current quaternion
  76973. * @returns a new quaternion copied from the current one
  76974. */
  76975. clone(): Quaternion;
  76976. /**
  76977. * Copy a quaternion to the current one
  76978. * @param other defines the other quaternion
  76979. * @returns the updated current quaternion
  76980. */
  76981. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76982. /**
  76983. * Updates the current quaternion with the given float coordinates
  76984. * @param x defines the x coordinate
  76985. * @param y defines the y coordinate
  76986. * @param z defines the z coordinate
  76987. * @param w defines the w coordinate
  76988. * @returns the updated current quaternion
  76989. */
  76990. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76991. /**
  76992. * Updates the current quaternion from the given float coordinates
  76993. * @param x defines the x coordinate
  76994. * @param y defines the y coordinate
  76995. * @param z defines the z coordinate
  76996. * @param w defines the w coordinate
  76997. * @returns the updated current quaternion
  76998. */
  76999. set(x: number, y: number, z: number, w: number): Quaternion;
  77000. /**
  77001. * Adds two quaternions
  77002. * @param other defines the second operand
  77003. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77004. */
  77005. add(other: DeepImmutable<Quaternion>): Quaternion;
  77006. /**
  77007. * Add a quaternion to the current one
  77008. * @param other defines the quaternion to add
  77009. * @returns the current quaternion
  77010. */
  77011. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77012. /**
  77013. * Subtract two quaternions
  77014. * @param other defines the second operand
  77015. * @returns a new quaternion as the subtraction result of the given one from the current one
  77016. */
  77017. subtract(other: Quaternion): Quaternion;
  77018. /**
  77019. * Multiplies the current quaternion by a scale factor
  77020. * @param value defines the scale factor
  77021. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77022. */
  77023. scale(value: number): Quaternion;
  77024. /**
  77025. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77026. * @param scale defines the scale factor
  77027. * @param result defines the Quaternion object where to store the result
  77028. * @returns the unmodified current quaternion
  77029. */
  77030. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77031. /**
  77032. * Multiplies in place the current quaternion by a scale factor
  77033. * @param value defines the scale factor
  77034. * @returns the current modified quaternion
  77035. */
  77036. scaleInPlace(value: number): Quaternion;
  77037. /**
  77038. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77039. * @param scale defines the scale factor
  77040. * @param result defines the Quaternion object where to store the result
  77041. * @returns the unmodified current quaternion
  77042. */
  77043. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77044. /**
  77045. * Multiplies two quaternions
  77046. * @param q1 defines the second operand
  77047. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77048. */
  77049. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77050. /**
  77051. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77052. * @param q1 defines the second operand
  77053. * @param result defines the target quaternion
  77054. * @returns the current quaternion
  77055. */
  77056. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77057. /**
  77058. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77059. * @param q1 defines the second operand
  77060. * @returns the currentupdated quaternion
  77061. */
  77062. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77063. /**
  77064. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77065. * @param ref defines the target quaternion
  77066. * @returns the current quaternion
  77067. */
  77068. conjugateToRef(ref: Quaternion): Quaternion;
  77069. /**
  77070. * Conjugates in place (1-q) the current quaternion
  77071. * @returns the current updated quaternion
  77072. */
  77073. conjugateInPlace(): Quaternion;
  77074. /**
  77075. * Conjugates in place (1-q) the current quaternion
  77076. * @returns a new quaternion
  77077. */
  77078. conjugate(): Quaternion;
  77079. /**
  77080. * Gets length of current quaternion
  77081. * @returns the quaternion length (float)
  77082. */
  77083. length(): number;
  77084. /**
  77085. * Normalize in place the current quaternion
  77086. * @returns the current updated quaternion
  77087. */
  77088. normalize(): Quaternion;
  77089. /**
  77090. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77091. * @param order is a reserved parameter and is ignore for now
  77092. * @returns a new Vector3 containing the Euler angles
  77093. */
  77094. toEulerAngles(order?: string): Vector3;
  77095. /**
  77096. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77097. * @param result defines the vector which will be filled with the Euler angles
  77098. * @param order is a reserved parameter and is ignore for now
  77099. * @returns the current unchanged quaternion
  77100. */
  77101. toEulerAnglesToRef(result: Vector3): Quaternion;
  77102. /**
  77103. * Updates the given rotation matrix with the current quaternion values
  77104. * @param result defines the target matrix
  77105. * @returns the current unchanged quaternion
  77106. */
  77107. toRotationMatrix(result: Matrix): Quaternion;
  77108. /**
  77109. * Updates the current quaternion from the given rotation matrix values
  77110. * @param matrix defines the source matrix
  77111. * @returns the current updated quaternion
  77112. */
  77113. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77114. /**
  77115. * Creates a new quaternion from a rotation matrix
  77116. * @param matrix defines the source matrix
  77117. * @returns a new quaternion created from the given rotation matrix values
  77118. */
  77119. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77120. /**
  77121. * Updates the given quaternion with the given rotation matrix values
  77122. * @param matrix defines the source matrix
  77123. * @param result defines the target quaternion
  77124. */
  77125. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77126. /**
  77127. * Returns the dot product (float) between the quaternions "left" and "right"
  77128. * @param left defines the left operand
  77129. * @param right defines the right operand
  77130. * @returns the dot product
  77131. */
  77132. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77133. /**
  77134. * Checks if the two quaternions are close to each other
  77135. * @param quat0 defines the first quaternion to check
  77136. * @param quat1 defines the second quaternion to check
  77137. * @returns true if the two quaternions are close to each other
  77138. */
  77139. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77140. /**
  77141. * Creates an empty quaternion
  77142. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77143. */
  77144. static Zero(): Quaternion;
  77145. /**
  77146. * Inverse a given quaternion
  77147. * @param q defines the source quaternion
  77148. * @returns a new quaternion as the inverted current quaternion
  77149. */
  77150. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77151. /**
  77152. * Inverse a given quaternion
  77153. * @param q defines the source quaternion
  77154. * @param result the quaternion the result will be stored in
  77155. * @returns the result quaternion
  77156. */
  77157. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77158. /**
  77159. * Creates an identity quaternion
  77160. * @returns the identity quaternion
  77161. */
  77162. static Identity(): Quaternion;
  77163. /**
  77164. * Gets a boolean indicating if the given quaternion is identity
  77165. * @param quaternion defines the quaternion to check
  77166. * @returns true if the quaternion is identity
  77167. */
  77168. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77169. /**
  77170. * Creates a quaternion from a rotation around an axis
  77171. * @param axis defines the axis to use
  77172. * @param angle defines the angle to use
  77173. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77174. */
  77175. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77176. /**
  77177. * Creates a rotation around an axis and stores it into the given quaternion
  77178. * @param axis defines the axis to use
  77179. * @param angle defines the angle to use
  77180. * @param result defines the target quaternion
  77181. * @returns the target quaternion
  77182. */
  77183. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77184. /**
  77185. * Creates a new quaternion from data stored into an array
  77186. * @param array defines the data source
  77187. * @param offset defines the offset in the source array where the data starts
  77188. * @returns a new quaternion
  77189. */
  77190. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77191. /**
  77192. * Updates the given quaternion "result" from the starting index of the given array.
  77193. * @param array the array to pull values from
  77194. * @param offset the offset into the array to start at
  77195. * @param result the quaternion to store the result in
  77196. */
  77197. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  77198. /**
  77199. * Create a quaternion from Euler rotation angles
  77200. * @param x Pitch
  77201. * @param y Yaw
  77202. * @param z Roll
  77203. * @returns the new Quaternion
  77204. */
  77205. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77206. /**
  77207. * Updates a quaternion from Euler rotation angles
  77208. * @param x Pitch
  77209. * @param y Yaw
  77210. * @param z Roll
  77211. * @param result the quaternion to store the result
  77212. * @returns the updated quaternion
  77213. */
  77214. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77215. /**
  77216. * Create a quaternion from Euler rotation vector
  77217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77218. * @returns the new Quaternion
  77219. */
  77220. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77221. /**
  77222. * Updates a quaternion from Euler rotation vector
  77223. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77224. * @param result the quaternion to store the result
  77225. * @returns the updated quaternion
  77226. */
  77227. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77228. /**
  77229. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77230. * @param yaw defines the rotation around Y axis
  77231. * @param pitch defines the rotation around X axis
  77232. * @param roll defines the rotation around Z axis
  77233. * @returns the new quaternion
  77234. */
  77235. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77236. /**
  77237. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77238. * @param yaw defines the rotation around Y axis
  77239. * @param pitch defines the rotation around X axis
  77240. * @param roll defines the rotation around Z axis
  77241. * @param result defines the target quaternion
  77242. */
  77243. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77244. /**
  77245. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77246. * @param alpha defines the rotation around first axis
  77247. * @param beta defines the rotation around second axis
  77248. * @param gamma defines the rotation around third axis
  77249. * @returns the new quaternion
  77250. */
  77251. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77252. /**
  77253. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77254. * @param alpha defines the rotation around first axis
  77255. * @param beta defines the rotation around second axis
  77256. * @param gamma defines the rotation around third axis
  77257. * @param result defines the target quaternion
  77258. */
  77259. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77260. /**
  77261. * 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)
  77262. * @param axis1 defines the first axis
  77263. * @param axis2 defines the second axis
  77264. * @param axis3 defines the third axis
  77265. * @returns the new quaternion
  77266. */
  77267. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77268. /**
  77269. * 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
  77270. * @param axis1 defines the first axis
  77271. * @param axis2 defines the second axis
  77272. * @param axis3 defines the third axis
  77273. * @param ref defines the target quaternion
  77274. */
  77275. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77276. /**
  77277. * Interpolates between two quaternions
  77278. * @param left defines first quaternion
  77279. * @param right defines second quaternion
  77280. * @param amount defines the gradient to use
  77281. * @returns the new interpolated quaternion
  77282. */
  77283. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77284. /**
  77285. * Interpolates between two quaternions and stores it into a target quaternion
  77286. * @param left defines first quaternion
  77287. * @param right defines second quaternion
  77288. * @param amount defines the gradient to use
  77289. * @param result defines the target quaternion
  77290. */
  77291. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77292. /**
  77293. * Interpolate between two quaternions using Hermite interpolation
  77294. * @param value1 defines first quaternion
  77295. * @param tangent1 defines the incoming tangent
  77296. * @param value2 defines second quaternion
  77297. * @param tangent2 defines the outgoing tangent
  77298. * @param amount defines the target quaternion
  77299. * @returns the new interpolated quaternion
  77300. */
  77301. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77302. }
  77303. /**
  77304. * Class used to store matrix data (4x4)
  77305. */
  77306. export class Matrix {
  77307. private static _updateFlagSeed;
  77308. private static _identityReadOnly;
  77309. private _isIdentity;
  77310. private _isIdentityDirty;
  77311. private _isIdentity3x2;
  77312. private _isIdentity3x2Dirty;
  77313. /**
  77314. * Gets the update flag of the matrix which is an unique number for the matrix.
  77315. * It will be incremented every time the matrix data change.
  77316. * You can use it to speed the comparison between two versions of the same matrix.
  77317. */
  77318. updateFlag: number;
  77319. private readonly _m;
  77320. /**
  77321. * Gets the internal data of the matrix
  77322. */
  77323. get m(): DeepImmutable<Float32Array>;
  77324. /** @hidden */
  77325. _markAsUpdated(): void;
  77326. /** @hidden */
  77327. private _updateIdentityStatus;
  77328. /**
  77329. * Creates an empty matrix (filled with zeros)
  77330. */
  77331. constructor();
  77332. /**
  77333. * Check if the current matrix is identity
  77334. * @returns true is the matrix is the identity matrix
  77335. */
  77336. isIdentity(): boolean;
  77337. /**
  77338. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77339. * @returns true is the matrix is the identity matrix
  77340. */
  77341. isIdentityAs3x2(): boolean;
  77342. /**
  77343. * Gets the determinant of the matrix
  77344. * @returns the matrix determinant
  77345. */
  77346. determinant(): number;
  77347. /**
  77348. * Returns the matrix as a Float32Array
  77349. * @returns the matrix underlying array
  77350. */
  77351. toArray(): DeepImmutable<Float32Array>;
  77352. /**
  77353. * Returns the matrix as a Float32Array
  77354. * @returns the matrix underlying array.
  77355. */
  77356. asArray(): DeepImmutable<Float32Array>;
  77357. /**
  77358. * Inverts the current matrix in place
  77359. * @returns the current inverted matrix
  77360. */
  77361. invert(): Matrix;
  77362. /**
  77363. * Sets all the matrix elements to zero
  77364. * @returns the current matrix
  77365. */
  77366. reset(): Matrix;
  77367. /**
  77368. * Adds the current matrix with a second one
  77369. * @param other defines the matrix to add
  77370. * @returns a new matrix as the addition of the current matrix and the given one
  77371. */
  77372. add(other: DeepImmutable<Matrix>): Matrix;
  77373. /**
  77374. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77375. * @param other defines the matrix to add
  77376. * @param result defines the target matrix
  77377. * @returns the current matrix
  77378. */
  77379. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77380. /**
  77381. * Adds in place the given matrix to the current matrix
  77382. * @param other defines the second operand
  77383. * @returns the current updated matrix
  77384. */
  77385. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77386. /**
  77387. * Sets the given matrix to the current inverted Matrix
  77388. * @param other defines the target matrix
  77389. * @returns the unmodified current matrix
  77390. */
  77391. invertToRef(other: Matrix): Matrix;
  77392. /**
  77393. * add a value at the specified position in the current Matrix
  77394. * @param index the index of the value within the matrix. between 0 and 15.
  77395. * @param value the value to be added
  77396. * @returns the current updated matrix
  77397. */
  77398. addAtIndex(index: number, value: number): Matrix;
  77399. /**
  77400. * mutiply the specified position in the current Matrix by a value
  77401. * @param index the index of the value within the matrix. between 0 and 15.
  77402. * @param value the value to be added
  77403. * @returns the current updated matrix
  77404. */
  77405. multiplyAtIndex(index: number, value: number): Matrix;
  77406. /**
  77407. * Inserts the translation vector (using 3 floats) in the current matrix
  77408. * @param x defines the 1st component of the translation
  77409. * @param y defines the 2nd component of the translation
  77410. * @param z defines the 3rd component of the translation
  77411. * @returns the current updated matrix
  77412. */
  77413. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77414. /**
  77415. * Adds the translation vector (using 3 floats) in the current matrix
  77416. * @param x defines the 1st component of the translation
  77417. * @param y defines the 2nd component of the translation
  77418. * @param z defines the 3rd component of the translation
  77419. * @returns the current updated matrix
  77420. */
  77421. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77422. /**
  77423. * Inserts the translation vector in the current matrix
  77424. * @param vector3 defines the translation to insert
  77425. * @returns the current updated matrix
  77426. */
  77427. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77428. /**
  77429. * Gets the translation value of the current matrix
  77430. * @returns a new Vector3 as the extracted translation from the matrix
  77431. */
  77432. getTranslation(): Vector3;
  77433. /**
  77434. * Fill a Vector3 with the extracted translation from the matrix
  77435. * @param result defines the Vector3 where to store the translation
  77436. * @returns the current matrix
  77437. */
  77438. getTranslationToRef(result: Vector3): Matrix;
  77439. /**
  77440. * Remove rotation and scaling part from the matrix
  77441. * @returns the updated matrix
  77442. */
  77443. removeRotationAndScaling(): Matrix;
  77444. /**
  77445. * Multiply two matrices
  77446. * @param other defines the second operand
  77447. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77448. */
  77449. multiply(other: DeepImmutable<Matrix>): Matrix;
  77450. /**
  77451. * Copy the current matrix from the given one
  77452. * @param other defines the source matrix
  77453. * @returns the current updated matrix
  77454. */
  77455. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77456. /**
  77457. * Populates the given array from the starting index with the current matrix values
  77458. * @param array defines the target array
  77459. * @param offset defines the offset in the target array where to start storing values
  77460. * @returns the current matrix
  77461. */
  77462. copyToArray(array: Float32Array, offset?: number): Matrix;
  77463. /**
  77464. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77465. * @param other defines the second operand
  77466. * @param result defines the matrix where to store the multiplication
  77467. * @returns the current matrix
  77468. */
  77469. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77470. /**
  77471. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77472. * @param other defines the second operand
  77473. * @param result defines the array where to store the multiplication
  77474. * @param offset defines the offset in the target array where to start storing values
  77475. * @returns the current matrix
  77476. */
  77477. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77478. /**
  77479. * Check equality between this matrix and a second one
  77480. * @param value defines the second matrix to compare
  77481. * @returns true is the current matrix and the given one values are strictly equal
  77482. */
  77483. equals(value: DeepImmutable<Matrix>): boolean;
  77484. /**
  77485. * Clone the current matrix
  77486. * @returns a new matrix from the current matrix
  77487. */
  77488. clone(): Matrix;
  77489. /**
  77490. * Returns the name of the current matrix class
  77491. * @returns the string "Matrix"
  77492. */
  77493. getClassName(): string;
  77494. /**
  77495. * Gets the hash code of the current matrix
  77496. * @returns the hash code
  77497. */
  77498. getHashCode(): number;
  77499. /**
  77500. * Decomposes the current Matrix into a translation, rotation and scaling components
  77501. * @param scale defines the scale vector3 given as a reference to update
  77502. * @param rotation defines the rotation quaternion given as a reference to update
  77503. * @param translation defines the translation vector3 given as a reference to update
  77504. * @returns true if operation was successful
  77505. */
  77506. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77507. /**
  77508. * Gets specific row of the matrix
  77509. * @param index defines the number of the row to get
  77510. * @returns the index-th row of the current matrix as a new Vector4
  77511. */
  77512. getRow(index: number): Nullable<Vector4>;
  77513. /**
  77514. * Sets the index-th row of the current matrix to the vector4 values
  77515. * @param index defines the number of the row to set
  77516. * @param row defines the target vector4
  77517. * @returns the updated current matrix
  77518. */
  77519. setRow(index: number, row: Vector4): Matrix;
  77520. /**
  77521. * Compute the transpose of the matrix
  77522. * @returns the new transposed matrix
  77523. */
  77524. transpose(): Matrix;
  77525. /**
  77526. * Compute the transpose of the matrix and store it in a given matrix
  77527. * @param result defines the target matrix
  77528. * @returns the current matrix
  77529. */
  77530. transposeToRef(result: Matrix): Matrix;
  77531. /**
  77532. * Sets the index-th row of the current matrix with the given 4 x float values
  77533. * @param index defines the row index
  77534. * @param x defines the x component to set
  77535. * @param y defines the y component to set
  77536. * @param z defines the z component to set
  77537. * @param w defines the w component to set
  77538. * @returns the updated current matrix
  77539. */
  77540. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77541. /**
  77542. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77543. * @param scale defines the scale factor
  77544. * @returns a new matrix
  77545. */
  77546. scale(scale: number): Matrix;
  77547. /**
  77548. * Scale the current matrix values by a factor to a given result matrix
  77549. * @param scale defines the scale factor
  77550. * @param result defines the matrix to store the result
  77551. * @returns the current matrix
  77552. */
  77553. scaleToRef(scale: number, result: Matrix): Matrix;
  77554. /**
  77555. * Scale the current matrix values by a factor and add the result to a given matrix
  77556. * @param scale defines the scale factor
  77557. * @param result defines the Matrix to store the result
  77558. * @returns the current matrix
  77559. */
  77560. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77561. /**
  77562. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77563. * @param ref matrix to store the result
  77564. */
  77565. toNormalMatrix(ref: Matrix): void;
  77566. /**
  77567. * Gets only rotation part of the current matrix
  77568. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77569. */
  77570. getRotationMatrix(): Matrix;
  77571. /**
  77572. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77573. * @param result defines the target matrix to store data to
  77574. * @returns the current matrix
  77575. */
  77576. getRotationMatrixToRef(result: Matrix): Matrix;
  77577. /**
  77578. * Toggles model matrix from being right handed to left handed in place and vice versa
  77579. */
  77580. toggleModelMatrixHandInPlace(): void;
  77581. /**
  77582. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77583. */
  77584. toggleProjectionMatrixHandInPlace(): void;
  77585. /**
  77586. * Creates a matrix from an array
  77587. * @param array defines the source array
  77588. * @param offset defines an offset in the source array
  77589. * @returns a new Matrix set from the starting index of the given array
  77590. */
  77591. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77592. /**
  77593. * Copy the content of an array into a given matrix
  77594. * @param array defines the source array
  77595. * @param offset defines an offset in the source array
  77596. * @param result defines the target matrix
  77597. */
  77598. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77599. /**
  77600. * Stores an array into a matrix after having multiplied each component by a given factor
  77601. * @param array defines the source array
  77602. * @param offset defines the offset in the source array
  77603. * @param scale defines the scaling factor
  77604. * @param result defines the target matrix
  77605. */
  77606. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77607. /**
  77608. * Gets an identity matrix that must not be updated
  77609. */
  77610. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77611. /**
  77612. * Stores a list of values (16) inside a given matrix
  77613. * @param initialM11 defines 1st value of 1st row
  77614. * @param initialM12 defines 2nd value of 1st row
  77615. * @param initialM13 defines 3rd value of 1st row
  77616. * @param initialM14 defines 4th value of 1st row
  77617. * @param initialM21 defines 1st value of 2nd row
  77618. * @param initialM22 defines 2nd value of 2nd row
  77619. * @param initialM23 defines 3rd value of 2nd row
  77620. * @param initialM24 defines 4th value of 2nd row
  77621. * @param initialM31 defines 1st value of 3rd row
  77622. * @param initialM32 defines 2nd value of 3rd row
  77623. * @param initialM33 defines 3rd value of 3rd row
  77624. * @param initialM34 defines 4th value of 3rd row
  77625. * @param initialM41 defines 1st value of 4th row
  77626. * @param initialM42 defines 2nd value of 4th row
  77627. * @param initialM43 defines 3rd value of 4th row
  77628. * @param initialM44 defines 4th value of 4th row
  77629. * @param result defines the target matrix
  77630. */
  77631. 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;
  77632. /**
  77633. * Creates new matrix from a list of values (16)
  77634. * @param initialM11 defines 1st value of 1st row
  77635. * @param initialM12 defines 2nd value of 1st row
  77636. * @param initialM13 defines 3rd value of 1st row
  77637. * @param initialM14 defines 4th value of 1st row
  77638. * @param initialM21 defines 1st value of 2nd row
  77639. * @param initialM22 defines 2nd value of 2nd row
  77640. * @param initialM23 defines 3rd value of 2nd row
  77641. * @param initialM24 defines 4th value of 2nd row
  77642. * @param initialM31 defines 1st value of 3rd row
  77643. * @param initialM32 defines 2nd value of 3rd row
  77644. * @param initialM33 defines 3rd value of 3rd row
  77645. * @param initialM34 defines 4th value of 3rd row
  77646. * @param initialM41 defines 1st value of 4th row
  77647. * @param initialM42 defines 2nd value of 4th row
  77648. * @param initialM43 defines 3rd value of 4th row
  77649. * @param initialM44 defines 4th value of 4th row
  77650. * @returns the new matrix
  77651. */
  77652. 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;
  77653. /**
  77654. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77655. * @param scale defines the scale vector3
  77656. * @param rotation defines the rotation quaternion
  77657. * @param translation defines the translation vector3
  77658. * @returns a new matrix
  77659. */
  77660. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77661. /**
  77662. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77663. * @param scale defines the scale vector3
  77664. * @param rotation defines the rotation quaternion
  77665. * @param translation defines the translation vector3
  77666. * @param result defines the target matrix
  77667. */
  77668. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77669. /**
  77670. * Creates a new identity matrix
  77671. * @returns a new identity matrix
  77672. */
  77673. static Identity(): Matrix;
  77674. /**
  77675. * Creates a new identity matrix and stores the result in a given matrix
  77676. * @param result defines the target matrix
  77677. */
  77678. static IdentityToRef(result: Matrix): void;
  77679. /**
  77680. * Creates a new zero matrix
  77681. * @returns a new zero matrix
  77682. */
  77683. static Zero(): Matrix;
  77684. /**
  77685. * Creates a new rotation matrix for "angle" radians around the X axis
  77686. * @param angle defines the angle (in radians) to use
  77687. * @return the new matrix
  77688. */
  77689. static RotationX(angle: number): Matrix;
  77690. /**
  77691. * Creates a new matrix as the invert of a given matrix
  77692. * @param source defines the source matrix
  77693. * @returns the new matrix
  77694. */
  77695. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77696. /**
  77697. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77698. * @param angle defines the angle (in radians) to use
  77699. * @param result defines the target matrix
  77700. */
  77701. static RotationXToRef(angle: number, result: Matrix): void;
  77702. /**
  77703. * Creates a new rotation matrix for "angle" radians around the Y axis
  77704. * @param angle defines the angle (in radians) to use
  77705. * @return the new matrix
  77706. */
  77707. static RotationY(angle: number): Matrix;
  77708. /**
  77709. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77710. * @param angle defines the angle (in radians) to use
  77711. * @param result defines the target matrix
  77712. */
  77713. static RotationYToRef(angle: number, result: Matrix): void;
  77714. /**
  77715. * Creates a new rotation matrix for "angle" radians around the Z axis
  77716. * @param angle defines the angle (in radians) to use
  77717. * @return the new matrix
  77718. */
  77719. static RotationZ(angle: number): Matrix;
  77720. /**
  77721. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77722. * @param angle defines the angle (in radians) to use
  77723. * @param result defines the target matrix
  77724. */
  77725. static RotationZToRef(angle: number, result: Matrix): void;
  77726. /**
  77727. * Creates a new rotation matrix for "angle" radians around the given axis
  77728. * @param axis defines the axis to use
  77729. * @param angle defines the angle (in radians) to use
  77730. * @return the new matrix
  77731. */
  77732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77733. /**
  77734. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77735. * @param axis defines the axis to use
  77736. * @param angle defines the angle (in radians) to use
  77737. * @param result defines the target matrix
  77738. */
  77739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77740. /**
  77741. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77742. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77743. * @param from defines the vector to align
  77744. * @param to defines the vector to align to
  77745. * @param result defines the target matrix
  77746. */
  77747. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77748. /**
  77749. * Creates a rotation matrix
  77750. * @param yaw defines the yaw angle in radians (Y axis)
  77751. * @param pitch defines the pitch angle in radians (X axis)
  77752. * @param roll defines the roll angle in radians (X axis)
  77753. * @returns the new rotation matrix
  77754. */
  77755. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77756. /**
  77757. * Creates a rotation matrix and stores it in a given matrix
  77758. * @param yaw defines the yaw angle in radians (Y axis)
  77759. * @param pitch defines the pitch angle in radians (X axis)
  77760. * @param roll defines the roll angle in radians (X axis)
  77761. * @param result defines the target matrix
  77762. */
  77763. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77764. /**
  77765. * Creates a scaling matrix
  77766. * @param x defines the scale factor on X axis
  77767. * @param y defines the scale factor on Y axis
  77768. * @param z defines the scale factor on Z axis
  77769. * @returns the new matrix
  77770. */
  77771. static Scaling(x: number, y: number, z: number): Matrix;
  77772. /**
  77773. * Creates a scaling matrix and stores it in a given matrix
  77774. * @param x defines the scale factor on X axis
  77775. * @param y defines the scale factor on Y axis
  77776. * @param z defines the scale factor on Z axis
  77777. * @param result defines the target matrix
  77778. */
  77779. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77780. /**
  77781. * Creates a translation matrix
  77782. * @param x defines the translation on X axis
  77783. * @param y defines the translation on Y axis
  77784. * @param z defines the translationon Z axis
  77785. * @returns the new matrix
  77786. */
  77787. static Translation(x: number, y: number, z: number): Matrix;
  77788. /**
  77789. * Creates a translation matrix and stores it in a given matrix
  77790. * @param x defines the translation on X axis
  77791. * @param y defines the translation on Y axis
  77792. * @param z defines the translationon Z axis
  77793. * @param result defines the target matrix
  77794. */
  77795. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77796. /**
  77797. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77798. * @param startValue defines the start value
  77799. * @param endValue defines the end value
  77800. * @param gradient defines the gradient factor
  77801. * @returns the new matrix
  77802. */
  77803. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77804. /**
  77805. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77806. * @param startValue defines the start value
  77807. * @param endValue defines the end value
  77808. * @param gradient defines the gradient factor
  77809. * @param result defines the Matrix object where to store data
  77810. */
  77811. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77812. /**
  77813. * Builds a new matrix whose values are computed by:
  77814. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77815. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77816. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77817. * @param startValue defines the first matrix
  77818. * @param endValue defines the second matrix
  77819. * @param gradient defines the gradient between the two matrices
  77820. * @returns the new matrix
  77821. */
  77822. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77823. /**
  77824. * Update a matrix to values which are computed by:
  77825. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77826. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77827. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77828. * @param startValue defines the first matrix
  77829. * @param endValue defines the second matrix
  77830. * @param gradient defines the gradient between the two matrices
  77831. * @param result defines the target matrix
  77832. */
  77833. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77834. /**
  77835. * 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"
  77836. * This function works in left handed mode
  77837. * @param eye defines the final position of the entity
  77838. * @param target defines where the entity should look at
  77839. * @param up defines the up vector for the entity
  77840. * @returns the new matrix
  77841. */
  77842. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77843. /**
  77844. * 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".
  77845. * This function works in left handed mode
  77846. * @param eye defines the final position of the entity
  77847. * @param target defines where the entity should look at
  77848. * @param up defines the up vector for the entity
  77849. * @param result defines the target matrix
  77850. */
  77851. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77852. /**
  77853. * 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"
  77854. * This function works in right handed mode
  77855. * @param eye defines the final position of the entity
  77856. * @param target defines where the entity should look at
  77857. * @param up defines the up vector for the entity
  77858. * @returns the new matrix
  77859. */
  77860. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77861. /**
  77862. * 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".
  77863. * This function works in right handed mode
  77864. * @param eye defines the final position of the entity
  77865. * @param target defines where the entity should look at
  77866. * @param up defines the up vector for the entity
  77867. * @param result defines the target matrix
  77868. */
  77869. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77870. /**
  77871. * Create a left-handed orthographic 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 orthographic projection matrix
  77877. */
  77878. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77879. /**
  77880. * Store a left-handed orthographic projection to a given matrix
  77881. * @param width defines the viewport width
  77882. * @param height defines the viewport height
  77883. * @param znear defines the near clip plane
  77884. * @param zfar defines the far clip plane
  77885. * @param result defines the target matrix
  77886. */
  77887. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77888. /**
  77889. * Create a left-handed orthographic projection matrix
  77890. * @param left defines the viewport left coordinate
  77891. * @param right defines the viewport right coordinate
  77892. * @param bottom defines the viewport bottom coordinate
  77893. * @param top defines the viewport top coordinate
  77894. * @param znear defines the near clip plane
  77895. * @param zfar defines the far clip plane
  77896. * @returns a new matrix as a left-handed orthographic projection matrix
  77897. */
  77898. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77899. /**
  77900. * Stores a left-handed orthographic projection into a given matrix
  77901. * @param left defines the viewport left coordinate
  77902. * @param right defines the viewport right coordinate
  77903. * @param bottom defines the viewport bottom coordinate
  77904. * @param top defines the viewport top coordinate
  77905. * @param znear defines the near clip plane
  77906. * @param zfar defines the far clip plane
  77907. * @param result defines the target matrix
  77908. */
  77909. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77910. /**
  77911. * Creates a right-handed orthographic projection matrix
  77912. * @param left defines the viewport left coordinate
  77913. * @param right defines the viewport right coordinate
  77914. * @param bottom defines the viewport bottom coordinate
  77915. * @param top defines the viewport top coordinate
  77916. * @param znear defines the near clip plane
  77917. * @param zfar defines the far clip plane
  77918. * @returns a new matrix as a right-handed orthographic projection matrix
  77919. */
  77920. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77921. /**
  77922. * Stores a right-handed orthographic projection into a given matrix
  77923. * @param left defines the viewport left coordinate
  77924. * @param right defines the viewport right coordinate
  77925. * @param bottom defines the viewport bottom coordinate
  77926. * @param top defines the viewport top coordinate
  77927. * @param znear defines the near clip plane
  77928. * @param zfar defines the far clip plane
  77929. * @param result defines the target matrix
  77930. */
  77931. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77932. /**
  77933. * Creates a left-handed perspective projection matrix
  77934. * @param width defines the viewport width
  77935. * @param height defines the viewport height
  77936. * @param znear defines the near clip plane
  77937. * @param zfar defines the far clip plane
  77938. * @returns a new matrix as a left-handed perspective projection matrix
  77939. */
  77940. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77941. /**
  77942. * Creates a left-handed perspective projection matrix
  77943. * @param fov defines the horizontal field of view
  77944. * @param aspect defines the aspect ratio
  77945. * @param znear defines the near clip plane
  77946. * @param zfar defines the far clip plane
  77947. * @returns a new matrix as a left-handed perspective projection matrix
  77948. */
  77949. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77950. /**
  77951. * Stores a left-handed perspective projection into a given matrix
  77952. * @param fov defines the horizontal field of view
  77953. * @param aspect defines the aspect ratio
  77954. * @param znear defines the near clip plane
  77955. * @param zfar defines the far clip plane
  77956. * @param result defines the target matrix
  77957. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77958. */
  77959. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77960. /**
  77961. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77962. * @param fov defines the horizontal field of view
  77963. * @param aspect defines the aspect ratio
  77964. * @param znear defines the near clip plane
  77965. * @param zfar not used as infinity is used as far clip
  77966. * @param result defines the target matrix
  77967. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77968. */
  77969. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77970. /**
  77971. * Creates a right-handed perspective projection matrix
  77972. * @param fov defines the horizontal field of view
  77973. * @param aspect defines the aspect ratio
  77974. * @param znear defines the near clip plane
  77975. * @param zfar defines the far clip plane
  77976. * @returns a new matrix as a right-handed perspective projection matrix
  77977. */
  77978. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77979. /**
  77980. * Stores a right-handed perspective projection into a given matrix
  77981. * @param fov defines the horizontal field of view
  77982. * @param aspect defines the aspect ratio
  77983. * @param znear defines the near clip plane
  77984. * @param zfar defines the far clip plane
  77985. * @param result defines the target matrix
  77986. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77987. */
  77988. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77989. /**
  77990. * Stores a right-handed perspective projection into a given matrix
  77991. * @param fov defines the horizontal field of view
  77992. * @param aspect defines the aspect ratio
  77993. * @param znear defines the near clip plane
  77994. * @param zfar not used as infinity is used as far clip
  77995. * @param result defines the target matrix
  77996. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77997. */
  77998. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77999. /**
  78000. * Stores a perspective projection for WebVR info a given matrix
  78001. * @param fov defines the field of view
  78002. * @param znear defines the near clip plane
  78003. * @param zfar defines the far clip plane
  78004. * @param result defines the target matrix
  78005. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78006. */
  78007. static PerspectiveFovWebVRToRef(fov: {
  78008. upDegrees: number;
  78009. downDegrees: number;
  78010. leftDegrees: number;
  78011. rightDegrees: number;
  78012. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78013. /**
  78014. * Computes a complete transformation matrix
  78015. * @param viewport defines the viewport to use
  78016. * @param world defines the world matrix
  78017. * @param view defines the view matrix
  78018. * @param projection defines the projection matrix
  78019. * @param zmin defines the near clip plane
  78020. * @param zmax defines the far clip plane
  78021. * @returns the transformation matrix
  78022. */
  78023. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78024. /**
  78025. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78026. * @param matrix defines the matrix to use
  78027. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78028. */
  78029. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78030. /**
  78031. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78032. * @param matrix defines the matrix to use
  78033. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78034. */
  78035. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78036. /**
  78037. * Compute the transpose of a given matrix
  78038. * @param matrix defines the matrix to transpose
  78039. * @returns the new matrix
  78040. */
  78041. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78042. /**
  78043. * Compute the transpose of a matrix and store it in a target matrix
  78044. * @param matrix defines the matrix to transpose
  78045. * @param result defines the target matrix
  78046. */
  78047. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78048. /**
  78049. * Computes a reflection matrix from a plane
  78050. * @param plane defines the reflection plane
  78051. * @returns a new matrix
  78052. */
  78053. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78054. /**
  78055. * Computes a reflection matrix from a plane
  78056. * @param plane defines the reflection plane
  78057. * @param result defines the target matrix
  78058. */
  78059. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78060. /**
  78061. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78062. * @param xaxis defines the value of the 1st axis
  78063. * @param yaxis defines the value of the 2nd axis
  78064. * @param zaxis defines the value of the 3rd axis
  78065. * @param result defines the target matrix
  78066. */
  78067. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78068. /**
  78069. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78070. * @param quat defines the quaternion to use
  78071. * @param result defines the target matrix
  78072. */
  78073. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78074. }
  78075. /**
  78076. * @hidden
  78077. */
  78078. export class TmpVectors {
  78079. static Vector2: Vector2[];
  78080. static Vector3: Vector3[];
  78081. static Vector4: Vector4[];
  78082. static Quaternion: Quaternion[];
  78083. static Matrix: Matrix[];
  78084. }
  78085. }
  78086. declare module BABYLON {
  78087. /**
  78088. * Defines potential orientation for back face culling
  78089. */
  78090. export enum Orientation {
  78091. /**
  78092. * Clockwise
  78093. */
  78094. CW = 0,
  78095. /** Counter clockwise */
  78096. CCW = 1
  78097. }
  78098. /** Class used to represent a Bezier curve */
  78099. export class BezierCurve {
  78100. /**
  78101. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78102. * @param t defines the time
  78103. * @param x1 defines the left coordinate on X axis
  78104. * @param y1 defines the left coordinate on Y axis
  78105. * @param x2 defines the right coordinate on X axis
  78106. * @param y2 defines the right coordinate on Y axis
  78107. * @returns the interpolated value
  78108. */
  78109. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78110. }
  78111. /**
  78112. * Defines angle representation
  78113. */
  78114. export class Angle {
  78115. private _radians;
  78116. /**
  78117. * Creates an Angle object of "radians" radians (float).
  78118. * @param radians the angle in radians
  78119. */
  78120. constructor(radians: number);
  78121. /**
  78122. * Get value in degrees
  78123. * @returns the Angle value in degrees (float)
  78124. */
  78125. degrees(): number;
  78126. /**
  78127. * Get value in radians
  78128. * @returns the Angle value in radians (float)
  78129. */
  78130. radians(): number;
  78131. /**
  78132. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78133. * @param a defines first vector
  78134. * @param b defines second vector
  78135. * @returns a new Angle
  78136. */
  78137. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78138. /**
  78139. * Gets a new Angle object from the given float in radians
  78140. * @param radians defines the angle value in radians
  78141. * @returns a new Angle
  78142. */
  78143. static FromRadians(radians: number): Angle;
  78144. /**
  78145. * Gets a new Angle object from the given float in degrees
  78146. * @param degrees defines the angle value in degrees
  78147. * @returns a new Angle
  78148. */
  78149. static FromDegrees(degrees: number): Angle;
  78150. }
  78151. /**
  78152. * This represents an arc in a 2d space.
  78153. */
  78154. export class Arc2 {
  78155. /** Defines the start point of the arc */
  78156. startPoint: Vector2;
  78157. /** Defines the mid point of the arc */
  78158. midPoint: Vector2;
  78159. /** Defines the end point of the arc */
  78160. endPoint: Vector2;
  78161. /**
  78162. * Defines the center point of the arc.
  78163. */
  78164. centerPoint: Vector2;
  78165. /**
  78166. * Defines the radius of the arc.
  78167. */
  78168. radius: number;
  78169. /**
  78170. * Defines the angle of the arc (from mid point to end point).
  78171. */
  78172. angle: Angle;
  78173. /**
  78174. * Defines the start angle of the arc (from start point to middle point).
  78175. */
  78176. startAngle: Angle;
  78177. /**
  78178. * Defines the orientation of the arc (clock wise/counter clock wise).
  78179. */
  78180. orientation: Orientation;
  78181. /**
  78182. * Creates an Arc object from the three given points : start, middle and end.
  78183. * @param startPoint Defines the start point of the arc
  78184. * @param midPoint Defines the midlle point of the arc
  78185. * @param endPoint Defines the end point of the arc
  78186. */
  78187. constructor(
  78188. /** Defines the start point of the arc */
  78189. startPoint: Vector2,
  78190. /** Defines the mid point of the arc */
  78191. midPoint: Vector2,
  78192. /** Defines the end point of the arc */
  78193. endPoint: Vector2);
  78194. }
  78195. /**
  78196. * Represents a 2D path made up of multiple 2D points
  78197. */
  78198. export class Path2 {
  78199. private _points;
  78200. private _length;
  78201. /**
  78202. * If the path start and end point are the same
  78203. */
  78204. closed: boolean;
  78205. /**
  78206. * Creates a Path2 object from the starting 2D coordinates x and y.
  78207. * @param x the starting points x value
  78208. * @param y the starting points y value
  78209. */
  78210. constructor(x: number, y: number);
  78211. /**
  78212. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78213. * @param x the added points x value
  78214. * @param y the added points y value
  78215. * @returns the updated Path2.
  78216. */
  78217. addLineTo(x: number, y: number): Path2;
  78218. /**
  78219. * 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.
  78220. * @param midX middle point x value
  78221. * @param midY middle point y value
  78222. * @param endX end point x value
  78223. * @param endY end point y value
  78224. * @param numberOfSegments (default: 36)
  78225. * @returns the updated Path2.
  78226. */
  78227. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78228. /**
  78229. * Closes the Path2.
  78230. * @returns the Path2.
  78231. */
  78232. close(): Path2;
  78233. /**
  78234. * Gets the sum of the distance between each sequential point in the path
  78235. * @returns the Path2 total length (float).
  78236. */
  78237. length(): number;
  78238. /**
  78239. * Gets the points which construct the path
  78240. * @returns the Path2 internal array of points.
  78241. */
  78242. getPoints(): Vector2[];
  78243. /**
  78244. * Retreives the point at the distance aways from the starting point
  78245. * @param normalizedLengthPosition the length along the path to retreive the point from
  78246. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78247. */
  78248. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78249. /**
  78250. * Creates a new path starting from an x and y position
  78251. * @param x starting x value
  78252. * @param y starting y value
  78253. * @returns a new Path2 starting at the coordinates (x, y).
  78254. */
  78255. static StartingAt(x: number, y: number): Path2;
  78256. }
  78257. /**
  78258. * Represents a 3D path made up of multiple 3D points
  78259. */
  78260. export class Path3D {
  78261. /**
  78262. * an array of Vector3, the curve axis of the Path3D
  78263. */
  78264. path: Vector3[];
  78265. private _curve;
  78266. private _distances;
  78267. private _tangents;
  78268. private _normals;
  78269. private _binormals;
  78270. private _raw;
  78271. private _alignTangentsWithPath;
  78272. private readonly _pointAtData;
  78273. /**
  78274. * new Path3D(path, normal, raw)
  78275. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78276. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78277. * @param path an array of Vector3, the curve axis of the Path3D
  78278. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78279. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78280. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78281. */
  78282. constructor(
  78283. /**
  78284. * an array of Vector3, the curve axis of the Path3D
  78285. */
  78286. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78287. /**
  78288. * Returns the Path3D array of successive Vector3 designing its curve.
  78289. * @returns the Path3D array of successive Vector3 designing its curve.
  78290. */
  78291. getCurve(): Vector3[];
  78292. /**
  78293. * Returns the Path3D array of successive Vector3 designing its curve.
  78294. * @returns the Path3D array of successive Vector3 designing its curve.
  78295. */
  78296. getPoints(): Vector3[];
  78297. /**
  78298. * @returns the computed length (float) of the path.
  78299. */
  78300. length(): number;
  78301. /**
  78302. * Returns an array populated with tangent vectors on each Path3D curve point.
  78303. * @returns an array populated with tangent vectors on each Path3D curve point.
  78304. */
  78305. getTangents(): Vector3[];
  78306. /**
  78307. * Returns an array populated with normal vectors on each Path3D curve point.
  78308. * @returns an array populated with normal vectors on each Path3D curve point.
  78309. */
  78310. getNormals(): Vector3[];
  78311. /**
  78312. * Returns an array populated with binormal vectors on each Path3D curve point.
  78313. * @returns an array populated with binormal vectors on each Path3D curve point.
  78314. */
  78315. getBinormals(): Vector3[];
  78316. /**
  78317. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78318. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78319. */
  78320. getDistances(): number[];
  78321. /**
  78322. * Returns an interpolated point along this path
  78323. * @param position the position of the point along this path, from 0.0 to 1.0
  78324. * @returns a new Vector3 as the point
  78325. */
  78326. getPointAt(position: number): Vector3;
  78327. /**
  78328. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78329. * @param position the position of the point along this path, from 0.0 to 1.0
  78330. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78331. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78332. */
  78333. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78334. /**
  78335. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78336. * @param position the position of the point along this path, from 0.0 to 1.0
  78337. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78338. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78339. */
  78340. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78341. /**
  78342. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78343. * @param position the position of the point along this path, from 0.0 to 1.0
  78344. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78345. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78346. */
  78347. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78348. /**
  78349. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78350. * @param position the position of the point along this path, from 0.0 to 1.0
  78351. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78352. */
  78353. getDistanceAt(position: number): number;
  78354. /**
  78355. * Returns the array index of the previous point of an interpolated point along this path
  78356. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78357. * @returns the array index
  78358. */
  78359. getPreviousPointIndexAt(position: number): number;
  78360. /**
  78361. * 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)
  78362. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78363. * @returns the sub position
  78364. */
  78365. getSubPositionAt(position: number): number;
  78366. /**
  78367. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78368. * @param target the vector of which to get the closest position to
  78369. * @returns the position of the closest virtual point on this path to the target vector
  78370. */
  78371. getClosestPositionTo(target: Vector3): number;
  78372. /**
  78373. * Returns a sub path (slice) of this path
  78374. * @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
  78375. * @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
  78376. * @returns a sub path (slice) of this path
  78377. */
  78378. slice(start?: number, end?: number): Path3D;
  78379. /**
  78380. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78381. * @param path path which all values are copied into the curves points
  78382. * @param firstNormal which should be projected onto the curve
  78383. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78384. * @returns the same object updated.
  78385. */
  78386. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78387. private _compute;
  78388. private _getFirstNonNullVector;
  78389. private _getLastNonNullVector;
  78390. private _normalVector;
  78391. /**
  78392. * Updates the point at data for an interpolated point along this curve
  78393. * @param position the position of the point along this curve, from 0.0 to 1.0
  78394. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78395. * @returns the (updated) point at data
  78396. */
  78397. private _updatePointAtData;
  78398. /**
  78399. * Updates the point at data from the specified parameters
  78400. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78401. * @param point the interpolated point
  78402. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78403. */
  78404. private _setPointAtData;
  78405. /**
  78406. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78407. */
  78408. private _updateInterpolationMatrix;
  78409. }
  78410. /**
  78411. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78412. * A Curve3 is designed from a series of successive Vector3.
  78413. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78414. */
  78415. export class Curve3 {
  78416. private _points;
  78417. private _length;
  78418. /**
  78419. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78420. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78421. * @param v1 (Vector3) the control point
  78422. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78423. * @param nbPoints (integer) the wanted number of points in the curve
  78424. * @returns the created Curve3
  78425. */
  78426. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78427. /**
  78428. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78429. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78430. * @param v1 (Vector3) the first control point
  78431. * @param v2 (Vector3) the second control point
  78432. * @param v3 (Vector3) the end point of the Cubic Bezier
  78433. * @param nbPoints (integer) the wanted number of points in the curve
  78434. * @returns the created Curve3
  78435. */
  78436. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78437. /**
  78438. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78439. * @param p1 (Vector3) the origin point of the Hermite Spline
  78440. * @param t1 (Vector3) the tangent vector at the origin point
  78441. * @param p2 (Vector3) the end point of the Hermite Spline
  78442. * @param t2 (Vector3) the tangent vector at the end point
  78443. * @param nbPoints (integer) the wanted number of points in the curve
  78444. * @returns the created Curve3
  78445. */
  78446. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78447. /**
  78448. * Returns a Curve3 object along a CatmullRom Spline curve :
  78449. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78450. * @param nbPoints (integer) the wanted number of points between each curve control points
  78451. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78452. * @returns the created Curve3
  78453. */
  78454. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78455. /**
  78456. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78457. * A Curve3 is designed from a series of successive Vector3.
  78458. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78459. * @param points points which make up the curve
  78460. */
  78461. constructor(points: Vector3[]);
  78462. /**
  78463. * @returns the Curve3 stored array of successive Vector3
  78464. */
  78465. getPoints(): Vector3[];
  78466. /**
  78467. * @returns the computed length (float) of the curve.
  78468. */
  78469. length(): number;
  78470. /**
  78471. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78472. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78473. * curveA and curveB keep unchanged.
  78474. * @param curve the curve to continue from this curve
  78475. * @returns the newly constructed curve
  78476. */
  78477. continue(curve: DeepImmutable<Curve3>): Curve3;
  78478. private _computeLength;
  78479. }
  78480. }
  78481. declare module BABYLON {
  78482. /**
  78483. * This represents the main contract an easing function should follow.
  78484. * Easing functions are used throughout the animation system.
  78485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78486. */
  78487. export interface IEasingFunction {
  78488. /**
  78489. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78490. * of the easing function.
  78491. * The link below provides some of the most common examples of easing functions.
  78492. * @see https://easings.net/
  78493. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78494. * @returns the corresponding value on the curve defined by the easing function
  78495. */
  78496. ease(gradient: number): number;
  78497. }
  78498. /**
  78499. * Base class used for every default easing function.
  78500. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78501. */
  78502. export class EasingFunction implements IEasingFunction {
  78503. /**
  78504. * Interpolation follows the mathematical formula associated with the easing function.
  78505. */
  78506. static readonly EASINGMODE_EASEIN: number;
  78507. /**
  78508. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78509. */
  78510. static readonly EASINGMODE_EASEOUT: number;
  78511. /**
  78512. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78513. */
  78514. static readonly EASINGMODE_EASEINOUT: number;
  78515. private _easingMode;
  78516. /**
  78517. * Sets the easing mode of the current function.
  78518. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78519. */
  78520. setEasingMode(easingMode: number): void;
  78521. /**
  78522. * Gets the current easing mode.
  78523. * @returns the easing mode
  78524. */
  78525. getEasingMode(): number;
  78526. /**
  78527. * @hidden
  78528. */
  78529. easeInCore(gradient: number): number;
  78530. /**
  78531. * Given an input gradient between 0 and 1, this returns the corresponding value
  78532. * of the easing function.
  78533. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78534. * @returns the corresponding value on the curve defined by the easing function
  78535. */
  78536. ease(gradient: number): number;
  78537. }
  78538. /**
  78539. * Easing function with a circle shape (see link below).
  78540. * @see https://easings.net/#easeInCirc
  78541. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78542. */
  78543. export class CircleEase extends EasingFunction implements IEasingFunction {
  78544. /** @hidden */
  78545. easeInCore(gradient: number): number;
  78546. }
  78547. /**
  78548. * Easing function with a ease back shape (see link below).
  78549. * @see https://easings.net/#easeInBack
  78550. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78551. */
  78552. export class BackEase extends EasingFunction implements IEasingFunction {
  78553. /** Defines the amplitude of the function */
  78554. amplitude: number;
  78555. /**
  78556. * Instantiates a back ease easing
  78557. * @see https://easings.net/#easeInBack
  78558. * @param amplitude Defines the amplitude of the function
  78559. */
  78560. constructor(
  78561. /** Defines the amplitude of the function */
  78562. amplitude?: number);
  78563. /** @hidden */
  78564. easeInCore(gradient: number): number;
  78565. }
  78566. /**
  78567. * Easing function with a bouncing shape (see link below).
  78568. * @see https://easings.net/#easeInBounce
  78569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78570. */
  78571. export class BounceEase extends EasingFunction implements IEasingFunction {
  78572. /** Defines the number of bounces */
  78573. bounces: number;
  78574. /** Defines the amplitude of the bounce */
  78575. bounciness: number;
  78576. /**
  78577. * Instantiates a bounce easing
  78578. * @see https://easings.net/#easeInBounce
  78579. * @param bounces Defines the number of bounces
  78580. * @param bounciness Defines the amplitude of the bounce
  78581. */
  78582. constructor(
  78583. /** Defines the number of bounces */
  78584. bounces?: number,
  78585. /** Defines the amplitude of the bounce */
  78586. bounciness?: number);
  78587. /** @hidden */
  78588. easeInCore(gradient: number): number;
  78589. }
  78590. /**
  78591. * Easing function with a power of 3 shape (see link below).
  78592. * @see https://easings.net/#easeInCubic
  78593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78594. */
  78595. export class CubicEase extends EasingFunction implements IEasingFunction {
  78596. /** @hidden */
  78597. easeInCore(gradient: number): number;
  78598. }
  78599. /**
  78600. * Easing function with an elastic shape (see link below).
  78601. * @see https://easings.net/#easeInElastic
  78602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78603. */
  78604. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78605. /** Defines the number of oscillations*/
  78606. oscillations: number;
  78607. /** Defines the amplitude of the oscillations*/
  78608. springiness: number;
  78609. /**
  78610. * Instantiates an elastic easing function
  78611. * @see https://easings.net/#easeInElastic
  78612. * @param oscillations Defines the number of oscillations
  78613. * @param springiness Defines the amplitude of the oscillations
  78614. */
  78615. constructor(
  78616. /** Defines the number of oscillations*/
  78617. oscillations?: number,
  78618. /** Defines the amplitude of the oscillations*/
  78619. springiness?: number);
  78620. /** @hidden */
  78621. easeInCore(gradient: number): number;
  78622. }
  78623. /**
  78624. * Easing function with an exponential shape (see link below).
  78625. * @see https://easings.net/#easeInExpo
  78626. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78627. */
  78628. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78629. /** Defines the exponent of the function */
  78630. exponent: number;
  78631. /**
  78632. * Instantiates an exponential easing function
  78633. * @see https://easings.net/#easeInExpo
  78634. * @param exponent Defines the exponent of the function
  78635. */
  78636. constructor(
  78637. /** Defines the exponent of the function */
  78638. exponent?: number);
  78639. /** @hidden */
  78640. easeInCore(gradient: number): number;
  78641. }
  78642. /**
  78643. * Easing function with a power shape (see link below).
  78644. * @see https://easings.net/#easeInQuad
  78645. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78646. */
  78647. export class PowerEase extends EasingFunction implements IEasingFunction {
  78648. /** Defines the power of the function */
  78649. power: number;
  78650. /**
  78651. * Instantiates an power base easing function
  78652. * @see https://easings.net/#easeInQuad
  78653. * @param power Defines the power of the function
  78654. */
  78655. constructor(
  78656. /** Defines the power of the function */
  78657. power?: number);
  78658. /** @hidden */
  78659. easeInCore(gradient: number): number;
  78660. }
  78661. /**
  78662. * Easing function with a power of 2 shape (see link below).
  78663. * @see https://easings.net/#easeInQuad
  78664. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78665. */
  78666. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78667. /** @hidden */
  78668. easeInCore(gradient: number): number;
  78669. }
  78670. /**
  78671. * Easing function with a power of 4 shape (see link below).
  78672. * @see https://easings.net/#easeInQuart
  78673. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78674. */
  78675. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78676. /** @hidden */
  78677. easeInCore(gradient: number): number;
  78678. }
  78679. /**
  78680. * Easing function with a power of 5 shape (see link below).
  78681. * @see https://easings.net/#easeInQuint
  78682. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78683. */
  78684. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78685. /** @hidden */
  78686. easeInCore(gradient: number): number;
  78687. }
  78688. /**
  78689. * Easing function with a sin shape (see link below).
  78690. * @see https://easings.net/#easeInSine
  78691. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78692. */
  78693. export class SineEase extends EasingFunction implements IEasingFunction {
  78694. /** @hidden */
  78695. easeInCore(gradient: number): number;
  78696. }
  78697. /**
  78698. * Easing function with a bezier shape (see link below).
  78699. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78700. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78701. */
  78702. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78703. /** Defines the x component of the start tangent in the bezier curve */
  78704. x1: number;
  78705. /** Defines the y component of the start tangent in the bezier curve */
  78706. y1: number;
  78707. /** Defines the x component of the end tangent in the bezier curve */
  78708. x2: number;
  78709. /** Defines the y component of the end tangent in the bezier curve */
  78710. y2: number;
  78711. /**
  78712. * Instantiates a bezier function
  78713. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78714. * @param x1 Defines the x component of the start tangent in the bezier curve
  78715. * @param y1 Defines the y component of the start tangent in the bezier curve
  78716. * @param x2 Defines the x component of the end tangent in the bezier curve
  78717. * @param y2 Defines the y component of the end tangent in the bezier curve
  78718. */
  78719. constructor(
  78720. /** Defines the x component of the start tangent in the bezier curve */
  78721. x1?: number,
  78722. /** Defines the y component of the start tangent in the bezier curve */
  78723. y1?: number,
  78724. /** Defines the x component of the end tangent in the bezier curve */
  78725. x2?: number,
  78726. /** Defines the y component of the end tangent in the bezier curve */
  78727. y2?: number);
  78728. /** @hidden */
  78729. easeInCore(gradient: number): number;
  78730. }
  78731. }
  78732. declare module BABYLON {
  78733. /**
  78734. * Class used to hold a RBG color
  78735. */
  78736. export class Color3 {
  78737. /**
  78738. * Defines the red component (between 0 and 1, default is 0)
  78739. */
  78740. r: number;
  78741. /**
  78742. * Defines the green component (between 0 and 1, default is 0)
  78743. */
  78744. g: number;
  78745. /**
  78746. * Defines the blue component (between 0 and 1, default is 0)
  78747. */
  78748. b: number;
  78749. /**
  78750. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78751. * @param r defines the red component (between 0 and 1, default is 0)
  78752. * @param g defines the green component (between 0 and 1, default is 0)
  78753. * @param b defines the blue component (between 0 and 1, default is 0)
  78754. */
  78755. constructor(
  78756. /**
  78757. * Defines the red component (between 0 and 1, default is 0)
  78758. */
  78759. r?: number,
  78760. /**
  78761. * Defines the green component (between 0 and 1, default is 0)
  78762. */
  78763. g?: number,
  78764. /**
  78765. * Defines the blue component (between 0 and 1, default is 0)
  78766. */
  78767. b?: number);
  78768. /**
  78769. * Creates a string with the Color3 current values
  78770. * @returns the string representation of the Color3 object
  78771. */
  78772. toString(): string;
  78773. /**
  78774. * Returns the string "Color3"
  78775. * @returns "Color3"
  78776. */
  78777. getClassName(): string;
  78778. /**
  78779. * Compute the Color3 hash code
  78780. * @returns an unique number that can be used to hash Color3 objects
  78781. */
  78782. getHashCode(): number;
  78783. /**
  78784. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78785. * @param array defines the array where to store the r,g,b components
  78786. * @param index defines an optional index in the target array to define where to start storing values
  78787. * @returns the current Color3 object
  78788. */
  78789. toArray(array: FloatArray, index?: number): Color3;
  78790. /**
  78791. * Returns a new Color4 object from the current Color3 and the given alpha
  78792. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78793. * @returns a new Color4 object
  78794. */
  78795. toColor4(alpha?: number): Color4;
  78796. /**
  78797. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78798. * @returns the new array
  78799. */
  78800. asArray(): number[];
  78801. /**
  78802. * Returns the luminance value
  78803. * @returns a float value
  78804. */
  78805. toLuminance(): number;
  78806. /**
  78807. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78808. * @param otherColor defines the second operand
  78809. * @returns the new Color3 object
  78810. */
  78811. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78812. /**
  78813. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78814. * @param otherColor defines the second operand
  78815. * @param result defines the Color3 object where to store the result
  78816. * @returns the current Color3
  78817. */
  78818. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78819. /**
  78820. * Determines equality between Color3 objects
  78821. * @param otherColor defines the second operand
  78822. * @returns true if the rgb values are equal to the given ones
  78823. */
  78824. equals(otherColor: DeepImmutable<Color3>): boolean;
  78825. /**
  78826. * Determines equality between the current Color3 object and a set of r,b,g values
  78827. * @param r defines the red component to check
  78828. * @param g defines the green component to check
  78829. * @param b defines the blue component to check
  78830. * @returns true if the rgb values are equal to the given ones
  78831. */
  78832. equalsFloats(r: number, g: number, b: number): boolean;
  78833. /**
  78834. * Multiplies in place each rgb value by scale
  78835. * @param scale defines the scaling factor
  78836. * @returns the updated Color3
  78837. */
  78838. scale(scale: number): Color3;
  78839. /**
  78840. * Multiplies the rgb values by scale and stores the result into "result"
  78841. * @param scale defines the scaling factor
  78842. * @param result defines the Color3 object where to store the result
  78843. * @returns the unmodified current Color3
  78844. */
  78845. scaleToRef(scale: number, result: Color3): Color3;
  78846. /**
  78847. * Scale the current Color3 values by a factor and add the result to a given Color3
  78848. * @param scale defines the scale factor
  78849. * @param result defines color to store the result into
  78850. * @returns the unmodified current Color3
  78851. */
  78852. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78853. /**
  78854. * Clamps the rgb values by the min and max values and stores the result into "result"
  78855. * @param min defines minimum clamping value (default is 0)
  78856. * @param max defines maximum clamping value (default is 1)
  78857. * @param result defines color to store the result into
  78858. * @returns the original Color3
  78859. */
  78860. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78861. /**
  78862. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78863. * @param otherColor defines the second operand
  78864. * @returns the new Color3
  78865. */
  78866. add(otherColor: DeepImmutable<Color3>): Color3;
  78867. /**
  78868. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78869. * @param otherColor defines the second operand
  78870. * @param result defines Color3 object to store the result into
  78871. * @returns the unmodified current Color3
  78872. */
  78873. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78874. /**
  78875. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78876. * @param otherColor defines the second operand
  78877. * @returns the new Color3
  78878. */
  78879. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78880. /**
  78881. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78882. * @param otherColor defines the second operand
  78883. * @param result defines Color3 object to store the result into
  78884. * @returns the unmodified current Color3
  78885. */
  78886. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78887. /**
  78888. * Copy the current object
  78889. * @returns a new Color3 copied the current one
  78890. */
  78891. clone(): Color3;
  78892. /**
  78893. * Copies the rgb values from the source in the current Color3
  78894. * @param source defines the source Color3 object
  78895. * @returns the updated Color3 object
  78896. */
  78897. copyFrom(source: DeepImmutable<Color3>): Color3;
  78898. /**
  78899. * Updates the Color3 rgb values from the given floats
  78900. * @param r defines the red component to read from
  78901. * @param g defines the green component to read from
  78902. * @param b defines the blue component to read from
  78903. * @returns the current Color3 object
  78904. */
  78905. copyFromFloats(r: number, g: number, b: number): Color3;
  78906. /**
  78907. * Updates the Color3 rgb values from the given floats
  78908. * @param r defines the red component to read from
  78909. * @param g defines the green component to read from
  78910. * @param b defines the blue component to read from
  78911. * @returns the current Color3 object
  78912. */
  78913. set(r: number, g: number, b: number): Color3;
  78914. /**
  78915. * Compute the Color3 hexadecimal code as a string
  78916. * @returns a string containing the hexadecimal representation of the Color3 object
  78917. */
  78918. toHexString(): string;
  78919. /**
  78920. * Computes a new Color3 converted from the current one to linear space
  78921. * @returns a new Color3 object
  78922. */
  78923. toLinearSpace(): Color3;
  78924. /**
  78925. * Converts current color in rgb space to HSV values
  78926. * @returns a new color3 representing the HSV values
  78927. */
  78928. toHSV(): Color3;
  78929. /**
  78930. * Converts current color in rgb space to HSV values
  78931. * @param result defines the Color3 where to store the HSV values
  78932. */
  78933. toHSVToRef(result: Color3): void;
  78934. /**
  78935. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78936. * @param convertedColor defines the Color3 object where to store the linear space version
  78937. * @returns the unmodified Color3
  78938. */
  78939. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78940. /**
  78941. * Computes a new Color3 converted from the current one to gamma space
  78942. * @returns a new Color3 object
  78943. */
  78944. toGammaSpace(): Color3;
  78945. /**
  78946. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78947. * @param convertedColor defines the Color3 object where to store the gamma space version
  78948. * @returns the unmodified Color3
  78949. */
  78950. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78951. private static _BlackReadOnly;
  78952. /**
  78953. * Convert Hue, saturation and value to a Color3 (RGB)
  78954. * @param hue defines the hue
  78955. * @param saturation defines the saturation
  78956. * @param value defines the value
  78957. * @param result defines the Color3 where to store the RGB values
  78958. */
  78959. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78960. /**
  78961. * Creates a new Color3 from the string containing valid hexadecimal values
  78962. * @param hex defines a string containing valid hexadecimal values
  78963. * @returns a new Color3 object
  78964. */
  78965. static FromHexString(hex: string): Color3;
  78966. /**
  78967. * Creates a new Color3 from the starting index of the given array
  78968. * @param array defines the source array
  78969. * @param offset defines an offset in the source array
  78970. * @returns a new Color3 object
  78971. */
  78972. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78973. /**
  78974. * Creates a new Color3 from integer values (< 256)
  78975. * @param r defines the red component to read from (value between 0 and 255)
  78976. * @param g defines the green component to read from (value between 0 and 255)
  78977. * @param b defines the blue component to read from (value between 0 and 255)
  78978. * @returns a new Color3 object
  78979. */
  78980. static FromInts(r: number, g: number, b: number): Color3;
  78981. /**
  78982. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78983. * @param start defines the start Color3 value
  78984. * @param end defines the end Color3 value
  78985. * @param amount defines the gradient value between start and end
  78986. * @returns a new Color3 object
  78987. */
  78988. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78989. /**
  78990. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78991. * @param left defines the start value
  78992. * @param right defines the end value
  78993. * @param amount defines the gradient factor
  78994. * @param result defines the Color3 object where to store the result
  78995. */
  78996. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78997. /**
  78998. * Returns a Color3 value containing a red color
  78999. * @returns a new Color3 object
  79000. */
  79001. static Red(): Color3;
  79002. /**
  79003. * Returns a Color3 value containing a green color
  79004. * @returns a new Color3 object
  79005. */
  79006. static Green(): Color3;
  79007. /**
  79008. * Returns a Color3 value containing a blue color
  79009. * @returns a new Color3 object
  79010. */
  79011. static Blue(): Color3;
  79012. /**
  79013. * Returns a Color3 value containing a black color
  79014. * @returns a new Color3 object
  79015. */
  79016. static Black(): Color3;
  79017. /**
  79018. * Gets a Color3 value containing a black color that must not be updated
  79019. */
  79020. static get BlackReadOnly(): DeepImmutable<Color3>;
  79021. /**
  79022. * Returns a Color3 value containing a white color
  79023. * @returns a new Color3 object
  79024. */
  79025. static White(): Color3;
  79026. /**
  79027. * Returns a Color3 value containing a purple color
  79028. * @returns a new Color3 object
  79029. */
  79030. static Purple(): Color3;
  79031. /**
  79032. * Returns a Color3 value containing a magenta color
  79033. * @returns a new Color3 object
  79034. */
  79035. static Magenta(): Color3;
  79036. /**
  79037. * Returns a Color3 value containing a yellow color
  79038. * @returns a new Color3 object
  79039. */
  79040. static Yellow(): Color3;
  79041. /**
  79042. * Returns a Color3 value containing a gray color
  79043. * @returns a new Color3 object
  79044. */
  79045. static Gray(): Color3;
  79046. /**
  79047. * Returns a Color3 value containing a teal color
  79048. * @returns a new Color3 object
  79049. */
  79050. static Teal(): Color3;
  79051. /**
  79052. * Returns a Color3 value containing a random color
  79053. * @returns a new Color3 object
  79054. */
  79055. static Random(): Color3;
  79056. }
  79057. /**
  79058. * Class used to hold a RBGA color
  79059. */
  79060. export class Color4 {
  79061. /**
  79062. * Defines the red component (between 0 and 1, default is 0)
  79063. */
  79064. r: number;
  79065. /**
  79066. * Defines the green component (between 0 and 1, default is 0)
  79067. */
  79068. g: number;
  79069. /**
  79070. * Defines the blue component (between 0 and 1, default is 0)
  79071. */
  79072. b: number;
  79073. /**
  79074. * Defines the alpha component (between 0 and 1, default is 1)
  79075. */
  79076. a: number;
  79077. /**
  79078. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79079. * @param r defines the red component (between 0 and 1, default is 0)
  79080. * @param g defines the green component (between 0 and 1, default is 0)
  79081. * @param b defines the blue component (between 0 and 1, default is 0)
  79082. * @param a defines the alpha component (between 0 and 1, default is 1)
  79083. */
  79084. constructor(
  79085. /**
  79086. * Defines the red component (between 0 and 1, default is 0)
  79087. */
  79088. r?: number,
  79089. /**
  79090. * Defines the green component (between 0 and 1, default is 0)
  79091. */
  79092. g?: number,
  79093. /**
  79094. * Defines the blue component (between 0 and 1, default is 0)
  79095. */
  79096. b?: number,
  79097. /**
  79098. * Defines the alpha component (between 0 and 1, default is 1)
  79099. */
  79100. a?: number);
  79101. /**
  79102. * Adds in place the given Color4 values to the current Color4 object
  79103. * @param right defines the second operand
  79104. * @returns the current updated Color4 object
  79105. */
  79106. addInPlace(right: DeepImmutable<Color4>): Color4;
  79107. /**
  79108. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79109. * @returns the new array
  79110. */
  79111. asArray(): number[];
  79112. /**
  79113. * Stores from the starting index in the given array the Color4 successive values
  79114. * @param array defines the array where to store the r,g,b components
  79115. * @param index defines an optional index in the target array to define where to start storing values
  79116. * @returns the current Color4 object
  79117. */
  79118. toArray(array: number[], index?: number): Color4;
  79119. /**
  79120. * Determines equality between Color4 objects
  79121. * @param otherColor defines the second operand
  79122. * @returns true if the rgba values are equal to the given ones
  79123. */
  79124. equals(otherColor: DeepImmutable<Color4>): boolean;
  79125. /**
  79126. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79127. * @param right defines the second operand
  79128. * @returns a new Color4 object
  79129. */
  79130. add(right: DeepImmutable<Color4>): Color4;
  79131. /**
  79132. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79133. * @param right defines the second operand
  79134. * @returns a new Color4 object
  79135. */
  79136. subtract(right: DeepImmutable<Color4>): Color4;
  79137. /**
  79138. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79139. * @param right defines the second operand
  79140. * @param result defines the Color4 object where to store the result
  79141. * @returns the current Color4 object
  79142. */
  79143. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79144. /**
  79145. * Creates a new Color4 with the current Color4 values multiplied by scale
  79146. * @param scale defines the scaling factor to apply
  79147. * @returns a new Color4 object
  79148. */
  79149. scale(scale: number): Color4;
  79150. /**
  79151. * Multiplies the current Color4 values by scale and stores the result in "result"
  79152. * @param scale defines the scaling factor to apply
  79153. * @param result defines the Color4 object where to store the result
  79154. * @returns the current unmodified Color4
  79155. */
  79156. scaleToRef(scale: number, result: Color4): Color4;
  79157. /**
  79158. * Scale the current Color4 values by a factor and add the result to a given Color4
  79159. * @param scale defines the scale factor
  79160. * @param result defines the Color4 object where to store the result
  79161. * @returns the unmodified current Color4
  79162. */
  79163. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79164. /**
  79165. * Clamps the rgb values by the min and max values and stores the result into "result"
  79166. * @param min defines minimum clamping value (default is 0)
  79167. * @param max defines maximum clamping value (default is 1)
  79168. * @param result defines color to store the result into.
  79169. * @returns the cuurent Color4
  79170. */
  79171. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79172. /**
  79173. * Multipy an Color4 value by another and return a new Color4 object
  79174. * @param color defines the Color4 value to multiply by
  79175. * @returns a new Color4 object
  79176. */
  79177. multiply(color: Color4): Color4;
  79178. /**
  79179. * Multipy a Color4 value by another and push the result in a reference value
  79180. * @param color defines the Color4 value to multiply by
  79181. * @param result defines the Color4 to fill the result in
  79182. * @returns the result Color4
  79183. */
  79184. multiplyToRef(color: Color4, result: Color4): Color4;
  79185. /**
  79186. * Creates a string with the Color4 current values
  79187. * @returns the string representation of the Color4 object
  79188. */
  79189. toString(): string;
  79190. /**
  79191. * Returns the string "Color4"
  79192. * @returns "Color4"
  79193. */
  79194. getClassName(): string;
  79195. /**
  79196. * Compute the Color4 hash code
  79197. * @returns an unique number that can be used to hash Color4 objects
  79198. */
  79199. getHashCode(): number;
  79200. /**
  79201. * Creates a new Color4 copied from the current one
  79202. * @returns a new Color4 object
  79203. */
  79204. clone(): Color4;
  79205. /**
  79206. * Copies the given Color4 values into the current one
  79207. * @param source defines the source Color4 object
  79208. * @returns the current updated Color4 object
  79209. */
  79210. copyFrom(source: Color4): Color4;
  79211. /**
  79212. * Copies the given float values into the current one
  79213. * @param r defines the red component to read from
  79214. * @param g defines the green component to read from
  79215. * @param b defines the blue component to read from
  79216. * @param a defines the alpha component to read from
  79217. * @returns the current updated Color4 object
  79218. */
  79219. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79220. /**
  79221. * Copies the given float values into the current one
  79222. * @param r defines the red component to read from
  79223. * @param g defines the green component to read from
  79224. * @param b defines the blue component to read from
  79225. * @param a defines the alpha component to read from
  79226. * @returns the current updated Color4 object
  79227. */
  79228. set(r: number, g: number, b: number, a: number): Color4;
  79229. /**
  79230. * Compute the Color4 hexadecimal code as a string
  79231. * @returns a string containing the hexadecimal representation of the Color4 object
  79232. */
  79233. toHexString(): string;
  79234. /**
  79235. * Computes a new Color4 converted from the current one to linear space
  79236. * @returns a new Color4 object
  79237. */
  79238. toLinearSpace(): Color4;
  79239. /**
  79240. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79241. * @param convertedColor defines the Color4 object where to store the linear space version
  79242. * @returns the unmodified Color4
  79243. */
  79244. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79245. /**
  79246. * Computes a new Color4 converted from the current one to gamma space
  79247. * @returns a new Color4 object
  79248. */
  79249. toGammaSpace(): Color4;
  79250. /**
  79251. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79252. * @param convertedColor defines the Color4 object where to store the gamma space version
  79253. * @returns the unmodified Color4
  79254. */
  79255. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79256. /**
  79257. * Creates a new Color4 from the string containing valid hexadecimal values
  79258. * @param hex defines a string containing valid hexadecimal values
  79259. * @returns a new Color4 object
  79260. */
  79261. static FromHexString(hex: string): Color4;
  79262. /**
  79263. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79264. * @param left defines the start value
  79265. * @param right defines the end value
  79266. * @param amount defines the gradient factor
  79267. * @returns a new Color4 object
  79268. */
  79269. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79270. /**
  79271. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79272. * @param left defines the start value
  79273. * @param right defines the end value
  79274. * @param amount defines the gradient factor
  79275. * @param result defines the Color4 object where to store data
  79276. */
  79277. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79278. /**
  79279. * Creates a new Color4 from a Color3 and an alpha value
  79280. * @param color3 defines the source Color3 to read from
  79281. * @param alpha defines the alpha component (1.0 by default)
  79282. * @returns a new Color4 object
  79283. */
  79284. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79285. /**
  79286. * Creates a new Color4 from the starting index element of the given array
  79287. * @param array defines the source array to read from
  79288. * @param offset defines the offset in the source array
  79289. * @returns a new Color4 object
  79290. */
  79291. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79292. /**
  79293. * Creates a new Color3 from integer values (< 256)
  79294. * @param r defines the red component to read from (value between 0 and 255)
  79295. * @param g defines the green component to read from (value between 0 and 255)
  79296. * @param b defines the blue component to read from (value between 0 and 255)
  79297. * @param a defines the alpha component to read from (value between 0 and 255)
  79298. * @returns a new Color3 object
  79299. */
  79300. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79301. /**
  79302. * Check the content of a given array and convert it to an array containing RGBA data
  79303. * If the original array was already containing count * 4 values then it is returned directly
  79304. * @param colors defines the array to check
  79305. * @param count defines the number of RGBA data to expect
  79306. * @returns an array containing count * 4 values (RGBA)
  79307. */
  79308. static CheckColors4(colors: number[], count: number): number[];
  79309. }
  79310. /**
  79311. * @hidden
  79312. */
  79313. export class TmpColors {
  79314. static Color3: Color3[];
  79315. static Color4: Color4[];
  79316. }
  79317. }
  79318. declare module BABYLON {
  79319. /**
  79320. * Defines an interface which represents an animation key frame
  79321. */
  79322. export interface IAnimationKey {
  79323. /**
  79324. * Frame of the key frame
  79325. */
  79326. frame: number;
  79327. /**
  79328. * Value at the specifies key frame
  79329. */
  79330. value: any;
  79331. /**
  79332. * The input tangent for the cubic hermite spline
  79333. */
  79334. inTangent?: any;
  79335. /**
  79336. * The output tangent for the cubic hermite spline
  79337. */
  79338. outTangent?: any;
  79339. /**
  79340. * The animation interpolation type
  79341. */
  79342. interpolation?: AnimationKeyInterpolation;
  79343. }
  79344. /**
  79345. * Enum for the animation key frame interpolation type
  79346. */
  79347. export enum AnimationKeyInterpolation {
  79348. /**
  79349. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79350. */
  79351. STEP = 1
  79352. }
  79353. }
  79354. declare module BABYLON {
  79355. /**
  79356. * Represents the range of an animation
  79357. */
  79358. export class AnimationRange {
  79359. /**The name of the animation range**/
  79360. name: string;
  79361. /**The starting frame of the animation */
  79362. from: number;
  79363. /**The ending frame of the animation*/
  79364. to: number;
  79365. /**
  79366. * Initializes the range of an animation
  79367. * @param name The name of the animation range
  79368. * @param from The starting frame of the animation
  79369. * @param to The ending frame of the animation
  79370. */
  79371. constructor(
  79372. /**The name of the animation range**/
  79373. name: string,
  79374. /**The starting frame of the animation */
  79375. from: number,
  79376. /**The ending frame of the animation*/
  79377. to: number);
  79378. /**
  79379. * Makes a copy of the animation range
  79380. * @returns A copy of the animation range
  79381. */
  79382. clone(): AnimationRange;
  79383. }
  79384. }
  79385. declare module BABYLON {
  79386. /**
  79387. * Composed of a frame, and an action function
  79388. */
  79389. export class AnimationEvent {
  79390. /** The frame for which the event is triggered **/
  79391. frame: number;
  79392. /** The event to perform when triggered **/
  79393. action: (currentFrame: number) => void;
  79394. /** Specifies if the event should be triggered only once**/
  79395. onlyOnce?: boolean | undefined;
  79396. /**
  79397. * Specifies if the animation event is done
  79398. */
  79399. isDone: boolean;
  79400. /**
  79401. * Initializes the animation event
  79402. * @param frame The frame for which the event is triggered
  79403. * @param action The event to perform when triggered
  79404. * @param onlyOnce Specifies if the event should be triggered only once
  79405. */
  79406. constructor(
  79407. /** The frame for which the event is triggered **/
  79408. frame: number,
  79409. /** The event to perform when triggered **/
  79410. action: (currentFrame: number) => void,
  79411. /** Specifies if the event should be triggered only once**/
  79412. onlyOnce?: boolean | undefined);
  79413. /** @hidden */
  79414. _clone(): AnimationEvent;
  79415. }
  79416. }
  79417. declare module BABYLON {
  79418. /**
  79419. * Interface used to define a behavior
  79420. */
  79421. export interface Behavior<T> {
  79422. /** gets or sets behavior's name */
  79423. name: string;
  79424. /**
  79425. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79426. */
  79427. init(): void;
  79428. /**
  79429. * Called when the behavior is attached to a target
  79430. * @param target defines the target where the behavior is attached to
  79431. */
  79432. attach(target: T): void;
  79433. /**
  79434. * Called when the behavior is detached from its target
  79435. */
  79436. detach(): void;
  79437. }
  79438. /**
  79439. * Interface implemented by classes supporting behaviors
  79440. */
  79441. export interface IBehaviorAware<T> {
  79442. /**
  79443. * Attach a behavior
  79444. * @param behavior defines the behavior to attach
  79445. * @returns the current host
  79446. */
  79447. addBehavior(behavior: Behavior<T>): T;
  79448. /**
  79449. * Remove a behavior from the current object
  79450. * @param behavior defines the behavior to detach
  79451. * @returns the current host
  79452. */
  79453. removeBehavior(behavior: Behavior<T>): T;
  79454. /**
  79455. * Gets a behavior using its name to search
  79456. * @param name defines the name to search
  79457. * @returns the behavior or null if not found
  79458. */
  79459. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79460. }
  79461. }
  79462. declare module BABYLON {
  79463. /**
  79464. * Defines an array and its length.
  79465. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79466. */
  79467. export interface ISmartArrayLike<T> {
  79468. /**
  79469. * The data of the array.
  79470. */
  79471. data: Array<T>;
  79472. /**
  79473. * The active length of the array.
  79474. */
  79475. length: number;
  79476. }
  79477. /**
  79478. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79479. */
  79480. export class SmartArray<T> implements ISmartArrayLike<T> {
  79481. /**
  79482. * The full set of data from the array.
  79483. */
  79484. data: Array<T>;
  79485. /**
  79486. * The active length of the array.
  79487. */
  79488. length: number;
  79489. protected _id: number;
  79490. /**
  79491. * Instantiates a Smart Array.
  79492. * @param capacity defines the default capacity of the array.
  79493. */
  79494. constructor(capacity: number);
  79495. /**
  79496. * Pushes a value at the end of the active data.
  79497. * @param value defines the object to push in the array.
  79498. */
  79499. push(value: T): void;
  79500. /**
  79501. * Iterates over the active data and apply the lambda to them.
  79502. * @param func defines the action to apply on each value.
  79503. */
  79504. forEach(func: (content: T) => void): void;
  79505. /**
  79506. * Sorts the full sets of data.
  79507. * @param compareFn defines the comparison function to apply.
  79508. */
  79509. sort(compareFn: (a: T, b: T) => number): void;
  79510. /**
  79511. * Resets the active data to an empty array.
  79512. */
  79513. reset(): void;
  79514. /**
  79515. * Releases all the data from the array as well as the array.
  79516. */
  79517. dispose(): void;
  79518. /**
  79519. * Concats the active data with a given array.
  79520. * @param array defines the data to concatenate with.
  79521. */
  79522. concat(array: any): void;
  79523. /**
  79524. * Returns the position of a value in the active data.
  79525. * @param value defines the value to find the index for
  79526. * @returns the index if found in the active data otherwise -1
  79527. */
  79528. indexOf(value: T): number;
  79529. /**
  79530. * Returns whether an element is part of the active data.
  79531. * @param value defines the value to look for
  79532. * @returns true if found in the active data otherwise false
  79533. */
  79534. contains(value: T): boolean;
  79535. private static _GlobalId;
  79536. }
  79537. /**
  79538. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79539. * The data in this array can only be present once
  79540. */
  79541. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79542. private _duplicateId;
  79543. /**
  79544. * Pushes a value at the end of the active data.
  79545. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79546. * @param value defines the object to push in the array.
  79547. */
  79548. push(value: T): void;
  79549. /**
  79550. * Pushes a value at the end of the active data.
  79551. * If the data is already present, it won t be added again
  79552. * @param value defines the object to push in the array.
  79553. * @returns true if added false if it was already present
  79554. */
  79555. pushNoDuplicate(value: T): boolean;
  79556. /**
  79557. * Resets the active data to an empty array.
  79558. */
  79559. reset(): void;
  79560. /**
  79561. * Concats the active data with a given array.
  79562. * This ensures no dupplicate will be present in the result.
  79563. * @param array defines the data to concatenate with.
  79564. */
  79565. concatWithNoDuplicate(array: any): void;
  79566. }
  79567. }
  79568. declare module BABYLON {
  79569. /**
  79570. * @ignore
  79571. * This is a list of all the different input types that are available in the application.
  79572. * Fo instance: ArcRotateCameraGamepadInput...
  79573. */
  79574. export var CameraInputTypes: {};
  79575. /**
  79576. * This is the contract to implement in order to create a new input class.
  79577. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79578. */
  79579. export interface ICameraInput<TCamera extends Camera> {
  79580. /**
  79581. * Defines the camera the input is attached to.
  79582. */
  79583. camera: Nullable<TCamera>;
  79584. /**
  79585. * Gets the class name of the current intput.
  79586. * @returns the class name
  79587. */
  79588. getClassName(): string;
  79589. /**
  79590. * Get the friendly name associated with the input class.
  79591. * @returns the input friendly name
  79592. */
  79593. getSimpleName(): string;
  79594. /**
  79595. * Attach the input controls to a specific dom element to get the input from.
  79596. * @param element Defines the element the controls should be listened from
  79597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79598. */
  79599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79600. /**
  79601. * Detach the current controls from the specified dom element.
  79602. * @param element Defines the element to stop listening the inputs from
  79603. */
  79604. detachControl(element: Nullable<HTMLElement>): void;
  79605. /**
  79606. * Update the current camera state depending on the inputs that have been used this frame.
  79607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79608. */
  79609. checkInputs?: () => void;
  79610. }
  79611. /**
  79612. * Represents a map of input types to input instance or input index to input instance.
  79613. */
  79614. export interface CameraInputsMap<TCamera extends Camera> {
  79615. /**
  79616. * Accessor to the input by input type.
  79617. */
  79618. [name: string]: ICameraInput<TCamera>;
  79619. /**
  79620. * Accessor to the input by input index.
  79621. */
  79622. [idx: number]: ICameraInput<TCamera>;
  79623. }
  79624. /**
  79625. * This represents the input manager used within a camera.
  79626. * It helps dealing with all the different kind of input attached to a camera.
  79627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79628. */
  79629. export class CameraInputsManager<TCamera extends Camera> {
  79630. /**
  79631. * Defines the list of inputs attahed to the camera.
  79632. */
  79633. attached: CameraInputsMap<TCamera>;
  79634. /**
  79635. * Defines the dom element the camera is collecting inputs from.
  79636. * This is null if the controls have not been attached.
  79637. */
  79638. attachedElement: Nullable<HTMLElement>;
  79639. /**
  79640. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79641. */
  79642. noPreventDefault: boolean;
  79643. /**
  79644. * Defined the camera the input manager belongs to.
  79645. */
  79646. camera: TCamera;
  79647. /**
  79648. * Update the current camera state depending on the inputs that have been used this frame.
  79649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79650. */
  79651. checkInputs: () => void;
  79652. /**
  79653. * Instantiate a new Camera Input Manager.
  79654. * @param camera Defines the camera the input manager blongs to
  79655. */
  79656. constructor(camera: TCamera);
  79657. /**
  79658. * Add an input method to a camera
  79659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79660. * @param input camera input method
  79661. */
  79662. add(input: ICameraInput<TCamera>): void;
  79663. /**
  79664. * Remove a specific input method from a camera
  79665. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79666. * @param inputToRemove camera input method
  79667. */
  79668. remove(inputToRemove: ICameraInput<TCamera>): void;
  79669. /**
  79670. * Remove a specific input type from a camera
  79671. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79672. * @param inputType the type of the input to remove
  79673. */
  79674. removeByType(inputType: string): void;
  79675. private _addCheckInputs;
  79676. /**
  79677. * Attach the input controls to the currently attached dom element to listen the events from.
  79678. * @param input Defines the input to attach
  79679. */
  79680. attachInput(input: ICameraInput<TCamera>): void;
  79681. /**
  79682. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79683. * @param element Defines the dom element to collect the events from
  79684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79685. */
  79686. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79687. /**
  79688. * Detach the current manager inputs controls from a specific dom element.
  79689. * @param element Defines the dom element to collect the events from
  79690. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79691. */
  79692. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79693. /**
  79694. * Rebuild the dynamic inputCheck function from the current list of
  79695. * defined inputs in the manager.
  79696. */
  79697. rebuildInputCheck(): void;
  79698. /**
  79699. * Remove all attached input methods from a camera
  79700. */
  79701. clear(): void;
  79702. /**
  79703. * Serialize the current input manager attached to a camera.
  79704. * This ensures than once parsed,
  79705. * the input associated to the camera will be identical to the current ones
  79706. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79707. */
  79708. serialize(serializedCamera: any): void;
  79709. /**
  79710. * Parses an input manager serialized JSON to restore the previous list of inputs
  79711. * and states associated to a camera.
  79712. * @param parsedCamera Defines the JSON to parse
  79713. */
  79714. parse(parsedCamera: any): void;
  79715. }
  79716. }
  79717. declare module BABYLON {
  79718. /**
  79719. * Class used to store data that will be store in GPU memory
  79720. */
  79721. export class Buffer {
  79722. private _engine;
  79723. private _buffer;
  79724. /** @hidden */
  79725. _data: Nullable<DataArray>;
  79726. private _updatable;
  79727. private _instanced;
  79728. private _divisor;
  79729. /**
  79730. * Gets the byte stride.
  79731. */
  79732. readonly byteStride: number;
  79733. /**
  79734. * Constructor
  79735. * @param engine the engine
  79736. * @param data the data to use for this buffer
  79737. * @param updatable whether the data is updatable
  79738. * @param stride the stride (optional)
  79739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79740. * @param instanced whether the buffer is instanced (optional)
  79741. * @param useBytes set to true if the stride in in bytes (optional)
  79742. * @param divisor sets an optional divisor for instances (1 by default)
  79743. */
  79744. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79745. /**
  79746. * Create a new VertexBuffer based on the current buffer
  79747. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79748. * @param offset defines offset in the buffer (0 by default)
  79749. * @param size defines the size in floats of attributes (position is 3 for instance)
  79750. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79751. * @param instanced defines if the vertex buffer contains indexed data
  79752. * @param useBytes defines if the offset and stride are in bytes *
  79753. * @param divisor sets an optional divisor for instances (1 by default)
  79754. * @returns the new vertex buffer
  79755. */
  79756. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79757. /**
  79758. * Gets a boolean indicating if the Buffer is updatable?
  79759. * @returns true if the buffer is updatable
  79760. */
  79761. isUpdatable(): boolean;
  79762. /**
  79763. * Gets current buffer's data
  79764. * @returns a DataArray or null
  79765. */
  79766. getData(): Nullable<DataArray>;
  79767. /**
  79768. * Gets underlying native buffer
  79769. * @returns underlying native buffer
  79770. */
  79771. getBuffer(): Nullable<DataBuffer>;
  79772. /**
  79773. * Gets the stride in float32 units (i.e. byte stride / 4).
  79774. * May not be an integer if the byte stride is not divisible by 4.
  79775. * @returns the stride in float32 units
  79776. * @deprecated Please use byteStride instead.
  79777. */
  79778. getStrideSize(): number;
  79779. /**
  79780. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79781. * @param data defines the data to store
  79782. */
  79783. create(data?: Nullable<DataArray>): void;
  79784. /** @hidden */
  79785. _rebuild(): void;
  79786. /**
  79787. * Update current buffer data
  79788. * @param data defines the data to store
  79789. */
  79790. update(data: DataArray): void;
  79791. /**
  79792. * Updates the data directly.
  79793. * @param data the new data
  79794. * @param offset the new offset
  79795. * @param vertexCount the vertex count (optional)
  79796. * @param useBytes set to true if the offset is in bytes
  79797. */
  79798. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79799. /**
  79800. * Release all resources
  79801. */
  79802. dispose(): void;
  79803. }
  79804. /**
  79805. * Specialized buffer used to store vertex data
  79806. */
  79807. export class VertexBuffer {
  79808. /** @hidden */
  79809. _buffer: Buffer;
  79810. private _kind;
  79811. private _size;
  79812. private _ownsBuffer;
  79813. private _instanced;
  79814. private _instanceDivisor;
  79815. /**
  79816. * The byte type.
  79817. */
  79818. static readonly BYTE: number;
  79819. /**
  79820. * The unsigned byte type.
  79821. */
  79822. static readonly UNSIGNED_BYTE: number;
  79823. /**
  79824. * The short type.
  79825. */
  79826. static readonly SHORT: number;
  79827. /**
  79828. * The unsigned short type.
  79829. */
  79830. static readonly UNSIGNED_SHORT: number;
  79831. /**
  79832. * The integer type.
  79833. */
  79834. static readonly INT: number;
  79835. /**
  79836. * The unsigned integer type.
  79837. */
  79838. static readonly UNSIGNED_INT: number;
  79839. /**
  79840. * The float type.
  79841. */
  79842. static readonly FLOAT: number;
  79843. /**
  79844. * Gets or sets the instance divisor when in instanced mode
  79845. */
  79846. get instanceDivisor(): number;
  79847. set instanceDivisor(value: number);
  79848. /**
  79849. * Gets the byte stride.
  79850. */
  79851. readonly byteStride: number;
  79852. /**
  79853. * Gets the byte offset.
  79854. */
  79855. readonly byteOffset: number;
  79856. /**
  79857. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79858. */
  79859. readonly normalized: boolean;
  79860. /**
  79861. * Gets the data type of each component in the array.
  79862. */
  79863. readonly type: number;
  79864. /**
  79865. * Constructor
  79866. * @param engine the engine
  79867. * @param data the data to use for this vertex buffer
  79868. * @param kind the vertex buffer kind
  79869. * @param updatable whether the data is updatable
  79870. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79871. * @param stride the stride (optional)
  79872. * @param instanced whether the buffer is instanced (optional)
  79873. * @param offset the offset of the data (optional)
  79874. * @param size the number of components (optional)
  79875. * @param type the type of the component (optional)
  79876. * @param normalized whether the data contains normalized data (optional)
  79877. * @param useBytes set to true if stride and offset are in bytes (optional)
  79878. * @param divisor defines the instance divisor to use (1 by default)
  79879. */
  79880. 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);
  79881. /** @hidden */
  79882. _rebuild(): void;
  79883. /**
  79884. * Returns the kind of the VertexBuffer (string)
  79885. * @returns a string
  79886. */
  79887. getKind(): string;
  79888. /**
  79889. * Gets a boolean indicating if the VertexBuffer is updatable?
  79890. * @returns true if the buffer is updatable
  79891. */
  79892. isUpdatable(): boolean;
  79893. /**
  79894. * Gets current buffer's data
  79895. * @returns a DataArray or null
  79896. */
  79897. getData(): Nullable<DataArray>;
  79898. /**
  79899. * Gets underlying native buffer
  79900. * @returns underlying native buffer
  79901. */
  79902. getBuffer(): Nullable<DataBuffer>;
  79903. /**
  79904. * Gets the stride in float32 units (i.e. byte stride / 4).
  79905. * May not be an integer if the byte stride is not divisible by 4.
  79906. * @returns the stride in float32 units
  79907. * @deprecated Please use byteStride instead.
  79908. */
  79909. getStrideSize(): number;
  79910. /**
  79911. * Returns the offset as a multiple of the type byte length.
  79912. * @returns the offset in bytes
  79913. * @deprecated Please use byteOffset instead.
  79914. */
  79915. getOffset(): number;
  79916. /**
  79917. * Returns the number of components per vertex attribute (integer)
  79918. * @returns the size in float
  79919. */
  79920. getSize(): number;
  79921. /**
  79922. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79923. * @returns true if this buffer is instanced
  79924. */
  79925. getIsInstanced(): boolean;
  79926. /**
  79927. * Returns the instancing divisor, zero for non-instanced (integer).
  79928. * @returns a number
  79929. */
  79930. getInstanceDivisor(): number;
  79931. /**
  79932. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79933. * @param data defines the data to store
  79934. */
  79935. create(data?: DataArray): void;
  79936. /**
  79937. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79938. * This function will create a new buffer if the current one is not updatable
  79939. * @param data defines the data to store
  79940. */
  79941. update(data: DataArray): void;
  79942. /**
  79943. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79944. * Returns the directly updated WebGLBuffer.
  79945. * @param data the new data
  79946. * @param offset the new offset
  79947. * @param useBytes set to true if the offset is in bytes
  79948. */
  79949. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79950. /**
  79951. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79952. */
  79953. dispose(): void;
  79954. /**
  79955. * Enumerates each value of this vertex buffer as numbers.
  79956. * @param count the number of values to enumerate
  79957. * @param callback the callback function called for each value
  79958. */
  79959. forEach(count: number, callback: (value: number, index: number) => void): void;
  79960. /**
  79961. * Positions
  79962. */
  79963. static readonly PositionKind: string;
  79964. /**
  79965. * Normals
  79966. */
  79967. static readonly NormalKind: string;
  79968. /**
  79969. * Tangents
  79970. */
  79971. static readonly TangentKind: string;
  79972. /**
  79973. * Texture coordinates
  79974. */
  79975. static readonly UVKind: string;
  79976. /**
  79977. * Texture coordinates 2
  79978. */
  79979. static readonly UV2Kind: string;
  79980. /**
  79981. * Texture coordinates 3
  79982. */
  79983. static readonly UV3Kind: string;
  79984. /**
  79985. * Texture coordinates 4
  79986. */
  79987. static readonly UV4Kind: string;
  79988. /**
  79989. * Texture coordinates 5
  79990. */
  79991. static readonly UV5Kind: string;
  79992. /**
  79993. * Texture coordinates 6
  79994. */
  79995. static readonly UV6Kind: string;
  79996. /**
  79997. * Colors
  79998. */
  79999. static readonly ColorKind: string;
  80000. /**
  80001. * Matrix indices (for bones)
  80002. */
  80003. static readonly MatricesIndicesKind: string;
  80004. /**
  80005. * Matrix weights (for bones)
  80006. */
  80007. static readonly MatricesWeightsKind: string;
  80008. /**
  80009. * Additional matrix indices (for bones)
  80010. */
  80011. static readonly MatricesIndicesExtraKind: string;
  80012. /**
  80013. * Additional matrix weights (for bones)
  80014. */
  80015. static readonly MatricesWeightsExtraKind: string;
  80016. /**
  80017. * Deduces the stride given a kind.
  80018. * @param kind The kind string to deduce
  80019. * @returns The deduced stride
  80020. */
  80021. static DeduceStride(kind: string): number;
  80022. /**
  80023. * Gets the byte length of the given type.
  80024. * @param type the type
  80025. * @returns the number of bytes
  80026. */
  80027. static GetTypeByteLength(type: number): number;
  80028. /**
  80029. * Enumerates each value of the given parameters as numbers.
  80030. * @param data the data to enumerate
  80031. * @param byteOffset the byte offset of the data
  80032. * @param byteStride the byte stride of the data
  80033. * @param componentCount the number of components per element
  80034. * @param componentType the type of the component
  80035. * @param count the number of values to enumerate
  80036. * @param normalized whether the data is normalized
  80037. * @param callback the callback function called for each value
  80038. */
  80039. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80040. private static _GetFloatValue;
  80041. }
  80042. }
  80043. declare module BABYLON {
  80044. /**
  80045. * @hidden
  80046. */
  80047. export class IntersectionInfo {
  80048. bu: Nullable<number>;
  80049. bv: Nullable<number>;
  80050. distance: number;
  80051. faceId: number;
  80052. subMeshId: number;
  80053. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80054. }
  80055. }
  80056. declare module BABYLON {
  80057. /**
  80058. * Represens a plane by the equation ax + by + cz + d = 0
  80059. */
  80060. export class Plane {
  80061. private static _TmpMatrix;
  80062. /**
  80063. * Normal of the plane (a,b,c)
  80064. */
  80065. normal: Vector3;
  80066. /**
  80067. * d component of the plane
  80068. */
  80069. d: number;
  80070. /**
  80071. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80072. * @param a a component of the plane
  80073. * @param b b component of the plane
  80074. * @param c c component of the plane
  80075. * @param d d component of the plane
  80076. */
  80077. constructor(a: number, b: number, c: number, d: number);
  80078. /**
  80079. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80080. */
  80081. asArray(): number[];
  80082. /**
  80083. * @returns a new plane copied from the current Plane.
  80084. */
  80085. clone(): Plane;
  80086. /**
  80087. * @returns the string "Plane".
  80088. */
  80089. getClassName(): string;
  80090. /**
  80091. * @returns the Plane hash code.
  80092. */
  80093. getHashCode(): number;
  80094. /**
  80095. * Normalize the current Plane in place.
  80096. * @returns the updated Plane.
  80097. */
  80098. normalize(): Plane;
  80099. /**
  80100. * Applies a transformation the plane and returns the result
  80101. * @param transformation the transformation matrix to be applied to the plane
  80102. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80103. */
  80104. transform(transformation: DeepImmutable<Matrix>): Plane;
  80105. /**
  80106. * Calcualtte the dot product between the point and the plane normal
  80107. * @param point point to calculate the dot product with
  80108. * @returns the dot product (float) of the point coordinates and the plane normal.
  80109. */
  80110. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80111. /**
  80112. * Updates the current Plane from the plane defined by the three given points.
  80113. * @param point1 one of the points used to contruct the plane
  80114. * @param point2 one of the points used to contruct the plane
  80115. * @param point3 one of the points used to contruct the plane
  80116. * @returns the updated Plane.
  80117. */
  80118. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80119. /**
  80120. * Checks if the plane is facing a given direction
  80121. * @param direction the direction to check if the plane is facing
  80122. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80123. * @returns True is the vector "direction" is the same side than the plane normal.
  80124. */
  80125. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80126. /**
  80127. * Calculates the distance to a point
  80128. * @param point point to calculate distance to
  80129. * @returns the signed distance (float) from the given point to the Plane.
  80130. */
  80131. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80132. /**
  80133. * Creates a plane from an array
  80134. * @param array the array to create a plane from
  80135. * @returns a new Plane from the given array.
  80136. */
  80137. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80138. /**
  80139. * Creates a plane from three points
  80140. * @param point1 point used to create the plane
  80141. * @param point2 point used to create the plane
  80142. * @param point3 point used to create the plane
  80143. * @returns a new Plane defined by the three given points.
  80144. */
  80145. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80146. /**
  80147. * Creates a plane from an origin point and a normal
  80148. * @param origin origin of the plane to be constructed
  80149. * @param normal normal of the plane to be constructed
  80150. * @returns a new Plane the normal vector to this plane at the given origin point.
  80151. * Note : the vector "normal" is updated because normalized.
  80152. */
  80153. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80154. /**
  80155. * Calculates the distance from a plane and a point
  80156. * @param origin origin of the plane to be constructed
  80157. * @param normal normal of the plane to be constructed
  80158. * @param point point to calculate distance to
  80159. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80160. */
  80161. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80162. }
  80163. }
  80164. declare module BABYLON {
  80165. /**
  80166. * Class used to store bounding sphere information
  80167. */
  80168. export class BoundingSphere {
  80169. /**
  80170. * Gets the center of the bounding sphere in local space
  80171. */
  80172. readonly center: Vector3;
  80173. /**
  80174. * Radius of the bounding sphere in local space
  80175. */
  80176. radius: number;
  80177. /**
  80178. * Gets the center of the bounding sphere in world space
  80179. */
  80180. readonly centerWorld: Vector3;
  80181. /**
  80182. * Radius of the bounding sphere in world space
  80183. */
  80184. radiusWorld: number;
  80185. /**
  80186. * Gets the minimum vector in local space
  80187. */
  80188. readonly minimum: Vector3;
  80189. /**
  80190. * Gets the maximum vector in local space
  80191. */
  80192. readonly maximum: Vector3;
  80193. private _worldMatrix;
  80194. private static readonly TmpVector3;
  80195. /**
  80196. * Creates a new bounding sphere
  80197. * @param min defines the minimum vector (in local space)
  80198. * @param max defines the maximum vector (in local space)
  80199. * @param worldMatrix defines the new world matrix
  80200. */
  80201. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80202. /**
  80203. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80204. * @param min defines the new minimum vector (in local space)
  80205. * @param max defines the new maximum vector (in local space)
  80206. * @param worldMatrix defines the new world matrix
  80207. */
  80208. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80209. /**
  80210. * Scale the current bounding sphere by applying a scale factor
  80211. * @param factor defines the scale factor to apply
  80212. * @returns the current bounding box
  80213. */
  80214. scale(factor: number): BoundingSphere;
  80215. /**
  80216. * Gets the world matrix of the bounding box
  80217. * @returns a matrix
  80218. */
  80219. getWorldMatrix(): DeepImmutable<Matrix>;
  80220. /** @hidden */
  80221. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80222. /**
  80223. * Tests if the bounding sphere is intersecting the frustum planes
  80224. * @param frustumPlanes defines the frustum planes to test
  80225. * @returns true if there is an intersection
  80226. */
  80227. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80228. /**
  80229. * Tests if the bounding sphere center is in between the frustum planes.
  80230. * Used for optimistic fast inclusion.
  80231. * @param frustumPlanes defines the frustum planes to test
  80232. * @returns true if the sphere center is in between the frustum planes
  80233. */
  80234. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80235. /**
  80236. * Tests if a point is inside the bounding sphere
  80237. * @param point defines the point to test
  80238. * @returns true if the point is inside the bounding sphere
  80239. */
  80240. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80241. /**
  80242. * Checks if two sphere intersct
  80243. * @param sphere0 sphere 0
  80244. * @param sphere1 sphere 1
  80245. * @returns true if the speres intersect
  80246. */
  80247. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80248. }
  80249. }
  80250. declare module BABYLON {
  80251. /**
  80252. * Class used to store bounding box information
  80253. */
  80254. export class BoundingBox implements ICullable {
  80255. /**
  80256. * Gets the 8 vectors representing the bounding box in local space
  80257. */
  80258. readonly vectors: Vector3[];
  80259. /**
  80260. * Gets the center of the bounding box in local space
  80261. */
  80262. readonly center: Vector3;
  80263. /**
  80264. * Gets the center of the bounding box in world space
  80265. */
  80266. readonly centerWorld: Vector3;
  80267. /**
  80268. * Gets the extend size in local space
  80269. */
  80270. readonly extendSize: Vector3;
  80271. /**
  80272. * Gets the extend size in world space
  80273. */
  80274. readonly extendSizeWorld: Vector3;
  80275. /**
  80276. * Gets the OBB (object bounding box) directions
  80277. */
  80278. readonly directions: Vector3[];
  80279. /**
  80280. * Gets the 8 vectors representing the bounding box in world space
  80281. */
  80282. readonly vectorsWorld: Vector3[];
  80283. /**
  80284. * Gets the minimum vector in world space
  80285. */
  80286. readonly minimumWorld: Vector3;
  80287. /**
  80288. * Gets the maximum vector in world space
  80289. */
  80290. readonly maximumWorld: Vector3;
  80291. /**
  80292. * Gets the minimum vector in local space
  80293. */
  80294. readonly minimum: Vector3;
  80295. /**
  80296. * Gets the maximum vector in local space
  80297. */
  80298. readonly maximum: Vector3;
  80299. private _worldMatrix;
  80300. private static readonly TmpVector3;
  80301. /**
  80302. * @hidden
  80303. */
  80304. _tag: number;
  80305. /**
  80306. * Creates a new bounding box
  80307. * @param min defines the minimum vector (in local space)
  80308. * @param max defines the maximum vector (in local space)
  80309. * @param worldMatrix defines the new world matrix
  80310. */
  80311. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80312. /**
  80313. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80314. * @param min defines the new minimum vector (in local space)
  80315. * @param max defines the new maximum vector (in local space)
  80316. * @param worldMatrix defines the new world matrix
  80317. */
  80318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80319. /**
  80320. * Scale the current bounding box by applying a scale factor
  80321. * @param factor defines the scale factor to apply
  80322. * @returns the current bounding box
  80323. */
  80324. scale(factor: number): BoundingBox;
  80325. /**
  80326. * Gets the world matrix of the bounding box
  80327. * @returns a matrix
  80328. */
  80329. getWorldMatrix(): DeepImmutable<Matrix>;
  80330. /** @hidden */
  80331. _update(world: DeepImmutable<Matrix>): void;
  80332. /**
  80333. * Tests if the bounding box is intersecting the frustum planes
  80334. * @param frustumPlanes defines the frustum planes to test
  80335. * @returns true if there is an intersection
  80336. */
  80337. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80338. /**
  80339. * Tests if the bounding box is entirely inside the frustum planes
  80340. * @param frustumPlanes defines the frustum planes to test
  80341. * @returns true if there is an inclusion
  80342. */
  80343. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80344. /**
  80345. * Tests if a point is inside the bounding box
  80346. * @param point defines the point to test
  80347. * @returns true if the point is inside the bounding box
  80348. */
  80349. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80350. /**
  80351. * Tests if the bounding box intersects with a bounding sphere
  80352. * @param sphere defines the sphere to test
  80353. * @returns true if there is an intersection
  80354. */
  80355. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80356. /**
  80357. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80358. * @param min defines the min vector to use
  80359. * @param max defines the max vector to use
  80360. * @returns true if there is an intersection
  80361. */
  80362. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80363. /**
  80364. * Tests if two bounding boxes are intersections
  80365. * @param box0 defines the first box to test
  80366. * @param box1 defines the second box to test
  80367. * @returns true if there is an intersection
  80368. */
  80369. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80370. /**
  80371. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80372. * @param minPoint defines the minimum vector of the bounding box
  80373. * @param maxPoint defines the maximum vector of the bounding box
  80374. * @param sphereCenter defines the sphere center
  80375. * @param sphereRadius defines the sphere radius
  80376. * @returns true if there is an intersection
  80377. */
  80378. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80379. /**
  80380. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80381. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80382. * @param frustumPlanes defines the frustum planes to test
  80383. * @return true if there is an inclusion
  80384. */
  80385. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80386. /**
  80387. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80388. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80389. * @param frustumPlanes defines the frustum planes to test
  80390. * @return true if there is an intersection
  80391. */
  80392. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80393. }
  80394. }
  80395. declare module BABYLON {
  80396. /** @hidden */
  80397. export class Collider {
  80398. /** Define if a collision was found */
  80399. collisionFound: boolean;
  80400. /**
  80401. * Define last intersection point in local space
  80402. */
  80403. intersectionPoint: Vector3;
  80404. /**
  80405. * Define last collided mesh
  80406. */
  80407. collidedMesh: Nullable<AbstractMesh>;
  80408. private _collisionPoint;
  80409. private _planeIntersectionPoint;
  80410. private _tempVector;
  80411. private _tempVector2;
  80412. private _tempVector3;
  80413. private _tempVector4;
  80414. private _edge;
  80415. private _baseToVertex;
  80416. private _destinationPoint;
  80417. private _slidePlaneNormal;
  80418. private _displacementVector;
  80419. /** @hidden */
  80420. _radius: Vector3;
  80421. /** @hidden */
  80422. _retry: number;
  80423. private _velocity;
  80424. private _basePoint;
  80425. private _epsilon;
  80426. /** @hidden */
  80427. _velocityWorldLength: number;
  80428. /** @hidden */
  80429. _basePointWorld: Vector3;
  80430. private _velocityWorld;
  80431. private _normalizedVelocity;
  80432. /** @hidden */
  80433. _initialVelocity: Vector3;
  80434. /** @hidden */
  80435. _initialPosition: Vector3;
  80436. private _nearestDistance;
  80437. private _collisionMask;
  80438. get collisionMask(): number;
  80439. set collisionMask(mask: number);
  80440. /**
  80441. * Gets the plane normal used to compute the sliding response (in local space)
  80442. */
  80443. get slidePlaneNormal(): Vector3;
  80444. /** @hidden */
  80445. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80446. /** @hidden */
  80447. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80448. /** @hidden */
  80449. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80450. /** @hidden */
  80451. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80452. /** @hidden */
  80453. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80454. /** @hidden */
  80455. _getResponse(pos: Vector3, vel: Vector3): void;
  80456. }
  80457. }
  80458. declare module BABYLON {
  80459. /**
  80460. * Interface for cullable objects
  80461. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80462. */
  80463. export interface ICullable {
  80464. /**
  80465. * Checks if the object or part of the object is in the frustum
  80466. * @param frustumPlanes Camera near/planes
  80467. * @returns true if the object is in frustum otherwise false
  80468. */
  80469. isInFrustum(frustumPlanes: Plane[]): boolean;
  80470. /**
  80471. * Checks if a cullable object (mesh...) is in the camera frustum
  80472. * Unlike isInFrustum this cheks the full bounding box
  80473. * @param frustumPlanes Camera near/planes
  80474. * @returns true if the object is in frustum otherwise false
  80475. */
  80476. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80477. }
  80478. /**
  80479. * Info for a bounding data of a mesh
  80480. */
  80481. export class BoundingInfo implements ICullable {
  80482. /**
  80483. * Bounding box for the mesh
  80484. */
  80485. readonly boundingBox: BoundingBox;
  80486. /**
  80487. * Bounding sphere for the mesh
  80488. */
  80489. readonly boundingSphere: BoundingSphere;
  80490. private _isLocked;
  80491. private static readonly TmpVector3;
  80492. /**
  80493. * Constructs bounding info
  80494. * @param minimum min vector of the bounding box/sphere
  80495. * @param maximum max vector of the bounding box/sphere
  80496. * @param worldMatrix defines the new world matrix
  80497. */
  80498. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80499. /**
  80500. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80501. * @param min defines the new minimum vector (in local space)
  80502. * @param max defines the new maximum vector (in local space)
  80503. * @param worldMatrix defines the new world matrix
  80504. */
  80505. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80506. /**
  80507. * min vector of the bounding box/sphere
  80508. */
  80509. get minimum(): Vector3;
  80510. /**
  80511. * max vector of the bounding box/sphere
  80512. */
  80513. get maximum(): Vector3;
  80514. /**
  80515. * If the info is locked and won't be updated to avoid perf overhead
  80516. */
  80517. get isLocked(): boolean;
  80518. set isLocked(value: boolean);
  80519. /**
  80520. * Updates the bounding sphere and box
  80521. * @param world world matrix to be used to update
  80522. */
  80523. update(world: DeepImmutable<Matrix>): void;
  80524. /**
  80525. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80526. * @param center New center of the bounding info
  80527. * @param extend New extend of the bounding info
  80528. * @returns the current bounding info
  80529. */
  80530. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80531. /**
  80532. * Scale the current bounding info by applying a scale factor
  80533. * @param factor defines the scale factor to apply
  80534. * @returns the current bounding info
  80535. */
  80536. scale(factor: number): BoundingInfo;
  80537. /**
  80538. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80539. * @param frustumPlanes defines the frustum to test
  80540. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80541. * @returns true if the bounding info is in the frustum planes
  80542. */
  80543. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80544. /**
  80545. * Gets the world distance between the min and max points of the bounding box
  80546. */
  80547. get diagonalLength(): number;
  80548. /**
  80549. * Checks if a cullable object (mesh...) is in the camera frustum
  80550. * Unlike isInFrustum this cheks the full bounding box
  80551. * @param frustumPlanes Camera near/planes
  80552. * @returns true if the object is in frustum otherwise false
  80553. */
  80554. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80555. /** @hidden */
  80556. _checkCollision(collider: Collider): boolean;
  80557. /**
  80558. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80559. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80560. * @param point the point to check intersection with
  80561. * @returns if the point intersects
  80562. */
  80563. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80564. /**
  80565. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80566. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80567. * @param boundingInfo the bounding info to check intersection with
  80568. * @param precise if the intersection should be done using OBB
  80569. * @returns if the bounding info intersects
  80570. */
  80571. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80572. }
  80573. }
  80574. declare module BABYLON {
  80575. /**
  80576. * Extracts minimum and maximum values from a list of indexed positions
  80577. * @param positions defines the positions to use
  80578. * @param indices defines the indices to the positions
  80579. * @param indexStart defines the start index
  80580. * @param indexCount defines the end index
  80581. * @param bias defines bias value to add to the result
  80582. * @return minimum and maximum values
  80583. */
  80584. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80585. minimum: Vector3;
  80586. maximum: Vector3;
  80587. };
  80588. /**
  80589. * Extracts minimum and maximum values from a list of positions
  80590. * @param positions defines the positions to use
  80591. * @param start defines the start index in the positions array
  80592. * @param count defines the number of positions to handle
  80593. * @param bias defines bias value to add to the result
  80594. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80595. * @return minimum and maximum values
  80596. */
  80597. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80598. minimum: Vector3;
  80599. maximum: Vector3;
  80600. };
  80601. }
  80602. declare module BABYLON {
  80603. /** @hidden */
  80604. export class WebGLDataBuffer extends DataBuffer {
  80605. private _buffer;
  80606. constructor(resource: WebGLBuffer);
  80607. get underlyingResource(): any;
  80608. }
  80609. }
  80610. declare module BABYLON {
  80611. /** @hidden */
  80612. export class WebGLPipelineContext implements IPipelineContext {
  80613. engine: ThinEngine;
  80614. program: Nullable<WebGLProgram>;
  80615. context?: WebGLRenderingContext;
  80616. vertexShader?: WebGLShader;
  80617. fragmentShader?: WebGLShader;
  80618. isParallelCompiled: boolean;
  80619. onCompiled?: () => void;
  80620. transformFeedback?: WebGLTransformFeedback | null;
  80621. vertexCompilationError: Nullable<string>;
  80622. fragmentCompilationError: Nullable<string>;
  80623. programLinkError: Nullable<string>;
  80624. programValidationError: Nullable<string>;
  80625. get isAsync(): boolean;
  80626. get isReady(): boolean;
  80627. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80628. _getVertexShaderCode(): string | null;
  80629. _getFragmentShaderCode(): string | null;
  80630. }
  80631. }
  80632. declare module BABYLON {
  80633. interface ThinEngine {
  80634. /**
  80635. * Create an uniform buffer
  80636. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80637. * @param elements defines the content of the uniform buffer
  80638. * @returns the webGL uniform buffer
  80639. */
  80640. createUniformBuffer(elements: FloatArray): DataBuffer;
  80641. /**
  80642. * Create a dynamic uniform buffer
  80643. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80644. * @param elements defines the content of the uniform buffer
  80645. * @returns the webGL uniform buffer
  80646. */
  80647. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80648. /**
  80649. * Update an existing uniform buffer
  80650. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80651. * @param uniformBuffer defines the target uniform buffer
  80652. * @param elements defines the content to update
  80653. * @param offset defines the offset in the uniform buffer where update should start
  80654. * @param count defines the size of the data to update
  80655. */
  80656. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80657. /**
  80658. * Bind an uniform buffer to the current webGL context
  80659. * @param buffer defines the buffer to bind
  80660. */
  80661. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80662. /**
  80663. * Bind a buffer to the current webGL context at a given location
  80664. * @param buffer defines the buffer to bind
  80665. * @param location defines the index where to bind the buffer
  80666. */
  80667. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80668. /**
  80669. * Bind a specific block at a given index in a specific shader program
  80670. * @param pipelineContext defines the pipeline context to use
  80671. * @param blockName defines the block name
  80672. * @param index defines the index where to bind the block
  80673. */
  80674. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80675. }
  80676. }
  80677. declare module BABYLON {
  80678. /**
  80679. * Uniform buffer objects.
  80680. *
  80681. * Handles blocks of uniform on the GPU.
  80682. *
  80683. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80684. *
  80685. * For more information, please refer to :
  80686. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80687. */
  80688. export class UniformBuffer {
  80689. private _engine;
  80690. private _buffer;
  80691. private _data;
  80692. private _bufferData;
  80693. private _dynamic?;
  80694. private _uniformLocations;
  80695. private _uniformSizes;
  80696. private _uniformLocationPointer;
  80697. private _needSync;
  80698. private _noUBO;
  80699. private _currentEffect;
  80700. /** @hidden */
  80701. _alreadyBound: boolean;
  80702. private static _MAX_UNIFORM_SIZE;
  80703. private static _tempBuffer;
  80704. /**
  80705. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80706. * This is dynamic to allow compat with webgl 1 and 2.
  80707. * You will need to pass the name of the uniform as well as the value.
  80708. */
  80709. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80710. /**
  80711. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80712. * This is dynamic to allow compat with webgl 1 and 2.
  80713. * You will need to pass the name of the uniform as well as the value.
  80714. */
  80715. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80716. /**
  80717. * Lambda to Update a single float in a uniform buffer.
  80718. * This is dynamic to allow compat with webgl 1 and 2.
  80719. * You will need to pass the name of the uniform as well as the value.
  80720. */
  80721. updateFloat: (name: string, x: number) => void;
  80722. /**
  80723. * Lambda to Update a vec2 of float in a uniform buffer.
  80724. * This is dynamic to allow compat with webgl 1 and 2.
  80725. * You will need to pass the name of the uniform as well as the value.
  80726. */
  80727. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80728. /**
  80729. * Lambda to Update a vec3 of float in a uniform buffer.
  80730. * This is dynamic to allow compat with webgl 1 and 2.
  80731. * You will need to pass the name of the uniform as well as the value.
  80732. */
  80733. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80734. /**
  80735. * Lambda to Update a vec4 of float in a uniform buffer.
  80736. * This is dynamic to allow compat with webgl 1 and 2.
  80737. * You will need to pass the name of the uniform as well as the value.
  80738. */
  80739. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80740. /**
  80741. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80742. * This is dynamic to allow compat with webgl 1 and 2.
  80743. * You will need to pass the name of the uniform as well as the value.
  80744. */
  80745. updateMatrix: (name: string, mat: Matrix) => void;
  80746. /**
  80747. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80748. * This is dynamic to allow compat with webgl 1 and 2.
  80749. * You will need to pass the name of the uniform as well as the value.
  80750. */
  80751. updateVector3: (name: string, vector: Vector3) => void;
  80752. /**
  80753. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80754. * This is dynamic to allow compat with webgl 1 and 2.
  80755. * You will need to pass the name of the uniform as well as the value.
  80756. */
  80757. updateVector4: (name: string, vector: Vector4) => void;
  80758. /**
  80759. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80760. * This is dynamic to allow compat with webgl 1 and 2.
  80761. * You will need to pass the name of the uniform as well as the value.
  80762. */
  80763. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80764. /**
  80765. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80766. * This is dynamic to allow compat with webgl 1 and 2.
  80767. * You will need to pass the name of the uniform as well as the value.
  80768. */
  80769. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80770. /**
  80771. * Instantiates a new Uniform buffer objects.
  80772. *
  80773. * Handles blocks of uniform on the GPU.
  80774. *
  80775. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80776. *
  80777. * For more information, please refer to :
  80778. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80779. * @param engine Define the engine the buffer is associated with
  80780. * @param data Define the data contained in the buffer
  80781. * @param dynamic Define if the buffer is updatable
  80782. */
  80783. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80784. /**
  80785. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80786. * or just falling back on setUniformXXX calls.
  80787. */
  80788. get useUbo(): boolean;
  80789. /**
  80790. * Indicates if the WebGL underlying uniform buffer is in sync
  80791. * with the javascript cache data.
  80792. */
  80793. get isSync(): boolean;
  80794. /**
  80795. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80796. * Also, a dynamic UniformBuffer will disable cache verification and always
  80797. * update the underlying WebGL uniform buffer to the GPU.
  80798. * @returns if Dynamic, otherwise false
  80799. */
  80800. isDynamic(): boolean;
  80801. /**
  80802. * The data cache on JS side.
  80803. * @returns the underlying data as a float array
  80804. */
  80805. getData(): Float32Array;
  80806. /**
  80807. * The underlying WebGL Uniform buffer.
  80808. * @returns the webgl buffer
  80809. */
  80810. getBuffer(): Nullable<DataBuffer>;
  80811. /**
  80812. * std140 layout specifies how to align data within an UBO structure.
  80813. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80814. * for specs.
  80815. */
  80816. private _fillAlignment;
  80817. /**
  80818. * Adds an uniform in the buffer.
  80819. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80820. * for the layout to be correct !
  80821. * @param name Name of the uniform, as used in the uniform block in the shader.
  80822. * @param size Data size, or data directly.
  80823. */
  80824. addUniform(name: string, size: number | number[]): void;
  80825. /**
  80826. * Adds a Matrix 4x4 to the uniform buffer.
  80827. * @param name Name of the uniform, as used in the uniform block in the shader.
  80828. * @param mat A 4x4 matrix.
  80829. */
  80830. addMatrix(name: string, mat: Matrix): void;
  80831. /**
  80832. * Adds a vec2 to the uniform buffer.
  80833. * @param name Name of the uniform, as used in the uniform block in the shader.
  80834. * @param x Define the x component value of the vec2
  80835. * @param y Define the y component value of the vec2
  80836. */
  80837. addFloat2(name: string, x: number, y: number): void;
  80838. /**
  80839. * Adds a vec3 to the uniform buffer.
  80840. * @param name Name of the uniform, as used in the uniform block in the shader.
  80841. * @param x Define the x component value of the vec3
  80842. * @param y Define the y component value of the vec3
  80843. * @param z Define the z component value of the vec3
  80844. */
  80845. addFloat3(name: string, x: number, y: number, z: number): void;
  80846. /**
  80847. * Adds a vec3 to the uniform buffer.
  80848. * @param name Name of the uniform, as used in the uniform block in the shader.
  80849. * @param color Define the vec3 from a Color
  80850. */
  80851. addColor3(name: string, color: Color3): void;
  80852. /**
  80853. * Adds a vec4 to the uniform buffer.
  80854. * @param name Name of the uniform, as used in the uniform block in the shader.
  80855. * @param color Define the rgb components from a Color
  80856. * @param alpha Define the a component of the vec4
  80857. */
  80858. addColor4(name: string, color: Color3, alpha: number): void;
  80859. /**
  80860. * Adds a vec3 to the uniform buffer.
  80861. * @param name Name of the uniform, as used in the uniform block in the shader.
  80862. * @param vector Define the vec3 components from a Vector
  80863. */
  80864. addVector3(name: string, vector: Vector3): void;
  80865. /**
  80866. * Adds a Matrix 3x3 to the uniform buffer.
  80867. * @param name Name of the uniform, as used in the uniform block in the shader.
  80868. */
  80869. addMatrix3x3(name: string): void;
  80870. /**
  80871. * Adds a Matrix 2x2 to the uniform buffer.
  80872. * @param name Name of the uniform, as used in the uniform block in the shader.
  80873. */
  80874. addMatrix2x2(name: string): void;
  80875. /**
  80876. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80877. */
  80878. create(): void;
  80879. /** @hidden */
  80880. _rebuild(): void;
  80881. /**
  80882. * Updates the WebGL Uniform Buffer on the GPU.
  80883. * If the `dynamic` flag is set to true, no cache comparison is done.
  80884. * Otherwise, the buffer will be updated only if the cache differs.
  80885. */
  80886. update(): void;
  80887. /**
  80888. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80889. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80890. * @param data Define the flattened data
  80891. * @param size Define the size of the data.
  80892. */
  80893. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80894. private _valueCache;
  80895. private _cacheMatrix;
  80896. private _updateMatrix3x3ForUniform;
  80897. private _updateMatrix3x3ForEffect;
  80898. private _updateMatrix2x2ForEffect;
  80899. private _updateMatrix2x2ForUniform;
  80900. private _updateFloatForEffect;
  80901. private _updateFloatForUniform;
  80902. private _updateFloat2ForEffect;
  80903. private _updateFloat2ForUniform;
  80904. private _updateFloat3ForEffect;
  80905. private _updateFloat3ForUniform;
  80906. private _updateFloat4ForEffect;
  80907. private _updateFloat4ForUniform;
  80908. private _updateMatrixForEffect;
  80909. private _updateMatrixForUniform;
  80910. private _updateVector3ForEffect;
  80911. private _updateVector3ForUniform;
  80912. private _updateVector4ForEffect;
  80913. private _updateVector4ForUniform;
  80914. private _updateColor3ForEffect;
  80915. private _updateColor3ForUniform;
  80916. private _updateColor4ForEffect;
  80917. private _updateColor4ForUniform;
  80918. /**
  80919. * Sets a sampler uniform on the effect.
  80920. * @param name Define the name of the sampler.
  80921. * @param texture Define the texture to set in the sampler
  80922. */
  80923. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80924. /**
  80925. * Directly updates the value of the uniform in the cache AND on the GPU.
  80926. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80927. * @param data Define the flattened data
  80928. */
  80929. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80930. /**
  80931. * Binds this uniform buffer to an effect.
  80932. * @param effect Define the effect to bind the buffer to
  80933. * @param name Name of the uniform block in the shader.
  80934. */
  80935. bindToEffect(effect: Effect, name: string): void;
  80936. /**
  80937. * Disposes the uniform buffer.
  80938. */
  80939. dispose(): void;
  80940. }
  80941. }
  80942. declare module BABYLON {
  80943. /**
  80944. * Enum that determines the text-wrapping mode to use.
  80945. */
  80946. export enum InspectableType {
  80947. /**
  80948. * Checkbox for booleans
  80949. */
  80950. Checkbox = 0,
  80951. /**
  80952. * Sliders for numbers
  80953. */
  80954. Slider = 1,
  80955. /**
  80956. * Vector3
  80957. */
  80958. Vector3 = 2,
  80959. /**
  80960. * Quaternions
  80961. */
  80962. Quaternion = 3,
  80963. /**
  80964. * Color3
  80965. */
  80966. Color3 = 4,
  80967. /**
  80968. * String
  80969. */
  80970. String = 5
  80971. }
  80972. /**
  80973. * Interface used to define custom inspectable properties.
  80974. * This interface is used by the inspector to display custom property grids
  80975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80976. */
  80977. export interface IInspectable {
  80978. /**
  80979. * Gets the label to display
  80980. */
  80981. label: string;
  80982. /**
  80983. * Gets the name of the property to edit
  80984. */
  80985. propertyName: string;
  80986. /**
  80987. * Gets the type of the editor to use
  80988. */
  80989. type: InspectableType;
  80990. /**
  80991. * Gets the minimum value of the property when using in "slider" mode
  80992. */
  80993. min?: number;
  80994. /**
  80995. * Gets the maximum value of the property when using in "slider" mode
  80996. */
  80997. max?: number;
  80998. /**
  80999. * Gets the setp to use when using in "slider" mode
  81000. */
  81001. step?: number;
  81002. }
  81003. }
  81004. declare module BABYLON {
  81005. /**
  81006. * Class used to provide helper for timing
  81007. */
  81008. export class TimingTools {
  81009. /**
  81010. * Polyfill for setImmediate
  81011. * @param action defines the action to execute after the current execution block
  81012. */
  81013. static SetImmediate(action: () => void): void;
  81014. }
  81015. }
  81016. declare module BABYLON {
  81017. /**
  81018. * Class used to enable instatition of objects by class name
  81019. */
  81020. export class InstantiationTools {
  81021. /**
  81022. * Use this object to register external classes like custom textures or material
  81023. * to allow the laoders to instantiate them
  81024. */
  81025. static RegisteredExternalClasses: {
  81026. [key: string]: Object;
  81027. };
  81028. /**
  81029. * Tries to instantiate a new object from a given class name
  81030. * @param className defines the class name to instantiate
  81031. * @returns the new object or null if the system was not able to do the instantiation
  81032. */
  81033. static Instantiate(className: string): any;
  81034. }
  81035. }
  81036. declare module BABYLON {
  81037. /**
  81038. * Define options used to create a depth texture
  81039. */
  81040. export class DepthTextureCreationOptions {
  81041. /** Specifies whether or not a stencil should be allocated in the texture */
  81042. generateStencil?: boolean;
  81043. /** Specifies whether or not bilinear filtering is enable on the texture */
  81044. bilinearFiltering?: boolean;
  81045. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81046. comparisonFunction?: number;
  81047. /** Specifies if the created texture is a cube texture */
  81048. isCube?: boolean;
  81049. }
  81050. }
  81051. declare module BABYLON {
  81052. interface ThinEngine {
  81053. /**
  81054. * Creates a depth stencil cube texture.
  81055. * This is only available in WebGL 2.
  81056. * @param size The size of face edge in the cube texture.
  81057. * @param options The options defining the cube texture.
  81058. * @returns The cube texture
  81059. */
  81060. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81061. /**
  81062. * Creates a cube texture
  81063. * @param rootUrl defines the url where the files to load is located
  81064. * @param scene defines the current scene
  81065. * @param files defines the list of files to load (1 per face)
  81066. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81067. * @param onLoad defines an optional callback raised when the texture is loaded
  81068. * @param onError defines an optional callback raised if there is an issue to load the texture
  81069. * @param format defines the format of the data
  81070. * @param forcedExtension defines the extension to use to pick the right loader
  81071. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81072. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81073. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81074. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81075. * @returns the cube texture as an InternalTexture
  81076. */
  81077. 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;
  81078. /**
  81079. * Creates a cube texture
  81080. * @param rootUrl defines the url where the files to load is located
  81081. * @param scene defines the current scene
  81082. * @param files defines the list of files to load (1 per face)
  81083. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81084. * @param onLoad defines an optional callback raised when the texture is loaded
  81085. * @param onError defines an optional callback raised if there is an issue to load the texture
  81086. * @param format defines the format of the data
  81087. * @param forcedExtension defines the extension to use to pick the right loader
  81088. * @returns the cube texture as an InternalTexture
  81089. */
  81090. 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;
  81091. /**
  81092. * Creates a cube texture
  81093. * @param rootUrl defines the url where the files to load is located
  81094. * @param scene defines the current scene
  81095. * @param files defines the list of files to load (1 per face)
  81096. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81097. * @param onLoad defines an optional callback raised when the texture is loaded
  81098. * @param onError defines an optional callback raised if there is an issue to load the texture
  81099. * @param format defines the format of the data
  81100. * @param forcedExtension defines the extension to use to pick the right loader
  81101. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81102. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81103. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81104. * @returns the cube texture as an InternalTexture
  81105. */
  81106. 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;
  81107. /** @hidden */
  81108. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81109. /** @hidden */
  81110. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81111. /** @hidden */
  81112. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81113. /** @hidden */
  81114. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81115. /**
  81116. * @hidden
  81117. */
  81118. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81119. }
  81120. }
  81121. declare module BABYLON {
  81122. /**
  81123. * Class for creating a cube texture
  81124. */
  81125. export class CubeTexture extends BaseTexture {
  81126. private _delayedOnLoad;
  81127. /**
  81128. * Observable triggered once the texture has been loaded.
  81129. */
  81130. onLoadObservable: Observable<CubeTexture>;
  81131. /**
  81132. * The url of the texture
  81133. */
  81134. url: string;
  81135. /**
  81136. * Gets or sets the center of the bounding box associated with the cube texture.
  81137. * It must define where the camera used to render the texture was set
  81138. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81139. */
  81140. boundingBoxPosition: Vector3;
  81141. private _boundingBoxSize;
  81142. /**
  81143. * Gets or sets the size of the bounding box associated with the cube texture
  81144. * When defined, the cubemap will switch to local mode
  81145. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81146. * @example https://www.babylonjs-playground.com/#RNASML
  81147. */
  81148. set boundingBoxSize(value: Vector3);
  81149. /**
  81150. * Returns the bounding box size
  81151. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81152. */
  81153. get boundingBoxSize(): Vector3;
  81154. protected _rotationY: number;
  81155. /**
  81156. * Sets texture matrix rotation angle around Y axis in radians.
  81157. */
  81158. set rotationY(value: number);
  81159. /**
  81160. * Gets texture matrix rotation angle around Y axis radians.
  81161. */
  81162. get rotationY(): number;
  81163. /**
  81164. * Are mip maps generated for this texture or not.
  81165. */
  81166. get noMipmap(): boolean;
  81167. private _noMipmap;
  81168. private _files;
  81169. protected _forcedExtension: Nullable<string>;
  81170. private _extensions;
  81171. private _textureMatrix;
  81172. private _format;
  81173. private _createPolynomials;
  81174. /** @hidden */
  81175. _prefiltered: boolean;
  81176. /**
  81177. * Creates a cube texture from an array of image urls
  81178. * @param files defines an array of image urls
  81179. * @param scene defines the hosting scene
  81180. * @param noMipmap specifies if mip maps are not used
  81181. * @returns a cube texture
  81182. */
  81183. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81184. /**
  81185. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81186. * @param url defines the url of the prefiltered texture
  81187. * @param scene defines the scene the texture is attached to
  81188. * @param forcedExtension defines the extension of the file if different from the url
  81189. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81190. * @return the prefiltered texture
  81191. */
  81192. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81193. /**
  81194. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81195. * as prefiltered data.
  81196. * @param rootUrl defines the url of the texture or the root name of the six images
  81197. * @param scene defines the scene the texture is attached to
  81198. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81199. * @param noMipmap defines if mipmaps should be created or not
  81200. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81201. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81202. * @param onError defines a callback triggered in case of error during load
  81203. * @param format defines the internal format to use for the texture once loaded
  81204. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81205. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81206. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81207. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81208. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81209. * @return the cube texture
  81210. */
  81211. 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);
  81212. /**
  81213. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81214. */
  81215. get isPrefiltered(): boolean;
  81216. /**
  81217. * Get the current class name of the texture useful for serialization or dynamic coding.
  81218. * @returns "CubeTexture"
  81219. */
  81220. getClassName(): string;
  81221. /**
  81222. * Update the url (and optional buffer) of this texture if url was null during construction.
  81223. * @param url the url of the texture
  81224. * @param forcedExtension defines the extension to use
  81225. * @param onLoad callback called when the texture is loaded (defaults to null)
  81226. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81227. */
  81228. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81229. /**
  81230. * Delays loading of the cube texture
  81231. * @param forcedExtension defines the extension to use
  81232. */
  81233. delayLoad(forcedExtension?: string): void;
  81234. /**
  81235. * Returns the reflection texture matrix
  81236. * @returns the reflection texture matrix
  81237. */
  81238. getReflectionTextureMatrix(): Matrix;
  81239. /**
  81240. * Sets the reflection texture matrix
  81241. * @param value Reflection texture matrix
  81242. */
  81243. setReflectionTextureMatrix(value: Matrix): void;
  81244. /**
  81245. * Parses text to create a cube texture
  81246. * @param parsedTexture define the serialized text to read from
  81247. * @param scene defines the hosting scene
  81248. * @param rootUrl defines the root url of the cube texture
  81249. * @returns a cube texture
  81250. */
  81251. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81252. /**
  81253. * Makes a clone, or deep copy, of the cube texture
  81254. * @returns a new cube texture
  81255. */
  81256. clone(): CubeTexture;
  81257. }
  81258. }
  81259. declare module BABYLON {
  81260. /**
  81261. * Manages the defines for the Material
  81262. */
  81263. export class MaterialDefines {
  81264. /** @hidden */
  81265. protected _keys: string[];
  81266. private _isDirty;
  81267. /** @hidden */
  81268. _renderId: number;
  81269. /** @hidden */
  81270. _areLightsDirty: boolean;
  81271. /** @hidden */
  81272. _areLightsDisposed: boolean;
  81273. /** @hidden */
  81274. _areAttributesDirty: boolean;
  81275. /** @hidden */
  81276. _areTexturesDirty: boolean;
  81277. /** @hidden */
  81278. _areFresnelDirty: boolean;
  81279. /** @hidden */
  81280. _areMiscDirty: boolean;
  81281. /** @hidden */
  81282. _areImageProcessingDirty: boolean;
  81283. /** @hidden */
  81284. _normals: boolean;
  81285. /** @hidden */
  81286. _uvs: boolean;
  81287. /** @hidden */
  81288. _needNormals: boolean;
  81289. /** @hidden */
  81290. _needUVs: boolean;
  81291. [id: string]: any;
  81292. /**
  81293. * Specifies if the material needs to be re-calculated
  81294. */
  81295. get isDirty(): boolean;
  81296. /**
  81297. * Marks the material to indicate that it has been re-calculated
  81298. */
  81299. markAsProcessed(): void;
  81300. /**
  81301. * Marks the material to indicate that it needs to be re-calculated
  81302. */
  81303. markAsUnprocessed(): void;
  81304. /**
  81305. * Marks the material to indicate all of its defines need to be re-calculated
  81306. */
  81307. markAllAsDirty(): void;
  81308. /**
  81309. * Marks the material to indicate that image processing needs to be re-calculated
  81310. */
  81311. markAsImageProcessingDirty(): void;
  81312. /**
  81313. * Marks the material to indicate the lights need to be re-calculated
  81314. * @param disposed Defines whether the light is dirty due to dispose or not
  81315. */
  81316. markAsLightDirty(disposed?: boolean): void;
  81317. /**
  81318. * Marks the attribute state as changed
  81319. */
  81320. markAsAttributesDirty(): void;
  81321. /**
  81322. * Marks the texture state as changed
  81323. */
  81324. markAsTexturesDirty(): void;
  81325. /**
  81326. * Marks the fresnel state as changed
  81327. */
  81328. markAsFresnelDirty(): void;
  81329. /**
  81330. * Marks the misc state as changed
  81331. */
  81332. markAsMiscDirty(): void;
  81333. /**
  81334. * Rebuilds the material defines
  81335. */
  81336. rebuild(): void;
  81337. /**
  81338. * Specifies if two material defines are equal
  81339. * @param other - A material define instance to compare to
  81340. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81341. */
  81342. isEqual(other: MaterialDefines): boolean;
  81343. /**
  81344. * Clones this instance's defines to another instance
  81345. * @param other - material defines to clone values to
  81346. */
  81347. cloneTo(other: MaterialDefines): void;
  81348. /**
  81349. * Resets the material define values
  81350. */
  81351. reset(): void;
  81352. /**
  81353. * Converts the material define values to a string
  81354. * @returns - String of material define information
  81355. */
  81356. toString(): string;
  81357. }
  81358. }
  81359. declare module BABYLON {
  81360. /**
  81361. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81362. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81363. * 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;
  81364. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81365. */
  81366. export class ColorCurves {
  81367. private _dirty;
  81368. private _tempColor;
  81369. private _globalCurve;
  81370. private _highlightsCurve;
  81371. private _midtonesCurve;
  81372. private _shadowsCurve;
  81373. private _positiveCurve;
  81374. private _negativeCurve;
  81375. private _globalHue;
  81376. private _globalDensity;
  81377. private _globalSaturation;
  81378. private _globalExposure;
  81379. /**
  81380. * Gets the global Hue value.
  81381. * 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).
  81382. */
  81383. get globalHue(): number;
  81384. /**
  81385. * Sets the global Hue value.
  81386. * 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).
  81387. */
  81388. set globalHue(value: number);
  81389. /**
  81390. * Gets the global Density value.
  81391. * 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.
  81392. * Values less than zero provide a filter of opposite hue.
  81393. */
  81394. get globalDensity(): number;
  81395. /**
  81396. * Sets the global Density value.
  81397. * 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.
  81398. * Values less than zero provide a filter of opposite hue.
  81399. */
  81400. set globalDensity(value: number);
  81401. /**
  81402. * Gets the global Saturation value.
  81403. * 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.
  81404. */
  81405. get globalSaturation(): number;
  81406. /**
  81407. * Sets the global Saturation value.
  81408. * 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.
  81409. */
  81410. set globalSaturation(value: number);
  81411. /**
  81412. * Gets the global Exposure value.
  81413. * 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.
  81414. */
  81415. get globalExposure(): number;
  81416. /**
  81417. * Sets the global Exposure value.
  81418. * 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.
  81419. */
  81420. set globalExposure(value: number);
  81421. private _highlightsHue;
  81422. private _highlightsDensity;
  81423. private _highlightsSaturation;
  81424. private _highlightsExposure;
  81425. /**
  81426. * Gets the highlights Hue value.
  81427. * 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).
  81428. */
  81429. get highlightsHue(): number;
  81430. /**
  81431. * Sets the highlights Hue value.
  81432. * 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).
  81433. */
  81434. set highlightsHue(value: number);
  81435. /**
  81436. * Gets the highlights Density value.
  81437. * 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.
  81438. * Values less than zero provide a filter of opposite hue.
  81439. */
  81440. get highlightsDensity(): number;
  81441. /**
  81442. * Sets the highlights Density value.
  81443. * 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.
  81444. * Values less than zero provide a filter of opposite hue.
  81445. */
  81446. set highlightsDensity(value: number);
  81447. /**
  81448. * Gets the highlights Saturation value.
  81449. * 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.
  81450. */
  81451. get highlightsSaturation(): number;
  81452. /**
  81453. * Sets the highlights Saturation value.
  81454. * 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.
  81455. */
  81456. set highlightsSaturation(value: number);
  81457. /**
  81458. * Gets the highlights Exposure value.
  81459. * 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.
  81460. */
  81461. get highlightsExposure(): number;
  81462. /**
  81463. * Sets the highlights Exposure value.
  81464. * 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.
  81465. */
  81466. set highlightsExposure(value: number);
  81467. private _midtonesHue;
  81468. private _midtonesDensity;
  81469. private _midtonesSaturation;
  81470. private _midtonesExposure;
  81471. /**
  81472. * Gets the midtones Hue value.
  81473. * 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).
  81474. */
  81475. get midtonesHue(): number;
  81476. /**
  81477. * Sets the midtones Hue value.
  81478. * 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).
  81479. */
  81480. set midtonesHue(value: number);
  81481. /**
  81482. * Gets the midtones Density value.
  81483. * 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.
  81484. * Values less than zero provide a filter of opposite hue.
  81485. */
  81486. get midtonesDensity(): number;
  81487. /**
  81488. * Sets the midtones Density value.
  81489. * 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.
  81490. * Values less than zero provide a filter of opposite hue.
  81491. */
  81492. set midtonesDensity(value: number);
  81493. /**
  81494. * Gets the midtones Saturation value.
  81495. * 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.
  81496. */
  81497. get midtonesSaturation(): number;
  81498. /**
  81499. * Sets the midtones Saturation value.
  81500. * 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.
  81501. */
  81502. set midtonesSaturation(value: number);
  81503. /**
  81504. * Gets the midtones Exposure value.
  81505. * 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.
  81506. */
  81507. get midtonesExposure(): number;
  81508. /**
  81509. * Sets the midtones Exposure value.
  81510. * 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.
  81511. */
  81512. set midtonesExposure(value: number);
  81513. private _shadowsHue;
  81514. private _shadowsDensity;
  81515. private _shadowsSaturation;
  81516. private _shadowsExposure;
  81517. /**
  81518. * Gets the shadows Hue value.
  81519. * 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).
  81520. */
  81521. get shadowsHue(): number;
  81522. /**
  81523. * Sets the shadows Hue value.
  81524. * 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).
  81525. */
  81526. set shadowsHue(value: number);
  81527. /**
  81528. * Gets the shadows Density value.
  81529. * 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.
  81530. * Values less than zero provide a filter of opposite hue.
  81531. */
  81532. get shadowsDensity(): number;
  81533. /**
  81534. * Sets the shadows Density value.
  81535. * 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.
  81536. * Values less than zero provide a filter of opposite hue.
  81537. */
  81538. set shadowsDensity(value: number);
  81539. /**
  81540. * Gets the shadows Saturation value.
  81541. * 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.
  81542. */
  81543. get shadowsSaturation(): number;
  81544. /**
  81545. * Sets the shadows Saturation value.
  81546. * 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.
  81547. */
  81548. set shadowsSaturation(value: number);
  81549. /**
  81550. * Gets the shadows Exposure value.
  81551. * 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.
  81552. */
  81553. get shadowsExposure(): number;
  81554. /**
  81555. * Sets the shadows Exposure value.
  81556. * 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.
  81557. */
  81558. set shadowsExposure(value: number);
  81559. /**
  81560. * Returns the class name
  81561. * @returns The class name
  81562. */
  81563. getClassName(): string;
  81564. /**
  81565. * Binds the color curves to the shader.
  81566. * @param colorCurves The color curve to bind
  81567. * @param effect The effect to bind to
  81568. * @param positiveUniform The positive uniform shader parameter
  81569. * @param neutralUniform The neutral uniform shader parameter
  81570. * @param negativeUniform The negative uniform shader parameter
  81571. */
  81572. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81573. /**
  81574. * Prepare the list of uniforms associated with the ColorCurves effects.
  81575. * @param uniformsList The list of uniforms used in the effect
  81576. */
  81577. static PrepareUniforms(uniformsList: string[]): void;
  81578. /**
  81579. * Returns color grading data based on a hue, density, saturation and exposure value.
  81580. * @param filterHue The hue of the color filter.
  81581. * @param filterDensity The density of the color filter.
  81582. * @param saturation The saturation.
  81583. * @param exposure The exposure.
  81584. * @param result The result data container.
  81585. */
  81586. private getColorGradingDataToRef;
  81587. /**
  81588. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81589. * @param value The input slider value in range [-100,100].
  81590. * @returns Adjusted value.
  81591. */
  81592. private static applyColorGradingSliderNonlinear;
  81593. /**
  81594. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81595. * @param hue The hue (H) input.
  81596. * @param saturation The saturation (S) input.
  81597. * @param brightness The brightness (B) input.
  81598. * @result An RGBA color represented as Vector4.
  81599. */
  81600. private static fromHSBToRef;
  81601. /**
  81602. * Returns a value clamped between min and max
  81603. * @param value The value to clamp
  81604. * @param min The minimum of value
  81605. * @param max The maximum of value
  81606. * @returns The clamped value.
  81607. */
  81608. private static clamp;
  81609. /**
  81610. * Clones the current color curve instance.
  81611. * @return The cloned curves
  81612. */
  81613. clone(): ColorCurves;
  81614. /**
  81615. * Serializes the current color curve instance to a json representation.
  81616. * @return a JSON representation
  81617. */
  81618. serialize(): any;
  81619. /**
  81620. * Parses the color curve from a json representation.
  81621. * @param source the JSON source to parse
  81622. * @return The parsed curves
  81623. */
  81624. static Parse(source: any): ColorCurves;
  81625. }
  81626. }
  81627. declare module BABYLON {
  81628. /**
  81629. * Interface to follow in your material defines to integrate easily the
  81630. * Image proccessing functions.
  81631. * @hidden
  81632. */
  81633. export interface IImageProcessingConfigurationDefines {
  81634. IMAGEPROCESSING: boolean;
  81635. VIGNETTE: boolean;
  81636. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81637. VIGNETTEBLENDMODEOPAQUE: boolean;
  81638. TONEMAPPING: boolean;
  81639. TONEMAPPING_ACES: boolean;
  81640. CONTRAST: boolean;
  81641. EXPOSURE: boolean;
  81642. COLORCURVES: boolean;
  81643. COLORGRADING: boolean;
  81644. COLORGRADING3D: boolean;
  81645. SAMPLER3DGREENDEPTH: boolean;
  81646. SAMPLER3DBGRMAP: boolean;
  81647. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81648. }
  81649. /**
  81650. * @hidden
  81651. */
  81652. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81653. IMAGEPROCESSING: boolean;
  81654. VIGNETTE: boolean;
  81655. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81656. VIGNETTEBLENDMODEOPAQUE: boolean;
  81657. TONEMAPPING: boolean;
  81658. TONEMAPPING_ACES: boolean;
  81659. CONTRAST: boolean;
  81660. COLORCURVES: boolean;
  81661. COLORGRADING: boolean;
  81662. COLORGRADING3D: boolean;
  81663. SAMPLER3DGREENDEPTH: boolean;
  81664. SAMPLER3DBGRMAP: boolean;
  81665. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81666. EXPOSURE: boolean;
  81667. constructor();
  81668. }
  81669. /**
  81670. * This groups together the common properties used for image processing either in direct forward pass
  81671. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81672. * or not.
  81673. */
  81674. export class ImageProcessingConfiguration {
  81675. /**
  81676. * Default tone mapping applied in BabylonJS.
  81677. */
  81678. static readonly TONEMAPPING_STANDARD: number;
  81679. /**
  81680. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81681. * to other engines rendering to increase portability.
  81682. */
  81683. static readonly TONEMAPPING_ACES: number;
  81684. /**
  81685. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81686. */
  81687. colorCurves: Nullable<ColorCurves>;
  81688. private _colorCurvesEnabled;
  81689. /**
  81690. * Gets wether the color curves effect is enabled.
  81691. */
  81692. get colorCurvesEnabled(): boolean;
  81693. /**
  81694. * Sets wether the color curves effect is enabled.
  81695. */
  81696. set colorCurvesEnabled(value: boolean);
  81697. private _colorGradingTexture;
  81698. /**
  81699. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81700. */
  81701. get colorGradingTexture(): Nullable<BaseTexture>;
  81702. /**
  81703. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81704. */
  81705. set colorGradingTexture(value: Nullable<BaseTexture>);
  81706. private _colorGradingEnabled;
  81707. /**
  81708. * Gets wether the color grading effect is enabled.
  81709. */
  81710. get colorGradingEnabled(): boolean;
  81711. /**
  81712. * Sets wether the color grading effect is enabled.
  81713. */
  81714. set colorGradingEnabled(value: boolean);
  81715. private _colorGradingWithGreenDepth;
  81716. /**
  81717. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81718. */
  81719. get colorGradingWithGreenDepth(): boolean;
  81720. /**
  81721. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81722. */
  81723. set colorGradingWithGreenDepth(value: boolean);
  81724. private _colorGradingBGR;
  81725. /**
  81726. * Gets wether the color grading texture contains BGR values.
  81727. */
  81728. get colorGradingBGR(): boolean;
  81729. /**
  81730. * Sets wether the color grading texture contains BGR values.
  81731. */
  81732. set colorGradingBGR(value: boolean);
  81733. /** @hidden */
  81734. _exposure: number;
  81735. /**
  81736. * Gets the Exposure used in the effect.
  81737. */
  81738. get exposure(): number;
  81739. /**
  81740. * Sets the Exposure used in the effect.
  81741. */
  81742. set exposure(value: number);
  81743. private _toneMappingEnabled;
  81744. /**
  81745. * Gets wether the tone mapping effect is enabled.
  81746. */
  81747. get toneMappingEnabled(): boolean;
  81748. /**
  81749. * Sets wether the tone mapping effect is enabled.
  81750. */
  81751. set toneMappingEnabled(value: boolean);
  81752. private _toneMappingType;
  81753. /**
  81754. * Gets the type of tone mapping effect.
  81755. */
  81756. get toneMappingType(): number;
  81757. /**
  81758. * Sets the type of tone mapping effect used in BabylonJS.
  81759. */
  81760. set toneMappingType(value: number);
  81761. protected _contrast: number;
  81762. /**
  81763. * Gets the contrast used in the effect.
  81764. */
  81765. get contrast(): number;
  81766. /**
  81767. * Sets the contrast used in the effect.
  81768. */
  81769. set contrast(value: number);
  81770. /**
  81771. * Vignette stretch size.
  81772. */
  81773. vignetteStretch: number;
  81774. /**
  81775. * Vignette centre X Offset.
  81776. */
  81777. vignetteCentreX: number;
  81778. /**
  81779. * Vignette centre Y Offset.
  81780. */
  81781. vignetteCentreY: number;
  81782. /**
  81783. * Vignette weight or intensity of the vignette effect.
  81784. */
  81785. vignetteWeight: number;
  81786. /**
  81787. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81788. * if vignetteEnabled is set to true.
  81789. */
  81790. vignetteColor: Color4;
  81791. /**
  81792. * Camera field of view used by the Vignette effect.
  81793. */
  81794. vignetteCameraFov: number;
  81795. private _vignetteBlendMode;
  81796. /**
  81797. * Gets the vignette blend mode allowing different kind of effect.
  81798. */
  81799. get vignetteBlendMode(): number;
  81800. /**
  81801. * Sets the vignette blend mode allowing different kind of effect.
  81802. */
  81803. set vignetteBlendMode(value: number);
  81804. private _vignetteEnabled;
  81805. /**
  81806. * Gets wether the vignette effect is enabled.
  81807. */
  81808. get vignetteEnabled(): boolean;
  81809. /**
  81810. * Sets wether the vignette effect is enabled.
  81811. */
  81812. set vignetteEnabled(value: boolean);
  81813. private _applyByPostProcess;
  81814. /**
  81815. * Gets wether the image processing is applied through a post process or not.
  81816. */
  81817. get applyByPostProcess(): boolean;
  81818. /**
  81819. * Sets wether the image processing is applied through a post process or not.
  81820. */
  81821. set applyByPostProcess(value: boolean);
  81822. private _isEnabled;
  81823. /**
  81824. * Gets wether the image processing is enabled or not.
  81825. */
  81826. get isEnabled(): boolean;
  81827. /**
  81828. * Sets wether the image processing is enabled or not.
  81829. */
  81830. set isEnabled(value: boolean);
  81831. /**
  81832. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81833. */
  81834. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81835. /**
  81836. * Method called each time the image processing information changes requires to recompile the effect.
  81837. */
  81838. protected _updateParameters(): void;
  81839. /**
  81840. * Gets the current class name.
  81841. * @return "ImageProcessingConfiguration"
  81842. */
  81843. getClassName(): string;
  81844. /**
  81845. * Prepare the list of uniforms associated with the Image Processing effects.
  81846. * @param uniforms The list of uniforms used in the effect
  81847. * @param defines the list of defines currently in use
  81848. */
  81849. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81850. /**
  81851. * Prepare the list of samplers associated with the Image Processing effects.
  81852. * @param samplersList The list of uniforms used in the effect
  81853. * @param defines the list of defines currently in use
  81854. */
  81855. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81856. /**
  81857. * Prepare the list of defines associated to the shader.
  81858. * @param defines the list of defines to complete
  81859. * @param forPostProcess Define if we are currently in post process mode or not
  81860. */
  81861. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81862. /**
  81863. * Returns true if all the image processing information are ready.
  81864. * @returns True if ready, otherwise, false
  81865. */
  81866. isReady(): boolean;
  81867. /**
  81868. * Binds the image processing to the shader.
  81869. * @param effect The effect to bind to
  81870. * @param overrideAspectRatio Override the aspect ratio of the effect
  81871. */
  81872. bind(effect: Effect, overrideAspectRatio?: number): void;
  81873. /**
  81874. * Clones the current image processing instance.
  81875. * @return The cloned image processing
  81876. */
  81877. clone(): ImageProcessingConfiguration;
  81878. /**
  81879. * Serializes the current image processing instance to a json representation.
  81880. * @return a JSON representation
  81881. */
  81882. serialize(): any;
  81883. /**
  81884. * Parses the image processing from a json representation.
  81885. * @param source the JSON source to parse
  81886. * @return The parsed image processing
  81887. */
  81888. static Parse(source: any): ImageProcessingConfiguration;
  81889. private static _VIGNETTEMODE_MULTIPLY;
  81890. private static _VIGNETTEMODE_OPAQUE;
  81891. /**
  81892. * Used to apply the vignette as a mix with the pixel color.
  81893. */
  81894. static get VIGNETTEMODE_MULTIPLY(): number;
  81895. /**
  81896. * Used to apply the vignette as a replacement of the pixel color.
  81897. */
  81898. static get VIGNETTEMODE_OPAQUE(): number;
  81899. }
  81900. }
  81901. declare module BABYLON {
  81902. /** @hidden */
  81903. export var postprocessVertexShader: {
  81904. name: string;
  81905. shader: string;
  81906. };
  81907. }
  81908. declare module BABYLON {
  81909. interface ThinEngine {
  81910. /**
  81911. * Creates a new render target texture
  81912. * @param size defines the size of the texture
  81913. * @param options defines the options used to create the texture
  81914. * @returns a new render target texture stored in an InternalTexture
  81915. */
  81916. createRenderTargetTexture(size: number | {
  81917. width: number;
  81918. height: number;
  81919. layers?: number;
  81920. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81921. /**
  81922. * Creates a depth stencil texture.
  81923. * This is only available in WebGL 2 or with the depth texture extension available.
  81924. * @param size The size of face edge in the texture.
  81925. * @param options The options defining the texture.
  81926. * @returns The texture
  81927. */
  81928. createDepthStencilTexture(size: number | {
  81929. width: number;
  81930. height: number;
  81931. layers?: number;
  81932. }, options: DepthTextureCreationOptions): InternalTexture;
  81933. /** @hidden */
  81934. _createDepthStencilTexture(size: number | {
  81935. width: number;
  81936. height: number;
  81937. layers?: number;
  81938. }, options: DepthTextureCreationOptions): InternalTexture;
  81939. }
  81940. }
  81941. declare module BABYLON {
  81942. /** Defines supported spaces */
  81943. export enum Space {
  81944. /** Local (object) space */
  81945. LOCAL = 0,
  81946. /** World space */
  81947. WORLD = 1,
  81948. /** Bone space */
  81949. BONE = 2
  81950. }
  81951. /** Defines the 3 main axes */
  81952. export class Axis {
  81953. /** X axis */
  81954. static X: Vector3;
  81955. /** Y axis */
  81956. static Y: Vector3;
  81957. /** Z axis */
  81958. static Z: Vector3;
  81959. }
  81960. }
  81961. declare module BABYLON {
  81962. /**
  81963. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81964. * This is the base of the follow, arc rotate cameras and Free camera
  81965. * @see http://doc.babylonjs.com/features/cameras
  81966. */
  81967. export class TargetCamera extends Camera {
  81968. private static _RigCamTransformMatrix;
  81969. private static _TargetTransformMatrix;
  81970. private static _TargetFocalPoint;
  81971. /**
  81972. * Define the current direction the camera is moving to
  81973. */
  81974. cameraDirection: Vector3;
  81975. /**
  81976. * Define the current rotation the camera is rotating to
  81977. */
  81978. cameraRotation: Vector2;
  81979. /**
  81980. * When set, the up vector of the camera will be updated by the rotation of the camera
  81981. */
  81982. updateUpVectorFromRotation: boolean;
  81983. private _tmpQuaternion;
  81984. /**
  81985. * Define the current rotation of the camera
  81986. */
  81987. rotation: Vector3;
  81988. /**
  81989. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81990. */
  81991. rotationQuaternion: Quaternion;
  81992. /**
  81993. * Define the current speed of the camera
  81994. */
  81995. speed: number;
  81996. /**
  81997. * Add constraint to the camera to prevent it to move freely in all directions and
  81998. * around all axis.
  81999. */
  82000. noRotationConstraint: boolean;
  82001. /**
  82002. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82003. * panning
  82004. */
  82005. invertRotation: boolean;
  82006. /**
  82007. * Speed multiplier for inverse camera panning
  82008. */
  82009. inverseRotationSpeed: number;
  82010. /**
  82011. * Define the current target of the camera as an object or a position.
  82012. */
  82013. lockedTarget: any;
  82014. /** @hidden */
  82015. _currentTarget: Vector3;
  82016. /** @hidden */
  82017. _initialFocalDistance: number;
  82018. /** @hidden */
  82019. _viewMatrix: Matrix;
  82020. /** @hidden */
  82021. _camMatrix: Matrix;
  82022. /** @hidden */
  82023. _cameraTransformMatrix: Matrix;
  82024. /** @hidden */
  82025. _cameraRotationMatrix: Matrix;
  82026. /** @hidden */
  82027. _referencePoint: Vector3;
  82028. /** @hidden */
  82029. _transformedReferencePoint: Vector3;
  82030. protected _globalCurrentTarget: Vector3;
  82031. protected _globalCurrentUpVector: Vector3;
  82032. /** @hidden */
  82033. _reset: () => void;
  82034. private _defaultUp;
  82035. /**
  82036. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82037. * This is the base of the follow, arc rotate cameras and Free camera
  82038. * @see http://doc.babylonjs.com/features/cameras
  82039. * @param name Defines the name of the camera in the scene
  82040. * @param position Defines the start position of the camera in the scene
  82041. * @param scene Defines the scene the camera belongs to
  82042. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82043. */
  82044. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82045. /**
  82046. * Gets the position in front of the camera at a given distance.
  82047. * @param distance The distance from the camera we want the position to be
  82048. * @returns the position
  82049. */
  82050. getFrontPosition(distance: number): Vector3;
  82051. /** @hidden */
  82052. _getLockedTargetPosition(): Nullable<Vector3>;
  82053. private _storedPosition;
  82054. private _storedRotation;
  82055. private _storedRotationQuaternion;
  82056. /**
  82057. * Store current camera state of the camera (fov, position, rotation, etc..)
  82058. * @returns the camera
  82059. */
  82060. storeState(): Camera;
  82061. /**
  82062. * Restored camera state. You must call storeState() first
  82063. * @returns whether it was successful or not
  82064. * @hidden
  82065. */
  82066. _restoreStateValues(): boolean;
  82067. /** @hidden */
  82068. _initCache(): void;
  82069. /** @hidden */
  82070. _updateCache(ignoreParentClass?: boolean): void;
  82071. /** @hidden */
  82072. _isSynchronizedViewMatrix(): boolean;
  82073. /** @hidden */
  82074. _computeLocalCameraSpeed(): number;
  82075. /**
  82076. * Defines the target the camera should look at.
  82077. * @param target Defines the new target as a Vector or a mesh
  82078. */
  82079. setTarget(target: Vector3): void;
  82080. /**
  82081. * Return the current target position of the camera. This value is expressed in local space.
  82082. * @returns the target position
  82083. */
  82084. getTarget(): Vector3;
  82085. /** @hidden */
  82086. _decideIfNeedsToMove(): boolean;
  82087. /** @hidden */
  82088. _updatePosition(): void;
  82089. /** @hidden */
  82090. _checkInputs(): void;
  82091. protected _updateCameraRotationMatrix(): void;
  82092. /**
  82093. * 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)
  82094. * @returns the current camera
  82095. */
  82096. private _rotateUpVectorWithCameraRotationMatrix;
  82097. private _cachedRotationZ;
  82098. private _cachedQuaternionRotationZ;
  82099. /** @hidden */
  82100. _getViewMatrix(): Matrix;
  82101. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82102. /**
  82103. * @hidden
  82104. */
  82105. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82106. /**
  82107. * @hidden
  82108. */
  82109. _updateRigCameras(): void;
  82110. private _getRigCamPositionAndTarget;
  82111. /**
  82112. * Gets the current object class name.
  82113. * @return the class name
  82114. */
  82115. getClassName(): string;
  82116. }
  82117. }
  82118. declare module BABYLON {
  82119. /**
  82120. * Gather the list of keyboard event types as constants.
  82121. */
  82122. export class KeyboardEventTypes {
  82123. /**
  82124. * The keydown event is fired when a key becomes active (pressed).
  82125. */
  82126. static readonly KEYDOWN: number;
  82127. /**
  82128. * The keyup event is fired when a key has been released.
  82129. */
  82130. static readonly KEYUP: number;
  82131. }
  82132. /**
  82133. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82134. */
  82135. export class KeyboardInfo {
  82136. /**
  82137. * Defines the type of event (KeyboardEventTypes)
  82138. */
  82139. type: number;
  82140. /**
  82141. * Defines the related dom event
  82142. */
  82143. event: KeyboardEvent;
  82144. /**
  82145. * Instantiates a new keyboard info.
  82146. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82147. * @param type Defines the type of event (KeyboardEventTypes)
  82148. * @param event Defines the related dom event
  82149. */
  82150. constructor(
  82151. /**
  82152. * Defines the type of event (KeyboardEventTypes)
  82153. */
  82154. type: number,
  82155. /**
  82156. * Defines the related dom event
  82157. */
  82158. event: KeyboardEvent);
  82159. }
  82160. /**
  82161. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82162. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82163. */
  82164. export class KeyboardInfoPre extends KeyboardInfo {
  82165. /**
  82166. * Defines the type of event (KeyboardEventTypes)
  82167. */
  82168. type: number;
  82169. /**
  82170. * Defines the related dom event
  82171. */
  82172. event: KeyboardEvent;
  82173. /**
  82174. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82175. */
  82176. skipOnPointerObservable: boolean;
  82177. /**
  82178. * Instantiates a new keyboard pre info.
  82179. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82180. * @param type Defines the type of event (KeyboardEventTypes)
  82181. * @param event Defines the related dom event
  82182. */
  82183. constructor(
  82184. /**
  82185. * Defines the type of event (KeyboardEventTypes)
  82186. */
  82187. type: number,
  82188. /**
  82189. * Defines the related dom event
  82190. */
  82191. event: KeyboardEvent);
  82192. }
  82193. }
  82194. declare module BABYLON {
  82195. /**
  82196. * Manage the keyboard inputs to control the movement of a free camera.
  82197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82198. */
  82199. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82200. /**
  82201. * Defines the camera the input is attached to.
  82202. */
  82203. camera: FreeCamera;
  82204. /**
  82205. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82206. */
  82207. keysUp: number[];
  82208. /**
  82209. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82210. */
  82211. keysDown: number[];
  82212. /**
  82213. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82214. */
  82215. keysLeft: number[];
  82216. /**
  82217. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82218. */
  82219. keysRight: number[];
  82220. private _keys;
  82221. private _onCanvasBlurObserver;
  82222. private _onKeyboardObserver;
  82223. private _engine;
  82224. private _scene;
  82225. /**
  82226. * Attach the input controls to a specific dom element to get the input from.
  82227. * @param element Defines the element the controls should be listened from
  82228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82229. */
  82230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82231. /**
  82232. * Detach the current controls from the specified dom element.
  82233. * @param element Defines the element to stop listening the inputs from
  82234. */
  82235. detachControl(element: Nullable<HTMLElement>): void;
  82236. /**
  82237. * Update the current camera state depending on the inputs that have been used this frame.
  82238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82239. */
  82240. checkInputs(): void;
  82241. /**
  82242. * Gets the class name of the current intput.
  82243. * @returns the class name
  82244. */
  82245. getClassName(): string;
  82246. /** @hidden */
  82247. _onLostFocus(): void;
  82248. /**
  82249. * Get the friendly name associated with the input class.
  82250. * @returns the input friendly name
  82251. */
  82252. getSimpleName(): string;
  82253. }
  82254. }
  82255. declare module BABYLON {
  82256. /**
  82257. * Interface describing all the common properties and methods a shadow light needs to implement.
  82258. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82259. * as well as binding the different shadow properties to the effects.
  82260. */
  82261. export interface IShadowLight extends Light {
  82262. /**
  82263. * The light id in the scene (used in scene.findLighById for instance)
  82264. */
  82265. id: string;
  82266. /**
  82267. * The position the shdow will be casted from.
  82268. */
  82269. position: Vector3;
  82270. /**
  82271. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82272. */
  82273. direction: Vector3;
  82274. /**
  82275. * The transformed position. Position of the light in world space taking parenting in account.
  82276. */
  82277. transformedPosition: Vector3;
  82278. /**
  82279. * The transformed direction. Direction of the light in world space taking parenting in account.
  82280. */
  82281. transformedDirection: Vector3;
  82282. /**
  82283. * The friendly name of the light in the scene.
  82284. */
  82285. name: string;
  82286. /**
  82287. * Defines the shadow projection clipping minimum z value.
  82288. */
  82289. shadowMinZ: number;
  82290. /**
  82291. * Defines the shadow projection clipping maximum z value.
  82292. */
  82293. shadowMaxZ: number;
  82294. /**
  82295. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82296. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82297. */
  82298. computeTransformedInformation(): boolean;
  82299. /**
  82300. * Gets the scene the light belongs to.
  82301. * @returns The scene
  82302. */
  82303. getScene(): Scene;
  82304. /**
  82305. * Callback defining a custom Projection Matrix Builder.
  82306. * This can be used to override the default projection matrix computation.
  82307. */
  82308. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82309. /**
  82310. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82311. * @param matrix The materix to updated with the projection information
  82312. * @param viewMatrix The transform matrix of the light
  82313. * @param renderList The list of mesh to render in the map
  82314. * @returns The current light
  82315. */
  82316. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82317. /**
  82318. * Gets the current depth scale used in ESM.
  82319. * @returns The scale
  82320. */
  82321. getDepthScale(): number;
  82322. /**
  82323. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82324. * @returns true if a cube texture needs to be use
  82325. */
  82326. needCube(): boolean;
  82327. /**
  82328. * Detects if the projection matrix requires to be recomputed this frame.
  82329. * @returns true if it requires to be recomputed otherwise, false.
  82330. */
  82331. needProjectionMatrixCompute(): boolean;
  82332. /**
  82333. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82334. */
  82335. forceProjectionMatrixCompute(): void;
  82336. /**
  82337. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82338. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82339. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82340. */
  82341. getShadowDirection(faceIndex?: number): Vector3;
  82342. /**
  82343. * Gets the minZ used for shadow according to both the scene and the light.
  82344. * @param activeCamera The camera we are returning the min for
  82345. * @returns the depth min z
  82346. */
  82347. getDepthMinZ(activeCamera: Camera): number;
  82348. /**
  82349. * Gets the maxZ used for shadow according to both the scene and the light.
  82350. * @param activeCamera The camera we are returning the max for
  82351. * @returns the depth max z
  82352. */
  82353. getDepthMaxZ(activeCamera: Camera): number;
  82354. }
  82355. /**
  82356. * Base implementation IShadowLight
  82357. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82358. */
  82359. export abstract class ShadowLight extends Light implements IShadowLight {
  82360. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82361. protected _position: Vector3;
  82362. protected _setPosition(value: Vector3): void;
  82363. /**
  82364. * Sets the position the shadow will be casted from. Also use as the light position for both
  82365. * point and spot lights.
  82366. */
  82367. get position(): Vector3;
  82368. /**
  82369. * Sets the position the shadow will be casted from. Also use as the light position for both
  82370. * point and spot lights.
  82371. */
  82372. set position(value: Vector3);
  82373. protected _direction: Vector3;
  82374. protected _setDirection(value: Vector3): void;
  82375. /**
  82376. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82377. * Also use as the light direction on spot and directional lights.
  82378. */
  82379. get direction(): Vector3;
  82380. /**
  82381. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82382. * Also use as the light direction on spot and directional lights.
  82383. */
  82384. set direction(value: Vector3);
  82385. protected _shadowMinZ: number;
  82386. /**
  82387. * Gets the shadow projection clipping minimum z value.
  82388. */
  82389. get shadowMinZ(): number;
  82390. /**
  82391. * Sets the shadow projection clipping minimum z value.
  82392. */
  82393. set shadowMinZ(value: number);
  82394. protected _shadowMaxZ: number;
  82395. /**
  82396. * Sets the shadow projection clipping maximum z value.
  82397. */
  82398. get shadowMaxZ(): number;
  82399. /**
  82400. * Gets the shadow projection clipping maximum z value.
  82401. */
  82402. set shadowMaxZ(value: number);
  82403. /**
  82404. * Callback defining a custom Projection Matrix Builder.
  82405. * This can be used to override the default projection matrix computation.
  82406. */
  82407. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82408. /**
  82409. * The transformed position. Position of the light in world space taking parenting in account.
  82410. */
  82411. transformedPosition: Vector3;
  82412. /**
  82413. * The transformed direction. Direction of the light in world space taking parenting in account.
  82414. */
  82415. transformedDirection: Vector3;
  82416. private _needProjectionMatrixCompute;
  82417. /**
  82418. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82419. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82420. */
  82421. computeTransformedInformation(): boolean;
  82422. /**
  82423. * Return the depth scale used for the shadow map.
  82424. * @returns the depth scale.
  82425. */
  82426. getDepthScale(): number;
  82427. /**
  82428. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82429. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82430. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82431. */
  82432. getShadowDirection(faceIndex?: number): Vector3;
  82433. /**
  82434. * Returns the ShadowLight absolute position in the World.
  82435. * @returns the position vector in world space
  82436. */
  82437. getAbsolutePosition(): Vector3;
  82438. /**
  82439. * Sets the ShadowLight direction toward the passed target.
  82440. * @param target The point to target in local space
  82441. * @returns the updated ShadowLight direction
  82442. */
  82443. setDirectionToTarget(target: Vector3): Vector3;
  82444. /**
  82445. * Returns the light rotation in euler definition.
  82446. * @returns the x y z rotation in local space.
  82447. */
  82448. getRotation(): Vector3;
  82449. /**
  82450. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82451. * @returns true if a cube texture needs to be use
  82452. */
  82453. needCube(): boolean;
  82454. /**
  82455. * Detects if the projection matrix requires to be recomputed this frame.
  82456. * @returns true if it requires to be recomputed otherwise, false.
  82457. */
  82458. needProjectionMatrixCompute(): boolean;
  82459. /**
  82460. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82461. */
  82462. forceProjectionMatrixCompute(): void;
  82463. /** @hidden */
  82464. _initCache(): void;
  82465. /** @hidden */
  82466. _isSynchronized(): boolean;
  82467. /**
  82468. * Computes the world matrix of the node
  82469. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82470. * @returns the world matrix
  82471. */
  82472. computeWorldMatrix(force?: boolean): Matrix;
  82473. /**
  82474. * Gets the minZ used for shadow according to both the scene and the light.
  82475. * @param activeCamera The camera we are returning the min for
  82476. * @returns the depth min z
  82477. */
  82478. getDepthMinZ(activeCamera: Camera): number;
  82479. /**
  82480. * Gets the maxZ used for shadow according to both the scene and the light.
  82481. * @param activeCamera The camera we are returning the max for
  82482. * @returns the depth max z
  82483. */
  82484. getDepthMaxZ(activeCamera: Camera): number;
  82485. /**
  82486. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82487. * @param matrix The materix to updated with the projection information
  82488. * @param viewMatrix The transform matrix of the light
  82489. * @param renderList The list of mesh to render in the map
  82490. * @returns The current light
  82491. */
  82492. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82493. }
  82494. }
  82495. declare module BABYLON {
  82496. /**
  82497. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82498. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82499. */
  82500. export class EffectFallbacks implements IEffectFallbacks {
  82501. private _defines;
  82502. private _currentRank;
  82503. private _maxRank;
  82504. private _mesh;
  82505. /**
  82506. * Removes the fallback from the bound mesh.
  82507. */
  82508. unBindMesh(): void;
  82509. /**
  82510. * Adds a fallback on the specified property.
  82511. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82512. * @param define The name of the define in the shader
  82513. */
  82514. addFallback(rank: number, define: string): void;
  82515. /**
  82516. * Sets the mesh to use CPU skinning when needing to fallback.
  82517. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82518. * @param mesh The mesh to use the fallbacks.
  82519. */
  82520. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82521. /**
  82522. * Checks to see if more fallbacks are still availible.
  82523. */
  82524. get hasMoreFallbacks(): boolean;
  82525. /**
  82526. * Removes the defines that should be removed when falling back.
  82527. * @param currentDefines defines the current define statements for the shader.
  82528. * @param effect defines the current effect we try to compile
  82529. * @returns The resulting defines with defines of the current rank removed.
  82530. */
  82531. reduce(currentDefines: string, effect: Effect): string;
  82532. }
  82533. }
  82534. declare module BABYLON {
  82535. /**
  82536. * "Static Class" containing the most commonly used helper while dealing with material for
  82537. * rendering purpose.
  82538. *
  82539. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82540. *
  82541. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82542. */
  82543. export class MaterialHelper {
  82544. /**
  82545. * Bind the current view position to an effect.
  82546. * @param effect The effect to be bound
  82547. * @param scene The scene the eyes position is used from
  82548. */
  82549. static BindEyePosition(effect: Effect, scene: Scene): void;
  82550. /**
  82551. * Helps preparing the defines values about the UVs in used in the effect.
  82552. * UVs are shared as much as we can accross channels in the shaders.
  82553. * @param texture The texture we are preparing the UVs for
  82554. * @param defines The defines to update
  82555. * @param key The channel key "diffuse", "specular"... used in the shader
  82556. */
  82557. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82558. /**
  82559. * Binds a texture matrix value to its corrsponding uniform
  82560. * @param texture The texture to bind the matrix for
  82561. * @param uniformBuffer The uniform buffer receivin the data
  82562. * @param key The channel key "diffuse", "specular"... used in the shader
  82563. */
  82564. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82565. /**
  82566. * Gets the current status of the fog (should it be enabled?)
  82567. * @param mesh defines the mesh to evaluate for fog support
  82568. * @param scene defines the hosting scene
  82569. * @returns true if fog must be enabled
  82570. */
  82571. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82572. /**
  82573. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82574. * @param mesh defines the current mesh
  82575. * @param scene defines the current scene
  82576. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82577. * @param pointsCloud defines if point cloud rendering has to be turned on
  82578. * @param fogEnabled defines if fog has to be turned on
  82579. * @param alphaTest defines if alpha testing has to be turned on
  82580. * @param defines defines the current list of defines
  82581. */
  82582. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82583. /**
  82584. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82585. * @param scene defines the current scene
  82586. * @param engine defines the current engine
  82587. * @param defines specifies the list of active defines
  82588. * @param useInstances defines if instances have to be turned on
  82589. * @param useClipPlane defines if clip plane have to be turned on
  82590. */
  82591. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82592. /**
  82593. * Prepares the defines for bones
  82594. * @param mesh The mesh containing the geometry data we will draw
  82595. * @param defines The defines to update
  82596. */
  82597. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82598. /**
  82599. * Prepares the defines for morph targets
  82600. * @param mesh The mesh containing the geometry data we will draw
  82601. * @param defines The defines to update
  82602. */
  82603. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82604. /**
  82605. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82606. * @param mesh The mesh containing the geometry data we will draw
  82607. * @param defines The defines to update
  82608. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82609. * @param useBones Precise whether bones should be used or not (override mesh info)
  82610. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82611. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82612. * @returns false if defines are considered not dirty and have not been checked
  82613. */
  82614. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82615. /**
  82616. * Prepares the defines related to multiview
  82617. * @param scene The scene we are intending to draw
  82618. * @param defines The defines to update
  82619. */
  82620. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82621. /**
  82622. * Prepares the defines related to the light information passed in parameter
  82623. * @param scene The scene we are intending to draw
  82624. * @param mesh The mesh the effect is compiling for
  82625. * @param light The light the effect is compiling for
  82626. * @param lightIndex The index of the light
  82627. * @param defines The defines to update
  82628. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82629. * @param state Defines the current state regarding what is needed (normals, etc...)
  82630. */
  82631. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82632. needNormals: boolean;
  82633. needRebuild: boolean;
  82634. shadowEnabled: boolean;
  82635. specularEnabled: boolean;
  82636. lightmapMode: boolean;
  82637. }): void;
  82638. /**
  82639. * Prepares the defines related to the light information passed in parameter
  82640. * @param scene The scene we are intending to draw
  82641. * @param mesh The mesh the effect is compiling for
  82642. * @param defines The defines to update
  82643. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82644. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82645. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82646. * @returns true if normals will be required for the rest of the effect
  82647. */
  82648. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82649. /**
  82650. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82651. * @param lightIndex defines the light index
  82652. * @param uniformsList The uniform list
  82653. * @param samplersList The sampler list
  82654. * @param projectedLightTexture defines if projected texture must be used
  82655. * @param uniformBuffersList defines an optional list of uniform buffers
  82656. */
  82657. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82658. /**
  82659. * Prepares the uniforms and samplers list to be used in the effect
  82660. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82661. * @param samplersList The sampler list
  82662. * @param defines The defines helping in the list generation
  82663. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82664. */
  82665. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82666. /**
  82667. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82668. * @param defines The defines to update while falling back
  82669. * @param fallbacks The authorized effect fallbacks
  82670. * @param maxSimultaneousLights The maximum number of lights allowed
  82671. * @param rank the current rank of the Effect
  82672. * @returns The newly affected rank
  82673. */
  82674. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82675. private static _TmpMorphInfluencers;
  82676. /**
  82677. * Prepares the list of attributes required for morph targets according to the effect defines.
  82678. * @param attribs The current list of supported attribs
  82679. * @param mesh The mesh to prepare the morph targets attributes for
  82680. * @param influencers The number of influencers
  82681. */
  82682. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82683. /**
  82684. * Prepares the list of attributes required for morph targets according to the effect defines.
  82685. * @param attribs The current list of supported attribs
  82686. * @param mesh The mesh to prepare the morph targets attributes for
  82687. * @param defines The current Defines of the effect
  82688. */
  82689. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82690. /**
  82691. * Prepares the list of attributes required for bones according to the effect defines.
  82692. * @param attribs The current list of supported attribs
  82693. * @param mesh The mesh to prepare the bones attributes for
  82694. * @param defines The current Defines of the effect
  82695. * @param fallbacks The current efffect fallback strategy
  82696. */
  82697. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82698. /**
  82699. * Check and prepare the list of attributes required for instances according to the effect defines.
  82700. * @param attribs The current list of supported attribs
  82701. * @param defines The current MaterialDefines of the effect
  82702. */
  82703. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82704. /**
  82705. * Add the list of attributes required for instances to the attribs array.
  82706. * @param attribs The current list of supported attribs
  82707. */
  82708. static PushAttributesForInstances(attribs: string[]): void;
  82709. /**
  82710. * Binds the light information to the effect.
  82711. * @param light The light containing the generator
  82712. * @param effect The effect we are binding the data to
  82713. * @param lightIndex The light index in the effect used to render
  82714. */
  82715. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82716. /**
  82717. * Binds the lights information from the scene to the effect for the given mesh.
  82718. * @param light Light to bind
  82719. * @param lightIndex Light index
  82720. * @param scene The scene where the light belongs to
  82721. * @param effect The effect we are binding the data to
  82722. * @param useSpecular Defines if specular is supported
  82723. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82724. */
  82725. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82726. /**
  82727. * Binds the lights information from the scene to the effect for the given mesh.
  82728. * @param scene The scene the lights belongs to
  82729. * @param mesh The mesh we are binding the information to render
  82730. * @param effect The effect we are binding the data to
  82731. * @param defines The generated defines for the effect
  82732. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82733. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82734. */
  82735. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82736. private static _tempFogColor;
  82737. /**
  82738. * Binds the fog information from the scene to the effect for the given mesh.
  82739. * @param scene The scene the lights belongs to
  82740. * @param mesh The mesh we are binding the information to render
  82741. * @param effect The effect we are binding the data to
  82742. * @param linearSpace Defines if the fog effect is applied in linear space
  82743. */
  82744. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82745. /**
  82746. * Binds the bones information from the mesh to the effect.
  82747. * @param mesh The mesh we are binding the information to render
  82748. * @param effect The effect we are binding the data to
  82749. */
  82750. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82751. /**
  82752. * Binds the morph targets information from the mesh to the effect.
  82753. * @param abstractMesh The mesh we are binding the information to render
  82754. * @param effect The effect we are binding the data to
  82755. */
  82756. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82757. /**
  82758. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82759. * @param defines The generated defines used in the effect
  82760. * @param effect The effect we are binding the data to
  82761. * @param scene The scene we are willing to render with logarithmic scale for
  82762. */
  82763. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82764. /**
  82765. * Binds the clip plane information from the scene to the effect.
  82766. * @param scene The scene the clip plane information are extracted from
  82767. * @param effect The effect we are binding the data to
  82768. */
  82769. static BindClipPlane(effect: Effect, scene: Scene): void;
  82770. }
  82771. }
  82772. declare module BABYLON {
  82773. /** @hidden */
  82774. export var packingFunctions: {
  82775. name: string;
  82776. shader: string;
  82777. };
  82778. }
  82779. declare module BABYLON {
  82780. /** @hidden */
  82781. export var clipPlaneFragmentDeclaration: {
  82782. name: string;
  82783. shader: string;
  82784. };
  82785. }
  82786. declare module BABYLON {
  82787. /** @hidden */
  82788. export var clipPlaneFragment: {
  82789. name: string;
  82790. shader: string;
  82791. };
  82792. }
  82793. declare module BABYLON {
  82794. /** @hidden */
  82795. export var shadowMapPixelShader: {
  82796. name: string;
  82797. shader: string;
  82798. };
  82799. }
  82800. declare module BABYLON {
  82801. /** @hidden */
  82802. export var bonesDeclaration: {
  82803. name: string;
  82804. shader: string;
  82805. };
  82806. }
  82807. declare module BABYLON {
  82808. /** @hidden */
  82809. export var morphTargetsVertexGlobalDeclaration: {
  82810. name: string;
  82811. shader: string;
  82812. };
  82813. }
  82814. declare module BABYLON {
  82815. /** @hidden */
  82816. export var morphTargetsVertexDeclaration: {
  82817. name: string;
  82818. shader: string;
  82819. };
  82820. }
  82821. declare module BABYLON {
  82822. /** @hidden */
  82823. export var instancesDeclaration: {
  82824. name: string;
  82825. shader: string;
  82826. };
  82827. }
  82828. declare module BABYLON {
  82829. /** @hidden */
  82830. export var helperFunctions: {
  82831. name: string;
  82832. shader: string;
  82833. };
  82834. }
  82835. declare module BABYLON {
  82836. /** @hidden */
  82837. export var clipPlaneVertexDeclaration: {
  82838. name: string;
  82839. shader: string;
  82840. };
  82841. }
  82842. declare module BABYLON {
  82843. /** @hidden */
  82844. export var morphTargetsVertex: {
  82845. name: string;
  82846. shader: string;
  82847. };
  82848. }
  82849. declare module BABYLON {
  82850. /** @hidden */
  82851. export var instancesVertex: {
  82852. name: string;
  82853. shader: string;
  82854. };
  82855. }
  82856. declare module BABYLON {
  82857. /** @hidden */
  82858. export var bonesVertex: {
  82859. name: string;
  82860. shader: string;
  82861. };
  82862. }
  82863. declare module BABYLON {
  82864. /** @hidden */
  82865. export var clipPlaneVertex: {
  82866. name: string;
  82867. shader: string;
  82868. };
  82869. }
  82870. declare module BABYLON {
  82871. /** @hidden */
  82872. export var shadowMapVertexShader: {
  82873. name: string;
  82874. shader: string;
  82875. };
  82876. }
  82877. declare module BABYLON {
  82878. /** @hidden */
  82879. export var depthBoxBlurPixelShader: {
  82880. name: string;
  82881. shader: string;
  82882. };
  82883. }
  82884. declare module BABYLON {
  82885. /**
  82886. * Class representing a ray with position and direction
  82887. */
  82888. export class Ray {
  82889. /** origin point */
  82890. origin: Vector3;
  82891. /** direction */
  82892. direction: Vector3;
  82893. /** length of the ray */
  82894. length: number;
  82895. private static readonly TmpVector3;
  82896. private _tmpRay;
  82897. /**
  82898. * Creates a new ray
  82899. * @param origin origin point
  82900. * @param direction direction
  82901. * @param length length of the ray
  82902. */
  82903. constructor(
  82904. /** origin point */
  82905. origin: Vector3,
  82906. /** direction */
  82907. direction: Vector3,
  82908. /** length of the ray */
  82909. length?: number);
  82910. /**
  82911. * Checks if the ray intersects a box
  82912. * @param minimum bound of the box
  82913. * @param maximum bound of the box
  82914. * @param intersectionTreshold extra extend to be added to the box in all direction
  82915. * @returns if the box was hit
  82916. */
  82917. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82918. /**
  82919. * Checks if the ray intersects a box
  82920. * @param box the bounding box to check
  82921. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82922. * @returns if the box was hit
  82923. */
  82924. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82925. /**
  82926. * If the ray hits a sphere
  82927. * @param sphere the bounding sphere to check
  82928. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82929. * @returns true if it hits the sphere
  82930. */
  82931. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82932. /**
  82933. * If the ray hits a triange
  82934. * @param vertex0 triangle vertex
  82935. * @param vertex1 triangle vertex
  82936. * @param vertex2 triangle vertex
  82937. * @returns intersection information if hit
  82938. */
  82939. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82940. /**
  82941. * Checks if ray intersects a plane
  82942. * @param plane the plane to check
  82943. * @returns the distance away it was hit
  82944. */
  82945. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82946. /**
  82947. * Calculate the intercept of a ray on a given axis
  82948. * @param axis to check 'x' | 'y' | 'z'
  82949. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82950. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82951. */
  82952. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82953. /**
  82954. * Checks if ray intersects a mesh
  82955. * @param mesh the mesh to check
  82956. * @param fastCheck if only the bounding box should checked
  82957. * @returns picking info of the intersecton
  82958. */
  82959. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82960. /**
  82961. * Checks if ray intersects a mesh
  82962. * @param meshes the meshes to check
  82963. * @param fastCheck if only the bounding box should checked
  82964. * @param results array to store result in
  82965. * @returns Array of picking infos
  82966. */
  82967. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82968. private _comparePickingInfo;
  82969. private static smallnum;
  82970. private static rayl;
  82971. /**
  82972. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82973. * @param sega the first point of the segment to test the intersection against
  82974. * @param segb the second point of the segment to test the intersection against
  82975. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82976. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82977. */
  82978. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82979. /**
  82980. * Update the ray from viewport position
  82981. * @param x position
  82982. * @param y y position
  82983. * @param viewportWidth viewport width
  82984. * @param viewportHeight viewport height
  82985. * @param world world matrix
  82986. * @param view view matrix
  82987. * @param projection projection matrix
  82988. * @returns this ray updated
  82989. */
  82990. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82991. /**
  82992. * Creates a ray with origin and direction of 0,0,0
  82993. * @returns the new ray
  82994. */
  82995. static Zero(): Ray;
  82996. /**
  82997. * Creates a new ray from screen space and viewport
  82998. * @param x position
  82999. * @param y y position
  83000. * @param viewportWidth viewport width
  83001. * @param viewportHeight viewport height
  83002. * @param world world matrix
  83003. * @param view view matrix
  83004. * @param projection projection matrix
  83005. * @returns new ray
  83006. */
  83007. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83008. /**
  83009. * 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
  83010. * transformed to the given world matrix.
  83011. * @param origin The origin point
  83012. * @param end The end point
  83013. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83014. * @returns the new ray
  83015. */
  83016. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83017. /**
  83018. * Transforms a ray by a matrix
  83019. * @param ray ray to transform
  83020. * @param matrix matrix to apply
  83021. * @returns the resulting new ray
  83022. */
  83023. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83024. /**
  83025. * Transforms a ray by a matrix
  83026. * @param ray ray to transform
  83027. * @param matrix matrix to apply
  83028. * @param result ray to store result in
  83029. */
  83030. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83031. /**
  83032. * Unproject a ray from screen space to object space
  83033. * @param sourceX defines the screen space x coordinate to use
  83034. * @param sourceY defines the screen space y coordinate to use
  83035. * @param viewportWidth defines the current width of the viewport
  83036. * @param viewportHeight defines the current height of the viewport
  83037. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83038. * @param view defines the view matrix to use
  83039. * @param projection defines the projection matrix to use
  83040. */
  83041. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83042. }
  83043. /**
  83044. * Type used to define predicate used to select faces when a mesh intersection is detected
  83045. */
  83046. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83047. interface Scene {
  83048. /** @hidden */
  83049. _tempPickingRay: Nullable<Ray>;
  83050. /** @hidden */
  83051. _cachedRayForTransform: Ray;
  83052. /** @hidden */
  83053. _pickWithRayInverseMatrix: Matrix;
  83054. /** @hidden */
  83055. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83056. /** @hidden */
  83057. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83058. }
  83059. }
  83060. declare module BABYLON {
  83061. /**
  83062. * Groups all the scene component constants in one place to ease maintenance.
  83063. * @hidden
  83064. */
  83065. export class SceneComponentConstants {
  83066. static readonly NAME_EFFECTLAYER: string;
  83067. static readonly NAME_LAYER: string;
  83068. static readonly NAME_LENSFLARESYSTEM: string;
  83069. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83070. static readonly NAME_PARTICLESYSTEM: string;
  83071. static readonly NAME_GAMEPAD: string;
  83072. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83073. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83074. static readonly NAME_DEPTHRENDERER: string;
  83075. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83076. static readonly NAME_SPRITE: string;
  83077. static readonly NAME_OUTLINERENDERER: string;
  83078. static readonly NAME_PROCEDURALTEXTURE: string;
  83079. static readonly NAME_SHADOWGENERATOR: string;
  83080. static readonly NAME_OCTREE: string;
  83081. static readonly NAME_PHYSICSENGINE: string;
  83082. static readonly NAME_AUDIO: string;
  83083. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83084. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83085. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83086. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83087. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83088. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83089. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83090. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83091. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83092. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83093. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83094. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83095. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83096. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83097. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83098. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83099. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83100. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83101. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83102. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83103. static readonly STEP_AFTERRENDER_AUDIO: number;
  83104. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83105. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83106. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83107. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83108. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83109. static readonly STEP_POINTERMOVE_SPRITE: number;
  83110. static readonly STEP_POINTERDOWN_SPRITE: number;
  83111. static readonly STEP_POINTERUP_SPRITE: number;
  83112. }
  83113. /**
  83114. * This represents a scene component.
  83115. *
  83116. * This is used to decouple the dependency the scene is having on the different workloads like
  83117. * layers, post processes...
  83118. */
  83119. export interface ISceneComponent {
  83120. /**
  83121. * The name of the component. Each component must have a unique name.
  83122. */
  83123. name: string;
  83124. /**
  83125. * The scene the component belongs to.
  83126. */
  83127. scene: Scene;
  83128. /**
  83129. * Register the component to one instance of a scene.
  83130. */
  83131. register(): void;
  83132. /**
  83133. * Rebuilds the elements related to this component in case of
  83134. * context lost for instance.
  83135. */
  83136. rebuild(): void;
  83137. /**
  83138. * Disposes the component and the associated ressources.
  83139. */
  83140. dispose(): void;
  83141. }
  83142. /**
  83143. * This represents a SERIALIZABLE scene component.
  83144. *
  83145. * This extends Scene Component to add Serialization methods on top.
  83146. */
  83147. export interface ISceneSerializableComponent extends ISceneComponent {
  83148. /**
  83149. * Adds all the elements from the container to the scene
  83150. * @param container the container holding the elements
  83151. */
  83152. addFromContainer(container: AbstractScene): void;
  83153. /**
  83154. * Removes all the elements in the container from the scene
  83155. * @param container contains the elements to remove
  83156. * @param dispose if the removed element should be disposed (default: false)
  83157. */
  83158. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83159. /**
  83160. * Serializes the component data to the specified json object
  83161. * @param serializationObject The object to serialize to
  83162. */
  83163. serialize(serializationObject: any): void;
  83164. }
  83165. /**
  83166. * Strong typing of a Mesh related stage step action
  83167. */
  83168. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83169. /**
  83170. * Strong typing of a Evaluate Sub Mesh related stage step action
  83171. */
  83172. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83173. /**
  83174. * Strong typing of a Active Mesh related stage step action
  83175. */
  83176. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83177. /**
  83178. * Strong typing of a Camera related stage step action
  83179. */
  83180. export type CameraStageAction = (camera: Camera) => void;
  83181. /**
  83182. * Strong typing of a Camera Frame buffer related stage step action
  83183. */
  83184. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83185. /**
  83186. * Strong typing of a Render Target related stage step action
  83187. */
  83188. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83189. /**
  83190. * Strong typing of a RenderingGroup related stage step action
  83191. */
  83192. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83193. /**
  83194. * Strong typing of a Mesh Render related stage step action
  83195. */
  83196. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83197. /**
  83198. * Strong typing of a simple stage step action
  83199. */
  83200. export type SimpleStageAction = () => void;
  83201. /**
  83202. * Strong typing of a render target action.
  83203. */
  83204. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83205. /**
  83206. * Strong typing of a pointer move action.
  83207. */
  83208. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83209. /**
  83210. * Strong typing of a pointer up/down action.
  83211. */
  83212. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83213. /**
  83214. * Representation of a stage in the scene (Basically a list of ordered steps)
  83215. * @hidden
  83216. */
  83217. export class Stage<T extends Function> extends Array<{
  83218. index: number;
  83219. component: ISceneComponent;
  83220. action: T;
  83221. }> {
  83222. /**
  83223. * Hide ctor from the rest of the world.
  83224. * @param items The items to add.
  83225. */
  83226. private constructor();
  83227. /**
  83228. * Creates a new Stage.
  83229. * @returns A new instance of a Stage
  83230. */
  83231. static Create<T extends Function>(): Stage<T>;
  83232. /**
  83233. * Registers a step in an ordered way in the targeted stage.
  83234. * @param index Defines the position to register the step in
  83235. * @param component Defines the component attached to the step
  83236. * @param action Defines the action to launch during the step
  83237. */
  83238. registerStep(index: number, component: ISceneComponent, action: T): void;
  83239. /**
  83240. * Clears all the steps from the stage.
  83241. */
  83242. clear(): void;
  83243. }
  83244. }
  83245. declare module BABYLON {
  83246. interface Scene {
  83247. /** @hidden */
  83248. _pointerOverSprite: Nullable<Sprite>;
  83249. /** @hidden */
  83250. _pickedDownSprite: Nullable<Sprite>;
  83251. /** @hidden */
  83252. _tempSpritePickingRay: Nullable<Ray>;
  83253. /**
  83254. * All of the sprite managers added to this scene
  83255. * @see http://doc.babylonjs.com/babylon101/sprites
  83256. */
  83257. spriteManagers: Array<ISpriteManager>;
  83258. /**
  83259. * An event triggered when sprites rendering is about to start
  83260. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83261. */
  83262. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83263. /**
  83264. * An event triggered when sprites rendering is done
  83265. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83266. */
  83267. onAfterSpritesRenderingObservable: Observable<Scene>;
  83268. /** @hidden */
  83269. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83270. /** Launch a ray to try to pick a sprite in the scene
  83271. * @param x position on screen
  83272. * @param y position on screen
  83273. * @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
  83274. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83275. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83276. * @returns a PickingInfo
  83277. */
  83278. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83279. /** Use the given ray to pick a sprite in the scene
  83280. * @param ray The ray (in world space) to use to pick meshes
  83281. * @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
  83282. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83283. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83284. * @returns a PickingInfo
  83285. */
  83286. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83287. /** @hidden */
  83288. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83289. /** Launch a ray to try to pick sprites in the scene
  83290. * @param x position on screen
  83291. * @param y position on screen
  83292. * @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
  83293. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83294. * @returns a PickingInfo array
  83295. */
  83296. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83297. /** Use the given ray to pick sprites in the scene
  83298. * @param ray The ray (in world space) to use to pick meshes
  83299. * @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
  83300. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83301. * @returns a PickingInfo array
  83302. */
  83303. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83304. /**
  83305. * Force the sprite under the pointer
  83306. * @param sprite defines the sprite to use
  83307. */
  83308. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83309. /**
  83310. * Gets the sprite under the pointer
  83311. * @returns a Sprite or null if no sprite is under the pointer
  83312. */
  83313. getPointerOverSprite(): Nullable<Sprite>;
  83314. }
  83315. /**
  83316. * Defines the sprite scene component responsible to manage sprites
  83317. * in a given scene.
  83318. */
  83319. export class SpriteSceneComponent implements ISceneComponent {
  83320. /**
  83321. * The component name helpfull to identify the component in the list of scene components.
  83322. */
  83323. readonly name: string;
  83324. /**
  83325. * The scene the component belongs to.
  83326. */
  83327. scene: Scene;
  83328. /** @hidden */
  83329. private _spritePredicate;
  83330. /**
  83331. * Creates a new instance of the component for the given scene
  83332. * @param scene Defines the scene to register the component in
  83333. */
  83334. constructor(scene: Scene);
  83335. /**
  83336. * Registers the component in a given scene
  83337. */
  83338. register(): void;
  83339. /**
  83340. * Rebuilds the elements related to this component in case of
  83341. * context lost for instance.
  83342. */
  83343. rebuild(): void;
  83344. /**
  83345. * Disposes the component and the associated ressources.
  83346. */
  83347. dispose(): void;
  83348. private _pickSpriteButKeepRay;
  83349. private _pointerMove;
  83350. private _pointerDown;
  83351. private _pointerUp;
  83352. }
  83353. }
  83354. declare module BABYLON {
  83355. /** @hidden */
  83356. export var fogFragmentDeclaration: {
  83357. name: string;
  83358. shader: string;
  83359. };
  83360. }
  83361. declare module BABYLON {
  83362. /** @hidden */
  83363. export var fogFragment: {
  83364. name: string;
  83365. shader: string;
  83366. };
  83367. }
  83368. declare module BABYLON {
  83369. /** @hidden */
  83370. export var spritesPixelShader: {
  83371. name: string;
  83372. shader: string;
  83373. };
  83374. }
  83375. declare module BABYLON {
  83376. /** @hidden */
  83377. export var fogVertexDeclaration: {
  83378. name: string;
  83379. shader: string;
  83380. };
  83381. }
  83382. declare module BABYLON {
  83383. /** @hidden */
  83384. export var spritesVertexShader: {
  83385. name: string;
  83386. shader: string;
  83387. };
  83388. }
  83389. declare module BABYLON {
  83390. /**
  83391. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83392. */
  83393. export interface ISpriteManager extends IDisposable {
  83394. /**
  83395. * Restricts the camera to viewing objects with the same layerMask.
  83396. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83397. */
  83398. layerMask: number;
  83399. /**
  83400. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83401. */
  83402. isPickable: boolean;
  83403. /**
  83404. * Specifies the rendering group id for this mesh (0 by default)
  83405. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83406. */
  83407. renderingGroupId: number;
  83408. /**
  83409. * Defines the list of sprites managed by the manager.
  83410. */
  83411. sprites: Array<Sprite>;
  83412. /**
  83413. * Tests the intersection of a sprite with a specific ray.
  83414. * @param ray The ray we are sending to test the collision
  83415. * @param camera The camera space we are sending rays in
  83416. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83417. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83418. * @returns picking info or null.
  83419. */
  83420. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83421. /**
  83422. * Intersects the sprites with a ray
  83423. * @param ray defines the ray to intersect with
  83424. * @param camera defines the current active camera
  83425. * @param predicate defines a predicate used to select candidate sprites
  83426. * @returns null if no hit or a PickingInfo array
  83427. */
  83428. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83429. /**
  83430. * Renders the list of sprites on screen.
  83431. */
  83432. render(): void;
  83433. }
  83434. /**
  83435. * Class used to manage multiple sprites on the same spritesheet
  83436. * @see http://doc.babylonjs.com/babylon101/sprites
  83437. */
  83438. export class SpriteManager implements ISpriteManager {
  83439. /** defines the manager's name */
  83440. name: string;
  83441. /** Gets the list of sprites */
  83442. sprites: Sprite[];
  83443. /** Gets or sets the rendering group id (0 by default) */
  83444. renderingGroupId: number;
  83445. /** Gets or sets camera layer mask */
  83446. layerMask: number;
  83447. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83448. fogEnabled: boolean;
  83449. /** Gets or sets a boolean indicating if the sprites are pickable */
  83450. isPickable: boolean;
  83451. /** Defines the default width of a cell in the spritesheet */
  83452. cellWidth: number;
  83453. /** Defines the default height of a cell in the spritesheet */
  83454. cellHeight: number;
  83455. /** Associative array from JSON sprite data file */
  83456. private _cellData;
  83457. /** Array of sprite names from JSON sprite data file */
  83458. private _spriteMap;
  83459. /** True when packed cell data from JSON file is ready*/
  83460. private _packedAndReady;
  83461. /**
  83462. * An event triggered when the manager is disposed.
  83463. */
  83464. onDisposeObservable: Observable<SpriteManager>;
  83465. private _onDisposeObserver;
  83466. /**
  83467. * Callback called when the manager is disposed
  83468. */
  83469. set onDispose(callback: () => void);
  83470. private _capacity;
  83471. private _fromPacked;
  83472. private _spriteTexture;
  83473. private _epsilon;
  83474. private _scene;
  83475. private _vertexData;
  83476. private _buffer;
  83477. private _vertexBuffers;
  83478. private _indexBuffer;
  83479. private _effectBase;
  83480. private _effectFog;
  83481. /**
  83482. * Gets or sets the spritesheet texture
  83483. */
  83484. get texture(): Texture;
  83485. set texture(value: Texture);
  83486. private _blendMode;
  83487. /**
  83488. * Blend mode use to render the particle, it can be any of
  83489. * the static Constants.ALPHA_x properties provided in this class.
  83490. * Default value is Constants.ALPHA_COMBINE
  83491. */
  83492. get blendMode(): number;
  83493. set blendMode(blendMode: number);
  83494. /** Disables writing to the depth buffer when rendering the sprites.
  83495. * It can be handy to disable depth writing when using textures without alpha channel
  83496. * and setting some specific blend modes.
  83497. */
  83498. disableDepthWrite: boolean;
  83499. /**
  83500. * Creates a new sprite manager
  83501. * @param name defines the manager's name
  83502. * @param imgUrl defines the sprite sheet url
  83503. * @param capacity defines the maximum allowed number of sprites
  83504. * @param cellSize defines the size of a sprite cell
  83505. * @param scene defines the hosting scene
  83506. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83507. * @param samplingMode defines the smapling mode to use with spritesheet
  83508. * @param fromPacked set to false; do not alter
  83509. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83510. */
  83511. constructor(
  83512. /** defines the manager's name */
  83513. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83514. private _makePacked;
  83515. private _appendSpriteVertex;
  83516. /**
  83517. * Intersects the sprites with a ray
  83518. * @param ray defines the ray to intersect with
  83519. * @param camera defines the current active camera
  83520. * @param predicate defines a predicate used to select candidate sprites
  83521. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83522. * @returns null if no hit or a PickingInfo
  83523. */
  83524. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83525. /**
  83526. * Intersects the sprites with a ray
  83527. * @param ray defines the ray to intersect with
  83528. * @param camera defines the current active camera
  83529. * @param predicate defines a predicate used to select candidate sprites
  83530. * @returns null if no hit or a PickingInfo array
  83531. */
  83532. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83533. /**
  83534. * Render all child sprites
  83535. */
  83536. render(): void;
  83537. /**
  83538. * Release associated resources
  83539. */
  83540. dispose(): void;
  83541. }
  83542. }
  83543. declare module BABYLON {
  83544. /** Interface used by value gradients (color, factor, ...) */
  83545. export interface IValueGradient {
  83546. /**
  83547. * Gets or sets the gradient value (between 0 and 1)
  83548. */
  83549. gradient: number;
  83550. }
  83551. /** Class used to store color4 gradient */
  83552. export class ColorGradient implements IValueGradient {
  83553. /**
  83554. * Gets or sets the gradient value (between 0 and 1)
  83555. */
  83556. gradient: number;
  83557. /**
  83558. * Gets or sets first associated color
  83559. */
  83560. color1: Color4;
  83561. /**
  83562. * Gets or sets second associated color
  83563. */
  83564. color2?: Color4;
  83565. /**
  83566. * Will get a color picked randomly between color1 and color2.
  83567. * If color2 is undefined then color1 will be used
  83568. * @param result defines the target Color4 to store the result in
  83569. */
  83570. getColorToRef(result: Color4): void;
  83571. }
  83572. /** Class used to store color 3 gradient */
  83573. export class Color3Gradient implements IValueGradient {
  83574. /**
  83575. * Gets or sets the gradient value (between 0 and 1)
  83576. */
  83577. gradient: number;
  83578. /**
  83579. * Gets or sets the associated color
  83580. */
  83581. color: Color3;
  83582. }
  83583. /** Class used to store factor gradient */
  83584. export class FactorGradient implements IValueGradient {
  83585. /**
  83586. * Gets or sets the gradient value (between 0 and 1)
  83587. */
  83588. gradient: number;
  83589. /**
  83590. * Gets or sets first associated factor
  83591. */
  83592. factor1: number;
  83593. /**
  83594. * Gets or sets second associated factor
  83595. */
  83596. factor2?: number;
  83597. /**
  83598. * Will get a number picked randomly between factor1 and factor2.
  83599. * If factor2 is undefined then factor1 will be used
  83600. * @returns the picked number
  83601. */
  83602. getFactor(): number;
  83603. }
  83604. /**
  83605. * Helper used to simplify some generic gradient tasks
  83606. */
  83607. export class GradientHelper {
  83608. /**
  83609. * Gets the current gradient from an array of IValueGradient
  83610. * @param ratio defines the current ratio to get
  83611. * @param gradients defines the array of IValueGradient
  83612. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83613. */
  83614. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83615. }
  83616. }
  83617. declare module BABYLON {
  83618. /**
  83619. * Interface for the size containing width and height
  83620. */
  83621. export interface ISize {
  83622. /**
  83623. * Width
  83624. */
  83625. width: number;
  83626. /**
  83627. * Heighht
  83628. */
  83629. height: number;
  83630. }
  83631. /**
  83632. * Size containing widht and height
  83633. */
  83634. export class Size implements ISize {
  83635. /**
  83636. * Width
  83637. */
  83638. width: number;
  83639. /**
  83640. * Height
  83641. */
  83642. height: number;
  83643. /**
  83644. * Creates a Size object from the given width and height (floats).
  83645. * @param width width of the new size
  83646. * @param height height of the new size
  83647. */
  83648. constructor(width: number, height: number);
  83649. /**
  83650. * Returns a string with the Size width and height
  83651. * @returns a string with the Size width and height
  83652. */
  83653. toString(): string;
  83654. /**
  83655. * "Size"
  83656. * @returns the string "Size"
  83657. */
  83658. getClassName(): string;
  83659. /**
  83660. * Returns the Size hash code.
  83661. * @returns a hash code for a unique width and height
  83662. */
  83663. getHashCode(): number;
  83664. /**
  83665. * Updates the current size from the given one.
  83666. * @param src the given size
  83667. */
  83668. copyFrom(src: Size): void;
  83669. /**
  83670. * Updates in place the current Size from the given floats.
  83671. * @param width width of the new size
  83672. * @param height height of the new size
  83673. * @returns the updated Size.
  83674. */
  83675. copyFromFloats(width: number, height: number): Size;
  83676. /**
  83677. * Updates in place the current Size from the given floats.
  83678. * @param width width to set
  83679. * @param height height to set
  83680. * @returns the updated Size.
  83681. */
  83682. set(width: number, height: number): Size;
  83683. /**
  83684. * Multiplies the width and height by numbers
  83685. * @param w factor to multiple the width by
  83686. * @param h factor to multiple the height by
  83687. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83688. */
  83689. multiplyByFloats(w: number, h: number): Size;
  83690. /**
  83691. * Clones the size
  83692. * @returns a new Size copied from the given one.
  83693. */
  83694. clone(): Size;
  83695. /**
  83696. * True if the current Size and the given one width and height are strictly equal.
  83697. * @param other the other size to compare against
  83698. * @returns True if the current Size and the given one width and height are strictly equal.
  83699. */
  83700. equals(other: Size): boolean;
  83701. /**
  83702. * The surface of the Size : width * height (float).
  83703. */
  83704. get surface(): number;
  83705. /**
  83706. * Create a new size of zero
  83707. * @returns a new Size set to (0.0, 0.0)
  83708. */
  83709. static Zero(): Size;
  83710. /**
  83711. * Sums the width and height of two sizes
  83712. * @param otherSize size to add to this size
  83713. * @returns a new Size set as the addition result of the current Size and the given one.
  83714. */
  83715. add(otherSize: Size): Size;
  83716. /**
  83717. * Subtracts the width and height of two
  83718. * @param otherSize size to subtract to this size
  83719. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83720. */
  83721. subtract(otherSize: Size): Size;
  83722. /**
  83723. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83724. * @param start starting size to lerp between
  83725. * @param end end size to lerp between
  83726. * @param amount amount to lerp between the start and end values
  83727. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83728. */
  83729. static Lerp(start: Size, end: Size, amount: number): Size;
  83730. }
  83731. }
  83732. declare module BABYLON {
  83733. interface ThinEngine {
  83734. /**
  83735. * Creates a dynamic texture
  83736. * @param width defines the width of the texture
  83737. * @param height defines the height of the texture
  83738. * @param generateMipMaps defines if the engine should generate the mip levels
  83739. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83740. * @returns the dynamic texture inside an InternalTexture
  83741. */
  83742. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83743. /**
  83744. * Update the content of a dynamic texture
  83745. * @param texture defines the texture to update
  83746. * @param canvas defines the canvas containing the source
  83747. * @param invertY defines if data must be stored with Y axis inverted
  83748. * @param premulAlpha defines if alpha is stored as premultiplied
  83749. * @param format defines the format of the data
  83750. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83751. */
  83752. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83753. }
  83754. }
  83755. declare module BABYLON {
  83756. /**
  83757. * Helper class used to generate a canvas to manipulate images
  83758. */
  83759. export class CanvasGenerator {
  83760. /**
  83761. * Create a new canvas (or offscreen canvas depending on the context)
  83762. * @param width defines the expected width
  83763. * @param height defines the expected height
  83764. * @return a new canvas or offscreen canvas
  83765. */
  83766. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83767. }
  83768. }
  83769. declare module BABYLON {
  83770. /**
  83771. * A class extending Texture allowing drawing on a texture
  83772. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83773. */
  83774. export class DynamicTexture extends Texture {
  83775. private _generateMipMaps;
  83776. private _canvas;
  83777. private _context;
  83778. private _engine;
  83779. /**
  83780. * Creates a DynamicTexture
  83781. * @param name defines the name of the texture
  83782. * @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
  83783. * @param scene defines the scene where you want the texture
  83784. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83785. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83786. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83787. */
  83788. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83789. /**
  83790. * Get the current class name of the texture useful for serialization or dynamic coding.
  83791. * @returns "DynamicTexture"
  83792. */
  83793. getClassName(): string;
  83794. /**
  83795. * Gets the current state of canRescale
  83796. */
  83797. get canRescale(): boolean;
  83798. private _recreate;
  83799. /**
  83800. * Scales the texture
  83801. * @param ratio the scale factor to apply to both width and height
  83802. */
  83803. scale(ratio: number): void;
  83804. /**
  83805. * Resizes the texture
  83806. * @param width the new width
  83807. * @param height the new height
  83808. */
  83809. scaleTo(width: number, height: number): void;
  83810. /**
  83811. * Gets the context of the canvas used by the texture
  83812. * @returns the canvas context of the dynamic texture
  83813. */
  83814. getContext(): CanvasRenderingContext2D;
  83815. /**
  83816. * Clears the texture
  83817. */
  83818. clear(): void;
  83819. /**
  83820. * Updates the texture
  83821. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83822. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83823. */
  83824. update(invertY?: boolean, premulAlpha?: boolean): void;
  83825. /**
  83826. * Draws text onto the texture
  83827. * @param text defines the text to be drawn
  83828. * @param x defines the placement of the text from the left
  83829. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83830. * @param font defines the font to be used with font-style, font-size, font-name
  83831. * @param color defines the color used for the text
  83832. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83833. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83834. * @param update defines whether texture is immediately update (default is true)
  83835. */
  83836. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83837. /**
  83838. * Clones the texture
  83839. * @returns the clone of the texture.
  83840. */
  83841. clone(): DynamicTexture;
  83842. /**
  83843. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83844. * @returns a serialized dynamic texture object
  83845. */
  83846. serialize(): any;
  83847. /** @hidden */
  83848. _rebuild(): void;
  83849. }
  83850. }
  83851. declare module BABYLON {
  83852. interface Engine {
  83853. /**
  83854. * Creates a raw texture
  83855. * @param data defines the data to store in the texture
  83856. * @param width defines the width of the texture
  83857. * @param height defines the height of the texture
  83858. * @param format defines the format of the data
  83859. * @param generateMipMaps defines if the engine should generate the mip levels
  83860. * @param invertY defines if data must be stored with Y axis inverted
  83861. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83862. * @param compression defines the compression used (null by default)
  83863. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83864. * @returns the raw texture inside an InternalTexture
  83865. */
  83866. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83867. /**
  83868. * Update a raw texture
  83869. * @param texture defines the texture to update
  83870. * @param data defines the data to store in the texture
  83871. * @param format defines the format of the data
  83872. * @param invertY defines if data must be stored with Y axis inverted
  83873. */
  83874. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83875. /**
  83876. * Update a raw texture
  83877. * @param texture defines the texture to update
  83878. * @param data defines the data to store in the texture
  83879. * @param format defines the format of the data
  83880. * @param invertY defines if data must be stored with Y axis inverted
  83881. * @param compression defines the compression used (null by default)
  83882. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83883. */
  83884. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83885. /**
  83886. * Creates a new raw cube texture
  83887. * @param data defines the array of data to use to create each face
  83888. * @param size defines the size of the textures
  83889. * @param format defines the format of the data
  83890. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83891. * @param generateMipMaps defines if the engine should generate the mip levels
  83892. * @param invertY defines if data must be stored with Y axis inverted
  83893. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83894. * @param compression defines the compression used (null by default)
  83895. * @returns the cube texture as an InternalTexture
  83896. */
  83897. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83898. /**
  83899. * Update a raw cube texture
  83900. * @param texture defines the texture to udpdate
  83901. * @param data defines the data to store
  83902. * @param format defines the data format
  83903. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83904. * @param invertY defines if data must be stored with Y axis inverted
  83905. */
  83906. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83907. /**
  83908. * Update a raw cube texture
  83909. * @param texture defines the texture to udpdate
  83910. * @param data defines the data to store
  83911. * @param format defines the data format
  83912. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83913. * @param invertY defines if data must be stored with Y axis inverted
  83914. * @param compression defines the compression used (null by default)
  83915. */
  83916. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83917. /**
  83918. * Update a raw cube texture
  83919. * @param texture defines the texture to udpdate
  83920. * @param data defines the data to store
  83921. * @param format defines the data format
  83922. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83923. * @param invertY defines if data must be stored with Y axis inverted
  83924. * @param compression defines the compression used (null by default)
  83925. * @param level defines which level of the texture to update
  83926. */
  83927. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83928. /**
  83929. * Creates a new raw cube texture from a specified url
  83930. * @param url defines the url where the data is located
  83931. * @param scene defines the current scene
  83932. * @param size defines the size of the textures
  83933. * @param format defines the format of the data
  83934. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83935. * @param noMipmap defines if the engine should avoid generating the mip levels
  83936. * @param callback defines a callback used to extract texture data from loaded data
  83937. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83938. * @param onLoad defines a callback called when texture is loaded
  83939. * @param onError defines a callback called if there is an error
  83940. * @returns the cube texture as an InternalTexture
  83941. */
  83942. 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;
  83943. /**
  83944. * Creates a new raw cube texture from a specified url
  83945. * @param url defines the url where the data is located
  83946. * @param scene defines the current scene
  83947. * @param size defines the size of the textures
  83948. * @param format defines the format of the data
  83949. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83950. * @param noMipmap defines if the engine should avoid generating the mip levels
  83951. * @param callback defines a callback used to extract texture data from loaded data
  83952. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83953. * @param onLoad defines a callback called when texture is loaded
  83954. * @param onError defines a callback called if there is an error
  83955. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83956. * @param invertY defines if data must be stored with Y axis inverted
  83957. * @returns the cube texture as an InternalTexture
  83958. */
  83959. 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;
  83960. /**
  83961. * Creates a new raw 3D texture
  83962. * @param data defines the data used to create the texture
  83963. * @param width defines the width of the texture
  83964. * @param height defines the height of the texture
  83965. * @param depth defines the depth of the texture
  83966. * @param format defines the format of the texture
  83967. * @param generateMipMaps defines if the engine must generate mip levels
  83968. * @param invertY defines if data must be stored with Y axis inverted
  83969. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83970. * @param compression defines the compressed used (can be null)
  83971. * @param textureType defines the compressed used (can be null)
  83972. * @returns a new raw 3D texture (stored in an InternalTexture)
  83973. */
  83974. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83975. /**
  83976. * Update a raw 3D texture
  83977. * @param texture defines the texture to update
  83978. * @param data defines the data to store
  83979. * @param format defines the data format
  83980. * @param invertY defines if data must be stored with Y axis inverted
  83981. */
  83982. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83983. /**
  83984. * Update a raw 3D texture
  83985. * @param texture defines the texture to update
  83986. * @param data defines the data to store
  83987. * @param format defines the data format
  83988. * @param invertY defines if data must be stored with Y axis inverted
  83989. * @param compression defines the used compression (can be null)
  83990. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83991. */
  83992. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83993. /**
  83994. * Creates a new raw 2D array texture
  83995. * @param data defines the data used to create the texture
  83996. * @param width defines the width of the texture
  83997. * @param height defines the height of the texture
  83998. * @param depth defines the number of layers of the texture
  83999. * @param format defines the format of the texture
  84000. * @param generateMipMaps defines if the engine must generate mip levels
  84001. * @param invertY defines if data must be stored with Y axis inverted
  84002. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84003. * @param compression defines the compressed used (can be null)
  84004. * @param textureType defines the compressed used (can be null)
  84005. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84006. */
  84007. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84008. /**
  84009. * Update a raw 2D array texture
  84010. * @param texture defines the texture to update
  84011. * @param data defines the data to store
  84012. * @param format defines the data format
  84013. * @param invertY defines if data must be stored with Y axis inverted
  84014. */
  84015. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84016. /**
  84017. * Update a raw 2D array texture
  84018. * @param texture defines the texture to update
  84019. * @param data defines the data to store
  84020. * @param format defines the data format
  84021. * @param invertY defines if data must be stored with Y axis inverted
  84022. * @param compression defines the used compression (can be null)
  84023. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84024. */
  84025. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84026. }
  84027. }
  84028. declare module BABYLON {
  84029. /**
  84030. * Raw texture can help creating a texture directly from an array of data.
  84031. * This can be super useful if you either get the data from an uncompressed source or
  84032. * if you wish to create your texture pixel by pixel.
  84033. */
  84034. export class RawTexture extends Texture {
  84035. /**
  84036. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84037. */
  84038. format: number;
  84039. private _engine;
  84040. /**
  84041. * Instantiates a new RawTexture.
  84042. * Raw texture can help creating a texture directly from an array of data.
  84043. * This can be super useful if you either get the data from an uncompressed source or
  84044. * if you wish to create your texture pixel by pixel.
  84045. * @param data define the array of data to use to create the texture
  84046. * @param width define the width of the texture
  84047. * @param height define the height of the texture
  84048. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84049. * @param scene define the scene the texture belongs to
  84050. * @param generateMipMaps define whether mip maps should be generated or not
  84051. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84052. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84053. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84054. */
  84055. constructor(data: ArrayBufferView, width: number, height: number,
  84056. /**
  84057. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84058. */
  84059. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84060. /**
  84061. * Updates the texture underlying data.
  84062. * @param data Define the new data of the texture
  84063. */
  84064. update(data: ArrayBufferView): void;
  84065. /**
  84066. * Creates a luminance texture from some data.
  84067. * @param data Define the texture data
  84068. * @param width Define the width of the texture
  84069. * @param height Define the height of the texture
  84070. * @param scene Define the scene the texture belongs to
  84071. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84072. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84073. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84074. * @returns the luminance texture
  84075. */
  84076. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84077. /**
  84078. * Creates a luminance alpha texture from some data.
  84079. * @param data Define the texture data
  84080. * @param width Define the width of the texture
  84081. * @param height Define the height of the texture
  84082. * @param scene Define the scene the texture belongs to
  84083. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84084. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84085. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84086. * @returns the luminance alpha texture
  84087. */
  84088. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84089. /**
  84090. * Creates an alpha texture from some data.
  84091. * @param data Define the texture data
  84092. * @param width Define the width of the texture
  84093. * @param height Define the height of the texture
  84094. * @param scene Define the scene the texture belongs to
  84095. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84096. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84097. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84098. * @returns the alpha texture
  84099. */
  84100. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84101. /**
  84102. * Creates a RGB texture from some data.
  84103. * @param data Define the texture data
  84104. * @param width Define the width of the texture
  84105. * @param height Define the height of the texture
  84106. * @param scene Define the scene the texture belongs to
  84107. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84108. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84109. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84110. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84111. * @returns the RGB alpha texture
  84112. */
  84113. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84114. /**
  84115. * Creates a RGBA texture from some data.
  84116. * @param data Define the texture data
  84117. * @param width Define the width of the texture
  84118. * @param height Define the height of the texture
  84119. * @param scene Define the scene the texture belongs to
  84120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84123. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84124. * @returns the RGBA texture
  84125. */
  84126. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84127. /**
  84128. * Creates a R texture from some data.
  84129. * @param data Define the texture data
  84130. * @param width Define the width of the texture
  84131. * @param height Define the height of the texture
  84132. * @param scene Define the scene the texture belongs to
  84133. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84134. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84135. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84136. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84137. * @returns the R texture
  84138. */
  84139. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84140. }
  84141. }
  84142. declare module BABYLON {
  84143. interface AbstractScene {
  84144. /**
  84145. * The list of procedural textures added to the scene
  84146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84147. */
  84148. proceduralTextures: Array<ProceduralTexture>;
  84149. }
  84150. /**
  84151. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84152. * in a given scene.
  84153. */
  84154. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84155. /**
  84156. * The component name helpfull to identify the component in the list of scene components.
  84157. */
  84158. readonly name: string;
  84159. /**
  84160. * The scene the component belongs to.
  84161. */
  84162. scene: Scene;
  84163. /**
  84164. * Creates a new instance of the component for the given scene
  84165. * @param scene Defines the scene to register the component in
  84166. */
  84167. constructor(scene: Scene);
  84168. /**
  84169. * Registers the component in a given scene
  84170. */
  84171. register(): void;
  84172. /**
  84173. * Rebuilds the elements related to this component in case of
  84174. * context lost for instance.
  84175. */
  84176. rebuild(): void;
  84177. /**
  84178. * Disposes the component and the associated ressources.
  84179. */
  84180. dispose(): void;
  84181. private _beforeClear;
  84182. }
  84183. }
  84184. declare module BABYLON {
  84185. interface ThinEngine {
  84186. /**
  84187. * Creates a new render target cube texture
  84188. * @param size defines the size of the texture
  84189. * @param options defines the options used to create the texture
  84190. * @returns a new render target cube texture stored in an InternalTexture
  84191. */
  84192. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84193. }
  84194. }
  84195. declare module BABYLON {
  84196. /** @hidden */
  84197. export var proceduralVertexShader: {
  84198. name: string;
  84199. shader: string;
  84200. };
  84201. }
  84202. declare module BABYLON {
  84203. /**
  84204. * 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.
  84205. * This is the base class of any Procedural texture and contains most of the shareable code.
  84206. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84207. */
  84208. export class ProceduralTexture extends Texture {
  84209. isCube: boolean;
  84210. /**
  84211. * Define if the texture is enabled or not (disabled texture will not render)
  84212. */
  84213. isEnabled: boolean;
  84214. /**
  84215. * Define if the texture must be cleared before rendering (default is true)
  84216. */
  84217. autoClear: boolean;
  84218. /**
  84219. * Callback called when the texture is generated
  84220. */
  84221. onGenerated: () => void;
  84222. /**
  84223. * Event raised when the texture is generated
  84224. */
  84225. onGeneratedObservable: Observable<ProceduralTexture>;
  84226. /** @hidden */
  84227. _generateMipMaps: boolean;
  84228. /** @hidden **/
  84229. _effect: Effect;
  84230. /** @hidden */
  84231. _textures: {
  84232. [key: string]: Texture;
  84233. };
  84234. private _size;
  84235. private _currentRefreshId;
  84236. private _frameId;
  84237. private _refreshRate;
  84238. private _vertexBuffers;
  84239. private _indexBuffer;
  84240. private _uniforms;
  84241. private _samplers;
  84242. private _fragment;
  84243. private _floats;
  84244. private _ints;
  84245. private _floatsArrays;
  84246. private _colors3;
  84247. private _colors4;
  84248. private _vectors2;
  84249. private _vectors3;
  84250. private _matrices;
  84251. private _fallbackTexture;
  84252. private _fallbackTextureUsed;
  84253. private _engine;
  84254. private _cachedDefines;
  84255. private _contentUpdateId;
  84256. private _contentData;
  84257. /**
  84258. * Instantiates a new procedural texture.
  84259. * 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.
  84260. * This is the base class of any Procedural texture and contains most of the shareable code.
  84261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84262. * @param name Define the name of the texture
  84263. * @param size Define the size of the texture to create
  84264. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84265. * @param scene Define the scene the texture belongs to
  84266. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84267. * @param generateMipMaps Define if the texture should creates mip maps or not
  84268. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84269. */
  84270. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84271. /**
  84272. * The effect that is created when initializing the post process.
  84273. * @returns The created effect corresponding the the postprocess.
  84274. */
  84275. getEffect(): Effect;
  84276. /**
  84277. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84278. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84279. */
  84280. getContent(): Nullable<ArrayBufferView>;
  84281. private _createIndexBuffer;
  84282. /** @hidden */
  84283. _rebuild(): void;
  84284. /**
  84285. * Resets the texture in order to recreate its associated resources.
  84286. * This can be called in case of context loss
  84287. */
  84288. reset(): void;
  84289. protected _getDefines(): string;
  84290. /**
  84291. * Is the texture ready to be used ? (rendered at least once)
  84292. * @returns true if ready, otherwise, false.
  84293. */
  84294. isReady(): boolean;
  84295. /**
  84296. * Resets the refresh counter of the texture and start bak from scratch.
  84297. * Could be useful to regenerate the texture if it is setup to render only once.
  84298. */
  84299. resetRefreshCounter(): void;
  84300. /**
  84301. * Set the fragment shader to use in order to render the texture.
  84302. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84303. */
  84304. setFragment(fragment: any): void;
  84305. /**
  84306. * Define the refresh rate of the texture or the rendering frequency.
  84307. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84308. */
  84309. get refreshRate(): number;
  84310. set refreshRate(value: number);
  84311. /** @hidden */
  84312. _shouldRender(): boolean;
  84313. /**
  84314. * Get the size the texture is rendering at.
  84315. * @returns the size (texture is always squared)
  84316. */
  84317. getRenderSize(): number;
  84318. /**
  84319. * Resize the texture to new value.
  84320. * @param size Define the new size the texture should have
  84321. * @param generateMipMaps Define whether the new texture should create mip maps
  84322. */
  84323. resize(size: number, generateMipMaps: boolean): void;
  84324. private _checkUniform;
  84325. /**
  84326. * Set a texture in the shader program used to render.
  84327. * @param name Define the name of the uniform samplers as defined in the shader
  84328. * @param texture Define the texture to bind to this sampler
  84329. * @return the texture itself allowing "fluent" like uniform updates
  84330. */
  84331. setTexture(name: string, texture: Texture): ProceduralTexture;
  84332. /**
  84333. * Set a float in the shader.
  84334. * @param name Define the name of the uniform as defined in the shader
  84335. * @param value Define the value to give to the uniform
  84336. * @return the texture itself allowing "fluent" like uniform updates
  84337. */
  84338. setFloat(name: string, value: number): ProceduralTexture;
  84339. /**
  84340. * Set a int in the shader.
  84341. * @param name Define the name of the uniform as defined in the shader
  84342. * @param value Define the value to give to the uniform
  84343. * @return the texture itself allowing "fluent" like uniform updates
  84344. */
  84345. setInt(name: string, value: number): ProceduralTexture;
  84346. /**
  84347. * Set an array of floats in the shader.
  84348. * @param name Define the name of the uniform as defined in the shader
  84349. * @param value Define the value to give to the uniform
  84350. * @return the texture itself allowing "fluent" like uniform updates
  84351. */
  84352. setFloats(name: string, value: number[]): ProceduralTexture;
  84353. /**
  84354. * Set a vec3 in the shader from a Color3.
  84355. * @param name Define the name of the uniform as defined in the shader
  84356. * @param value Define the value to give to the uniform
  84357. * @return the texture itself allowing "fluent" like uniform updates
  84358. */
  84359. setColor3(name: string, value: Color3): ProceduralTexture;
  84360. /**
  84361. * Set a vec4 in the shader from a Color4.
  84362. * @param name Define the name of the uniform as defined in the shader
  84363. * @param value Define the value to give to the uniform
  84364. * @return the texture itself allowing "fluent" like uniform updates
  84365. */
  84366. setColor4(name: string, value: Color4): ProceduralTexture;
  84367. /**
  84368. * Set a vec2 in the shader from a Vector2.
  84369. * @param name Define the name of the uniform as defined in the shader
  84370. * @param value Define the value to give to the uniform
  84371. * @return the texture itself allowing "fluent" like uniform updates
  84372. */
  84373. setVector2(name: string, value: Vector2): ProceduralTexture;
  84374. /**
  84375. * Set a vec3 in the shader from a Vector3.
  84376. * @param name Define the name of the uniform as defined in the shader
  84377. * @param value Define the value to give to the uniform
  84378. * @return the texture itself allowing "fluent" like uniform updates
  84379. */
  84380. setVector3(name: string, value: Vector3): ProceduralTexture;
  84381. /**
  84382. * Set a mat4 in the shader from a MAtrix.
  84383. * @param name Define the name of the uniform as defined in the shader
  84384. * @param value Define the value to give to the uniform
  84385. * @return the texture itself allowing "fluent" like uniform updates
  84386. */
  84387. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84388. /**
  84389. * Render the texture to its associated render target.
  84390. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84391. */
  84392. render(useCameraPostProcess?: boolean): void;
  84393. /**
  84394. * Clone the texture.
  84395. * @returns the cloned texture
  84396. */
  84397. clone(): ProceduralTexture;
  84398. /**
  84399. * Dispose the texture and release its asoociated resources.
  84400. */
  84401. dispose(): void;
  84402. }
  84403. }
  84404. declare module BABYLON {
  84405. /**
  84406. * This represents the base class for particle system in Babylon.
  84407. * 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.
  84408. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84409. * @example https://doc.babylonjs.com/babylon101/particles
  84410. */
  84411. export class BaseParticleSystem {
  84412. /**
  84413. * Source color is added to the destination color without alpha affecting the result
  84414. */
  84415. static BLENDMODE_ONEONE: number;
  84416. /**
  84417. * Blend current color and particle color using particle’s alpha
  84418. */
  84419. static BLENDMODE_STANDARD: number;
  84420. /**
  84421. * Add current color and particle color multiplied by particle’s alpha
  84422. */
  84423. static BLENDMODE_ADD: number;
  84424. /**
  84425. * Multiply current color with particle color
  84426. */
  84427. static BLENDMODE_MULTIPLY: number;
  84428. /**
  84429. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84430. */
  84431. static BLENDMODE_MULTIPLYADD: number;
  84432. /**
  84433. * List of animations used by the particle system.
  84434. */
  84435. animations: Animation[];
  84436. /**
  84437. * The id of the Particle system.
  84438. */
  84439. id: string;
  84440. /**
  84441. * The friendly name of the Particle system.
  84442. */
  84443. name: string;
  84444. /**
  84445. * The rendering group used by the Particle system to chose when to render.
  84446. */
  84447. renderingGroupId: number;
  84448. /**
  84449. * The emitter represents the Mesh or position we are attaching the particle system to.
  84450. */
  84451. emitter: Nullable<AbstractMesh | Vector3>;
  84452. /**
  84453. * The maximum number of particles to emit per frame
  84454. */
  84455. emitRate: number;
  84456. /**
  84457. * If you want to launch only a few particles at once, that can be done, as well.
  84458. */
  84459. manualEmitCount: number;
  84460. /**
  84461. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84462. */
  84463. updateSpeed: number;
  84464. /**
  84465. * The amount of time the particle system is running (depends of the overall update speed).
  84466. */
  84467. targetStopDuration: number;
  84468. /**
  84469. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84470. */
  84471. disposeOnStop: boolean;
  84472. /**
  84473. * Minimum power of emitting particles.
  84474. */
  84475. minEmitPower: number;
  84476. /**
  84477. * Maximum power of emitting particles.
  84478. */
  84479. maxEmitPower: number;
  84480. /**
  84481. * Minimum life time of emitting particles.
  84482. */
  84483. minLifeTime: number;
  84484. /**
  84485. * Maximum life time of emitting particles.
  84486. */
  84487. maxLifeTime: number;
  84488. /**
  84489. * Minimum Size of emitting particles.
  84490. */
  84491. minSize: number;
  84492. /**
  84493. * Maximum Size of emitting particles.
  84494. */
  84495. maxSize: number;
  84496. /**
  84497. * Minimum scale of emitting particles on X axis.
  84498. */
  84499. minScaleX: number;
  84500. /**
  84501. * Maximum scale of emitting particles on X axis.
  84502. */
  84503. maxScaleX: number;
  84504. /**
  84505. * Minimum scale of emitting particles on Y axis.
  84506. */
  84507. minScaleY: number;
  84508. /**
  84509. * Maximum scale of emitting particles on Y axis.
  84510. */
  84511. maxScaleY: number;
  84512. /**
  84513. * Gets or sets the minimal initial rotation in radians.
  84514. */
  84515. minInitialRotation: number;
  84516. /**
  84517. * Gets or sets the maximal initial rotation in radians.
  84518. */
  84519. maxInitialRotation: number;
  84520. /**
  84521. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84522. */
  84523. minAngularSpeed: number;
  84524. /**
  84525. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84526. */
  84527. maxAngularSpeed: number;
  84528. /**
  84529. * The texture used to render each particle. (this can be a spritesheet)
  84530. */
  84531. particleTexture: Nullable<Texture>;
  84532. /**
  84533. * The layer mask we are rendering the particles through.
  84534. */
  84535. layerMask: number;
  84536. /**
  84537. * This can help using your own shader to render the particle system.
  84538. * The according effect will be created
  84539. */
  84540. customShader: any;
  84541. /**
  84542. * By default particle system starts as soon as they are created. This prevents the
  84543. * automatic start to happen and let you decide when to start emitting particles.
  84544. */
  84545. preventAutoStart: boolean;
  84546. private _noiseTexture;
  84547. /**
  84548. * Gets or sets a texture used to add random noise to particle positions
  84549. */
  84550. get noiseTexture(): Nullable<ProceduralTexture>;
  84551. set noiseTexture(value: Nullable<ProceduralTexture>);
  84552. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84553. noiseStrength: Vector3;
  84554. /**
  84555. * Callback triggered when the particle animation is ending.
  84556. */
  84557. onAnimationEnd: Nullable<() => void>;
  84558. /**
  84559. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84560. */
  84561. blendMode: number;
  84562. /**
  84563. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84564. * to override the particles.
  84565. */
  84566. forceDepthWrite: boolean;
  84567. /** 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 */
  84568. preWarmCycles: number;
  84569. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84570. preWarmStepOffset: number;
  84571. /**
  84572. * 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)
  84573. */
  84574. spriteCellChangeSpeed: number;
  84575. /**
  84576. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84577. */
  84578. startSpriteCellID: number;
  84579. /**
  84580. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84581. */
  84582. endSpriteCellID: number;
  84583. /**
  84584. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84585. */
  84586. spriteCellWidth: number;
  84587. /**
  84588. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84589. */
  84590. spriteCellHeight: number;
  84591. /**
  84592. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84593. */
  84594. spriteRandomStartCell: boolean;
  84595. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84596. translationPivot: Vector2;
  84597. /** @hidden */
  84598. protected _isAnimationSheetEnabled: boolean;
  84599. /**
  84600. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84601. */
  84602. beginAnimationOnStart: boolean;
  84603. /**
  84604. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84605. */
  84606. beginAnimationFrom: number;
  84607. /**
  84608. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84609. */
  84610. beginAnimationTo: number;
  84611. /**
  84612. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84613. */
  84614. beginAnimationLoop: boolean;
  84615. /**
  84616. * Gets or sets a world offset applied to all particles
  84617. */
  84618. worldOffset: Vector3;
  84619. /**
  84620. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84621. */
  84622. get isAnimationSheetEnabled(): boolean;
  84623. set isAnimationSheetEnabled(value: boolean);
  84624. /**
  84625. * Get hosting scene
  84626. * @returns the scene
  84627. */
  84628. getScene(): Scene;
  84629. /**
  84630. * You can use gravity if you want to give an orientation to your particles.
  84631. */
  84632. gravity: Vector3;
  84633. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84634. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84635. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84636. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84637. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84638. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84639. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84640. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84641. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84642. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84643. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84644. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84645. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84646. /**
  84647. * Defines the delay in milliseconds before starting the system (0 by default)
  84648. */
  84649. startDelay: number;
  84650. /**
  84651. * Gets the current list of drag gradients.
  84652. * You must use addDragGradient and removeDragGradient to udpate this list
  84653. * @returns the list of drag gradients
  84654. */
  84655. getDragGradients(): Nullable<Array<FactorGradient>>;
  84656. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84657. limitVelocityDamping: number;
  84658. /**
  84659. * Gets the current list of limit velocity gradients.
  84660. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84661. * @returns the list of limit velocity gradients
  84662. */
  84663. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84664. /**
  84665. * Gets the current list of color gradients.
  84666. * You must use addColorGradient and removeColorGradient to udpate this list
  84667. * @returns the list of color gradients
  84668. */
  84669. getColorGradients(): Nullable<Array<ColorGradient>>;
  84670. /**
  84671. * Gets the current list of size gradients.
  84672. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84673. * @returns the list of size gradients
  84674. */
  84675. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84676. /**
  84677. * Gets the current list of color remap gradients.
  84678. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84679. * @returns the list of color remap gradients
  84680. */
  84681. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84682. /**
  84683. * Gets the current list of alpha remap gradients.
  84684. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84685. * @returns the list of alpha remap gradients
  84686. */
  84687. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84688. /**
  84689. * Gets the current list of life time gradients.
  84690. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84691. * @returns the list of life time gradients
  84692. */
  84693. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84694. /**
  84695. * Gets the current list of angular speed gradients.
  84696. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84697. * @returns the list of angular speed gradients
  84698. */
  84699. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84700. /**
  84701. * Gets the current list of velocity gradients.
  84702. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84703. * @returns the list of velocity gradients
  84704. */
  84705. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84706. /**
  84707. * Gets the current list of start size gradients.
  84708. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84709. * @returns the list of start size gradients
  84710. */
  84711. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84712. /**
  84713. * Gets the current list of emit rate gradients.
  84714. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84715. * @returns the list of emit rate gradients
  84716. */
  84717. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84718. /**
  84719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84720. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84721. */
  84722. get direction1(): Vector3;
  84723. set direction1(value: Vector3);
  84724. /**
  84725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84726. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84727. */
  84728. get direction2(): Vector3;
  84729. set direction2(value: Vector3);
  84730. /**
  84731. * 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.
  84732. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84733. */
  84734. get minEmitBox(): Vector3;
  84735. set minEmitBox(value: Vector3);
  84736. /**
  84737. * 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.
  84738. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84739. */
  84740. get maxEmitBox(): Vector3;
  84741. set maxEmitBox(value: Vector3);
  84742. /**
  84743. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84744. */
  84745. color1: Color4;
  84746. /**
  84747. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84748. */
  84749. color2: Color4;
  84750. /**
  84751. * Color the particle will have at the end of its lifetime
  84752. */
  84753. colorDead: Color4;
  84754. /**
  84755. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84756. */
  84757. textureMask: Color4;
  84758. /**
  84759. * The particle emitter type defines the emitter used by the particle system.
  84760. * It can be for example box, sphere, or cone...
  84761. */
  84762. particleEmitterType: IParticleEmitterType;
  84763. /** @hidden */
  84764. _isSubEmitter: boolean;
  84765. /**
  84766. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84767. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84768. */
  84769. billboardMode: number;
  84770. protected _isBillboardBased: boolean;
  84771. /**
  84772. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84773. */
  84774. get isBillboardBased(): boolean;
  84775. set isBillboardBased(value: boolean);
  84776. /**
  84777. * The scene the particle system belongs to.
  84778. */
  84779. protected _scene: Scene;
  84780. /**
  84781. * Local cache of defines for image processing.
  84782. */
  84783. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84784. /**
  84785. * Default configuration related to image processing available in the standard Material.
  84786. */
  84787. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84788. /**
  84789. * Gets the image processing configuration used either in this material.
  84790. */
  84791. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84792. /**
  84793. * Sets the Default image processing configuration used either in the this material.
  84794. *
  84795. * If sets to null, the scene one is in use.
  84796. */
  84797. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84798. /**
  84799. * Attaches a new image processing configuration to the Standard Material.
  84800. * @param configuration
  84801. */
  84802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84803. /** @hidden */
  84804. protected _reset(): void;
  84805. /** @hidden */
  84806. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84807. /**
  84808. * Instantiates a particle system.
  84809. * 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.
  84810. * @param name The name of the particle system
  84811. */
  84812. constructor(name: string);
  84813. /**
  84814. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84817. * @returns the emitter
  84818. */
  84819. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84820. /**
  84821. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84822. * @param radius The radius of the hemisphere to emit from
  84823. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84824. * @returns the emitter
  84825. */
  84826. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84827. /**
  84828. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84829. * @param radius The radius of the sphere to emit from
  84830. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84831. * @returns the emitter
  84832. */
  84833. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84834. /**
  84835. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84836. * @param radius The radius of the sphere to emit from
  84837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84839. * @returns the emitter
  84840. */
  84841. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84842. /**
  84843. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84844. * @param radius The radius of the emission cylinder
  84845. * @param height The height of the emission cylinder
  84846. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84847. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84848. * @returns the emitter
  84849. */
  84850. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84851. /**
  84852. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84853. * @param radius The radius of the cylinder to emit from
  84854. * @param height The height of the emission cylinder
  84855. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84858. * @returns the emitter
  84859. */
  84860. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84861. /**
  84862. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84863. * @param radius The radius of the cone to emit from
  84864. * @param angle The base angle of the cone
  84865. * @returns the emitter
  84866. */
  84867. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84868. /**
  84869. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84872. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84873. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84874. * @returns the emitter
  84875. */
  84876. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84877. }
  84878. }
  84879. declare module BABYLON {
  84880. /**
  84881. * Type of sub emitter
  84882. */
  84883. export enum SubEmitterType {
  84884. /**
  84885. * Attached to the particle over it's lifetime
  84886. */
  84887. ATTACHED = 0,
  84888. /**
  84889. * Created when the particle dies
  84890. */
  84891. END = 1
  84892. }
  84893. /**
  84894. * Sub emitter class used to emit particles from an existing particle
  84895. */
  84896. export class SubEmitter {
  84897. /**
  84898. * the particle system to be used by the sub emitter
  84899. */
  84900. particleSystem: ParticleSystem;
  84901. /**
  84902. * Type of the submitter (Default: END)
  84903. */
  84904. type: SubEmitterType;
  84905. /**
  84906. * 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)
  84907. * Note: This only is supported when using an emitter of type Mesh
  84908. */
  84909. inheritDirection: boolean;
  84910. /**
  84911. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84912. */
  84913. inheritedVelocityAmount: number;
  84914. /**
  84915. * Creates a sub emitter
  84916. * @param particleSystem the particle system to be used by the sub emitter
  84917. */
  84918. constructor(
  84919. /**
  84920. * the particle system to be used by the sub emitter
  84921. */
  84922. particleSystem: ParticleSystem);
  84923. /**
  84924. * Clones the sub emitter
  84925. * @returns the cloned sub emitter
  84926. */
  84927. clone(): SubEmitter;
  84928. /**
  84929. * Serialize current object to a JSON object
  84930. * @returns the serialized object
  84931. */
  84932. serialize(): any;
  84933. /** @hidden */
  84934. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84935. /**
  84936. * Creates a new SubEmitter from a serialized JSON version
  84937. * @param serializationObject defines the JSON object to read from
  84938. * @param scene defines the hosting scene
  84939. * @param rootUrl defines the rootUrl for data loading
  84940. * @returns a new SubEmitter
  84941. */
  84942. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84943. /** Release associated resources */
  84944. dispose(): void;
  84945. }
  84946. }
  84947. declare module BABYLON {
  84948. /** @hidden */
  84949. export var imageProcessingDeclaration: {
  84950. name: string;
  84951. shader: string;
  84952. };
  84953. }
  84954. declare module BABYLON {
  84955. /** @hidden */
  84956. export var imageProcessingFunctions: {
  84957. name: string;
  84958. shader: string;
  84959. };
  84960. }
  84961. declare module BABYLON {
  84962. /** @hidden */
  84963. export var particlesPixelShader: {
  84964. name: string;
  84965. shader: string;
  84966. };
  84967. }
  84968. declare module BABYLON {
  84969. /** @hidden */
  84970. export var particlesVertexShader: {
  84971. name: string;
  84972. shader: string;
  84973. };
  84974. }
  84975. declare module BABYLON {
  84976. /**
  84977. * This represents a particle system in Babylon.
  84978. * 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.
  84979. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84980. * @example https://doc.babylonjs.com/babylon101/particles
  84981. */
  84982. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84983. /**
  84984. * Billboard mode will only apply to Y axis
  84985. */
  84986. static readonly BILLBOARDMODE_Y: number;
  84987. /**
  84988. * Billboard mode will apply to all axes
  84989. */
  84990. static readonly BILLBOARDMODE_ALL: number;
  84991. /**
  84992. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84993. */
  84994. static readonly BILLBOARDMODE_STRETCHED: number;
  84995. /**
  84996. * This function can be defined to provide custom update for active particles.
  84997. * This function will be called instead of regular update (age, position, color, etc.).
  84998. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84999. */
  85000. updateFunction: (particles: Particle[]) => void;
  85001. private _emitterWorldMatrix;
  85002. /**
  85003. * This function can be defined to specify initial direction for every new particle.
  85004. * It by default use the emitterType defined function
  85005. */
  85006. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85007. /**
  85008. * This function can be defined to specify initial position for every new particle.
  85009. * It by default use the emitterType defined function
  85010. */
  85011. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85012. /**
  85013. * @hidden
  85014. */
  85015. _inheritedVelocityOffset: Vector3;
  85016. /**
  85017. * An event triggered when the system is disposed
  85018. */
  85019. onDisposeObservable: Observable<ParticleSystem>;
  85020. private _onDisposeObserver;
  85021. /**
  85022. * Sets a callback that will be triggered when the system is disposed
  85023. */
  85024. set onDispose(callback: () => void);
  85025. private _particles;
  85026. private _epsilon;
  85027. private _capacity;
  85028. private _stockParticles;
  85029. private _newPartsExcess;
  85030. private _vertexData;
  85031. private _vertexBuffer;
  85032. private _vertexBuffers;
  85033. private _spriteBuffer;
  85034. private _indexBuffer;
  85035. private _effect;
  85036. private _customEffect;
  85037. private _cachedDefines;
  85038. private _scaledColorStep;
  85039. private _colorDiff;
  85040. private _scaledDirection;
  85041. private _scaledGravity;
  85042. private _currentRenderId;
  85043. private _alive;
  85044. private _useInstancing;
  85045. private _started;
  85046. private _stopped;
  85047. private _actualFrame;
  85048. private _scaledUpdateSpeed;
  85049. private _vertexBufferSize;
  85050. /** @hidden */
  85051. _currentEmitRateGradient: Nullable<FactorGradient>;
  85052. /** @hidden */
  85053. _currentEmitRate1: number;
  85054. /** @hidden */
  85055. _currentEmitRate2: number;
  85056. /** @hidden */
  85057. _currentStartSizeGradient: Nullable<FactorGradient>;
  85058. /** @hidden */
  85059. _currentStartSize1: number;
  85060. /** @hidden */
  85061. _currentStartSize2: number;
  85062. private readonly _rawTextureWidth;
  85063. private _rampGradientsTexture;
  85064. private _useRampGradients;
  85065. /** Gets or sets a boolean indicating that ramp gradients must be used
  85066. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85067. */
  85068. get useRampGradients(): boolean;
  85069. set useRampGradients(value: boolean);
  85070. /**
  85071. * 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.
  85072. * 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: [])
  85073. */
  85074. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85075. private _subEmitters;
  85076. /**
  85077. * @hidden
  85078. * If the particle systems emitter should be disposed when the particle system is disposed
  85079. */
  85080. _disposeEmitterOnDispose: boolean;
  85081. /**
  85082. * The current active Sub-systems, this property is used by the root particle system only.
  85083. */
  85084. activeSubSystems: Array<ParticleSystem>;
  85085. /**
  85086. * Specifies if the particles are updated in emitter local space or world space
  85087. */
  85088. isLocal: boolean;
  85089. private _rootParticleSystem;
  85090. /**
  85091. * Gets the current list of active particles
  85092. */
  85093. get particles(): Particle[];
  85094. /**
  85095. * Returns the string "ParticleSystem"
  85096. * @returns a string containing the class name
  85097. */
  85098. getClassName(): string;
  85099. /**
  85100. * Instantiates a particle system.
  85101. * 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.
  85102. * @param name The name of the particle system
  85103. * @param capacity The max number of particles alive at the same time
  85104. * @param scene The scene the particle system belongs to
  85105. * @param customEffect a custom effect used to change the way particles are rendered by default
  85106. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85107. * @param epsilon Offset used to render the particles
  85108. */
  85109. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85110. private _addFactorGradient;
  85111. private _removeFactorGradient;
  85112. /**
  85113. * Adds a new life time gradient
  85114. * @param gradient defines the gradient to use (between 0 and 1)
  85115. * @param factor defines the life time factor to affect to the specified gradient
  85116. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85117. * @returns the current particle system
  85118. */
  85119. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85120. /**
  85121. * Remove a specific life time gradient
  85122. * @param gradient defines the gradient to remove
  85123. * @returns the current particle system
  85124. */
  85125. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85126. /**
  85127. * Adds a new size gradient
  85128. * @param gradient defines the gradient to use (between 0 and 1)
  85129. * @param factor defines the size factor to affect to the specified gradient
  85130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85131. * @returns the current particle system
  85132. */
  85133. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85134. /**
  85135. * Remove a specific size gradient
  85136. * @param gradient defines the gradient to remove
  85137. * @returns the current particle system
  85138. */
  85139. removeSizeGradient(gradient: number): IParticleSystem;
  85140. /**
  85141. * Adds a new color remap gradient
  85142. * @param gradient defines the gradient to use (between 0 and 1)
  85143. * @param min defines the color remap minimal range
  85144. * @param max defines the color remap maximal range
  85145. * @returns the current particle system
  85146. */
  85147. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85148. /**
  85149. * Remove a specific color remap gradient
  85150. * @param gradient defines the gradient to remove
  85151. * @returns the current particle system
  85152. */
  85153. removeColorRemapGradient(gradient: number): IParticleSystem;
  85154. /**
  85155. * Adds a new alpha remap gradient
  85156. * @param gradient defines the gradient to use (between 0 and 1)
  85157. * @param min defines the alpha remap minimal range
  85158. * @param max defines the alpha remap maximal range
  85159. * @returns the current particle system
  85160. */
  85161. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85162. /**
  85163. * Remove a specific alpha remap gradient
  85164. * @param gradient defines the gradient to remove
  85165. * @returns the current particle system
  85166. */
  85167. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85168. /**
  85169. * Adds a new angular speed gradient
  85170. * @param gradient defines the gradient to use (between 0 and 1)
  85171. * @param factor defines the angular speed to affect to the specified gradient
  85172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85173. * @returns the current particle system
  85174. */
  85175. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85176. /**
  85177. * Remove a specific angular speed gradient
  85178. * @param gradient defines the gradient to remove
  85179. * @returns the current particle system
  85180. */
  85181. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85182. /**
  85183. * Adds a new velocity gradient
  85184. * @param gradient defines the gradient to use (between 0 and 1)
  85185. * @param factor defines the velocity to affect to the specified gradient
  85186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85187. * @returns the current particle system
  85188. */
  85189. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85190. /**
  85191. * Remove a specific velocity gradient
  85192. * @param gradient defines the gradient to remove
  85193. * @returns the current particle system
  85194. */
  85195. removeVelocityGradient(gradient: number): IParticleSystem;
  85196. /**
  85197. * Adds a new limit velocity gradient
  85198. * @param gradient defines the gradient to use (between 0 and 1)
  85199. * @param factor defines the limit velocity value to affect to the specified gradient
  85200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85201. * @returns the current particle system
  85202. */
  85203. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85204. /**
  85205. * Remove a specific limit velocity gradient
  85206. * @param gradient defines the gradient to remove
  85207. * @returns the current particle system
  85208. */
  85209. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85210. /**
  85211. * Adds a new drag gradient
  85212. * @param gradient defines the gradient to use (between 0 and 1)
  85213. * @param factor defines the drag value to affect to the specified gradient
  85214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85215. * @returns the current particle system
  85216. */
  85217. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85218. /**
  85219. * Remove a specific drag gradient
  85220. * @param gradient defines the gradient to remove
  85221. * @returns the current particle system
  85222. */
  85223. removeDragGradient(gradient: number): IParticleSystem;
  85224. /**
  85225. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85226. * @param gradient defines the gradient to use (between 0 and 1)
  85227. * @param factor defines the emit rate value to affect to the specified gradient
  85228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85229. * @returns the current particle system
  85230. */
  85231. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85232. /**
  85233. * Remove a specific emit rate gradient
  85234. * @param gradient defines the gradient to remove
  85235. * @returns the current particle system
  85236. */
  85237. removeEmitRateGradient(gradient: number): IParticleSystem;
  85238. /**
  85239. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85240. * @param gradient defines the gradient to use (between 0 and 1)
  85241. * @param factor defines the start size value to affect to the specified gradient
  85242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85243. * @returns the current particle system
  85244. */
  85245. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85246. /**
  85247. * Remove a specific start size gradient
  85248. * @param gradient defines the gradient to remove
  85249. * @returns the current particle system
  85250. */
  85251. removeStartSizeGradient(gradient: number): IParticleSystem;
  85252. private _createRampGradientTexture;
  85253. /**
  85254. * Gets the current list of ramp gradients.
  85255. * You must use addRampGradient and removeRampGradient to udpate this list
  85256. * @returns the list of ramp gradients
  85257. */
  85258. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85259. /**
  85260. * Adds a new ramp gradient used to remap particle colors
  85261. * @param gradient defines the gradient to use (between 0 and 1)
  85262. * @param color defines the color to affect to the specified gradient
  85263. * @returns the current particle system
  85264. */
  85265. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85266. /**
  85267. * Remove a specific ramp gradient
  85268. * @param gradient defines the gradient to remove
  85269. * @returns the current particle system
  85270. */
  85271. removeRampGradient(gradient: number): ParticleSystem;
  85272. /**
  85273. * Adds a new color gradient
  85274. * @param gradient defines the gradient to use (between 0 and 1)
  85275. * @param color1 defines the color to affect to the specified gradient
  85276. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85277. * @returns this particle system
  85278. */
  85279. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85280. /**
  85281. * Remove a specific color gradient
  85282. * @param gradient defines the gradient to remove
  85283. * @returns this particle system
  85284. */
  85285. removeColorGradient(gradient: number): IParticleSystem;
  85286. private _fetchR;
  85287. protected _reset(): void;
  85288. private _resetEffect;
  85289. private _createVertexBuffers;
  85290. private _createIndexBuffer;
  85291. /**
  85292. * Gets the maximum number of particles active at the same time.
  85293. * @returns The max number of active particles.
  85294. */
  85295. getCapacity(): number;
  85296. /**
  85297. * Gets whether there are still active particles in the system.
  85298. * @returns True if it is alive, otherwise false.
  85299. */
  85300. isAlive(): boolean;
  85301. /**
  85302. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85303. * @returns True if it has been started, otherwise false.
  85304. */
  85305. isStarted(): boolean;
  85306. private _prepareSubEmitterInternalArray;
  85307. /**
  85308. * Starts the particle system and begins to emit
  85309. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85310. */
  85311. start(delay?: number): void;
  85312. /**
  85313. * Stops the particle system.
  85314. * @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.
  85315. */
  85316. stop(stopSubEmitters?: boolean): void;
  85317. /**
  85318. * Remove all active particles
  85319. */
  85320. reset(): void;
  85321. /**
  85322. * @hidden (for internal use only)
  85323. */
  85324. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85325. /**
  85326. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85327. * Its lifetime will start back at 0.
  85328. */
  85329. recycleParticle: (particle: Particle) => void;
  85330. private _stopSubEmitters;
  85331. private _createParticle;
  85332. private _removeFromRoot;
  85333. private _emitFromParticle;
  85334. private _update;
  85335. /** @hidden */
  85336. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85337. /** @hidden */
  85338. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85339. /** @hidden */
  85340. private _getEffect;
  85341. /**
  85342. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85343. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85344. */
  85345. animate(preWarmOnly?: boolean): void;
  85346. private _appendParticleVertices;
  85347. /**
  85348. * Rebuilds the particle system.
  85349. */
  85350. rebuild(): void;
  85351. /**
  85352. * Is this system ready to be used/rendered
  85353. * @return true if the system is ready
  85354. */
  85355. isReady(): boolean;
  85356. private _render;
  85357. /**
  85358. * Renders the particle system in its current state.
  85359. * @returns the current number of particles
  85360. */
  85361. render(): number;
  85362. /**
  85363. * Disposes the particle system and free the associated resources
  85364. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85365. */
  85366. dispose(disposeTexture?: boolean): void;
  85367. /**
  85368. * Clones the particle system.
  85369. * @param name The name of the cloned object
  85370. * @param newEmitter The new emitter to use
  85371. * @returns the cloned particle system
  85372. */
  85373. clone(name: string, newEmitter: any): ParticleSystem;
  85374. /**
  85375. * Serializes the particle system to a JSON object.
  85376. * @returns the JSON object
  85377. */
  85378. serialize(): any;
  85379. /** @hidden */
  85380. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85381. /** @hidden */
  85382. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85383. /**
  85384. * Parses a JSON object to create a particle system.
  85385. * @param parsedParticleSystem The JSON object to parse
  85386. * @param scene The scene to create the particle system in
  85387. * @param rootUrl The root url to use to load external dependencies like texture
  85388. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85389. * @returns the Parsed particle system
  85390. */
  85391. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85392. }
  85393. }
  85394. declare module BABYLON {
  85395. /**
  85396. * A particle represents one of the element emitted by a particle system.
  85397. * This is mainly define by its coordinates, direction, velocity and age.
  85398. */
  85399. export class Particle {
  85400. /**
  85401. * The particle system the particle belongs to.
  85402. */
  85403. particleSystem: ParticleSystem;
  85404. private static _Count;
  85405. /**
  85406. * Unique ID of the particle
  85407. */
  85408. id: number;
  85409. /**
  85410. * The world position of the particle in the scene.
  85411. */
  85412. position: Vector3;
  85413. /**
  85414. * The world direction of the particle in the scene.
  85415. */
  85416. direction: Vector3;
  85417. /**
  85418. * The color of the particle.
  85419. */
  85420. color: Color4;
  85421. /**
  85422. * The color change of the particle per step.
  85423. */
  85424. colorStep: Color4;
  85425. /**
  85426. * Defines how long will the life of the particle be.
  85427. */
  85428. lifeTime: number;
  85429. /**
  85430. * The current age of the particle.
  85431. */
  85432. age: number;
  85433. /**
  85434. * The current size of the particle.
  85435. */
  85436. size: number;
  85437. /**
  85438. * The current scale of the particle.
  85439. */
  85440. scale: Vector2;
  85441. /**
  85442. * The current angle of the particle.
  85443. */
  85444. angle: number;
  85445. /**
  85446. * Defines how fast is the angle changing.
  85447. */
  85448. angularSpeed: number;
  85449. /**
  85450. * Defines the cell index used by the particle to be rendered from a sprite.
  85451. */
  85452. cellIndex: number;
  85453. /**
  85454. * The information required to support color remapping
  85455. */
  85456. remapData: Vector4;
  85457. /** @hidden */
  85458. _randomCellOffset?: number;
  85459. /** @hidden */
  85460. _initialDirection: Nullable<Vector3>;
  85461. /** @hidden */
  85462. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85463. /** @hidden */
  85464. _initialStartSpriteCellID: number;
  85465. /** @hidden */
  85466. _initialEndSpriteCellID: number;
  85467. /** @hidden */
  85468. _currentColorGradient: Nullable<ColorGradient>;
  85469. /** @hidden */
  85470. _currentColor1: Color4;
  85471. /** @hidden */
  85472. _currentColor2: Color4;
  85473. /** @hidden */
  85474. _currentSizeGradient: Nullable<FactorGradient>;
  85475. /** @hidden */
  85476. _currentSize1: number;
  85477. /** @hidden */
  85478. _currentSize2: number;
  85479. /** @hidden */
  85480. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85481. /** @hidden */
  85482. _currentAngularSpeed1: number;
  85483. /** @hidden */
  85484. _currentAngularSpeed2: number;
  85485. /** @hidden */
  85486. _currentVelocityGradient: Nullable<FactorGradient>;
  85487. /** @hidden */
  85488. _currentVelocity1: number;
  85489. /** @hidden */
  85490. _currentVelocity2: number;
  85491. /** @hidden */
  85492. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85493. /** @hidden */
  85494. _currentLimitVelocity1: number;
  85495. /** @hidden */
  85496. _currentLimitVelocity2: number;
  85497. /** @hidden */
  85498. _currentDragGradient: Nullable<FactorGradient>;
  85499. /** @hidden */
  85500. _currentDrag1: number;
  85501. /** @hidden */
  85502. _currentDrag2: number;
  85503. /** @hidden */
  85504. _randomNoiseCoordinates1: Vector3;
  85505. /** @hidden */
  85506. _randomNoiseCoordinates2: Vector3;
  85507. /** @hidden */
  85508. _localPosition?: Vector3;
  85509. /**
  85510. * Creates a new instance Particle
  85511. * @param particleSystem the particle system the particle belongs to
  85512. */
  85513. constructor(
  85514. /**
  85515. * The particle system the particle belongs to.
  85516. */
  85517. particleSystem: ParticleSystem);
  85518. private updateCellInfoFromSystem;
  85519. /**
  85520. * Defines how the sprite cell index is updated for the particle
  85521. */
  85522. updateCellIndex(): void;
  85523. /** @hidden */
  85524. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85525. /** @hidden */
  85526. _inheritParticleInfoToSubEmitters(): void;
  85527. /** @hidden */
  85528. _reset(): void;
  85529. /**
  85530. * Copy the properties of particle to another one.
  85531. * @param other the particle to copy the information to.
  85532. */
  85533. copyTo(other: Particle): void;
  85534. }
  85535. }
  85536. declare module BABYLON {
  85537. /**
  85538. * Particle emitter represents a volume emitting particles.
  85539. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85540. */
  85541. export interface IParticleEmitterType {
  85542. /**
  85543. * Called by the particle System when the direction is computed for the created particle.
  85544. * @param worldMatrix is the world matrix of the particle system
  85545. * @param directionToUpdate is the direction vector to update with the result
  85546. * @param particle is the particle we are computed the direction for
  85547. * @param isLocal defines if the direction should be set in local space
  85548. */
  85549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85550. /**
  85551. * Called by the particle System when the position is computed for the created particle.
  85552. * @param worldMatrix is the world matrix of the particle system
  85553. * @param positionToUpdate is the position vector to update with the result
  85554. * @param particle is the particle we are computed the position for
  85555. * @param isLocal defines if the position should be set in local space
  85556. */
  85557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85558. /**
  85559. * Clones the current emitter and returns a copy of it
  85560. * @returns the new emitter
  85561. */
  85562. clone(): IParticleEmitterType;
  85563. /**
  85564. * Called by the GPUParticleSystem to setup the update shader
  85565. * @param effect defines the update shader
  85566. */
  85567. applyToShader(effect: Effect): void;
  85568. /**
  85569. * Returns a string to use to update the GPU particles update shader
  85570. * @returns the effect defines string
  85571. */
  85572. getEffectDefines(): string;
  85573. /**
  85574. * Returns a string representing the class name
  85575. * @returns a string containing the class name
  85576. */
  85577. getClassName(): string;
  85578. /**
  85579. * Serializes the particle system to a JSON object.
  85580. * @returns the JSON object
  85581. */
  85582. serialize(): any;
  85583. /**
  85584. * Parse properties from a JSON object
  85585. * @param serializationObject defines the JSON object
  85586. * @param scene defines the hosting scene
  85587. */
  85588. parse(serializationObject: any, scene: Scene): void;
  85589. }
  85590. }
  85591. declare module BABYLON {
  85592. /**
  85593. * Particle emitter emitting particles from the inside of a box.
  85594. * It emits the particles randomly between 2 given directions.
  85595. */
  85596. export class BoxParticleEmitter implements IParticleEmitterType {
  85597. /**
  85598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85599. */
  85600. direction1: Vector3;
  85601. /**
  85602. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85603. */
  85604. direction2: Vector3;
  85605. /**
  85606. * 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.
  85607. */
  85608. minEmitBox: Vector3;
  85609. /**
  85610. * 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.
  85611. */
  85612. maxEmitBox: Vector3;
  85613. /**
  85614. * Creates a new instance BoxParticleEmitter
  85615. */
  85616. constructor();
  85617. /**
  85618. * Called by the particle System when the direction is computed for the created particle.
  85619. * @param worldMatrix is the world matrix of the particle system
  85620. * @param directionToUpdate is the direction vector to update with the result
  85621. * @param particle is the particle we are computed the direction for
  85622. * @param isLocal defines if the direction should be set in local space
  85623. */
  85624. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85625. /**
  85626. * Called by the particle System when the position is computed for the created particle.
  85627. * @param worldMatrix is the world matrix of the particle system
  85628. * @param positionToUpdate is the position vector to update with the result
  85629. * @param particle is the particle we are computed the position for
  85630. * @param isLocal defines if the position should be set in local space
  85631. */
  85632. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85633. /**
  85634. * Clones the current emitter and returns a copy of it
  85635. * @returns the new emitter
  85636. */
  85637. clone(): BoxParticleEmitter;
  85638. /**
  85639. * Called by the GPUParticleSystem to setup the update shader
  85640. * @param effect defines the update shader
  85641. */
  85642. applyToShader(effect: Effect): void;
  85643. /**
  85644. * Returns a string to use to update the GPU particles update shader
  85645. * @returns a string containng the defines string
  85646. */
  85647. getEffectDefines(): string;
  85648. /**
  85649. * Returns the string "BoxParticleEmitter"
  85650. * @returns a string containing the class name
  85651. */
  85652. getClassName(): string;
  85653. /**
  85654. * Serializes the particle system to a JSON object.
  85655. * @returns the JSON object
  85656. */
  85657. serialize(): any;
  85658. /**
  85659. * Parse properties from a JSON object
  85660. * @param serializationObject defines the JSON object
  85661. */
  85662. parse(serializationObject: any): void;
  85663. }
  85664. }
  85665. declare module BABYLON {
  85666. /**
  85667. * Particle emitter emitting particles from the inside of a cone.
  85668. * It emits the particles alongside the cone volume from the base to the particle.
  85669. * The emission direction might be randomized.
  85670. */
  85671. export class ConeParticleEmitter implements IParticleEmitterType {
  85672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85673. directionRandomizer: number;
  85674. private _radius;
  85675. private _angle;
  85676. private _height;
  85677. /**
  85678. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85679. */
  85680. radiusRange: number;
  85681. /**
  85682. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85683. */
  85684. heightRange: number;
  85685. /**
  85686. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85687. */
  85688. emitFromSpawnPointOnly: boolean;
  85689. /**
  85690. * Gets or sets the radius of the emission cone
  85691. */
  85692. get radius(): number;
  85693. set radius(value: number);
  85694. /**
  85695. * Gets or sets the angle of the emission cone
  85696. */
  85697. get angle(): number;
  85698. set angle(value: number);
  85699. private _buildHeight;
  85700. /**
  85701. * Creates a new instance ConeParticleEmitter
  85702. * @param radius the radius of the emission cone (1 by default)
  85703. * @param angle the cone base angle (PI by default)
  85704. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85705. */
  85706. constructor(radius?: number, angle?: number,
  85707. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85708. directionRandomizer?: number);
  85709. /**
  85710. * Called by the particle System when the direction is computed for the created particle.
  85711. * @param worldMatrix is the world matrix of the particle system
  85712. * @param directionToUpdate is the direction vector to update with the result
  85713. * @param particle is the particle we are computed the direction for
  85714. * @param isLocal defines if the direction should be set in local space
  85715. */
  85716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85717. /**
  85718. * Called by the particle System when the position is computed for the created particle.
  85719. * @param worldMatrix is the world matrix of the particle system
  85720. * @param positionToUpdate is the position vector to update with the result
  85721. * @param particle is the particle we are computed the position for
  85722. * @param isLocal defines if the position should be set in local space
  85723. */
  85724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85725. /**
  85726. * Clones the current emitter and returns a copy of it
  85727. * @returns the new emitter
  85728. */
  85729. clone(): ConeParticleEmitter;
  85730. /**
  85731. * Called by the GPUParticleSystem to setup the update shader
  85732. * @param effect defines the update shader
  85733. */
  85734. applyToShader(effect: Effect): void;
  85735. /**
  85736. * Returns a string to use to update the GPU particles update shader
  85737. * @returns a string containng the defines string
  85738. */
  85739. getEffectDefines(): string;
  85740. /**
  85741. * Returns the string "ConeParticleEmitter"
  85742. * @returns a string containing the class name
  85743. */
  85744. getClassName(): string;
  85745. /**
  85746. * Serializes the particle system to a JSON object.
  85747. * @returns the JSON object
  85748. */
  85749. serialize(): any;
  85750. /**
  85751. * Parse properties from a JSON object
  85752. * @param serializationObject defines the JSON object
  85753. */
  85754. parse(serializationObject: any): void;
  85755. }
  85756. }
  85757. declare module BABYLON {
  85758. /**
  85759. * Particle emitter emitting particles from the inside of a cylinder.
  85760. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85761. */
  85762. export class CylinderParticleEmitter implements IParticleEmitterType {
  85763. /**
  85764. * The radius of the emission cylinder.
  85765. */
  85766. radius: number;
  85767. /**
  85768. * The height of the emission cylinder.
  85769. */
  85770. height: number;
  85771. /**
  85772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85773. */
  85774. radiusRange: number;
  85775. /**
  85776. * How much to randomize the particle direction [0-1].
  85777. */
  85778. directionRandomizer: number;
  85779. /**
  85780. * Creates a new instance CylinderParticleEmitter
  85781. * @param radius the radius of the emission cylinder (1 by default)
  85782. * @param height the height of the emission cylinder (1 by default)
  85783. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85784. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85785. */
  85786. constructor(
  85787. /**
  85788. * The radius of the emission cylinder.
  85789. */
  85790. radius?: number,
  85791. /**
  85792. * The height of the emission cylinder.
  85793. */
  85794. height?: number,
  85795. /**
  85796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85797. */
  85798. radiusRange?: number,
  85799. /**
  85800. * How much to randomize the particle direction [0-1].
  85801. */
  85802. directionRandomizer?: number);
  85803. /**
  85804. * Called by the particle System when the direction is computed for the created particle.
  85805. * @param worldMatrix is the world matrix of the particle system
  85806. * @param directionToUpdate is the direction vector to update with the result
  85807. * @param particle is the particle we are computed the direction for
  85808. * @param isLocal defines if the direction should be set in local space
  85809. */
  85810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85811. /**
  85812. * Called by the particle System when the position is computed for the created particle.
  85813. * @param worldMatrix is the world matrix of the particle system
  85814. * @param positionToUpdate is the position vector to update with the result
  85815. * @param particle is the particle we are computed the position for
  85816. * @param isLocal defines if the position should be set in local space
  85817. */
  85818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85819. /**
  85820. * Clones the current emitter and returns a copy of it
  85821. * @returns the new emitter
  85822. */
  85823. clone(): CylinderParticleEmitter;
  85824. /**
  85825. * Called by the GPUParticleSystem to setup the update shader
  85826. * @param effect defines the update shader
  85827. */
  85828. applyToShader(effect: Effect): void;
  85829. /**
  85830. * Returns a string to use to update the GPU particles update shader
  85831. * @returns a string containng the defines string
  85832. */
  85833. getEffectDefines(): string;
  85834. /**
  85835. * Returns the string "CylinderParticleEmitter"
  85836. * @returns a string containing the class name
  85837. */
  85838. getClassName(): string;
  85839. /**
  85840. * Serializes the particle system to a JSON object.
  85841. * @returns the JSON object
  85842. */
  85843. serialize(): any;
  85844. /**
  85845. * Parse properties from a JSON object
  85846. * @param serializationObject defines the JSON object
  85847. */
  85848. parse(serializationObject: any): void;
  85849. }
  85850. /**
  85851. * Particle emitter emitting particles from the inside of a cylinder.
  85852. * It emits the particles randomly between two vectors.
  85853. */
  85854. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85855. /**
  85856. * The min limit of the emission direction.
  85857. */
  85858. direction1: Vector3;
  85859. /**
  85860. * The max limit of the emission direction.
  85861. */
  85862. direction2: Vector3;
  85863. /**
  85864. * Creates a new instance CylinderDirectedParticleEmitter
  85865. * @param radius the radius of the emission cylinder (1 by default)
  85866. * @param height the height of the emission cylinder (1 by default)
  85867. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85868. * @param direction1 the min limit of the emission direction (up vector by default)
  85869. * @param direction2 the max limit of the emission direction (up vector by default)
  85870. */
  85871. constructor(radius?: number, height?: number, radiusRange?: number,
  85872. /**
  85873. * The min limit of the emission direction.
  85874. */
  85875. direction1?: Vector3,
  85876. /**
  85877. * The max limit of the emission direction.
  85878. */
  85879. direction2?: Vector3);
  85880. /**
  85881. * Called by the particle System when the direction is computed for the created particle.
  85882. * @param worldMatrix is the world matrix of the particle system
  85883. * @param directionToUpdate is the direction vector to update with the result
  85884. * @param particle is the particle we are computed the direction for
  85885. */
  85886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85887. /**
  85888. * Clones the current emitter and returns a copy of it
  85889. * @returns the new emitter
  85890. */
  85891. clone(): CylinderDirectedParticleEmitter;
  85892. /**
  85893. * Called by the GPUParticleSystem to setup the update shader
  85894. * @param effect defines the update shader
  85895. */
  85896. applyToShader(effect: Effect): void;
  85897. /**
  85898. * Returns a string to use to update the GPU particles update shader
  85899. * @returns a string containng the defines string
  85900. */
  85901. getEffectDefines(): string;
  85902. /**
  85903. * Returns the string "CylinderDirectedParticleEmitter"
  85904. * @returns a string containing the class name
  85905. */
  85906. getClassName(): string;
  85907. /**
  85908. * Serializes the particle system to a JSON object.
  85909. * @returns the JSON object
  85910. */
  85911. serialize(): any;
  85912. /**
  85913. * Parse properties from a JSON object
  85914. * @param serializationObject defines the JSON object
  85915. */
  85916. parse(serializationObject: any): void;
  85917. }
  85918. }
  85919. declare module BABYLON {
  85920. /**
  85921. * Particle emitter emitting particles from the inside of a hemisphere.
  85922. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85923. */
  85924. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85925. /**
  85926. * The radius of the emission hemisphere.
  85927. */
  85928. radius: number;
  85929. /**
  85930. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85931. */
  85932. radiusRange: number;
  85933. /**
  85934. * How much to randomize the particle direction [0-1].
  85935. */
  85936. directionRandomizer: number;
  85937. /**
  85938. * Creates a new instance HemisphericParticleEmitter
  85939. * @param radius the radius of the emission hemisphere (1 by default)
  85940. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85941. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85942. */
  85943. constructor(
  85944. /**
  85945. * The radius of the emission hemisphere.
  85946. */
  85947. radius?: number,
  85948. /**
  85949. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85950. */
  85951. radiusRange?: number,
  85952. /**
  85953. * How much to randomize the particle direction [0-1].
  85954. */
  85955. directionRandomizer?: number);
  85956. /**
  85957. * Called by the particle System when the direction is computed for the created particle.
  85958. * @param worldMatrix is the world matrix of the particle system
  85959. * @param directionToUpdate is the direction vector to update with the result
  85960. * @param particle is the particle we are computed the direction for
  85961. * @param isLocal defines if the direction should be set in local space
  85962. */
  85963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85964. /**
  85965. * Called by the particle System when the position is computed for the created particle.
  85966. * @param worldMatrix is the world matrix of the particle system
  85967. * @param positionToUpdate is the position vector to update with the result
  85968. * @param particle is the particle we are computed the position for
  85969. * @param isLocal defines if the position should be set in local space
  85970. */
  85971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85972. /**
  85973. * Clones the current emitter and returns a copy of it
  85974. * @returns the new emitter
  85975. */
  85976. clone(): HemisphericParticleEmitter;
  85977. /**
  85978. * Called by the GPUParticleSystem to setup the update shader
  85979. * @param effect defines the update shader
  85980. */
  85981. applyToShader(effect: Effect): void;
  85982. /**
  85983. * Returns a string to use to update the GPU particles update shader
  85984. * @returns a string containng the defines string
  85985. */
  85986. getEffectDefines(): string;
  85987. /**
  85988. * Returns the string "HemisphericParticleEmitter"
  85989. * @returns a string containing the class name
  85990. */
  85991. getClassName(): string;
  85992. /**
  85993. * Serializes the particle system to a JSON object.
  85994. * @returns the JSON object
  85995. */
  85996. serialize(): any;
  85997. /**
  85998. * Parse properties from a JSON object
  85999. * @param serializationObject defines the JSON object
  86000. */
  86001. parse(serializationObject: any): void;
  86002. }
  86003. }
  86004. declare module BABYLON {
  86005. /**
  86006. * Particle emitter emitting particles from a point.
  86007. * It emits the particles randomly between 2 given directions.
  86008. */
  86009. export class PointParticleEmitter implements IParticleEmitterType {
  86010. /**
  86011. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86012. */
  86013. direction1: Vector3;
  86014. /**
  86015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86016. */
  86017. direction2: Vector3;
  86018. /**
  86019. * Creates a new instance PointParticleEmitter
  86020. */
  86021. constructor();
  86022. /**
  86023. * Called by the particle System when the direction is computed for the created particle.
  86024. * @param worldMatrix is the world matrix of the particle system
  86025. * @param directionToUpdate is the direction vector to update with the result
  86026. * @param particle is the particle we are computed the direction for
  86027. * @param isLocal defines if the direction should be set in local space
  86028. */
  86029. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86030. /**
  86031. * Called by the particle System when the position is computed for the created particle.
  86032. * @param worldMatrix is the world matrix of the particle system
  86033. * @param positionToUpdate is the position vector to update with the result
  86034. * @param particle is the particle we are computed the position for
  86035. * @param isLocal defines if the position should be set in local space
  86036. */
  86037. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86038. /**
  86039. * Clones the current emitter and returns a copy of it
  86040. * @returns the new emitter
  86041. */
  86042. clone(): PointParticleEmitter;
  86043. /**
  86044. * Called by the GPUParticleSystem to setup the update shader
  86045. * @param effect defines the update shader
  86046. */
  86047. applyToShader(effect: Effect): void;
  86048. /**
  86049. * Returns a string to use to update the GPU particles update shader
  86050. * @returns a string containng the defines string
  86051. */
  86052. getEffectDefines(): string;
  86053. /**
  86054. * Returns the string "PointParticleEmitter"
  86055. * @returns a string containing the class name
  86056. */
  86057. getClassName(): string;
  86058. /**
  86059. * Serializes the particle system to a JSON object.
  86060. * @returns the JSON object
  86061. */
  86062. serialize(): any;
  86063. /**
  86064. * Parse properties from a JSON object
  86065. * @param serializationObject defines the JSON object
  86066. */
  86067. parse(serializationObject: any): void;
  86068. }
  86069. }
  86070. declare module BABYLON {
  86071. /**
  86072. * Particle emitter emitting particles from the inside of a sphere.
  86073. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86074. */
  86075. export class SphereParticleEmitter implements IParticleEmitterType {
  86076. /**
  86077. * The radius of the emission sphere.
  86078. */
  86079. radius: number;
  86080. /**
  86081. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86082. */
  86083. radiusRange: number;
  86084. /**
  86085. * How much to randomize the particle direction [0-1].
  86086. */
  86087. directionRandomizer: number;
  86088. /**
  86089. * Creates a new instance SphereParticleEmitter
  86090. * @param radius the radius of the emission sphere (1 by default)
  86091. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86092. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86093. */
  86094. constructor(
  86095. /**
  86096. * The radius of the emission sphere.
  86097. */
  86098. radius?: number,
  86099. /**
  86100. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86101. */
  86102. radiusRange?: number,
  86103. /**
  86104. * How much to randomize the particle direction [0-1].
  86105. */
  86106. directionRandomizer?: number);
  86107. /**
  86108. * Called by the particle System when the direction is computed for the created particle.
  86109. * @param worldMatrix is the world matrix of the particle system
  86110. * @param directionToUpdate is the direction vector to update with the result
  86111. * @param particle is the particle we are computed the direction for
  86112. * @param isLocal defines if the direction should be set in local space
  86113. */
  86114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86115. /**
  86116. * Called by the particle System when the position is computed for the created particle.
  86117. * @param worldMatrix is the world matrix of the particle system
  86118. * @param positionToUpdate is the position vector to update with the result
  86119. * @param particle is the particle we are computed the position for
  86120. * @param isLocal defines if the position should be set in local space
  86121. */
  86122. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86123. /**
  86124. * Clones the current emitter and returns a copy of it
  86125. * @returns the new emitter
  86126. */
  86127. clone(): SphereParticleEmitter;
  86128. /**
  86129. * Called by the GPUParticleSystem to setup the update shader
  86130. * @param effect defines the update shader
  86131. */
  86132. applyToShader(effect: Effect): void;
  86133. /**
  86134. * Returns a string to use to update the GPU particles update shader
  86135. * @returns a string containng the defines string
  86136. */
  86137. getEffectDefines(): string;
  86138. /**
  86139. * Returns the string "SphereParticleEmitter"
  86140. * @returns a string containing the class name
  86141. */
  86142. getClassName(): string;
  86143. /**
  86144. * Serializes the particle system to a JSON object.
  86145. * @returns the JSON object
  86146. */
  86147. serialize(): any;
  86148. /**
  86149. * Parse properties from a JSON object
  86150. * @param serializationObject defines the JSON object
  86151. */
  86152. parse(serializationObject: any): void;
  86153. }
  86154. /**
  86155. * Particle emitter emitting particles from the inside of a sphere.
  86156. * It emits the particles randomly between two vectors.
  86157. */
  86158. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86159. /**
  86160. * The min limit of the emission direction.
  86161. */
  86162. direction1: Vector3;
  86163. /**
  86164. * The max limit of the emission direction.
  86165. */
  86166. direction2: Vector3;
  86167. /**
  86168. * Creates a new instance SphereDirectedParticleEmitter
  86169. * @param radius the radius of the emission sphere (1 by default)
  86170. * @param direction1 the min limit of the emission direction (up vector by default)
  86171. * @param direction2 the max limit of the emission direction (up vector by default)
  86172. */
  86173. constructor(radius?: number,
  86174. /**
  86175. * The min limit of the emission direction.
  86176. */
  86177. direction1?: Vector3,
  86178. /**
  86179. * The max limit of the emission direction.
  86180. */
  86181. direction2?: Vector3);
  86182. /**
  86183. * Called by the particle System when the direction is computed for the created particle.
  86184. * @param worldMatrix is the world matrix of the particle system
  86185. * @param directionToUpdate is the direction vector to update with the result
  86186. * @param particle is the particle we are computed the direction for
  86187. */
  86188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86189. /**
  86190. * Clones the current emitter and returns a copy of it
  86191. * @returns the new emitter
  86192. */
  86193. clone(): SphereDirectedParticleEmitter;
  86194. /**
  86195. * Called by the GPUParticleSystem to setup the update shader
  86196. * @param effect defines the update shader
  86197. */
  86198. applyToShader(effect: Effect): void;
  86199. /**
  86200. * Returns a string to use to update the GPU particles update shader
  86201. * @returns a string containng the defines string
  86202. */
  86203. getEffectDefines(): string;
  86204. /**
  86205. * Returns the string "SphereDirectedParticleEmitter"
  86206. * @returns a string containing the class name
  86207. */
  86208. getClassName(): string;
  86209. /**
  86210. * Serializes the particle system to a JSON object.
  86211. * @returns the JSON object
  86212. */
  86213. serialize(): any;
  86214. /**
  86215. * Parse properties from a JSON object
  86216. * @param serializationObject defines the JSON object
  86217. */
  86218. parse(serializationObject: any): void;
  86219. }
  86220. }
  86221. declare module BABYLON {
  86222. /**
  86223. * Particle emitter emitting particles from a custom list of positions.
  86224. */
  86225. export class CustomParticleEmitter implements IParticleEmitterType {
  86226. /**
  86227. * Gets or sets the position generator that will create the inital position of each particle.
  86228. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86229. */
  86230. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86231. /**
  86232. * Gets or sets the destination generator that will create the final destination of each particle.
  86233. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86234. */
  86235. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86236. /**
  86237. * Creates a new instance CustomParticleEmitter
  86238. */
  86239. constructor();
  86240. /**
  86241. * Called by the particle System when the direction is computed for the created particle.
  86242. * @param worldMatrix is the world matrix of the particle system
  86243. * @param directionToUpdate is the direction vector to update with the result
  86244. * @param particle is the particle we are computed the direction for
  86245. * @param isLocal defines if the direction should be set in local space
  86246. */
  86247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86248. /**
  86249. * Called by the particle System when the position is computed for the created particle.
  86250. * @param worldMatrix is the world matrix of the particle system
  86251. * @param positionToUpdate is the position vector to update with the result
  86252. * @param particle is the particle we are computed the position for
  86253. * @param isLocal defines if the position should be set in local space
  86254. */
  86255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86256. /**
  86257. * Clones the current emitter and returns a copy of it
  86258. * @returns the new emitter
  86259. */
  86260. clone(): CustomParticleEmitter;
  86261. /**
  86262. * Called by the GPUParticleSystem to setup the update shader
  86263. * @param effect defines the update shader
  86264. */
  86265. applyToShader(effect: Effect): void;
  86266. /**
  86267. * Returns a string to use to update the GPU particles update shader
  86268. * @returns a string containng the defines string
  86269. */
  86270. getEffectDefines(): string;
  86271. /**
  86272. * Returns the string "PointParticleEmitter"
  86273. * @returns a string containing the class name
  86274. */
  86275. getClassName(): string;
  86276. /**
  86277. * Serializes the particle system to a JSON object.
  86278. * @returns the JSON object
  86279. */
  86280. serialize(): any;
  86281. /**
  86282. * Parse properties from a JSON object
  86283. * @param serializationObject defines the JSON object
  86284. */
  86285. parse(serializationObject: any): void;
  86286. }
  86287. }
  86288. declare module BABYLON {
  86289. /**
  86290. * Particle emitter emitting particles from the inside of a box.
  86291. * It emits the particles randomly between 2 given directions.
  86292. */
  86293. export class MeshParticleEmitter implements IParticleEmitterType {
  86294. private _indices;
  86295. private _positions;
  86296. private _normals;
  86297. private _storedNormal;
  86298. private _mesh;
  86299. /**
  86300. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86301. */
  86302. direction1: Vector3;
  86303. /**
  86304. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86305. */
  86306. direction2: Vector3;
  86307. /**
  86308. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86309. */
  86310. useMeshNormalsForDirection: boolean;
  86311. /** Defines the mesh to use as source */
  86312. get mesh(): Nullable<AbstractMesh>;
  86313. set mesh(value: Nullable<AbstractMesh>);
  86314. /**
  86315. * Creates a new instance MeshParticleEmitter
  86316. * @param mesh defines the mesh to use as source
  86317. */
  86318. constructor(mesh?: Nullable<AbstractMesh>);
  86319. /**
  86320. * Called by the particle System when the direction is computed for the created particle.
  86321. * @param worldMatrix is the world matrix of the particle system
  86322. * @param directionToUpdate is the direction vector to update with the result
  86323. * @param particle is the particle we are computed the direction for
  86324. * @param isLocal defines if the direction should be set in local space
  86325. */
  86326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86327. /**
  86328. * Called by the particle System when the position is computed for the created particle.
  86329. * @param worldMatrix is the world matrix of the particle system
  86330. * @param positionToUpdate is the position vector to update with the result
  86331. * @param particle is the particle we are computed the position for
  86332. * @param isLocal defines if the position should be set in local space
  86333. */
  86334. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86335. /**
  86336. * Clones the current emitter and returns a copy of it
  86337. * @returns the new emitter
  86338. */
  86339. clone(): MeshParticleEmitter;
  86340. /**
  86341. * Called by the GPUParticleSystem to setup the update shader
  86342. * @param effect defines the update shader
  86343. */
  86344. applyToShader(effect: Effect): void;
  86345. /**
  86346. * Returns a string to use to update the GPU particles update shader
  86347. * @returns a string containng the defines string
  86348. */
  86349. getEffectDefines(): string;
  86350. /**
  86351. * Returns the string "BoxParticleEmitter"
  86352. * @returns a string containing the class name
  86353. */
  86354. getClassName(): string;
  86355. /**
  86356. * Serializes the particle system to a JSON object.
  86357. * @returns the JSON object
  86358. */
  86359. serialize(): any;
  86360. /**
  86361. * Parse properties from a JSON object
  86362. * @param serializationObject defines the JSON object
  86363. * @param scene defines the hosting scene
  86364. */
  86365. parse(serializationObject: any, scene: Scene): void;
  86366. }
  86367. }
  86368. declare module BABYLON {
  86369. /**
  86370. * Interface representing a particle system in Babylon.js.
  86371. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86372. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86373. */
  86374. export interface IParticleSystem {
  86375. /**
  86376. * List of animations used by the particle system.
  86377. */
  86378. animations: Animation[];
  86379. /**
  86380. * The id of the Particle system.
  86381. */
  86382. id: string;
  86383. /**
  86384. * The name of the Particle system.
  86385. */
  86386. name: string;
  86387. /**
  86388. * The emitter represents the Mesh or position we are attaching the particle system to.
  86389. */
  86390. emitter: Nullable<AbstractMesh | Vector3>;
  86391. /**
  86392. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86393. */
  86394. isBillboardBased: boolean;
  86395. /**
  86396. * The rendering group used by the Particle system to chose when to render.
  86397. */
  86398. renderingGroupId: number;
  86399. /**
  86400. * The layer mask we are rendering the particles through.
  86401. */
  86402. layerMask: number;
  86403. /**
  86404. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86405. */
  86406. updateSpeed: number;
  86407. /**
  86408. * The amount of time the particle system is running (depends of the overall update speed).
  86409. */
  86410. targetStopDuration: number;
  86411. /**
  86412. * The texture used to render each particle. (this can be a spritesheet)
  86413. */
  86414. particleTexture: Nullable<Texture>;
  86415. /**
  86416. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86417. */
  86418. blendMode: number;
  86419. /**
  86420. * Minimum life time of emitting particles.
  86421. */
  86422. minLifeTime: number;
  86423. /**
  86424. * Maximum life time of emitting particles.
  86425. */
  86426. maxLifeTime: number;
  86427. /**
  86428. * Minimum Size of emitting particles.
  86429. */
  86430. minSize: number;
  86431. /**
  86432. * Maximum Size of emitting particles.
  86433. */
  86434. maxSize: number;
  86435. /**
  86436. * Minimum scale of emitting particles on X axis.
  86437. */
  86438. minScaleX: number;
  86439. /**
  86440. * Maximum scale of emitting particles on X axis.
  86441. */
  86442. maxScaleX: number;
  86443. /**
  86444. * Minimum scale of emitting particles on Y axis.
  86445. */
  86446. minScaleY: number;
  86447. /**
  86448. * Maximum scale of emitting particles on Y axis.
  86449. */
  86450. maxScaleY: number;
  86451. /**
  86452. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86453. */
  86454. color1: Color4;
  86455. /**
  86456. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86457. */
  86458. color2: Color4;
  86459. /**
  86460. * Color the particle will have at the end of its lifetime.
  86461. */
  86462. colorDead: Color4;
  86463. /**
  86464. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86465. */
  86466. emitRate: number;
  86467. /**
  86468. * You can use gravity if you want to give an orientation to your particles.
  86469. */
  86470. gravity: Vector3;
  86471. /**
  86472. * Minimum power of emitting particles.
  86473. */
  86474. minEmitPower: number;
  86475. /**
  86476. * Maximum power of emitting particles.
  86477. */
  86478. maxEmitPower: number;
  86479. /**
  86480. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86481. */
  86482. minAngularSpeed: number;
  86483. /**
  86484. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86485. */
  86486. maxAngularSpeed: number;
  86487. /**
  86488. * Gets or sets the minimal initial rotation in radians.
  86489. */
  86490. minInitialRotation: number;
  86491. /**
  86492. * Gets or sets the maximal initial rotation in radians.
  86493. */
  86494. maxInitialRotation: number;
  86495. /**
  86496. * The particle emitter type defines the emitter used by the particle system.
  86497. * It can be for example box, sphere, or cone...
  86498. */
  86499. particleEmitterType: Nullable<IParticleEmitterType>;
  86500. /**
  86501. * Defines the delay in milliseconds before starting the system (0 by default)
  86502. */
  86503. startDelay: number;
  86504. /**
  86505. * 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
  86506. */
  86507. preWarmCycles: number;
  86508. /**
  86509. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86510. */
  86511. preWarmStepOffset: number;
  86512. /**
  86513. * 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)
  86514. */
  86515. spriteCellChangeSpeed: number;
  86516. /**
  86517. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86518. */
  86519. startSpriteCellID: number;
  86520. /**
  86521. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86522. */
  86523. endSpriteCellID: number;
  86524. /**
  86525. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86526. */
  86527. spriteCellWidth: number;
  86528. /**
  86529. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86530. */
  86531. spriteCellHeight: number;
  86532. /**
  86533. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86534. */
  86535. spriteRandomStartCell: boolean;
  86536. /**
  86537. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86538. */
  86539. isAnimationSheetEnabled: boolean;
  86540. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86541. translationPivot: Vector2;
  86542. /**
  86543. * Gets or sets a texture used to add random noise to particle positions
  86544. */
  86545. noiseTexture: Nullable<BaseTexture>;
  86546. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86547. noiseStrength: Vector3;
  86548. /**
  86549. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86550. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86551. */
  86552. billboardMode: number;
  86553. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86554. limitVelocityDamping: number;
  86555. /**
  86556. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86557. */
  86558. beginAnimationOnStart: boolean;
  86559. /**
  86560. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86561. */
  86562. beginAnimationFrom: number;
  86563. /**
  86564. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86565. */
  86566. beginAnimationTo: number;
  86567. /**
  86568. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86569. */
  86570. beginAnimationLoop: boolean;
  86571. /**
  86572. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86573. */
  86574. disposeOnStop: boolean;
  86575. /**
  86576. * Specifies if the particles are updated in emitter local space or world space
  86577. */
  86578. isLocal: boolean;
  86579. /**
  86580. * Gets the maximum number of particles active at the same time.
  86581. * @returns The max number of active particles.
  86582. */
  86583. getCapacity(): number;
  86584. /**
  86585. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86586. * @returns True if it has been started, otherwise false.
  86587. */
  86588. isStarted(): boolean;
  86589. /**
  86590. * Animates the particle system for this frame.
  86591. */
  86592. animate(): void;
  86593. /**
  86594. * Renders the particle system in its current state.
  86595. * @returns the current number of particles
  86596. */
  86597. render(): number;
  86598. /**
  86599. * Dispose the particle system and frees its associated resources.
  86600. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86601. */
  86602. dispose(disposeTexture?: boolean): void;
  86603. /**
  86604. * Clones the particle system.
  86605. * @param name The name of the cloned object
  86606. * @param newEmitter The new emitter to use
  86607. * @returns the cloned particle system
  86608. */
  86609. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86610. /**
  86611. * Serializes the particle system to a JSON object.
  86612. * @returns the JSON object
  86613. */
  86614. serialize(): any;
  86615. /**
  86616. * Rebuild the particle system
  86617. */
  86618. rebuild(): void;
  86619. /**
  86620. * Starts the particle system and begins to emit
  86621. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86622. */
  86623. start(delay?: number): void;
  86624. /**
  86625. * Stops the particle system.
  86626. */
  86627. stop(): void;
  86628. /**
  86629. * Remove all active particles
  86630. */
  86631. reset(): void;
  86632. /**
  86633. * Is this system ready to be used/rendered
  86634. * @return true if the system is ready
  86635. */
  86636. isReady(): boolean;
  86637. /**
  86638. * Returns the string "ParticleSystem"
  86639. * @returns a string containing the class name
  86640. */
  86641. getClassName(): string;
  86642. /**
  86643. * Adds a new color gradient
  86644. * @param gradient defines the gradient to use (between 0 and 1)
  86645. * @param color1 defines the color to affect to the specified gradient
  86646. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86647. * @returns the current particle system
  86648. */
  86649. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86650. /**
  86651. * Remove a specific color gradient
  86652. * @param gradient defines the gradient to remove
  86653. * @returns the current particle system
  86654. */
  86655. removeColorGradient(gradient: number): IParticleSystem;
  86656. /**
  86657. * Adds a new size gradient
  86658. * @param gradient defines the gradient to use (between 0 and 1)
  86659. * @param factor defines the size factor to affect to the specified gradient
  86660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86661. * @returns the current particle system
  86662. */
  86663. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86664. /**
  86665. * Remove a specific size gradient
  86666. * @param gradient defines the gradient to remove
  86667. * @returns the current particle system
  86668. */
  86669. removeSizeGradient(gradient: number): IParticleSystem;
  86670. /**
  86671. * Gets the current list of color gradients.
  86672. * You must use addColorGradient and removeColorGradient to udpate this list
  86673. * @returns the list of color gradients
  86674. */
  86675. getColorGradients(): Nullable<Array<ColorGradient>>;
  86676. /**
  86677. * Gets the current list of size gradients.
  86678. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86679. * @returns the list of size gradients
  86680. */
  86681. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86682. /**
  86683. * Gets the current list of angular speed gradients.
  86684. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86685. * @returns the list of angular speed gradients
  86686. */
  86687. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86688. /**
  86689. * Adds a new angular speed gradient
  86690. * @param gradient defines the gradient to use (between 0 and 1)
  86691. * @param factor defines the angular speed to affect to the specified gradient
  86692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86693. * @returns the current particle system
  86694. */
  86695. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86696. /**
  86697. * Remove a specific angular speed gradient
  86698. * @param gradient defines the gradient to remove
  86699. * @returns the current particle system
  86700. */
  86701. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86702. /**
  86703. * Gets the current list of velocity gradients.
  86704. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86705. * @returns the list of velocity gradients
  86706. */
  86707. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86708. /**
  86709. * Adds a new velocity gradient
  86710. * @param gradient defines the gradient to use (between 0 and 1)
  86711. * @param factor defines the velocity to affect to the specified gradient
  86712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86713. * @returns the current particle system
  86714. */
  86715. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86716. /**
  86717. * Remove a specific velocity gradient
  86718. * @param gradient defines the gradient to remove
  86719. * @returns the current particle system
  86720. */
  86721. removeVelocityGradient(gradient: number): IParticleSystem;
  86722. /**
  86723. * Gets the current list of limit velocity gradients.
  86724. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86725. * @returns the list of limit velocity gradients
  86726. */
  86727. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86728. /**
  86729. * Adds a new limit velocity gradient
  86730. * @param gradient defines the gradient to use (between 0 and 1)
  86731. * @param factor defines the limit velocity to affect to the specified gradient
  86732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86733. * @returns the current particle system
  86734. */
  86735. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86736. /**
  86737. * Remove a specific limit velocity gradient
  86738. * @param gradient defines the gradient to remove
  86739. * @returns the current particle system
  86740. */
  86741. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86742. /**
  86743. * Adds a new drag gradient
  86744. * @param gradient defines the gradient to use (between 0 and 1)
  86745. * @param factor defines the drag to affect to the specified gradient
  86746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86747. * @returns the current particle system
  86748. */
  86749. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86750. /**
  86751. * Remove a specific drag gradient
  86752. * @param gradient defines the gradient to remove
  86753. * @returns the current particle system
  86754. */
  86755. removeDragGradient(gradient: number): IParticleSystem;
  86756. /**
  86757. * Gets the current list of drag gradients.
  86758. * You must use addDragGradient and removeDragGradient to udpate this list
  86759. * @returns the list of drag gradients
  86760. */
  86761. getDragGradients(): Nullable<Array<FactorGradient>>;
  86762. /**
  86763. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86764. * @param gradient defines the gradient to use (between 0 and 1)
  86765. * @param factor defines the emit rate to affect to the specified gradient
  86766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86767. * @returns the current particle system
  86768. */
  86769. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86770. /**
  86771. * Remove a specific emit rate gradient
  86772. * @param gradient defines the gradient to remove
  86773. * @returns the current particle system
  86774. */
  86775. removeEmitRateGradient(gradient: number): IParticleSystem;
  86776. /**
  86777. * Gets the current list of emit rate gradients.
  86778. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86779. * @returns the list of emit rate gradients
  86780. */
  86781. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86782. /**
  86783. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86784. * @param gradient defines the gradient to use (between 0 and 1)
  86785. * @param factor defines the start size to affect to the specified gradient
  86786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86787. * @returns the current particle system
  86788. */
  86789. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86790. /**
  86791. * Remove a specific start size gradient
  86792. * @param gradient defines the gradient to remove
  86793. * @returns the current particle system
  86794. */
  86795. removeStartSizeGradient(gradient: number): IParticleSystem;
  86796. /**
  86797. * Gets the current list of start size gradients.
  86798. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86799. * @returns the list of start size gradients
  86800. */
  86801. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86802. /**
  86803. * Adds a new life time gradient
  86804. * @param gradient defines the gradient to use (between 0 and 1)
  86805. * @param factor defines the life time factor to affect to the specified gradient
  86806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86807. * @returns the current particle system
  86808. */
  86809. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86810. /**
  86811. * Remove a specific life time gradient
  86812. * @param gradient defines the gradient to remove
  86813. * @returns the current particle system
  86814. */
  86815. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86816. /**
  86817. * Gets the current list of life time gradients.
  86818. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86819. * @returns the list of life time gradients
  86820. */
  86821. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86822. /**
  86823. * Gets the current list of color gradients.
  86824. * You must use addColorGradient and removeColorGradient to udpate this list
  86825. * @returns the list of color gradients
  86826. */
  86827. getColorGradients(): Nullable<Array<ColorGradient>>;
  86828. /**
  86829. * Adds a new ramp gradient used to remap particle colors
  86830. * @param gradient defines the gradient to use (between 0 and 1)
  86831. * @param color defines the color to affect to the specified gradient
  86832. * @returns the current particle system
  86833. */
  86834. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86835. /**
  86836. * Gets the current list of ramp gradients.
  86837. * You must use addRampGradient and removeRampGradient to udpate this list
  86838. * @returns the list of ramp gradients
  86839. */
  86840. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86841. /** Gets or sets a boolean indicating that ramp gradients must be used
  86842. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86843. */
  86844. useRampGradients: boolean;
  86845. /**
  86846. * Adds a new color remap gradient
  86847. * @param gradient defines the gradient to use (between 0 and 1)
  86848. * @param min defines the color remap minimal range
  86849. * @param max defines the color remap maximal range
  86850. * @returns the current particle system
  86851. */
  86852. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86853. /**
  86854. * Gets the current list of color remap gradients.
  86855. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86856. * @returns the list of color remap gradients
  86857. */
  86858. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86859. /**
  86860. * Adds a new alpha remap gradient
  86861. * @param gradient defines the gradient to use (between 0 and 1)
  86862. * @param min defines the alpha remap minimal range
  86863. * @param max defines the alpha remap maximal range
  86864. * @returns the current particle system
  86865. */
  86866. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86867. /**
  86868. * Gets the current list of alpha remap gradients.
  86869. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86870. * @returns the list of alpha remap gradients
  86871. */
  86872. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86873. /**
  86874. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86877. * @returns the emitter
  86878. */
  86879. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86880. /**
  86881. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86882. * @param radius The radius of the hemisphere to emit from
  86883. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86884. * @returns the emitter
  86885. */
  86886. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86887. /**
  86888. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86889. * @param radius The radius of the sphere to emit from
  86890. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86891. * @returns the emitter
  86892. */
  86893. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86894. /**
  86895. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86896. * @param radius The radius of the sphere to emit from
  86897. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86898. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86899. * @returns the emitter
  86900. */
  86901. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86902. /**
  86903. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86904. * @param radius The radius of the emission cylinder
  86905. * @param height The height of the emission cylinder
  86906. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86907. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86908. * @returns the emitter
  86909. */
  86910. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86911. /**
  86912. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86913. * @param radius The radius of the cylinder to emit from
  86914. * @param height The height of the emission cylinder
  86915. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86916. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86917. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86918. * @returns the emitter
  86919. */
  86920. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86921. /**
  86922. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86923. * @param radius The radius of the cone to emit from
  86924. * @param angle The base angle of the cone
  86925. * @returns the emitter
  86926. */
  86927. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86928. /**
  86929. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86930. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86931. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86932. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86933. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86934. * @returns the emitter
  86935. */
  86936. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86937. /**
  86938. * Get hosting scene
  86939. * @returns the scene
  86940. */
  86941. getScene(): Scene;
  86942. }
  86943. }
  86944. declare module BABYLON {
  86945. /**
  86946. * 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.
  86947. * @see https://doc.babylonjs.com/how_to/transformnode
  86948. */
  86949. export class TransformNode extends Node {
  86950. /**
  86951. * Object will not rotate to face the camera
  86952. */
  86953. static BILLBOARDMODE_NONE: number;
  86954. /**
  86955. * Object will rotate to face the camera but only on the x axis
  86956. */
  86957. static BILLBOARDMODE_X: number;
  86958. /**
  86959. * Object will rotate to face the camera but only on the y axis
  86960. */
  86961. static BILLBOARDMODE_Y: number;
  86962. /**
  86963. * Object will rotate to face the camera but only on the z axis
  86964. */
  86965. static BILLBOARDMODE_Z: number;
  86966. /**
  86967. * Object will rotate to face the camera
  86968. */
  86969. static BILLBOARDMODE_ALL: number;
  86970. /**
  86971. * Object will rotate to face the camera's position instead of orientation
  86972. */
  86973. static BILLBOARDMODE_USE_POSITION: number;
  86974. private _forward;
  86975. private _forwardInverted;
  86976. private _up;
  86977. private _right;
  86978. private _rightInverted;
  86979. private _position;
  86980. private _rotation;
  86981. private _rotationQuaternion;
  86982. protected _scaling: Vector3;
  86983. protected _isDirty: boolean;
  86984. private _transformToBoneReferal;
  86985. private _isAbsoluteSynced;
  86986. private _billboardMode;
  86987. /**
  86988. * Gets or sets the billboard mode. Default is 0.
  86989. *
  86990. * | Value | Type | Description |
  86991. * | --- | --- | --- |
  86992. * | 0 | BILLBOARDMODE_NONE | |
  86993. * | 1 | BILLBOARDMODE_X | |
  86994. * | 2 | BILLBOARDMODE_Y | |
  86995. * | 4 | BILLBOARDMODE_Z | |
  86996. * | 7 | BILLBOARDMODE_ALL | |
  86997. *
  86998. */
  86999. get billboardMode(): number;
  87000. set billboardMode(value: number);
  87001. private _preserveParentRotationForBillboard;
  87002. /**
  87003. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87004. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87005. */
  87006. get preserveParentRotationForBillboard(): boolean;
  87007. set preserveParentRotationForBillboard(value: boolean);
  87008. /**
  87009. * 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
  87010. */
  87011. scalingDeterminant: number;
  87012. private _infiniteDistance;
  87013. /**
  87014. * Gets or sets the distance of the object to max, often used by skybox
  87015. */
  87016. get infiniteDistance(): boolean;
  87017. set infiniteDistance(value: boolean);
  87018. /**
  87019. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87020. * By default the system will update normals to compensate
  87021. */
  87022. ignoreNonUniformScaling: boolean;
  87023. /**
  87024. * 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
  87025. */
  87026. reIntegrateRotationIntoRotationQuaternion: boolean;
  87027. /** @hidden */
  87028. _poseMatrix: Nullable<Matrix>;
  87029. /** @hidden */
  87030. _localMatrix: Matrix;
  87031. private _usePivotMatrix;
  87032. private _absolutePosition;
  87033. private _absoluteScaling;
  87034. private _absoluteRotationQuaternion;
  87035. private _pivotMatrix;
  87036. private _pivotMatrixInverse;
  87037. protected _postMultiplyPivotMatrix: boolean;
  87038. protected _isWorldMatrixFrozen: boolean;
  87039. /** @hidden */
  87040. _indexInSceneTransformNodesArray: number;
  87041. /**
  87042. * An event triggered after the world matrix is updated
  87043. */
  87044. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87045. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87046. /**
  87047. * Gets a string identifying the name of the class
  87048. * @returns "TransformNode" string
  87049. */
  87050. getClassName(): string;
  87051. /**
  87052. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87053. */
  87054. get position(): Vector3;
  87055. set position(newPosition: Vector3);
  87056. /**
  87057. * 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)).
  87058. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87059. */
  87060. get rotation(): Vector3;
  87061. set rotation(newRotation: Vector3);
  87062. /**
  87063. * 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)).
  87064. */
  87065. get scaling(): Vector3;
  87066. set scaling(newScaling: Vector3);
  87067. /**
  87068. * 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).
  87069. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87070. */
  87071. get rotationQuaternion(): Nullable<Quaternion>;
  87072. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87073. /**
  87074. * The forward direction of that transform in world space.
  87075. */
  87076. get forward(): Vector3;
  87077. /**
  87078. * The up direction of that transform in world space.
  87079. */
  87080. get up(): Vector3;
  87081. /**
  87082. * The right direction of that transform in world space.
  87083. */
  87084. get right(): Vector3;
  87085. /**
  87086. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87087. * @param matrix the matrix to copy the pose from
  87088. * @returns this TransformNode.
  87089. */
  87090. updatePoseMatrix(matrix: Matrix): TransformNode;
  87091. /**
  87092. * Returns the mesh Pose matrix.
  87093. * @returns the pose matrix
  87094. */
  87095. getPoseMatrix(): Matrix;
  87096. /** @hidden */
  87097. _isSynchronized(): boolean;
  87098. /** @hidden */
  87099. _initCache(): void;
  87100. /**
  87101. * Flag the transform node as dirty (Forcing it to update everything)
  87102. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87103. * @returns this transform node
  87104. */
  87105. markAsDirty(property: string): TransformNode;
  87106. /**
  87107. * Returns the current mesh absolute position.
  87108. * Returns a Vector3.
  87109. */
  87110. get absolutePosition(): Vector3;
  87111. /**
  87112. * Returns the current mesh absolute scaling.
  87113. * Returns a Vector3.
  87114. */
  87115. get absoluteScaling(): Vector3;
  87116. /**
  87117. * Returns the current mesh absolute rotation.
  87118. * Returns a Quaternion.
  87119. */
  87120. get absoluteRotationQuaternion(): Quaternion;
  87121. /**
  87122. * Sets a new matrix to apply before all other transformation
  87123. * @param matrix defines the transform matrix
  87124. * @returns the current TransformNode
  87125. */
  87126. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87127. /**
  87128. * Sets a new pivot matrix to the current node
  87129. * @param matrix defines the new pivot matrix to use
  87130. * @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
  87131. * @returns the current TransformNode
  87132. */
  87133. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87134. /**
  87135. * Returns the mesh pivot matrix.
  87136. * Default : Identity.
  87137. * @returns the matrix
  87138. */
  87139. getPivotMatrix(): Matrix;
  87140. /**
  87141. * Instantiate (when possible) or clone that node with its hierarchy
  87142. * @param newParent defines the new parent to use for the instance (or clone)
  87143. * @param options defines options to configure how copy is done
  87144. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87145. * @returns an instance (or a clone) of the current node with its hiearchy
  87146. */
  87147. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87148. doNotInstantiate: boolean;
  87149. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87150. /**
  87151. * Prevents the World matrix to be computed any longer
  87152. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87153. * @returns the TransformNode.
  87154. */
  87155. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87156. /**
  87157. * Allows back the World matrix computation.
  87158. * @returns the TransformNode.
  87159. */
  87160. unfreezeWorldMatrix(): this;
  87161. /**
  87162. * True if the World matrix has been frozen.
  87163. */
  87164. get isWorldMatrixFrozen(): boolean;
  87165. /**
  87166. * Retuns the mesh absolute position in the World.
  87167. * @returns a Vector3.
  87168. */
  87169. getAbsolutePosition(): Vector3;
  87170. /**
  87171. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87172. * @param absolutePosition the absolute position to set
  87173. * @returns the TransformNode.
  87174. */
  87175. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87176. /**
  87177. * Sets the mesh position in its local space.
  87178. * @param vector3 the position to set in localspace
  87179. * @returns the TransformNode.
  87180. */
  87181. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87182. /**
  87183. * Returns the mesh position in the local space from the current World matrix values.
  87184. * @returns a new Vector3.
  87185. */
  87186. getPositionExpressedInLocalSpace(): Vector3;
  87187. /**
  87188. * Translates the mesh along the passed Vector3 in its local space.
  87189. * @param vector3 the distance to translate in localspace
  87190. * @returns the TransformNode.
  87191. */
  87192. locallyTranslate(vector3: Vector3): TransformNode;
  87193. private static _lookAtVectorCache;
  87194. /**
  87195. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87196. * @param targetPoint the position (must be in same space as current mesh) to look at
  87197. * @param yawCor optional yaw (y-axis) correction in radians
  87198. * @param pitchCor optional pitch (x-axis) correction in radians
  87199. * @param rollCor optional roll (z-axis) correction in radians
  87200. * @param space the choosen space of the target
  87201. * @returns the TransformNode.
  87202. */
  87203. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87204. /**
  87205. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87206. * This Vector3 is expressed in the World space.
  87207. * @param localAxis axis to rotate
  87208. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87209. */
  87210. getDirection(localAxis: Vector3): Vector3;
  87211. /**
  87212. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87213. * localAxis is expressed in the mesh local space.
  87214. * result is computed in the Wordl space from the mesh World matrix.
  87215. * @param localAxis axis to rotate
  87216. * @param result the resulting transformnode
  87217. * @returns this TransformNode.
  87218. */
  87219. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87220. /**
  87221. * Sets this transform node rotation to the given local axis.
  87222. * @param localAxis the axis in local space
  87223. * @param yawCor optional yaw (y-axis) correction in radians
  87224. * @param pitchCor optional pitch (x-axis) correction in radians
  87225. * @param rollCor optional roll (z-axis) correction in radians
  87226. * @returns this TransformNode
  87227. */
  87228. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87229. /**
  87230. * Sets a new pivot point to the current node
  87231. * @param point defines the new pivot point to use
  87232. * @param space defines if the point is in world or local space (local by default)
  87233. * @returns the current TransformNode
  87234. */
  87235. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87236. /**
  87237. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87238. * @returns the pivot point
  87239. */
  87240. getPivotPoint(): Vector3;
  87241. /**
  87242. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87243. * @param result the vector3 to store the result
  87244. * @returns this TransformNode.
  87245. */
  87246. getPivotPointToRef(result: Vector3): TransformNode;
  87247. /**
  87248. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87249. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87250. */
  87251. getAbsolutePivotPoint(): Vector3;
  87252. /**
  87253. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87254. * @param result vector3 to store the result
  87255. * @returns this TransformNode.
  87256. */
  87257. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87258. /**
  87259. * Defines the passed node as the parent of the current node.
  87260. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87261. * @see https://doc.babylonjs.com/how_to/parenting
  87262. * @param node the node ot set as the parent
  87263. * @returns this TransformNode.
  87264. */
  87265. setParent(node: Nullable<Node>): TransformNode;
  87266. private _nonUniformScaling;
  87267. /**
  87268. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87269. */
  87270. get nonUniformScaling(): boolean;
  87271. /** @hidden */
  87272. _updateNonUniformScalingState(value: boolean): boolean;
  87273. /**
  87274. * Attach the current TransformNode to another TransformNode associated with a bone
  87275. * @param bone Bone affecting the TransformNode
  87276. * @param affectedTransformNode TransformNode associated with the bone
  87277. * @returns this object
  87278. */
  87279. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87280. /**
  87281. * Detach the transform node if its associated with a bone
  87282. * @returns this object
  87283. */
  87284. detachFromBone(): TransformNode;
  87285. private static _rotationAxisCache;
  87286. /**
  87287. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87288. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87289. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87290. * The passed axis is also normalized.
  87291. * @param axis the axis to rotate around
  87292. * @param amount the amount to rotate in radians
  87293. * @param space Space to rotate in (Default: local)
  87294. * @returns the TransformNode.
  87295. */
  87296. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87297. /**
  87298. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87299. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87300. * The passed axis is also normalized. .
  87301. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87302. * @param point the point to rotate around
  87303. * @param axis the axis to rotate around
  87304. * @param amount the amount to rotate in radians
  87305. * @returns the TransformNode
  87306. */
  87307. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87308. /**
  87309. * Translates the mesh along the axis vector for the passed distance in the given space.
  87310. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87311. * @param axis the axis to translate in
  87312. * @param distance the distance to translate
  87313. * @param space Space to rotate in (Default: local)
  87314. * @returns the TransformNode.
  87315. */
  87316. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87317. /**
  87318. * Adds a rotation step to the mesh current rotation.
  87319. * x, y, z are Euler angles expressed in radians.
  87320. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87321. * This means this rotation is made in the mesh local space only.
  87322. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87323. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87324. * ```javascript
  87325. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87326. * ```
  87327. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87328. * 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.
  87329. * @param x Rotation to add
  87330. * @param y Rotation to add
  87331. * @param z Rotation to add
  87332. * @returns the TransformNode.
  87333. */
  87334. addRotation(x: number, y: number, z: number): TransformNode;
  87335. /**
  87336. * @hidden
  87337. */
  87338. protected _getEffectiveParent(): Nullable<Node>;
  87339. /**
  87340. * Computes the world matrix of the node
  87341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87342. * @returns the world matrix
  87343. */
  87344. computeWorldMatrix(force?: boolean): Matrix;
  87345. /**
  87346. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87347. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87348. */
  87349. resetLocalMatrix(independentOfChildren?: boolean): void;
  87350. protected _afterComputeWorldMatrix(): void;
  87351. /**
  87352. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87353. * @param func callback function to add
  87354. *
  87355. * @returns the TransformNode.
  87356. */
  87357. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87358. /**
  87359. * Removes a registered callback function.
  87360. * @param func callback function to remove
  87361. * @returns the TransformNode.
  87362. */
  87363. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87364. /**
  87365. * Gets the position of the current mesh in camera space
  87366. * @param camera defines the camera to use
  87367. * @returns a position
  87368. */
  87369. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87370. /**
  87371. * Returns the distance from the mesh to the active camera
  87372. * @param camera defines the camera to use
  87373. * @returns the distance
  87374. */
  87375. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87376. /**
  87377. * Clone the current transform node
  87378. * @param name Name of the new clone
  87379. * @param newParent New parent for the clone
  87380. * @param doNotCloneChildren Do not clone children hierarchy
  87381. * @returns the new transform node
  87382. */
  87383. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87384. /**
  87385. * Serializes the objects information.
  87386. * @param currentSerializationObject defines the object to serialize in
  87387. * @returns the serialized object
  87388. */
  87389. serialize(currentSerializationObject?: any): any;
  87390. /**
  87391. * Returns a new TransformNode object parsed from the source provided.
  87392. * @param parsedTransformNode is the source.
  87393. * @param scene the scne the object belongs to
  87394. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87395. * @returns a new TransformNode object parsed from the source provided.
  87396. */
  87397. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87398. /**
  87399. * Get all child-transformNodes of this node
  87400. * @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
  87401. * @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
  87402. * @returns an array of TransformNode
  87403. */
  87404. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87405. /**
  87406. * Releases resources associated with this transform node.
  87407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87409. */
  87410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87411. /**
  87412. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87413. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87414. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87415. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87416. * @returns the current mesh
  87417. */
  87418. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87419. private _syncAbsoluteScalingAndRotation;
  87420. }
  87421. }
  87422. declare module BABYLON {
  87423. /**
  87424. * Class used to override all child animations of a given target
  87425. */
  87426. export class AnimationPropertiesOverride {
  87427. /**
  87428. * Gets or sets a value indicating if animation blending must be used
  87429. */
  87430. enableBlending: boolean;
  87431. /**
  87432. * Gets or sets the blending speed to use when enableBlending is true
  87433. */
  87434. blendingSpeed: number;
  87435. /**
  87436. * Gets or sets the default loop mode to use
  87437. */
  87438. loopMode: number;
  87439. }
  87440. }
  87441. declare module BABYLON {
  87442. /**
  87443. * Class used to store bone information
  87444. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87445. */
  87446. export class Bone extends Node {
  87447. /**
  87448. * defines the bone name
  87449. */
  87450. name: string;
  87451. private static _tmpVecs;
  87452. private static _tmpQuat;
  87453. private static _tmpMats;
  87454. /**
  87455. * Gets the list of child bones
  87456. */
  87457. children: Bone[];
  87458. /** Gets the animations associated with this bone */
  87459. animations: Animation[];
  87460. /**
  87461. * Gets or sets bone length
  87462. */
  87463. length: number;
  87464. /**
  87465. * @hidden Internal only
  87466. * Set this value to map this bone to a different index in the transform matrices
  87467. * Set this value to -1 to exclude the bone from the transform matrices
  87468. */
  87469. _index: Nullable<number>;
  87470. private _skeleton;
  87471. private _localMatrix;
  87472. private _restPose;
  87473. private _baseMatrix;
  87474. private _absoluteTransform;
  87475. private _invertedAbsoluteTransform;
  87476. private _parent;
  87477. private _scalingDeterminant;
  87478. private _worldTransform;
  87479. private _localScaling;
  87480. private _localRotation;
  87481. private _localPosition;
  87482. private _needToDecompose;
  87483. private _needToCompose;
  87484. /** @hidden */
  87485. _linkedTransformNode: Nullable<TransformNode>;
  87486. /** @hidden */
  87487. _waitingTransformNodeId: Nullable<string>;
  87488. /** @hidden */
  87489. get _matrix(): Matrix;
  87490. /** @hidden */
  87491. set _matrix(value: Matrix);
  87492. /**
  87493. * Create a new bone
  87494. * @param name defines the bone name
  87495. * @param skeleton defines the parent skeleton
  87496. * @param parentBone defines the parent (can be null if the bone is the root)
  87497. * @param localMatrix defines the local matrix
  87498. * @param restPose defines the rest pose matrix
  87499. * @param baseMatrix defines the base matrix
  87500. * @param index defines index of the bone in the hiearchy
  87501. */
  87502. constructor(
  87503. /**
  87504. * defines the bone name
  87505. */
  87506. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87507. /**
  87508. * Gets the current object class name.
  87509. * @return the class name
  87510. */
  87511. getClassName(): string;
  87512. /**
  87513. * Gets the parent skeleton
  87514. * @returns a skeleton
  87515. */
  87516. getSkeleton(): Skeleton;
  87517. /**
  87518. * Gets parent bone
  87519. * @returns a bone or null if the bone is the root of the bone hierarchy
  87520. */
  87521. getParent(): Nullable<Bone>;
  87522. /**
  87523. * Returns an array containing the root bones
  87524. * @returns an array containing the root bones
  87525. */
  87526. getChildren(): Array<Bone>;
  87527. /**
  87528. * Gets the node index in matrix array generated for rendering
  87529. * @returns the node index
  87530. */
  87531. getIndex(): number;
  87532. /**
  87533. * Sets the parent bone
  87534. * @param parent defines the parent (can be null if the bone is the root)
  87535. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87536. */
  87537. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87538. /**
  87539. * Gets the local matrix
  87540. * @returns a matrix
  87541. */
  87542. getLocalMatrix(): Matrix;
  87543. /**
  87544. * Gets the base matrix (initial matrix which remains unchanged)
  87545. * @returns a matrix
  87546. */
  87547. getBaseMatrix(): Matrix;
  87548. /**
  87549. * Gets the rest pose matrix
  87550. * @returns a matrix
  87551. */
  87552. getRestPose(): Matrix;
  87553. /**
  87554. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87555. */
  87556. getWorldMatrix(): Matrix;
  87557. /**
  87558. * Sets the local matrix to rest pose matrix
  87559. */
  87560. returnToRest(): void;
  87561. /**
  87562. * Gets the inverse of the absolute transform matrix.
  87563. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87564. * @returns a matrix
  87565. */
  87566. getInvertedAbsoluteTransform(): Matrix;
  87567. /**
  87568. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87569. * @returns a matrix
  87570. */
  87571. getAbsoluteTransform(): Matrix;
  87572. /**
  87573. * Links with the given transform node.
  87574. * The local matrix of this bone is copied from the transform node every frame.
  87575. * @param transformNode defines the transform node to link to
  87576. */
  87577. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87578. /**
  87579. * Gets the node used to drive the bone's transformation
  87580. * @returns a transform node or null
  87581. */
  87582. getTransformNode(): Nullable<TransformNode>;
  87583. /** Gets or sets current position (in local space) */
  87584. get position(): Vector3;
  87585. set position(newPosition: Vector3);
  87586. /** Gets or sets current rotation (in local space) */
  87587. get rotation(): Vector3;
  87588. set rotation(newRotation: Vector3);
  87589. /** Gets or sets current rotation quaternion (in local space) */
  87590. get rotationQuaternion(): Quaternion;
  87591. set rotationQuaternion(newRotation: Quaternion);
  87592. /** Gets or sets current scaling (in local space) */
  87593. get scaling(): Vector3;
  87594. set scaling(newScaling: Vector3);
  87595. /**
  87596. * Gets the animation properties override
  87597. */
  87598. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87599. private _decompose;
  87600. private _compose;
  87601. /**
  87602. * Update the base and local matrices
  87603. * @param matrix defines the new base or local matrix
  87604. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87605. * @param updateLocalMatrix defines if the local matrix should be updated
  87606. */
  87607. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87608. /** @hidden */
  87609. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87610. /**
  87611. * Flag the bone as dirty (Forcing it to update everything)
  87612. */
  87613. markAsDirty(): void;
  87614. /** @hidden */
  87615. _markAsDirtyAndCompose(): void;
  87616. private _markAsDirtyAndDecompose;
  87617. /**
  87618. * Translate the bone in local or world space
  87619. * @param vec The amount to translate the bone
  87620. * @param space The space that the translation is in
  87621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87622. */
  87623. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87624. /**
  87625. * Set the postion of the bone in local or world space
  87626. * @param position The position to set the bone
  87627. * @param space The space that the position is in
  87628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87629. */
  87630. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87631. /**
  87632. * Set the absolute position of the bone (world space)
  87633. * @param position The position to set the bone
  87634. * @param mesh The mesh that this bone is attached to
  87635. */
  87636. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87637. /**
  87638. * Scale the bone on the x, y and z axes (in local space)
  87639. * @param x The amount to scale the bone on the x axis
  87640. * @param y The amount to scale the bone on the y axis
  87641. * @param z The amount to scale the bone on the z axis
  87642. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87643. */
  87644. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87645. /**
  87646. * Set the bone scaling in local space
  87647. * @param scale defines the scaling vector
  87648. */
  87649. setScale(scale: Vector3): void;
  87650. /**
  87651. * Gets the current scaling in local space
  87652. * @returns the current scaling vector
  87653. */
  87654. getScale(): Vector3;
  87655. /**
  87656. * Gets the current scaling in local space and stores it in a target vector
  87657. * @param result defines the target vector
  87658. */
  87659. getScaleToRef(result: Vector3): void;
  87660. /**
  87661. * Set the yaw, pitch, and roll of the bone in local or world space
  87662. * @param yaw The rotation of the bone on the y axis
  87663. * @param pitch The rotation of the bone on the x axis
  87664. * @param roll The rotation of the bone on the z axis
  87665. * @param space The space that the axes of rotation are in
  87666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87667. */
  87668. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87669. /**
  87670. * Add a rotation to the bone on an axis in local or world space
  87671. * @param axis The axis to rotate the bone on
  87672. * @param amount The amount to rotate the bone
  87673. * @param space The space that the axis is in
  87674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87675. */
  87676. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87677. /**
  87678. * Set the rotation of the bone to a particular axis angle in local or world space
  87679. * @param axis The axis to rotate the bone on
  87680. * @param angle The angle that the bone should be rotated to
  87681. * @param space The space that the axis is in
  87682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87683. */
  87684. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87685. /**
  87686. * Set the euler rotation of the bone in local of world space
  87687. * @param rotation The euler rotation that the bone should be set to
  87688. * @param space The space that the rotation is in
  87689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87690. */
  87691. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87692. /**
  87693. * Set the quaternion rotation of the bone in local of world space
  87694. * @param quat The quaternion rotation that the bone should be set to
  87695. * @param space The space that the rotation is in
  87696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87697. */
  87698. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87699. /**
  87700. * Set the rotation matrix of the bone in local of world space
  87701. * @param rotMat The rotation matrix that the bone should be set to
  87702. * @param space The space that the rotation is in
  87703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87704. */
  87705. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87706. private _rotateWithMatrix;
  87707. private _getNegativeRotationToRef;
  87708. /**
  87709. * Get the position of the bone in local or world space
  87710. * @param space The space that the returned position is in
  87711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87712. * @returns The position of the bone
  87713. */
  87714. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87715. /**
  87716. * Copy the position of the bone to a vector3 in local or world space
  87717. * @param space The space that the returned position is in
  87718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87719. * @param result The vector3 to copy the position to
  87720. */
  87721. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87722. /**
  87723. * Get the absolute position of the bone (world space)
  87724. * @param mesh The mesh that this bone is attached to
  87725. * @returns The absolute position of the bone
  87726. */
  87727. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87728. /**
  87729. * Copy the absolute position of the bone (world space) to the result param
  87730. * @param mesh The mesh that this bone is attached to
  87731. * @param result The vector3 to copy the absolute position to
  87732. */
  87733. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87734. /**
  87735. * Compute the absolute transforms of this bone and its children
  87736. */
  87737. computeAbsoluteTransforms(): void;
  87738. /**
  87739. * Get the world direction from an axis that is in the local space of the bone
  87740. * @param localAxis The local direction that is used to compute the world direction
  87741. * @param mesh The mesh that this bone is attached to
  87742. * @returns The world direction
  87743. */
  87744. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87745. /**
  87746. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87747. * @param localAxis The local direction that is used to compute the world direction
  87748. * @param mesh The mesh that this bone is attached to
  87749. * @param result The vector3 that the world direction will be copied to
  87750. */
  87751. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87752. /**
  87753. * Get the euler rotation of the bone in local or world space
  87754. * @param space The space that the rotation should be in
  87755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87756. * @returns The euler rotation
  87757. */
  87758. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87759. /**
  87760. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87761. * @param space The space that the rotation should be in
  87762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87763. * @param result The vector3 that the rotation should be copied to
  87764. */
  87765. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87766. /**
  87767. * Get the quaternion rotation of the bone in either local or world space
  87768. * @param space The space that the rotation should be in
  87769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87770. * @returns The quaternion rotation
  87771. */
  87772. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87773. /**
  87774. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87775. * @param space The space that the rotation should be in
  87776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87777. * @param result The quaternion that the rotation should be copied to
  87778. */
  87779. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87780. /**
  87781. * Get the rotation matrix of the bone in local or world space
  87782. * @param space The space that the rotation should be in
  87783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87784. * @returns The rotation matrix
  87785. */
  87786. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87787. /**
  87788. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87789. * @param space The space that the rotation should be in
  87790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87791. * @param result The quaternion that the rotation should be copied to
  87792. */
  87793. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87794. /**
  87795. * Get the world position of a point that is in the local space of the bone
  87796. * @param position The local position
  87797. * @param mesh The mesh that this bone is attached to
  87798. * @returns The world position
  87799. */
  87800. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87801. /**
  87802. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87803. * @param position The local position
  87804. * @param mesh The mesh that this bone is attached to
  87805. * @param result The vector3 that the world position should be copied to
  87806. */
  87807. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87808. /**
  87809. * Get the local position of a point that is in world space
  87810. * @param position The world position
  87811. * @param mesh The mesh that this bone is attached to
  87812. * @returns The local position
  87813. */
  87814. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87815. /**
  87816. * Get the local position of a point that is in world space and copy it to the result param
  87817. * @param position The world position
  87818. * @param mesh The mesh that this bone is attached to
  87819. * @param result The vector3 that the local position should be copied to
  87820. */
  87821. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87822. }
  87823. }
  87824. declare module BABYLON {
  87825. /**
  87826. * Defines a runtime animation
  87827. */
  87828. export class RuntimeAnimation {
  87829. private _events;
  87830. /**
  87831. * The current frame of the runtime animation
  87832. */
  87833. private _currentFrame;
  87834. /**
  87835. * The animation used by the runtime animation
  87836. */
  87837. private _animation;
  87838. /**
  87839. * The target of the runtime animation
  87840. */
  87841. private _target;
  87842. /**
  87843. * The initiating animatable
  87844. */
  87845. private _host;
  87846. /**
  87847. * The original value of the runtime animation
  87848. */
  87849. private _originalValue;
  87850. /**
  87851. * The original blend value of the runtime animation
  87852. */
  87853. private _originalBlendValue;
  87854. /**
  87855. * The offsets cache of the runtime animation
  87856. */
  87857. private _offsetsCache;
  87858. /**
  87859. * The high limits cache of the runtime animation
  87860. */
  87861. private _highLimitsCache;
  87862. /**
  87863. * Specifies if the runtime animation has been stopped
  87864. */
  87865. private _stopped;
  87866. /**
  87867. * The blending factor of the runtime animation
  87868. */
  87869. private _blendingFactor;
  87870. /**
  87871. * The BabylonJS scene
  87872. */
  87873. private _scene;
  87874. /**
  87875. * The current value of the runtime animation
  87876. */
  87877. private _currentValue;
  87878. /** @hidden */
  87879. _animationState: _IAnimationState;
  87880. /**
  87881. * The active target of the runtime animation
  87882. */
  87883. private _activeTargets;
  87884. private _currentActiveTarget;
  87885. private _directTarget;
  87886. /**
  87887. * The target path of the runtime animation
  87888. */
  87889. private _targetPath;
  87890. /**
  87891. * The weight of the runtime animation
  87892. */
  87893. private _weight;
  87894. /**
  87895. * The ratio offset of the runtime animation
  87896. */
  87897. private _ratioOffset;
  87898. /**
  87899. * The previous delay of the runtime animation
  87900. */
  87901. private _previousDelay;
  87902. /**
  87903. * The previous ratio of the runtime animation
  87904. */
  87905. private _previousRatio;
  87906. private _enableBlending;
  87907. private _keys;
  87908. private _minFrame;
  87909. private _maxFrame;
  87910. private _minValue;
  87911. private _maxValue;
  87912. private _targetIsArray;
  87913. /**
  87914. * Gets the current frame of the runtime animation
  87915. */
  87916. get currentFrame(): number;
  87917. /**
  87918. * Gets the weight of the runtime animation
  87919. */
  87920. get weight(): number;
  87921. /**
  87922. * Gets the current value of the runtime animation
  87923. */
  87924. get currentValue(): any;
  87925. /**
  87926. * Gets the target path of the runtime animation
  87927. */
  87928. get targetPath(): string;
  87929. /**
  87930. * Gets the actual target of the runtime animation
  87931. */
  87932. get target(): any;
  87933. /** @hidden */
  87934. _onLoop: () => void;
  87935. /**
  87936. * Create a new RuntimeAnimation object
  87937. * @param target defines the target of the animation
  87938. * @param animation defines the source animation object
  87939. * @param scene defines the hosting scene
  87940. * @param host defines the initiating Animatable
  87941. */
  87942. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87943. private _preparePath;
  87944. /**
  87945. * Gets the animation from the runtime animation
  87946. */
  87947. get animation(): Animation;
  87948. /**
  87949. * Resets the runtime animation to the beginning
  87950. * @param restoreOriginal defines whether to restore the target property to the original value
  87951. */
  87952. reset(restoreOriginal?: boolean): void;
  87953. /**
  87954. * Specifies if the runtime animation is stopped
  87955. * @returns Boolean specifying if the runtime animation is stopped
  87956. */
  87957. isStopped(): boolean;
  87958. /**
  87959. * Disposes of the runtime animation
  87960. */
  87961. dispose(): void;
  87962. /**
  87963. * Apply the interpolated value to the target
  87964. * @param currentValue defines the value computed by the animation
  87965. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87966. */
  87967. setValue(currentValue: any, weight: number): void;
  87968. private _getOriginalValues;
  87969. private _setValue;
  87970. /**
  87971. * Gets the loop pmode of the runtime animation
  87972. * @returns Loop Mode
  87973. */
  87974. private _getCorrectLoopMode;
  87975. /**
  87976. * Move the current animation to a given frame
  87977. * @param frame defines the frame to move to
  87978. */
  87979. goToFrame(frame: number): void;
  87980. /**
  87981. * @hidden Internal use only
  87982. */
  87983. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87984. /**
  87985. * Execute the current animation
  87986. * @param delay defines the delay to add to the current frame
  87987. * @param from defines the lower bound of the animation range
  87988. * @param to defines the upper bound of the animation range
  87989. * @param loop defines if the current animation must loop
  87990. * @param speedRatio defines the current speed ratio
  87991. * @param weight defines the weight of the animation (default is -1 so no weight)
  87992. * @param onLoop optional callback called when animation loops
  87993. * @returns a boolean indicating if the animation is running
  87994. */
  87995. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87996. }
  87997. }
  87998. declare module BABYLON {
  87999. /**
  88000. * Class used to store an actual running animation
  88001. */
  88002. export class Animatable {
  88003. /** defines the target object */
  88004. target: any;
  88005. /** defines the starting frame number (default is 0) */
  88006. fromFrame: number;
  88007. /** defines the ending frame number (default is 100) */
  88008. toFrame: number;
  88009. /** defines if the animation must loop (default is false) */
  88010. loopAnimation: boolean;
  88011. /** defines a callback to call when animation ends if it is not looping */
  88012. onAnimationEnd?: (() => void) | null | undefined;
  88013. /** defines a callback to call when animation loops */
  88014. onAnimationLoop?: (() => void) | null | undefined;
  88015. private _localDelayOffset;
  88016. private _pausedDelay;
  88017. private _runtimeAnimations;
  88018. private _paused;
  88019. private _scene;
  88020. private _speedRatio;
  88021. private _weight;
  88022. private _syncRoot;
  88023. /**
  88024. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88025. * This will only apply for non looping animation (default is true)
  88026. */
  88027. disposeOnEnd: boolean;
  88028. /**
  88029. * Gets a boolean indicating if the animation has started
  88030. */
  88031. animationStarted: boolean;
  88032. /**
  88033. * Observer raised when the animation ends
  88034. */
  88035. onAnimationEndObservable: Observable<Animatable>;
  88036. /**
  88037. * Observer raised when the animation loops
  88038. */
  88039. onAnimationLoopObservable: Observable<Animatable>;
  88040. /**
  88041. * Gets the root Animatable used to synchronize and normalize animations
  88042. */
  88043. get syncRoot(): Nullable<Animatable>;
  88044. /**
  88045. * Gets the current frame of the first RuntimeAnimation
  88046. * Used to synchronize Animatables
  88047. */
  88048. get masterFrame(): number;
  88049. /**
  88050. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88051. */
  88052. get weight(): number;
  88053. set weight(value: number);
  88054. /**
  88055. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88056. */
  88057. get speedRatio(): number;
  88058. set speedRatio(value: number);
  88059. /**
  88060. * Creates a new Animatable
  88061. * @param scene defines the hosting scene
  88062. * @param target defines the target object
  88063. * @param fromFrame defines the starting frame number (default is 0)
  88064. * @param toFrame defines the ending frame number (default is 100)
  88065. * @param loopAnimation defines if the animation must loop (default is false)
  88066. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88067. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88068. * @param animations defines a group of animation to add to the new Animatable
  88069. * @param onAnimationLoop defines a callback to call when animation loops
  88070. */
  88071. constructor(scene: Scene,
  88072. /** defines the target object */
  88073. target: any,
  88074. /** defines the starting frame number (default is 0) */
  88075. fromFrame?: number,
  88076. /** defines the ending frame number (default is 100) */
  88077. toFrame?: number,
  88078. /** defines if the animation must loop (default is false) */
  88079. loopAnimation?: boolean, speedRatio?: number,
  88080. /** defines a callback to call when animation ends if it is not looping */
  88081. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88082. /** defines a callback to call when animation loops */
  88083. onAnimationLoop?: (() => void) | null | undefined);
  88084. /**
  88085. * Synchronize and normalize current Animatable with a source Animatable
  88086. * This is useful when using animation weights and when animations are not of the same length
  88087. * @param root defines the root Animatable to synchronize with
  88088. * @returns the current Animatable
  88089. */
  88090. syncWith(root: Animatable): Animatable;
  88091. /**
  88092. * Gets the list of runtime animations
  88093. * @returns an array of RuntimeAnimation
  88094. */
  88095. getAnimations(): RuntimeAnimation[];
  88096. /**
  88097. * Adds more animations to the current animatable
  88098. * @param target defines the target of the animations
  88099. * @param animations defines the new animations to add
  88100. */
  88101. appendAnimations(target: any, animations: Animation[]): void;
  88102. /**
  88103. * Gets the source animation for a specific property
  88104. * @param property defines the propertyu to look for
  88105. * @returns null or the source animation for the given property
  88106. */
  88107. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88108. /**
  88109. * Gets the runtime animation for a specific property
  88110. * @param property defines the propertyu to look for
  88111. * @returns null or the runtime animation for the given property
  88112. */
  88113. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88114. /**
  88115. * Resets the animatable to its original state
  88116. */
  88117. reset(): void;
  88118. /**
  88119. * Allows the animatable to blend with current running animations
  88120. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88121. * @param blendingSpeed defines the blending speed to use
  88122. */
  88123. enableBlending(blendingSpeed: number): void;
  88124. /**
  88125. * Disable animation blending
  88126. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88127. */
  88128. disableBlending(): void;
  88129. /**
  88130. * Jump directly to a given frame
  88131. * @param frame defines the frame to jump to
  88132. */
  88133. goToFrame(frame: number): void;
  88134. /**
  88135. * Pause the animation
  88136. */
  88137. pause(): void;
  88138. /**
  88139. * Restart the animation
  88140. */
  88141. restart(): void;
  88142. private _raiseOnAnimationEnd;
  88143. /**
  88144. * Stop and delete the current animation
  88145. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88146. * @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)
  88147. */
  88148. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88149. /**
  88150. * Wait asynchronously for the animation to end
  88151. * @returns a promise which will be fullfilled when the animation ends
  88152. */
  88153. waitAsync(): Promise<Animatable>;
  88154. /** @hidden */
  88155. _animate(delay: number): boolean;
  88156. }
  88157. interface Scene {
  88158. /** @hidden */
  88159. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88160. /** @hidden */
  88161. _processLateAnimationBindingsForMatrices(holder: {
  88162. totalWeight: number;
  88163. animations: RuntimeAnimation[];
  88164. originalValue: Matrix;
  88165. }): any;
  88166. /** @hidden */
  88167. _processLateAnimationBindingsForQuaternions(holder: {
  88168. totalWeight: number;
  88169. animations: RuntimeAnimation[];
  88170. originalValue: Quaternion;
  88171. }, refQuaternion: Quaternion): Quaternion;
  88172. /** @hidden */
  88173. _processLateAnimationBindings(): void;
  88174. /**
  88175. * Will start the animation sequence of a given target
  88176. * @param target defines the target
  88177. * @param from defines from which frame should animation start
  88178. * @param to defines until which frame should animation run.
  88179. * @param weight defines the weight to apply to the animation (1.0 by default)
  88180. * @param loop defines if the animation loops
  88181. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88182. * @param onAnimationEnd defines the function to be executed when the animation ends
  88183. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88184. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88185. * @param onAnimationLoop defines the callback to call when an animation loops
  88186. * @returns the animatable object created for this animation
  88187. */
  88188. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88189. /**
  88190. * Will start the animation sequence of a given target
  88191. * @param target defines the target
  88192. * @param from defines from which frame should animation start
  88193. * @param to defines until which frame should animation run.
  88194. * @param loop defines if the animation loops
  88195. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88196. * @param onAnimationEnd defines the function to be executed when the animation ends
  88197. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88198. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88199. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88200. * @param onAnimationLoop defines the callback to call when an animation loops
  88201. * @returns the animatable object created for this animation
  88202. */
  88203. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88204. /**
  88205. * Will start the animation sequence of a given target and its hierarchy
  88206. * @param target defines the target
  88207. * @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.
  88208. * @param from defines from which frame should animation start
  88209. * @param to defines until which frame should animation run.
  88210. * @param loop defines if the animation loops
  88211. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88212. * @param onAnimationEnd defines the function to be executed when the animation ends
  88213. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88214. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88215. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88216. * @param onAnimationLoop defines the callback to call when an animation loops
  88217. * @returns the list of created animatables
  88218. */
  88219. 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[];
  88220. /**
  88221. * Begin a new animation on a given node
  88222. * @param target defines the target where the animation will take place
  88223. * @param animations defines the list of animations to start
  88224. * @param from defines the initial value
  88225. * @param to defines the final value
  88226. * @param loop defines if you want animation to loop (off by default)
  88227. * @param speedRatio defines the speed ratio to apply to all animations
  88228. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88229. * @param onAnimationLoop defines the callback to call when an animation loops
  88230. * @returns the list of created animatables
  88231. */
  88232. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88233. /**
  88234. * Begin a new animation on a given node and its hierarchy
  88235. * @param target defines the root node where the animation will take place
  88236. * @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.
  88237. * @param animations defines the list of animations to start
  88238. * @param from defines the initial value
  88239. * @param to defines the final value
  88240. * @param loop defines if you want animation to loop (off by default)
  88241. * @param speedRatio defines the speed ratio to apply to all animations
  88242. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88243. * @param onAnimationLoop defines the callback to call when an animation loops
  88244. * @returns the list of animatables created for all nodes
  88245. */
  88246. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88247. /**
  88248. * Gets the animatable associated with a specific target
  88249. * @param target defines the target of the animatable
  88250. * @returns the required animatable if found
  88251. */
  88252. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88253. /**
  88254. * Gets all animatables associated with a given target
  88255. * @param target defines the target to look animatables for
  88256. * @returns an array of Animatables
  88257. */
  88258. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88259. /**
  88260. * Stops and removes all animations that have been applied to the scene
  88261. */
  88262. stopAllAnimations(): void;
  88263. /**
  88264. * Gets the current delta time used by animation engine
  88265. */
  88266. deltaTime: number;
  88267. }
  88268. interface Bone {
  88269. /**
  88270. * Copy an animation range from another bone
  88271. * @param source defines the source bone
  88272. * @param rangeName defines the range name to copy
  88273. * @param frameOffset defines the frame offset
  88274. * @param rescaleAsRequired defines if rescaling must be applied if required
  88275. * @param skelDimensionsRatio defines the scaling ratio
  88276. * @returns true if operation was successful
  88277. */
  88278. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88279. }
  88280. }
  88281. declare module BABYLON {
  88282. /**
  88283. * Class used to handle skinning animations
  88284. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88285. */
  88286. export class Skeleton implements IAnimatable {
  88287. /** defines the skeleton name */
  88288. name: string;
  88289. /** defines the skeleton Id */
  88290. id: string;
  88291. /**
  88292. * Defines the list of child bones
  88293. */
  88294. bones: Bone[];
  88295. /**
  88296. * Defines an estimate of the dimension of the skeleton at rest
  88297. */
  88298. dimensionsAtRest: Vector3;
  88299. /**
  88300. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88301. */
  88302. needInitialSkinMatrix: boolean;
  88303. /**
  88304. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88305. */
  88306. overrideMesh: Nullable<AbstractMesh>;
  88307. /**
  88308. * Gets the list of animations attached to this skeleton
  88309. */
  88310. animations: Array<Animation>;
  88311. private _scene;
  88312. private _isDirty;
  88313. private _transformMatrices;
  88314. private _transformMatrixTexture;
  88315. private _meshesWithPoseMatrix;
  88316. private _animatables;
  88317. private _identity;
  88318. private _synchronizedWithMesh;
  88319. private _ranges;
  88320. private _lastAbsoluteTransformsUpdateId;
  88321. private _canUseTextureForBones;
  88322. private _uniqueId;
  88323. /** @hidden */
  88324. _numBonesWithLinkedTransformNode: number;
  88325. /** @hidden */
  88326. _hasWaitingData: Nullable<boolean>;
  88327. /**
  88328. * Specifies if the skeleton should be serialized
  88329. */
  88330. doNotSerialize: boolean;
  88331. private _useTextureToStoreBoneMatrices;
  88332. /**
  88333. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88334. * Please note that this option is not available if the hardware does not support it
  88335. */
  88336. get useTextureToStoreBoneMatrices(): boolean;
  88337. set useTextureToStoreBoneMatrices(value: boolean);
  88338. private _animationPropertiesOverride;
  88339. /**
  88340. * Gets or sets the animation properties override
  88341. */
  88342. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88343. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88344. /**
  88345. * List of inspectable custom properties (used by the Inspector)
  88346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88347. */
  88348. inspectableCustomProperties: IInspectable[];
  88349. /**
  88350. * An observable triggered before computing the skeleton's matrices
  88351. */
  88352. onBeforeComputeObservable: Observable<Skeleton>;
  88353. /**
  88354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88355. */
  88356. get isUsingTextureForMatrices(): boolean;
  88357. /**
  88358. * Gets the unique ID of this skeleton
  88359. */
  88360. get uniqueId(): number;
  88361. /**
  88362. * Creates a new skeleton
  88363. * @param name defines the skeleton name
  88364. * @param id defines the skeleton Id
  88365. * @param scene defines the hosting scene
  88366. */
  88367. constructor(
  88368. /** defines the skeleton name */
  88369. name: string,
  88370. /** defines the skeleton Id */
  88371. id: string, scene: Scene);
  88372. /**
  88373. * Gets the current object class name.
  88374. * @return the class name
  88375. */
  88376. getClassName(): string;
  88377. /**
  88378. * Returns an array containing the root bones
  88379. * @returns an array containing the root bones
  88380. */
  88381. getChildren(): Array<Bone>;
  88382. /**
  88383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88385. * @returns a Float32Array containing matrices data
  88386. */
  88387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88388. /**
  88389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88391. * @returns a raw texture containing the data
  88392. */
  88393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88394. /**
  88395. * Gets the current hosting scene
  88396. * @returns a scene object
  88397. */
  88398. getScene(): Scene;
  88399. /**
  88400. * Gets a string representing the current skeleton data
  88401. * @param fullDetails defines a boolean indicating if we want a verbose version
  88402. * @returns a string representing the current skeleton data
  88403. */
  88404. toString(fullDetails?: boolean): string;
  88405. /**
  88406. * Get bone's index searching by name
  88407. * @param name defines bone's name to search for
  88408. * @return the indice of the bone. Returns -1 if not found
  88409. */
  88410. getBoneIndexByName(name: string): number;
  88411. /**
  88412. * Creater a new animation range
  88413. * @param name defines the name of the range
  88414. * @param from defines the start key
  88415. * @param to defines the end key
  88416. */
  88417. createAnimationRange(name: string, from: number, to: number): void;
  88418. /**
  88419. * Delete a specific animation range
  88420. * @param name defines the name of the range
  88421. * @param deleteFrames defines if frames must be removed as well
  88422. */
  88423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88424. /**
  88425. * Gets a specific animation range
  88426. * @param name defines the name of the range to look for
  88427. * @returns the requested animation range or null if not found
  88428. */
  88429. getAnimationRange(name: string): Nullable<AnimationRange>;
  88430. /**
  88431. * Gets the list of all animation ranges defined on this skeleton
  88432. * @returns an array
  88433. */
  88434. getAnimationRanges(): Nullable<AnimationRange>[];
  88435. /**
  88436. * Copy animation range from a source skeleton.
  88437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88438. * @param source defines the source skeleton
  88439. * @param name defines the name of the range to copy
  88440. * @param rescaleAsRequired defines if rescaling must be applied if required
  88441. * @returns true if operation was successful
  88442. */
  88443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88444. /**
  88445. * Forces the skeleton to go to rest pose
  88446. */
  88447. returnToRest(): void;
  88448. private _getHighestAnimationFrame;
  88449. /**
  88450. * Begin a specific animation range
  88451. * @param name defines the name of the range to start
  88452. * @param loop defines if looping must be turned on (false by default)
  88453. * @param speedRatio defines the speed ratio to apply (1 by default)
  88454. * @param onAnimationEnd defines a callback which will be called when animation will end
  88455. * @returns a new animatable
  88456. */
  88457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88458. /** @hidden */
  88459. _markAsDirty(): void;
  88460. /** @hidden */
  88461. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88462. /** @hidden */
  88463. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88464. private _computeTransformMatrices;
  88465. /**
  88466. * Build all resources required to render a skeleton
  88467. */
  88468. prepare(): void;
  88469. /**
  88470. * Gets the list of animatables currently running for this skeleton
  88471. * @returns an array of animatables
  88472. */
  88473. getAnimatables(): IAnimatable[];
  88474. /**
  88475. * Clone the current skeleton
  88476. * @param name defines the name of the new skeleton
  88477. * @param id defines the id of the new skeleton
  88478. * @returns the new skeleton
  88479. */
  88480. clone(name: string, id?: string): Skeleton;
  88481. /**
  88482. * Enable animation blending for this skeleton
  88483. * @param blendingSpeed defines the blending speed to apply
  88484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88485. */
  88486. enableBlending(blendingSpeed?: number): void;
  88487. /**
  88488. * Releases all resources associated with the current skeleton
  88489. */
  88490. dispose(): void;
  88491. /**
  88492. * Serialize the skeleton in a JSON object
  88493. * @returns a JSON object
  88494. */
  88495. serialize(): any;
  88496. /**
  88497. * Creates a new skeleton from serialized data
  88498. * @param parsedSkeleton defines the serialized data
  88499. * @param scene defines the hosting scene
  88500. * @returns a new skeleton
  88501. */
  88502. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88503. /**
  88504. * Compute all node absolute transforms
  88505. * @param forceUpdate defines if computation must be done even if cache is up to date
  88506. */
  88507. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88508. /**
  88509. * Gets the root pose matrix
  88510. * @returns a matrix
  88511. */
  88512. getPoseMatrix(): Nullable<Matrix>;
  88513. /**
  88514. * Sorts bones per internal index
  88515. */
  88516. sortBones(): void;
  88517. private _sortBones;
  88518. }
  88519. }
  88520. declare module BABYLON {
  88521. /**
  88522. * Creates an instance based on a source mesh.
  88523. */
  88524. export class InstancedMesh extends AbstractMesh {
  88525. private _sourceMesh;
  88526. private _currentLOD;
  88527. /** @hidden */
  88528. _indexInSourceMeshInstanceArray: number;
  88529. constructor(name: string, source: Mesh);
  88530. /**
  88531. * Returns the string "InstancedMesh".
  88532. */
  88533. getClassName(): string;
  88534. /** Gets the list of lights affecting that mesh */
  88535. get lightSources(): Light[];
  88536. _resyncLightSources(): void;
  88537. _resyncLightSource(light: Light): void;
  88538. _removeLightSource(light: Light, dispose: boolean): void;
  88539. /**
  88540. * If the source mesh receives shadows
  88541. */
  88542. get receiveShadows(): boolean;
  88543. /**
  88544. * The material of the source mesh
  88545. */
  88546. get material(): Nullable<Material>;
  88547. /**
  88548. * Visibility of the source mesh
  88549. */
  88550. get visibility(): number;
  88551. /**
  88552. * Skeleton of the source mesh
  88553. */
  88554. get skeleton(): Nullable<Skeleton>;
  88555. /**
  88556. * Rendering ground id of the source mesh
  88557. */
  88558. get renderingGroupId(): number;
  88559. set renderingGroupId(value: number);
  88560. /**
  88561. * Returns the total number of vertices (integer).
  88562. */
  88563. getTotalVertices(): number;
  88564. /**
  88565. * Returns a positive integer : the total number of indices in this mesh geometry.
  88566. * @returns the numner of indices or zero if the mesh has no geometry.
  88567. */
  88568. getTotalIndices(): number;
  88569. /**
  88570. * The source mesh of the instance
  88571. */
  88572. get sourceMesh(): Mesh;
  88573. /**
  88574. * Is this node ready to be used/rendered
  88575. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88576. * @return {boolean} is it ready
  88577. */
  88578. isReady(completeCheck?: boolean): boolean;
  88579. /**
  88580. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88581. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88582. * @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.
  88583. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88584. */
  88585. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88586. /**
  88587. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88588. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88589. * The `data` are either a numeric array either a Float32Array.
  88590. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88591. * 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).
  88592. * Note that a new underlying VertexBuffer object is created each call.
  88593. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88594. *
  88595. * Possible `kind` values :
  88596. * - VertexBuffer.PositionKind
  88597. * - VertexBuffer.UVKind
  88598. * - VertexBuffer.UV2Kind
  88599. * - VertexBuffer.UV3Kind
  88600. * - VertexBuffer.UV4Kind
  88601. * - VertexBuffer.UV5Kind
  88602. * - VertexBuffer.UV6Kind
  88603. * - VertexBuffer.ColorKind
  88604. * - VertexBuffer.MatricesIndicesKind
  88605. * - VertexBuffer.MatricesIndicesExtraKind
  88606. * - VertexBuffer.MatricesWeightsKind
  88607. * - VertexBuffer.MatricesWeightsExtraKind
  88608. *
  88609. * Returns the Mesh.
  88610. */
  88611. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88612. /**
  88613. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88614. * If the mesh has no geometry, it is simply returned as it is.
  88615. * The `data` are either a numeric array either a Float32Array.
  88616. * No new underlying VertexBuffer object is created.
  88617. * 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.
  88618. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88619. *
  88620. * Possible `kind` values :
  88621. * - VertexBuffer.PositionKind
  88622. * - VertexBuffer.UVKind
  88623. * - VertexBuffer.UV2Kind
  88624. * - VertexBuffer.UV3Kind
  88625. * - VertexBuffer.UV4Kind
  88626. * - VertexBuffer.UV5Kind
  88627. * - VertexBuffer.UV6Kind
  88628. * - VertexBuffer.ColorKind
  88629. * - VertexBuffer.MatricesIndicesKind
  88630. * - VertexBuffer.MatricesIndicesExtraKind
  88631. * - VertexBuffer.MatricesWeightsKind
  88632. * - VertexBuffer.MatricesWeightsExtraKind
  88633. *
  88634. * Returns the Mesh.
  88635. */
  88636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88637. /**
  88638. * Sets the mesh indices.
  88639. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88640. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88641. * This method creates a new index buffer each call.
  88642. * Returns the Mesh.
  88643. */
  88644. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88645. /**
  88646. * Boolean : True if the mesh owns the requested kind of data.
  88647. */
  88648. isVerticesDataPresent(kind: string): boolean;
  88649. /**
  88650. * Returns an array of indices (IndicesArray).
  88651. */
  88652. getIndices(): Nullable<IndicesArray>;
  88653. get _positions(): Nullable<Vector3[]>;
  88654. /**
  88655. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88656. * This means the mesh underlying bounding box and sphere are recomputed.
  88657. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88658. * @returns the current mesh
  88659. */
  88660. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88661. /** @hidden */
  88662. _preActivate(): InstancedMesh;
  88663. /** @hidden */
  88664. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88665. /** @hidden */
  88666. _postActivate(): void;
  88667. getWorldMatrix(): Matrix;
  88668. get isAnInstance(): boolean;
  88669. /**
  88670. * Returns the current associated LOD AbstractMesh.
  88671. */
  88672. getLOD(camera: Camera): AbstractMesh;
  88673. /** @hidden */
  88674. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88675. /** @hidden */
  88676. _syncSubMeshes(): InstancedMesh;
  88677. /** @hidden */
  88678. _generatePointsArray(): boolean;
  88679. /**
  88680. * Creates a new InstancedMesh from the current mesh.
  88681. * - name (string) : the cloned mesh name
  88682. * - newParent (optional Node) : the optional Node to parent the clone to.
  88683. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88684. *
  88685. * Returns the clone.
  88686. */
  88687. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88688. /**
  88689. * Disposes the InstancedMesh.
  88690. * Returns nothing.
  88691. */
  88692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88693. }
  88694. interface Mesh {
  88695. /**
  88696. * Register a custom buffer that will be instanced
  88697. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88698. * @param kind defines the buffer kind
  88699. * @param stride defines the stride in floats
  88700. */
  88701. registerInstancedBuffer(kind: string, stride: number): void;
  88702. /** @hidden */
  88703. _userInstancedBuffersStorage: {
  88704. data: {
  88705. [key: string]: Float32Array;
  88706. };
  88707. sizes: {
  88708. [key: string]: number;
  88709. };
  88710. vertexBuffers: {
  88711. [key: string]: Nullable<VertexBuffer>;
  88712. };
  88713. strides: {
  88714. [key: string]: number;
  88715. };
  88716. };
  88717. }
  88718. interface AbstractMesh {
  88719. /**
  88720. * Object used to store instanced buffers defined by user
  88721. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88722. */
  88723. instancedBuffers: {
  88724. [key: string]: any;
  88725. };
  88726. }
  88727. }
  88728. declare module BABYLON {
  88729. /**
  88730. * Defines the options associated with the creation of a shader material.
  88731. */
  88732. export interface IShaderMaterialOptions {
  88733. /**
  88734. * Does the material work in alpha blend mode
  88735. */
  88736. needAlphaBlending: boolean;
  88737. /**
  88738. * Does the material work in alpha test mode
  88739. */
  88740. needAlphaTesting: boolean;
  88741. /**
  88742. * The list of attribute names used in the shader
  88743. */
  88744. attributes: string[];
  88745. /**
  88746. * The list of unifrom names used in the shader
  88747. */
  88748. uniforms: string[];
  88749. /**
  88750. * The list of UBO names used in the shader
  88751. */
  88752. uniformBuffers: string[];
  88753. /**
  88754. * The list of sampler names used in the shader
  88755. */
  88756. samplers: string[];
  88757. /**
  88758. * The list of defines used in the shader
  88759. */
  88760. defines: string[];
  88761. }
  88762. /**
  88763. * 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.
  88764. *
  88765. * This returned material effects how the mesh will look based on the code in the shaders.
  88766. *
  88767. * @see http://doc.babylonjs.com/how_to/shader_material
  88768. */
  88769. export class ShaderMaterial extends Material {
  88770. private _shaderPath;
  88771. private _options;
  88772. private _textures;
  88773. private _textureArrays;
  88774. private _floats;
  88775. private _ints;
  88776. private _floatsArrays;
  88777. private _colors3;
  88778. private _colors3Arrays;
  88779. private _colors4;
  88780. private _colors4Arrays;
  88781. private _vectors2;
  88782. private _vectors3;
  88783. private _vectors4;
  88784. private _matrices;
  88785. private _matrixArrays;
  88786. private _matrices3x3;
  88787. private _matrices2x2;
  88788. private _vectors2Arrays;
  88789. private _vectors3Arrays;
  88790. private _vectors4Arrays;
  88791. private _cachedWorldViewMatrix;
  88792. private _cachedWorldViewProjectionMatrix;
  88793. private _renderId;
  88794. private _multiview;
  88795. /**
  88796. * Instantiate a new shader material.
  88797. * 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.
  88798. * This returned material effects how the mesh will look based on the code in the shaders.
  88799. * @see http://doc.babylonjs.com/how_to/shader_material
  88800. * @param name Define the name of the material in the scene
  88801. * @param scene Define the scene the material belongs to
  88802. * @param shaderPath Defines the route to the shader code in one of three ways:
  88803. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88804. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88805. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88806. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88807. * @param options Define the options used to create the shader
  88808. */
  88809. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88810. /**
  88811. * Gets the shader path used to define the shader code
  88812. * It can be modified to trigger a new compilation
  88813. */
  88814. get shaderPath(): any;
  88815. /**
  88816. * Sets the shader path used to define the shader code
  88817. * It can be modified to trigger a new compilation
  88818. */
  88819. set shaderPath(shaderPath: any);
  88820. /**
  88821. * Gets the options used to compile the shader.
  88822. * They can be modified to trigger a new compilation
  88823. */
  88824. get options(): IShaderMaterialOptions;
  88825. /**
  88826. * Gets the current class name of the material e.g. "ShaderMaterial"
  88827. * Mainly use in serialization.
  88828. * @returns the class name
  88829. */
  88830. getClassName(): string;
  88831. /**
  88832. * Specifies if the material will require alpha blending
  88833. * @returns a boolean specifying if alpha blending is needed
  88834. */
  88835. needAlphaBlending(): boolean;
  88836. /**
  88837. * Specifies if this material should be rendered in alpha test mode
  88838. * @returns a boolean specifying if an alpha test is needed.
  88839. */
  88840. needAlphaTesting(): boolean;
  88841. private _checkUniform;
  88842. /**
  88843. * Set a texture in the shader.
  88844. * @param name Define the name of the uniform samplers as defined in the shader
  88845. * @param texture Define the texture to bind to this sampler
  88846. * @return the material itself allowing "fluent" like uniform updates
  88847. */
  88848. setTexture(name: string, texture: Texture): ShaderMaterial;
  88849. /**
  88850. * Set a texture array in the shader.
  88851. * @param name Define the name of the uniform sampler array as defined in the shader
  88852. * @param textures Define the list of textures to bind to this sampler
  88853. * @return the material itself allowing "fluent" like uniform updates
  88854. */
  88855. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88856. /**
  88857. * Set a float in the shader.
  88858. * @param name Define the name of the uniform as defined in the shader
  88859. * @param value Define the value to give to the uniform
  88860. * @return the material itself allowing "fluent" like uniform updates
  88861. */
  88862. setFloat(name: string, value: number): ShaderMaterial;
  88863. /**
  88864. * Set a int in the shader.
  88865. * @param name Define the name of the uniform as defined in the shader
  88866. * @param value Define the value to give to the uniform
  88867. * @return the material itself allowing "fluent" like uniform updates
  88868. */
  88869. setInt(name: string, value: number): ShaderMaterial;
  88870. /**
  88871. * Set an array of floats in the shader.
  88872. * @param name Define the name of the uniform as defined in the shader
  88873. * @param value Define the value to give to the uniform
  88874. * @return the material itself allowing "fluent" like uniform updates
  88875. */
  88876. setFloats(name: string, value: number[]): ShaderMaterial;
  88877. /**
  88878. * Set a vec3 in the shader from a Color3.
  88879. * @param name Define the name of the uniform as defined in the shader
  88880. * @param value Define the value to give to the uniform
  88881. * @return the material itself allowing "fluent" like uniform updates
  88882. */
  88883. setColor3(name: string, value: Color3): ShaderMaterial;
  88884. /**
  88885. * Set a vec3 array in the shader from a Color3 array.
  88886. * @param name Define the name of the uniform as defined in the shader
  88887. * @param value Define the value to give to the uniform
  88888. * @return the material itself allowing "fluent" like uniform updates
  88889. */
  88890. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88891. /**
  88892. * Set a vec4 in the shader from a Color4.
  88893. * @param name Define the name of the uniform as defined in the shader
  88894. * @param value Define the value to give to the uniform
  88895. * @return the material itself allowing "fluent" like uniform updates
  88896. */
  88897. setColor4(name: string, value: Color4): ShaderMaterial;
  88898. /**
  88899. * Set a vec4 array in the shader from a Color4 array.
  88900. * @param name Define the name of the uniform as defined in the shader
  88901. * @param value Define the value to give to the uniform
  88902. * @return the material itself allowing "fluent" like uniform updates
  88903. */
  88904. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88905. /**
  88906. * Set a vec2 in the shader from a Vector2.
  88907. * @param name Define the name of the uniform as defined in the shader
  88908. * @param value Define the value to give to the uniform
  88909. * @return the material itself allowing "fluent" like uniform updates
  88910. */
  88911. setVector2(name: string, value: Vector2): ShaderMaterial;
  88912. /**
  88913. * Set a vec3 in the shader from a Vector3.
  88914. * @param name Define the name of the uniform as defined in the shader
  88915. * @param value Define the value to give to the uniform
  88916. * @return the material itself allowing "fluent" like uniform updates
  88917. */
  88918. setVector3(name: string, value: Vector3): ShaderMaterial;
  88919. /**
  88920. * Set a vec4 in the shader from a Vector4.
  88921. * @param name Define the name of the uniform as defined in the shader
  88922. * @param value Define the value to give to the uniform
  88923. * @return the material itself allowing "fluent" like uniform updates
  88924. */
  88925. setVector4(name: string, value: Vector4): ShaderMaterial;
  88926. /**
  88927. * Set a mat4 in the shader from a Matrix.
  88928. * @param name Define the name of the uniform as defined in the shader
  88929. * @param value Define the value to give to the uniform
  88930. * @return the material itself allowing "fluent" like uniform updates
  88931. */
  88932. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88933. /**
  88934. * Set a float32Array in the shader from a matrix array.
  88935. * @param name Define the name of the uniform as defined in the shader
  88936. * @param value Define the value to give to the uniform
  88937. * @return the material itself allowing "fluent" like uniform updates
  88938. */
  88939. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88940. /**
  88941. * Set a mat3 in the shader from a Float32Array.
  88942. * @param name Define the name of the uniform as defined in the shader
  88943. * @param value Define the value to give to the uniform
  88944. * @return the material itself allowing "fluent" like uniform updates
  88945. */
  88946. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88947. /**
  88948. * Set a mat2 in the shader from a Float32Array.
  88949. * @param name Define the name of the uniform as defined in the shader
  88950. * @param value Define the value to give to the uniform
  88951. * @return the material itself allowing "fluent" like uniform updates
  88952. */
  88953. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88954. /**
  88955. * Set a vec2 array in the shader from a number array.
  88956. * @param name Define the name of the uniform as defined in the shader
  88957. * @param value Define the value to give to the uniform
  88958. * @return the material itself allowing "fluent" like uniform updates
  88959. */
  88960. setArray2(name: string, value: number[]): ShaderMaterial;
  88961. /**
  88962. * Set a vec3 array in the shader from a number array.
  88963. * @param name Define the name of the uniform as defined in the shader
  88964. * @param value Define the value to give to the uniform
  88965. * @return the material itself allowing "fluent" like uniform updates
  88966. */
  88967. setArray3(name: string, value: number[]): ShaderMaterial;
  88968. /**
  88969. * Set a vec4 array in the shader from a number array.
  88970. * @param name Define the name of the uniform as defined in the shader
  88971. * @param value Define the value to give to the uniform
  88972. * @return the material itself allowing "fluent" like uniform updates
  88973. */
  88974. setArray4(name: string, value: number[]): ShaderMaterial;
  88975. private _checkCache;
  88976. /**
  88977. * Specifies that the submesh is ready to be used
  88978. * @param mesh defines the mesh to check
  88979. * @param subMesh defines which submesh to check
  88980. * @param useInstances specifies that instances should be used
  88981. * @returns a boolean indicating that the submesh is ready or not
  88982. */
  88983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88984. /**
  88985. * Checks if the material is ready to render the requested mesh
  88986. * @param mesh Define the mesh to render
  88987. * @param useInstances Define whether or not the material is used with instances
  88988. * @returns true if ready, otherwise false
  88989. */
  88990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88991. /**
  88992. * Binds the world matrix to the material
  88993. * @param world defines the world transformation matrix
  88994. */
  88995. bindOnlyWorldMatrix(world: Matrix): void;
  88996. /**
  88997. * Binds the material to the mesh
  88998. * @param world defines the world transformation matrix
  88999. * @param mesh defines the mesh to bind the material to
  89000. */
  89001. bind(world: Matrix, mesh?: Mesh): void;
  89002. /**
  89003. * Gets the active textures from the material
  89004. * @returns an array of textures
  89005. */
  89006. getActiveTextures(): BaseTexture[];
  89007. /**
  89008. * Specifies if the material uses a texture
  89009. * @param texture defines the texture to check against the material
  89010. * @returns a boolean specifying if the material uses the texture
  89011. */
  89012. hasTexture(texture: BaseTexture): boolean;
  89013. /**
  89014. * Makes a duplicate of the material, and gives it a new name
  89015. * @param name defines the new name for the duplicated material
  89016. * @returns the cloned material
  89017. */
  89018. clone(name: string): ShaderMaterial;
  89019. /**
  89020. * Disposes the material
  89021. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89022. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89023. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89024. */
  89025. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89026. /**
  89027. * Serializes this material in a JSON representation
  89028. * @returns the serialized material object
  89029. */
  89030. serialize(): any;
  89031. /**
  89032. * Creates a shader material from parsed shader material data
  89033. * @param source defines the JSON represnetation of the material
  89034. * @param scene defines the hosting scene
  89035. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89036. * @returns a new material
  89037. */
  89038. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89039. }
  89040. }
  89041. declare module BABYLON {
  89042. /** @hidden */
  89043. export var colorPixelShader: {
  89044. name: string;
  89045. shader: string;
  89046. };
  89047. }
  89048. declare module BABYLON {
  89049. /** @hidden */
  89050. export var colorVertexShader: {
  89051. name: string;
  89052. shader: string;
  89053. };
  89054. }
  89055. declare module BABYLON {
  89056. /**
  89057. * Line mesh
  89058. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89059. */
  89060. export class LinesMesh extends Mesh {
  89061. /**
  89062. * If vertex color should be applied to the mesh
  89063. */
  89064. readonly useVertexColor?: boolean | undefined;
  89065. /**
  89066. * If vertex alpha should be applied to the mesh
  89067. */
  89068. readonly useVertexAlpha?: boolean | undefined;
  89069. /**
  89070. * Color of the line (Default: White)
  89071. */
  89072. color: Color3;
  89073. /**
  89074. * Alpha of the line (Default: 1)
  89075. */
  89076. alpha: number;
  89077. /**
  89078. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89079. * This margin is expressed in world space coordinates, so its value may vary.
  89080. * Default value is 0.1
  89081. */
  89082. intersectionThreshold: number;
  89083. private _colorShader;
  89084. private color4;
  89085. /**
  89086. * Creates a new LinesMesh
  89087. * @param name defines the name
  89088. * @param scene defines the hosting scene
  89089. * @param parent defines the parent mesh if any
  89090. * @param source defines the optional source LinesMesh used to clone data from
  89091. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89092. * When false, achieved by calling a clone(), also passing False.
  89093. * This will make creation of children, recursive.
  89094. * @param useVertexColor defines if this LinesMesh supports vertex color
  89095. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89096. */
  89097. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89098. /**
  89099. * If vertex color should be applied to the mesh
  89100. */
  89101. useVertexColor?: boolean | undefined,
  89102. /**
  89103. * If vertex alpha should be applied to the mesh
  89104. */
  89105. useVertexAlpha?: boolean | undefined);
  89106. private _addClipPlaneDefine;
  89107. private _removeClipPlaneDefine;
  89108. isReady(): boolean;
  89109. /**
  89110. * Returns the string "LineMesh"
  89111. */
  89112. getClassName(): string;
  89113. /**
  89114. * @hidden
  89115. */
  89116. get material(): Material;
  89117. /**
  89118. * @hidden
  89119. */
  89120. set material(value: Material);
  89121. /**
  89122. * @hidden
  89123. */
  89124. get checkCollisions(): boolean;
  89125. /** @hidden */
  89126. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89127. /** @hidden */
  89128. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89129. /**
  89130. * Disposes of the line mesh
  89131. * @param doNotRecurse If children should be disposed
  89132. */
  89133. dispose(doNotRecurse?: boolean): void;
  89134. /**
  89135. * Returns a new LineMesh object cloned from the current one.
  89136. */
  89137. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89138. /**
  89139. * Creates a new InstancedLinesMesh object from the mesh model.
  89140. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89141. * @param name defines the name of the new instance
  89142. * @returns a new InstancedLinesMesh
  89143. */
  89144. createInstance(name: string): InstancedLinesMesh;
  89145. }
  89146. /**
  89147. * Creates an instance based on a source LinesMesh
  89148. */
  89149. export class InstancedLinesMesh extends InstancedMesh {
  89150. /**
  89151. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89152. * This margin is expressed in world space coordinates, so its value may vary.
  89153. * Initilized with the intersectionThreshold value of the source LinesMesh
  89154. */
  89155. intersectionThreshold: number;
  89156. constructor(name: string, source: LinesMesh);
  89157. /**
  89158. * Returns the string "InstancedLinesMesh".
  89159. */
  89160. getClassName(): string;
  89161. }
  89162. }
  89163. declare module BABYLON {
  89164. /** @hidden */
  89165. export var linePixelShader: {
  89166. name: string;
  89167. shader: string;
  89168. };
  89169. }
  89170. declare module BABYLON {
  89171. /** @hidden */
  89172. export var lineVertexShader: {
  89173. name: string;
  89174. shader: string;
  89175. };
  89176. }
  89177. declare module BABYLON {
  89178. interface AbstractMesh {
  89179. /**
  89180. * Gets the edgesRenderer associated with the mesh
  89181. */
  89182. edgesRenderer: Nullable<EdgesRenderer>;
  89183. }
  89184. interface LinesMesh {
  89185. /**
  89186. * Enables the edge rendering mode on the mesh.
  89187. * This mode makes the mesh edges visible
  89188. * @param epsilon defines the maximal distance between two angles to detect a face
  89189. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89190. * @returns the currentAbstractMesh
  89191. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89192. */
  89193. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89194. }
  89195. interface InstancedLinesMesh {
  89196. /**
  89197. * Enables the edge rendering mode on the mesh.
  89198. * This mode makes the mesh edges visible
  89199. * @param epsilon defines the maximal distance between two angles to detect a face
  89200. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89201. * @returns the current InstancedLinesMesh
  89202. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89203. */
  89204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89205. }
  89206. /**
  89207. * Defines the minimum contract an Edges renderer should follow.
  89208. */
  89209. export interface IEdgesRenderer extends IDisposable {
  89210. /**
  89211. * Gets or sets a boolean indicating if the edgesRenderer is active
  89212. */
  89213. isEnabled: boolean;
  89214. /**
  89215. * Renders the edges of the attached mesh,
  89216. */
  89217. render(): void;
  89218. /**
  89219. * Checks wether or not the edges renderer is ready to render.
  89220. * @return true if ready, otherwise false.
  89221. */
  89222. isReady(): boolean;
  89223. }
  89224. /**
  89225. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89226. */
  89227. export class EdgesRenderer implements IEdgesRenderer {
  89228. /**
  89229. * Define the size of the edges with an orthographic camera
  89230. */
  89231. edgesWidthScalerForOrthographic: number;
  89232. /**
  89233. * Define the size of the edges with a perspective camera
  89234. */
  89235. edgesWidthScalerForPerspective: number;
  89236. protected _source: AbstractMesh;
  89237. protected _linesPositions: number[];
  89238. protected _linesNormals: number[];
  89239. protected _linesIndices: number[];
  89240. protected _epsilon: number;
  89241. protected _indicesCount: number;
  89242. protected _lineShader: ShaderMaterial;
  89243. protected _ib: DataBuffer;
  89244. protected _buffers: {
  89245. [key: string]: Nullable<VertexBuffer>;
  89246. };
  89247. protected _checkVerticesInsteadOfIndices: boolean;
  89248. private _meshRebuildObserver;
  89249. private _meshDisposeObserver;
  89250. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89251. isEnabled: boolean;
  89252. /**
  89253. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89254. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89255. * @param source Mesh used to create edges
  89256. * @param epsilon sum of angles in adjacency to check for edge
  89257. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89258. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89259. */
  89260. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89261. protected _prepareRessources(): void;
  89262. /** @hidden */
  89263. _rebuild(): void;
  89264. /**
  89265. * Releases the required resources for the edges renderer
  89266. */
  89267. dispose(): void;
  89268. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89269. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89270. /**
  89271. * Checks if the pair of p0 and p1 is en edge
  89272. * @param faceIndex
  89273. * @param edge
  89274. * @param faceNormals
  89275. * @param p0
  89276. * @param p1
  89277. * @private
  89278. */
  89279. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89280. /**
  89281. * push line into the position, normal and index buffer
  89282. * @protected
  89283. */
  89284. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89285. /**
  89286. * Generates lines edges from adjacencjes
  89287. * @private
  89288. */
  89289. _generateEdgesLines(): void;
  89290. /**
  89291. * Checks wether or not the edges renderer is ready to render.
  89292. * @return true if ready, otherwise false.
  89293. */
  89294. isReady(): boolean;
  89295. /**
  89296. * Renders the edges of the attached mesh,
  89297. */
  89298. render(): void;
  89299. }
  89300. /**
  89301. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89302. */
  89303. export class LineEdgesRenderer extends EdgesRenderer {
  89304. /**
  89305. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89306. * @param source LineMesh used to generate edges
  89307. * @param epsilon not important (specified angle for edge detection)
  89308. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89309. */
  89310. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89311. /**
  89312. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89313. */
  89314. _generateEdgesLines(): void;
  89315. }
  89316. }
  89317. declare module BABYLON {
  89318. /**
  89319. * This represents the object necessary to create a rendering group.
  89320. * This is exclusively used and created by the rendering manager.
  89321. * To modify the behavior, you use the available helpers in your scene or meshes.
  89322. * @hidden
  89323. */
  89324. export class RenderingGroup {
  89325. index: number;
  89326. private static _zeroVector;
  89327. private _scene;
  89328. private _opaqueSubMeshes;
  89329. private _transparentSubMeshes;
  89330. private _alphaTestSubMeshes;
  89331. private _depthOnlySubMeshes;
  89332. private _particleSystems;
  89333. private _spriteManagers;
  89334. private _opaqueSortCompareFn;
  89335. private _alphaTestSortCompareFn;
  89336. private _transparentSortCompareFn;
  89337. private _renderOpaque;
  89338. private _renderAlphaTest;
  89339. private _renderTransparent;
  89340. /** @hidden */
  89341. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89342. onBeforeTransparentRendering: () => void;
  89343. /**
  89344. * Set the opaque sort comparison function.
  89345. * If null the sub meshes will be render in the order they were created
  89346. */
  89347. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89348. /**
  89349. * Set the alpha test sort comparison function.
  89350. * If null the sub meshes will be render in the order they were created
  89351. */
  89352. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89353. /**
  89354. * Set the transparent sort comparison function.
  89355. * If null the sub meshes will be render in the order they were created
  89356. */
  89357. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89358. /**
  89359. * Creates a new rendering group.
  89360. * @param index The rendering group index
  89361. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89362. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89363. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89364. */
  89365. 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>);
  89366. /**
  89367. * Render all the sub meshes contained in the group.
  89368. * @param customRenderFunction Used to override the default render behaviour of the group.
  89369. * @returns true if rendered some submeshes.
  89370. */
  89371. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89372. /**
  89373. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89374. * @param subMeshes The submeshes to render
  89375. */
  89376. private renderOpaqueSorted;
  89377. /**
  89378. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89379. * @param subMeshes The submeshes to render
  89380. */
  89381. private renderAlphaTestSorted;
  89382. /**
  89383. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89384. * @param subMeshes The submeshes to render
  89385. */
  89386. private renderTransparentSorted;
  89387. /**
  89388. * Renders the submeshes in a specified order.
  89389. * @param subMeshes The submeshes to sort before render
  89390. * @param sortCompareFn The comparison function use to sort
  89391. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89392. * @param transparent Specifies to activate blending if true
  89393. */
  89394. private static renderSorted;
  89395. /**
  89396. * Renders the submeshes in the order they were dispatched (no sort applied).
  89397. * @param subMeshes The submeshes to render
  89398. */
  89399. private static renderUnsorted;
  89400. /**
  89401. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89402. * are rendered back to front if in the same alpha index.
  89403. *
  89404. * @param a The first submesh
  89405. * @param b The second submesh
  89406. * @returns The result of the comparison
  89407. */
  89408. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89409. /**
  89410. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89411. * are rendered back to front.
  89412. *
  89413. * @param a The first submesh
  89414. * @param b The second submesh
  89415. * @returns The result of the comparison
  89416. */
  89417. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89418. /**
  89419. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89420. * are rendered front to back (prevent overdraw).
  89421. *
  89422. * @param a The first submesh
  89423. * @param b The second submesh
  89424. * @returns The result of the comparison
  89425. */
  89426. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89427. /**
  89428. * Resets the different lists of submeshes to prepare a new frame.
  89429. */
  89430. prepare(): void;
  89431. dispose(): void;
  89432. /**
  89433. * Inserts the submesh in its correct queue depending on its material.
  89434. * @param subMesh The submesh to dispatch
  89435. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89436. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89437. */
  89438. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89439. dispatchSprites(spriteManager: ISpriteManager): void;
  89440. dispatchParticles(particleSystem: IParticleSystem): void;
  89441. private _renderParticles;
  89442. private _renderSprites;
  89443. }
  89444. }
  89445. declare module BABYLON {
  89446. /**
  89447. * Interface describing the different options available in the rendering manager
  89448. * regarding Auto Clear between groups.
  89449. */
  89450. export interface IRenderingManagerAutoClearSetup {
  89451. /**
  89452. * Defines whether or not autoclear is enable.
  89453. */
  89454. autoClear: boolean;
  89455. /**
  89456. * Defines whether or not to autoclear the depth buffer.
  89457. */
  89458. depth: boolean;
  89459. /**
  89460. * Defines whether or not to autoclear the stencil buffer.
  89461. */
  89462. stencil: boolean;
  89463. }
  89464. /**
  89465. * This class is used by the onRenderingGroupObservable
  89466. */
  89467. export class RenderingGroupInfo {
  89468. /**
  89469. * The Scene that being rendered
  89470. */
  89471. scene: Scene;
  89472. /**
  89473. * The camera currently used for the rendering pass
  89474. */
  89475. camera: Nullable<Camera>;
  89476. /**
  89477. * The ID of the renderingGroup being processed
  89478. */
  89479. renderingGroupId: number;
  89480. }
  89481. /**
  89482. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89483. * It is enable to manage the different groups as well as the different necessary sort functions.
  89484. * This should not be used directly aside of the few static configurations
  89485. */
  89486. export class RenderingManager {
  89487. /**
  89488. * The max id used for rendering groups (not included)
  89489. */
  89490. static MAX_RENDERINGGROUPS: number;
  89491. /**
  89492. * The min id used for rendering groups (included)
  89493. */
  89494. static MIN_RENDERINGGROUPS: number;
  89495. /**
  89496. * Used to globally prevent autoclearing scenes.
  89497. */
  89498. static AUTOCLEAR: boolean;
  89499. /**
  89500. * @hidden
  89501. */
  89502. _useSceneAutoClearSetup: boolean;
  89503. private _scene;
  89504. private _renderingGroups;
  89505. private _depthStencilBufferAlreadyCleaned;
  89506. private _autoClearDepthStencil;
  89507. private _customOpaqueSortCompareFn;
  89508. private _customAlphaTestSortCompareFn;
  89509. private _customTransparentSortCompareFn;
  89510. private _renderingGroupInfo;
  89511. /**
  89512. * Instantiates a new rendering group for a particular scene
  89513. * @param scene Defines the scene the groups belongs to
  89514. */
  89515. constructor(scene: Scene);
  89516. private _clearDepthStencilBuffer;
  89517. /**
  89518. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89519. * @hidden
  89520. */
  89521. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89522. /**
  89523. * Resets the different information of the group to prepare a new frame
  89524. * @hidden
  89525. */
  89526. reset(): void;
  89527. /**
  89528. * Dispose and release the group and its associated resources.
  89529. * @hidden
  89530. */
  89531. dispose(): void;
  89532. /**
  89533. * Clear the info related to rendering groups preventing retention points during dispose.
  89534. */
  89535. freeRenderingGroups(): void;
  89536. private _prepareRenderingGroup;
  89537. /**
  89538. * Add a sprite manager to the rendering manager in order to render it this frame.
  89539. * @param spriteManager Define the sprite manager to render
  89540. */
  89541. dispatchSprites(spriteManager: ISpriteManager): void;
  89542. /**
  89543. * Add a particle system to the rendering manager in order to render it this frame.
  89544. * @param particleSystem Define the particle system to render
  89545. */
  89546. dispatchParticles(particleSystem: IParticleSystem): void;
  89547. /**
  89548. * Add a submesh to the manager in order to render it this frame
  89549. * @param subMesh The submesh to dispatch
  89550. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89551. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89552. */
  89553. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89554. /**
  89555. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89556. * This allowed control for front to back rendering or reversly depending of the special needs.
  89557. *
  89558. * @param renderingGroupId The rendering group id corresponding to its index
  89559. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89560. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89561. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89562. */
  89563. 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;
  89564. /**
  89565. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89566. *
  89567. * @param renderingGroupId The rendering group id corresponding to its index
  89568. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89569. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89570. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89571. */
  89572. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89573. /**
  89574. * Gets the current auto clear configuration for one rendering group of the rendering
  89575. * manager.
  89576. * @param index the rendering group index to get the information for
  89577. * @returns The auto clear setup for the requested rendering group
  89578. */
  89579. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89580. }
  89581. }
  89582. declare module BABYLON {
  89583. /**
  89584. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89585. */
  89586. export interface ICustomShaderOptions {
  89587. /**
  89588. * Gets or sets the custom shader name to use
  89589. */
  89590. shaderName: string;
  89591. /**
  89592. * The list of attribute names used in the shader
  89593. */
  89594. attributes?: string[];
  89595. /**
  89596. * The list of unifrom names used in the shader
  89597. */
  89598. uniforms?: string[];
  89599. /**
  89600. * The list of sampler names used in the shader
  89601. */
  89602. samplers?: string[];
  89603. /**
  89604. * The list of defines used in the shader
  89605. */
  89606. defines?: string[];
  89607. }
  89608. /**
  89609. * Interface to implement to create a shadow generator compatible with BJS.
  89610. */
  89611. export interface IShadowGenerator {
  89612. /**
  89613. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89614. * @returns The render target texture if present otherwise, null
  89615. */
  89616. getShadowMap(): Nullable<RenderTargetTexture>;
  89617. /**
  89618. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89619. * @param subMesh The submesh we want to render in the shadow map
  89620. * @param useInstances Defines wether will draw in the map using instances
  89621. * @returns true if ready otherwise, false
  89622. */
  89623. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89624. /**
  89625. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89626. * @param defines Defines of the material we want to update
  89627. * @param lightIndex Index of the light in the enabled light list of the material
  89628. */
  89629. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89630. /**
  89631. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89632. * defined in the generator but impacting the effect).
  89633. * It implies the unifroms available on the materials are the standard BJS ones.
  89634. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89635. * @param effect The effect we are binfing the information for
  89636. */
  89637. bindShadowLight(lightIndex: string, effect: Effect): void;
  89638. /**
  89639. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89640. * (eq to shadow prjection matrix * light transform matrix)
  89641. * @returns The transform matrix used to create the shadow map
  89642. */
  89643. getTransformMatrix(): Matrix;
  89644. /**
  89645. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89646. * Cube and 2D textures for instance.
  89647. */
  89648. recreateShadowMap(): void;
  89649. /**
  89650. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89651. * @param onCompiled Callback triggered at the and of the effects compilation
  89652. * @param options Sets of optional options forcing the compilation with different modes
  89653. */
  89654. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89655. useInstances: boolean;
  89656. }>): void;
  89657. /**
  89658. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89659. * @param options Sets of optional options forcing the compilation with different modes
  89660. * @returns A promise that resolves when the compilation completes
  89661. */
  89662. forceCompilationAsync(options?: Partial<{
  89663. useInstances: boolean;
  89664. }>): Promise<void>;
  89665. /**
  89666. * Serializes the shadow generator setup to a json object.
  89667. * @returns The serialized JSON object
  89668. */
  89669. serialize(): any;
  89670. /**
  89671. * Disposes the Shadow map and related Textures and effects.
  89672. */
  89673. dispose(): void;
  89674. }
  89675. /**
  89676. * Default implementation IShadowGenerator.
  89677. * This is the main object responsible of generating shadows in the framework.
  89678. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89679. */
  89680. export class ShadowGenerator implements IShadowGenerator {
  89681. /**
  89682. * Name of the shadow generator class
  89683. */
  89684. static CLASSNAME: string;
  89685. /**
  89686. * Shadow generator mode None: no filtering applied.
  89687. */
  89688. static readonly FILTER_NONE: number;
  89689. /**
  89690. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89691. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89692. */
  89693. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89694. /**
  89695. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89696. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89697. */
  89698. static readonly FILTER_POISSONSAMPLING: number;
  89699. /**
  89700. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89701. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89702. */
  89703. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89704. /**
  89705. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89706. * edge artifacts on steep falloff.
  89707. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89708. */
  89709. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89710. /**
  89711. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89712. * edge artifacts on steep falloff.
  89713. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89714. */
  89715. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89716. /**
  89717. * Shadow generator mode PCF: Percentage Closer Filtering
  89718. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89719. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89720. */
  89721. static readonly FILTER_PCF: number;
  89722. /**
  89723. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89724. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89725. * Contact Hardening
  89726. */
  89727. static readonly FILTER_PCSS: number;
  89728. /**
  89729. * Reserved for PCF and PCSS
  89730. * Highest Quality.
  89731. *
  89732. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89733. *
  89734. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89735. */
  89736. static readonly QUALITY_HIGH: number;
  89737. /**
  89738. * Reserved for PCF and PCSS
  89739. * Good tradeoff for quality/perf cross devices
  89740. *
  89741. * Execute PCF on a 3*3 kernel.
  89742. *
  89743. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89744. */
  89745. static readonly QUALITY_MEDIUM: number;
  89746. /**
  89747. * Reserved for PCF and PCSS
  89748. * The lowest quality but the fastest.
  89749. *
  89750. * Execute PCF on a 1*1 kernel.
  89751. *
  89752. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89753. */
  89754. static readonly QUALITY_LOW: number;
  89755. /** Gets or sets the custom shader name to use */
  89756. customShaderOptions: ICustomShaderOptions;
  89757. /**
  89758. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89759. */
  89760. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89761. /**
  89762. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89763. */
  89764. onAfterShadowMapRenderObservable: Observable<Effect>;
  89765. /**
  89766. * Observable triggered before a mesh is rendered in the shadow map.
  89767. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89768. */
  89769. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89770. /**
  89771. * Observable triggered after a mesh is rendered in the shadow map.
  89772. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89773. */
  89774. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89775. protected _bias: number;
  89776. /**
  89777. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89778. */
  89779. get bias(): number;
  89780. /**
  89781. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89782. */
  89783. set bias(bias: number);
  89784. protected _normalBias: number;
  89785. /**
  89786. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89787. */
  89788. get normalBias(): number;
  89789. /**
  89790. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89791. */
  89792. set normalBias(normalBias: number);
  89793. protected _blurBoxOffset: number;
  89794. /**
  89795. * Gets the blur box offset: offset applied during the blur pass.
  89796. * Only useful if useKernelBlur = false
  89797. */
  89798. get blurBoxOffset(): number;
  89799. /**
  89800. * Sets the blur box offset: offset applied during the blur pass.
  89801. * Only useful if useKernelBlur = false
  89802. */
  89803. set blurBoxOffset(value: number);
  89804. protected _blurScale: number;
  89805. /**
  89806. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89807. * 2 means half of the size.
  89808. */
  89809. get blurScale(): number;
  89810. /**
  89811. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89812. * 2 means half of the size.
  89813. */
  89814. set blurScale(value: number);
  89815. protected _blurKernel: number;
  89816. /**
  89817. * Gets the blur kernel: kernel size of the blur pass.
  89818. * Only useful if useKernelBlur = true
  89819. */
  89820. get blurKernel(): number;
  89821. /**
  89822. * Sets the blur kernel: kernel size of the blur pass.
  89823. * Only useful if useKernelBlur = true
  89824. */
  89825. set blurKernel(value: number);
  89826. protected _useKernelBlur: boolean;
  89827. /**
  89828. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89829. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89830. */
  89831. get useKernelBlur(): boolean;
  89832. /**
  89833. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89834. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89835. */
  89836. set useKernelBlur(value: boolean);
  89837. protected _depthScale: number;
  89838. /**
  89839. * Gets the depth scale used in ESM mode.
  89840. */
  89841. get depthScale(): number;
  89842. /**
  89843. * Sets the depth scale used in ESM mode.
  89844. * This can override the scale stored on the light.
  89845. */
  89846. set depthScale(value: number);
  89847. protected _validateFilter(filter: number): number;
  89848. protected _filter: number;
  89849. /**
  89850. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89851. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89852. */
  89853. get filter(): number;
  89854. /**
  89855. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89856. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89857. */
  89858. set filter(value: number);
  89859. /**
  89860. * Gets if the current filter is set to Poisson Sampling.
  89861. */
  89862. get usePoissonSampling(): boolean;
  89863. /**
  89864. * Sets the current filter to Poisson Sampling.
  89865. */
  89866. set usePoissonSampling(value: boolean);
  89867. /**
  89868. * Gets if the current filter is set to ESM.
  89869. */
  89870. get useExponentialShadowMap(): boolean;
  89871. /**
  89872. * Sets the current filter is to ESM.
  89873. */
  89874. set useExponentialShadowMap(value: boolean);
  89875. /**
  89876. * Gets if the current filter is set to filtered ESM.
  89877. */
  89878. get useBlurExponentialShadowMap(): boolean;
  89879. /**
  89880. * Gets if the current filter is set to filtered ESM.
  89881. */
  89882. set useBlurExponentialShadowMap(value: boolean);
  89883. /**
  89884. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89885. * exponential to prevent steep falloff artifacts).
  89886. */
  89887. get useCloseExponentialShadowMap(): boolean;
  89888. /**
  89889. * Sets the current filter to "close ESM" (using the inverse of the
  89890. * exponential to prevent steep falloff artifacts).
  89891. */
  89892. set useCloseExponentialShadowMap(value: boolean);
  89893. /**
  89894. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89895. * exponential to prevent steep falloff artifacts).
  89896. */
  89897. get useBlurCloseExponentialShadowMap(): boolean;
  89898. /**
  89899. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89900. * exponential to prevent steep falloff artifacts).
  89901. */
  89902. set useBlurCloseExponentialShadowMap(value: boolean);
  89903. /**
  89904. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89905. */
  89906. get usePercentageCloserFiltering(): boolean;
  89907. /**
  89908. * Sets the current filter to "PCF" (percentage closer filtering).
  89909. */
  89910. set usePercentageCloserFiltering(value: boolean);
  89911. protected _filteringQuality: number;
  89912. /**
  89913. * Gets the PCF or PCSS Quality.
  89914. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89915. */
  89916. get filteringQuality(): number;
  89917. /**
  89918. * Sets the PCF or PCSS Quality.
  89919. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89920. */
  89921. set filteringQuality(filteringQuality: number);
  89922. /**
  89923. * Gets if the current filter is set to "PCSS" (contact hardening).
  89924. */
  89925. get useContactHardeningShadow(): boolean;
  89926. /**
  89927. * Sets the current filter to "PCSS" (contact hardening).
  89928. */
  89929. set useContactHardeningShadow(value: boolean);
  89930. protected _contactHardeningLightSizeUVRatio: number;
  89931. /**
  89932. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89933. * Using a ratio helps keeping shape stability independently of the map size.
  89934. *
  89935. * It does not account for the light projection as it was having too much
  89936. * instability during the light setup or during light position changes.
  89937. *
  89938. * Only valid if useContactHardeningShadow is true.
  89939. */
  89940. get contactHardeningLightSizeUVRatio(): number;
  89941. /**
  89942. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89943. * Using a ratio helps keeping shape stability independently of the map size.
  89944. *
  89945. * It does not account for the light projection as it was having too much
  89946. * instability during the light setup or during light position changes.
  89947. *
  89948. * Only valid if useContactHardeningShadow is true.
  89949. */
  89950. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89951. protected _darkness: number;
  89952. /** Gets or sets the actual darkness of a shadow */
  89953. get darkness(): number;
  89954. set darkness(value: number);
  89955. /**
  89956. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89957. * 0 means strongest and 1 would means no shadow.
  89958. * @returns the darkness.
  89959. */
  89960. getDarkness(): number;
  89961. /**
  89962. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89963. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89964. * @returns the shadow generator allowing fluent coding.
  89965. */
  89966. setDarkness(darkness: number): ShadowGenerator;
  89967. protected _transparencyShadow: boolean;
  89968. /** Gets or sets the ability to have transparent shadow */
  89969. get transparencyShadow(): boolean;
  89970. set transparencyShadow(value: boolean);
  89971. /**
  89972. * Sets the ability to have transparent shadow (boolean).
  89973. * @param transparent True if transparent else False
  89974. * @returns the shadow generator allowing fluent coding
  89975. */
  89976. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89977. protected _shadowMap: Nullable<RenderTargetTexture>;
  89978. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89979. /**
  89980. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89981. * @returns The render target texture if present otherwise, null
  89982. */
  89983. getShadowMap(): Nullable<RenderTargetTexture>;
  89984. /**
  89985. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89986. * @returns The render target texture if the shadow map is present otherwise, null
  89987. */
  89988. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89989. /**
  89990. * Gets the class name of that object
  89991. * @returns "ShadowGenerator"
  89992. */
  89993. getClassName(): string;
  89994. /**
  89995. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89996. * @param mesh Mesh to add
  89997. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89998. * @returns the Shadow Generator itself
  89999. */
  90000. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90001. /**
  90002. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90003. * @param mesh Mesh to remove
  90004. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90005. * @returns the Shadow Generator itself
  90006. */
  90007. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90008. /**
  90009. * Controls the extent to which the shadows fade out at the edge of the frustum
  90010. */
  90011. frustumEdgeFalloff: number;
  90012. protected _light: IShadowLight;
  90013. /**
  90014. * Returns the associated light object.
  90015. * @returns the light generating the shadow
  90016. */
  90017. getLight(): IShadowLight;
  90018. /**
  90019. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90020. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90021. * It might on the other hand introduce peter panning.
  90022. */
  90023. forceBackFacesOnly: boolean;
  90024. protected _scene: Scene;
  90025. protected _lightDirection: Vector3;
  90026. protected _effect: Effect;
  90027. protected _viewMatrix: Matrix;
  90028. protected _projectionMatrix: Matrix;
  90029. protected _transformMatrix: Matrix;
  90030. protected _cachedPosition: Vector3;
  90031. protected _cachedDirection: Vector3;
  90032. protected _cachedDefines: string;
  90033. protected _currentRenderID: number;
  90034. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90035. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90036. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90037. protected _blurPostProcesses: PostProcess[];
  90038. protected _mapSize: number;
  90039. protected _currentFaceIndex: number;
  90040. protected _currentFaceIndexCache: number;
  90041. protected _textureType: number;
  90042. protected _defaultTextureMatrix: Matrix;
  90043. protected _storedUniqueId: Nullable<number>;
  90044. /** @hidden */
  90045. static _SceneComponentInitialization: (scene: Scene) => void;
  90046. /**
  90047. * Creates a ShadowGenerator object.
  90048. * A ShadowGenerator is the required tool to use the shadows.
  90049. * Each light casting shadows needs to use its own ShadowGenerator.
  90050. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  90051. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  90052. * @param light The light object generating the shadows.
  90053. * @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.
  90054. */
  90055. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  90056. protected _initializeGenerator(): void;
  90057. protected _createTargetRenderTexture(): void;
  90058. protected _initializeShadowMap(): void;
  90059. protected _initializeBlurRTTAndPostProcesses(): void;
  90060. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  90061. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  90062. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  90063. protected _applyFilterValues(): void;
  90064. /**
  90065. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90066. * @param onCompiled Callback triggered at the and of the effects compilation
  90067. * @param options Sets of optional options forcing the compilation with different modes
  90068. */
  90069. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90070. useInstances: boolean;
  90071. }>): void;
  90072. /**
  90073. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90074. * @param options Sets of optional options forcing the compilation with different modes
  90075. * @returns A promise that resolves when the compilation completes
  90076. */
  90077. forceCompilationAsync(options?: Partial<{
  90078. useInstances: boolean;
  90079. }>): Promise<void>;
  90080. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90081. /**
  90082. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90083. * @param subMesh The submesh we want to render in the shadow map
  90084. * @param useInstances Defines wether will draw in the map using instances
  90085. * @returns true if ready otherwise, false
  90086. */
  90087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90088. /**
  90089. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90090. * @param defines Defines of the material we want to update
  90091. * @param lightIndex Index of the light in the enabled light list of the material
  90092. */
  90093. prepareDefines(defines: any, lightIndex: number): void;
  90094. /**
  90095. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90096. * defined in the generator but impacting the effect).
  90097. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90098. * @param effect The effect we are binfing the information for
  90099. */
  90100. bindShadowLight(lightIndex: string, effect: Effect): void;
  90101. /**
  90102. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90103. * (eq to shadow prjection matrix * light transform matrix)
  90104. * @returns The transform matrix used to create the shadow map
  90105. */
  90106. getTransformMatrix(): Matrix;
  90107. /**
  90108. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90109. * Cube and 2D textures for instance.
  90110. */
  90111. recreateShadowMap(): void;
  90112. protected _disposeBlurPostProcesses(): void;
  90113. protected _disposeRTTandPostProcesses(): void;
  90114. /**
  90115. * Disposes the ShadowGenerator.
  90116. * Returns nothing.
  90117. */
  90118. dispose(): void;
  90119. /**
  90120. * Serializes the shadow generator setup to a json object.
  90121. * @returns The serialized JSON object
  90122. */
  90123. serialize(): any;
  90124. /**
  90125. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90126. * @param parsedShadowGenerator The JSON object to parse
  90127. * @param scene The scene to create the shadow map for
  90128. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90129. * @returns The parsed shadow generator
  90130. */
  90131. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90132. }
  90133. }
  90134. declare module BABYLON {
  90135. /**
  90136. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90137. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90138. * 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.
  90139. */
  90140. export abstract class Light extends Node {
  90141. /**
  90142. * Falloff Default: light is falling off following the material specification:
  90143. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90144. */
  90145. static readonly FALLOFF_DEFAULT: number;
  90146. /**
  90147. * Falloff Physical: light is falling off following the inverse squared distance law.
  90148. */
  90149. static readonly FALLOFF_PHYSICAL: number;
  90150. /**
  90151. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90152. * to enhance interoperability with other engines.
  90153. */
  90154. static readonly FALLOFF_GLTF: number;
  90155. /**
  90156. * Falloff Standard: light is falling off like in the standard material
  90157. * to enhance interoperability with other materials.
  90158. */
  90159. static readonly FALLOFF_STANDARD: number;
  90160. /**
  90161. * If every light affecting the material is in this lightmapMode,
  90162. * material.lightmapTexture adds or multiplies
  90163. * (depends on material.useLightmapAsShadowmap)
  90164. * after every other light calculations.
  90165. */
  90166. static readonly LIGHTMAP_DEFAULT: number;
  90167. /**
  90168. * material.lightmapTexture as only diffuse lighting from this light
  90169. * adds only specular lighting from this light
  90170. * adds dynamic shadows
  90171. */
  90172. static readonly LIGHTMAP_SPECULAR: number;
  90173. /**
  90174. * material.lightmapTexture as only lighting
  90175. * no light calculation from this light
  90176. * only adds dynamic shadows from this light
  90177. */
  90178. static readonly LIGHTMAP_SHADOWSONLY: number;
  90179. /**
  90180. * Each light type uses the default quantity according to its type:
  90181. * point/spot lights use luminous intensity
  90182. * directional lights use illuminance
  90183. */
  90184. static readonly INTENSITYMODE_AUTOMATIC: number;
  90185. /**
  90186. * lumen (lm)
  90187. */
  90188. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90189. /**
  90190. * candela (lm/sr)
  90191. */
  90192. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90193. /**
  90194. * lux (lm/m^2)
  90195. */
  90196. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90197. /**
  90198. * nit (cd/m^2)
  90199. */
  90200. static readonly INTENSITYMODE_LUMINANCE: number;
  90201. /**
  90202. * Light type const id of the point light.
  90203. */
  90204. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90205. /**
  90206. * Light type const id of the directional light.
  90207. */
  90208. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90209. /**
  90210. * Light type const id of the spot light.
  90211. */
  90212. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90213. /**
  90214. * Light type const id of the hemispheric light.
  90215. */
  90216. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90217. /**
  90218. * Diffuse gives the basic color to an object.
  90219. */
  90220. diffuse: Color3;
  90221. /**
  90222. * Specular produces a highlight color on an object.
  90223. * Note: This is note affecting PBR materials.
  90224. */
  90225. specular: Color3;
  90226. /**
  90227. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90228. * falling off base on range or angle.
  90229. * This can be set to any values in Light.FALLOFF_x.
  90230. *
  90231. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90232. * other types of materials.
  90233. */
  90234. falloffType: number;
  90235. /**
  90236. * Strength of the light.
  90237. * Note: By default it is define in the framework own unit.
  90238. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90239. */
  90240. intensity: number;
  90241. private _range;
  90242. protected _inverseSquaredRange: number;
  90243. /**
  90244. * Defines how far from the source the light is impacting in scene units.
  90245. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90246. */
  90247. get range(): number;
  90248. /**
  90249. * Defines how far from the source the light is impacting in scene units.
  90250. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90251. */
  90252. set range(value: number);
  90253. /**
  90254. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90255. * of light.
  90256. */
  90257. private _photometricScale;
  90258. private _intensityMode;
  90259. /**
  90260. * Gets the photometric scale used to interpret the intensity.
  90261. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90262. */
  90263. get intensityMode(): number;
  90264. /**
  90265. * Sets the photometric scale used to interpret the intensity.
  90266. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90267. */
  90268. set intensityMode(value: number);
  90269. private _radius;
  90270. /**
  90271. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90272. */
  90273. get radius(): number;
  90274. /**
  90275. * sets the light radius used by PBR Materials to simulate soft area lights.
  90276. */
  90277. set radius(value: number);
  90278. private _renderPriority;
  90279. /**
  90280. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90281. * exceeding the number allowed of the materials.
  90282. */
  90283. renderPriority: number;
  90284. private _shadowEnabled;
  90285. /**
  90286. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90287. * the current shadow generator.
  90288. */
  90289. get shadowEnabled(): boolean;
  90290. /**
  90291. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90292. * the current shadow generator.
  90293. */
  90294. set shadowEnabled(value: boolean);
  90295. private _includedOnlyMeshes;
  90296. /**
  90297. * Gets the only meshes impacted by this light.
  90298. */
  90299. get includedOnlyMeshes(): AbstractMesh[];
  90300. /**
  90301. * Sets the only meshes impacted by this light.
  90302. */
  90303. set includedOnlyMeshes(value: AbstractMesh[]);
  90304. private _excludedMeshes;
  90305. /**
  90306. * Gets the meshes not impacted by this light.
  90307. */
  90308. get excludedMeshes(): AbstractMesh[];
  90309. /**
  90310. * Sets the meshes not impacted by this light.
  90311. */
  90312. set excludedMeshes(value: AbstractMesh[]);
  90313. private _excludeWithLayerMask;
  90314. /**
  90315. * Gets the layer id use to find what meshes are not impacted by the light.
  90316. * Inactive if 0
  90317. */
  90318. get excludeWithLayerMask(): number;
  90319. /**
  90320. * Sets the layer id use to find what meshes are not impacted by the light.
  90321. * Inactive if 0
  90322. */
  90323. set excludeWithLayerMask(value: number);
  90324. private _includeOnlyWithLayerMask;
  90325. /**
  90326. * Gets the layer id use to find what meshes are impacted by the light.
  90327. * Inactive if 0
  90328. */
  90329. get includeOnlyWithLayerMask(): number;
  90330. /**
  90331. * Sets the layer id use to find what meshes are impacted by the light.
  90332. * Inactive if 0
  90333. */
  90334. set includeOnlyWithLayerMask(value: number);
  90335. private _lightmapMode;
  90336. /**
  90337. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90338. */
  90339. get lightmapMode(): number;
  90340. /**
  90341. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90342. */
  90343. set lightmapMode(value: number);
  90344. /**
  90345. * Shadow generator associted to the light.
  90346. * @hidden Internal use only.
  90347. */
  90348. _shadowGenerator: Nullable<IShadowGenerator>;
  90349. /**
  90350. * @hidden Internal use only.
  90351. */
  90352. _excludedMeshesIds: string[];
  90353. /**
  90354. * @hidden Internal use only.
  90355. */
  90356. _includedOnlyMeshesIds: string[];
  90357. /**
  90358. * The current light unifom buffer.
  90359. * @hidden Internal use only.
  90360. */
  90361. _uniformBuffer: UniformBuffer;
  90362. /** @hidden */
  90363. _renderId: number;
  90364. /**
  90365. * Creates a Light object in the scene.
  90366. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90367. * @param name The firendly name of the light
  90368. * @param scene The scene the light belongs too
  90369. */
  90370. constructor(name: string, scene: Scene);
  90371. protected abstract _buildUniformLayout(): void;
  90372. /**
  90373. * Sets the passed Effect "effect" with the Light information.
  90374. * @param effect The effect to update
  90375. * @param lightIndex The index of the light in the effect to update
  90376. * @returns The light
  90377. */
  90378. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90379. /**
  90380. * Sets the passed Effect "effect" with the Light textures.
  90381. * @param effect The effect to update
  90382. * @param lightIndex The index of the light in the effect to update
  90383. * @returns The light
  90384. */
  90385. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90386. /**
  90387. * Binds the lights information from the scene to the effect for the given mesh.
  90388. * @param lightIndex Light index
  90389. * @param scene The scene where the light belongs to
  90390. * @param effect The effect we are binding the data to
  90391. * @param useSpecular Defines if specular is supported
  90392. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90393. */
  90394. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90395. /**
  90396. * Sets the passed Effect "effect" with the Light information.
  90397. * @param effect The effect to update
  90398. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90399. * @returns The light
  90400. */
  90401. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90402. /**
  90403. * Returns the string "Light".
  90404. * @returns the class name
  90405. */
  90406. getClassName(): string;
  90407. /** @hidden */
  90408. readonly _isLight: boolean;
  90409. /**
  90410. * Converts the light information to a readable string for debug purpose.
  90411. * @param fullDetails Supports for multiple levels of logging within scene loading
  90412. * @returns the human readable light info
  90413. */
  90414. toString(fullDetails?: boolean): string;
  90415. /** @hidden */
  90416. protected _syncParentEnabledState(): void;
  90417. /**
  90418. * Set the enabled state of this node.
  90419. * @param value - the new enabled state
  90420. */
  90421. setEnabled(value: boolean): void;
  90422. /**
  90423. * Returns the Light associated shadow generator if any.
  90424. * @return the associated shadow generator.
  90425. */
  90426. getShadowGenerator(): Nullable<IShadowGenerator>;
  90427. /**
  90428. * Returns a Vector3, the absolute light position in the World.
  90429. * @returns the world space position of the light
  90430. */
  90431. getAbsolutePosition(): Vector3;
  90432. /**
  90433. * Specifies if the light will affect the passed mesh.
  90434. * @param mesh The mesh to test against the light
  90435. * @return true the mesh is affected otherwise, false.
  90436. */
  90437. canAffectMesh(mesh: AbstractMesh): boolean;
  90438. /**
  90439. * Sort function to order lights for rendering.
  90440. * @param a First Light object to compare to second.
  90441. * @param b Second Light object to compare first.
  90442. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90443. */
  90444. static CompareLightsPriority(a: Light, b: Light): number;
  90445. /**
  90446. * Releases resources associated with this node.
  90447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90449. */
  90450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90451. /**
  90452. * Returns the light type ID (integer).
  90453. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90454. */
  90455. getTypeID(): number;
  90456. /**
  90457. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90458. * @returns the scaled intensity in intensity mode unit
  90459. */
  90460. getScaledIntensity(): number;
  90461. /**
  90462. * Returns a new Light object, named "name", from the current one.
  90463. * @param name The name of the cloned light
  90464. * @returns the new created light
  90465. */
  90466. clone(name: string): Nullable<Light>;
  90467. /**
  90468. * Serializes the current light into a Serialization object.
  90469. * @returns the serialized object.
  90470. */
  90471. serialize(): any;
  90472. /**
  90473. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90474. * This new light is named "name" and added to the passed scene.
  90475. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90476. * @param name The friendly name of the light
  90477. * @param scene The scene the new light will belong to
  90478. * @returns the constructor function
  90479. */
  90480. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90481. /**
  90482. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90483. * @param parsedLight The JSON representation of the light
  90484. * @param scene The scene to create the parsed light in
  90485. * @returns the created light after parsing
  90486. */
  90487. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90488. private _hookArrayForExcluded;
  90489. private _hookArrayForIncludedOnly;
  90490. private _resyncMeshes;
  90491. /**
  90492. * Forces the meshes to update their light related information in their rendering used effects
  90493. * @hidden Internal Use Only
  90494. */
  90495. _markMeshesAsLightDirty(): void;
  90496. /**
  90497. * Recomputes the cached photometric scale if needed.
  90498. */
  90499. private _computePhotometricScale;
  90500. /**
  90501. * Returns the Photometric Scale according to the light type and intensity mode.
  90502. */
  90503. private _getPhotometricScale;
  90504. /**
  90505. * Reorder the light in the scene according to their defined priority.
  90506. * @hidden Internal Use Only
  90507. */
  90508. _reorderLightsInScene(): void;
  90509. /**
  90510. * Prepares the list of defines specific to the light type.
  90511. * @param defines the list of defines
  90512. * @param lightIndex defines the index of the light for the effect
  90513. */
  90514. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90515. }
  90516. }
  90517. declare module BABYLON {
  90518. /**
  90519. * Interface used to define Action
  90520. */
  90521. export interface IAction {
  90522. /**
  90523. * Trigger for the action
  90524. */
  90525. trigger: number;
  90526. /** Options of the trigger */
  90527. triggerOptions: any;
  90528. /**
  90529. * Gets the trigger parameters
  90530. * @returns the trigger parameters
  90531. */
  90532. getTriggerParameter(): any;
  90533. /**
  90534. * Internal only - executes current action event
  90535. * @hidden
  90536. */
  90537. _executeCurrent(evt?: ActionEvent): void;
  90538. /**
  90539. * Serialize placeholder for child classes
  90540. * @param parent of child
  90541. * @returns the serialized object
  90542. */
  90543. serialize(parent: any): any;
  90544. /**
  90545. * Internal only
  90546. * @hidden
  90547. */
  90548. _prepare(): void;
  90549. /**
  90550. * Internal only - manager for action
  90551. * @hidden
  90552. */
  90553. _actionManager: AbstractActionManager;
  90554. /**
  90555. * Adds action to chain of actions, may be a DoNothingAction
  90556. * @param action defines the next action to execute
  90557. * @returns The action passed in
  90558. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90559. */
  90560. then(action: IAction): IAction;
  90561. }
  90562. /**
  90563. * The action to be carried out following a trigger
  90564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90565. */
  90566. export class Action implements IAction {
  90567. /** the trigger, with or without parameters, for the action */
  90568. triggerOptions: any;
  90569. /**
  90570. * Trigger for the action
  90571. */
  90572. trigger: number;
  90573. /**
  90574. * Internal only - manager for action
  90575. * @hidden
  90576. */
  90577. _actionManager: ActionManager;
  90578. private _nextActiveAction;
  90579. private _child;
  90580. private _condition?;
  90581. private _triggerParameter;
  90582. /**
  90583. * An event triggered prior to action being executed.
  90584. */
  90585. onBeforeExecuteObservable: Observable<Action>;
  90586. /**
  90587. * Creates a new Action
  90588. * @param triggerOptions the trigger, with or without parameters, for the action
  90589. * @param condition an optional determinant of action
  90590. */
  90591. constructor(
  90592. /** the trigger, with or without parameters, for the action */
  90593. triggerOptions: any, condition?: Condition);
  90594. /**
  90595. * Internal only
  90596. * @hidden
  90597. */
  90598. _prepare(): void;
  90599. /**
  90600. * Gets the trigger parameters
  90601. * @returns the trigger parameters
  90602. */
  90603. getTriggerParameter(): any;
  90604. /**
  90605. * Internal only - executes current action event
  90606. * @hidden
  90607. */
  90608. _executeCurrent(evt?: ActionEvent): void;
  90609. /**
  90610. * Execute placeholder for child classes
  90611. * @param evt optional action event
  90612. */
  90613. execute(evt?: ActionEvent): void;
  90614. /**
  90615. * Skips to next active action
  90616. */
  90617. skipToNextActiveAction(): void;
  90618. /**
  90619. * Adds action to chain of actions, may be a DoNothingAction
  90620. * @param action defines the next action to execute
  90621. * @returns The action passed in
  90622. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90623. */
  90624. then(action: Action): Action;
  90625. /**
  90626. * Internal only
  90627. * @hidden
  90628. */
  90629. _getProperty(propertyPath: string): string;
  90630. /**
  90631. * Internal only
  90632. * @hidden
  90633. */
  90634. _getEffectiveTarget(target: any, propertyPath: string): any;
  90635. /**
  90636. * Serialize placeholder for child classes
  90637. * @param parent of child
  90638. * @returns the serialized object
  90639. */
  90640. serialize(parent: any): any;
  90641. /**
  90642. * Internal only called by serialize
  90643. * @hidden
  90644. */
  90645. protected _serialize(serializedAction: any, parent?: any): any;
  90646. /**
  90647. * Internal only
  90648. * @hidden
  90649. */
  90650. static _SerializeValueAsString: (value: any) => string;
  90651. /**
  90652. * Internal only
  90653. * @hidden
  90654. */
  90655. static _GetTargetProperty: (target: Node | Scene) => {
  90656. name: string;
  90657. targetType: string;
  90658. value: string;
  90659. };
  90660. }
  90661. }
  90662. declare module BABYLON {
  90663. /**
  90664. * A Condition applied to an Action
  90665. */
  90666. export class Condition {
  90667. /**
  90668. * Internal only - manager for action
  90669. * @hidden
  90670. */
  90671. _actionManager: ActionManager;
  90672. /**
  90673. * Internal only
  90674. * @hidden
  90675. */
  90676. _evaluationId: number;
  90677. /**
  90678. * Internal only
  90679. * @hidden
  90680. */
  90681. _currentResult: boolean;
  90682. /**
  90683. * Creates a new Condition
  90684. * @param actionManager the manager of the action the condition is applied to
  90685. */
  90686. constructor(actionManager: ActionManager);
  90687. /**
  90688. * Check if the current condition is valid
  90689. * @returns a boolean
  90690. */
  90691. isValid(): boolean;
  90692. /**
  90693. * Internal only
  90694. * @hidden
  90695. */
  90696. _getProperty(propertyPath: string): string;
  90697. /**
  90698. * Internal only
  90699. * @hidden
  90700. */
  90701. _getEffectiveTarget(target: any, propertyPath: string): any;
  90702. /**
  90703. * Serialize placeholder for child classes
  90704. * @returns the serialized object
  90705. */
  90706. serialize(): any;
  90707. /**
  90708. * Internal only
  90709. * @hidden
  90710. */
  90711. protected _serialize(serializedCondition: any): any;
  90712. }
  90713. /**
  90714. * Defines specific conditional operators as extensions of Condition
  90715. */
  90716. export class ValueCondition extends Condition {
  90717. /** path to specify the property of the target the conditional operator uses */
  90718. propertyPath: string;
  90719. /** the value compared by the conditional operator against the current value of the property */
  90720. value: any;
  90721. /** the conditional operator, default ValueCondition.IsEqual */
  90722. operator: number;
  90723. /**
  90724. * Internal only
  90725. * @hidden
  90726. */
  90727. private static _IsEqual;
  90728. /**
  90729. * Internal only
  90730. * @hidden
  90731. */
  90732. private static _IsDifferent;
  90733. /**
  90734. * Internal only
  90735. * @hidden
  90736. */
  90737. private static _IsGreater;
  90738. /**
  90739. * Internal only
  90740. * @hidden
  90741. */
  90742. private static _IsLesser;
  90743. /**
  90744. * returns the number for IsEqual
  90745. */
  90746. static get IsEqual(): number;
  90747. /**
  90748. * Returns the number for IsDifferent
  90749. */
  90750. static get IsDifferent(): number;
  90751. /**
  90752. * Returns the number for IsGreater
  90753. */
  90754. static get IsGreater(): number;
  90755. /**
  90756. * Returns the number for IsLesser
  90757. */
  90758. static get IsLesser(): number;
  90759. /**
  90760. * Internal only The action manager for the condition
  90761. * @hidden
  90762. */
  90763. _actionManager: ActionManager;
  90764. /**
  90765. * Internal only
  90766. * @hidden
  90767. */
  90768. private _target;
  90769. /**
  90770. * Internal only
  90771. * @hidden
  90772. */
  90773. private _effectiveTarget;
  90774. /**
  90775. * Internal only
  90776. * @hidden
  90777. */
  90778. private _property;
  90779. /**
  90780. * Creates a new ValueCondition
  90781. * @param actionManager manager for the action the condition applies to
  90782. * @param target for the action
  90783. * @param propertyPath path to specify the property of the target the conditional operator uses
  90784. * @param value the value compared by the conditional operator against the current value of the property
  90785. * @param operator the conditional operator, default ValueCondition.IsEqual
  90786. */
  90787. constructor(actionManager: ActionManager, target: any,
  90788. /** path to specify the property of the target the conditional operator uses */
  90789. propertyPath: string,
  90790. /** the value compared by the conditional operator against the current value of the property */
  90791. value: any,
  90792. /** the conditional operator, default ValueCondition.IsEqual */
  90793. operator?: number);
  90794. /**
  90795. * Compares the given value with the property value for the specified conditional operator
  90796. * @returns the result of the comparison
  90797. */
  90798. isValid(): boolean;
  90799. /**
  90800. * Serialize the ValueCondition into a JSON compatible object
  90801. * @returns serialization object
  90802. */
  90803. serialize(): any;
  90804. /**
  90805. * Gets the name of the conditional operator for the ValueCondition
  90806. * @param operator the conditional operator
  90807. * @returns the name
  90808. */
  90809. static GetOperatorName(operator: number): string;
  90810. }
  90811. /**
  90812. * Defines a predicate condition as an extension of Condition
  90813. */
  90814. export class PredicateCondition extends Condition {
  90815. /** defines the predicate function used to validate the condition */
  90816. predicate: () => boolean;
  90817. /**
  90818. * Internal only - manager for action
  90819. * @hidden
  90820. */
  90821. _actionManager: ActionManager;
  90822. /**
  90823. * Creates a new PredicateCondition
  90824. * @param actionManager manager for the action the condition applies to
  90825. * @param predicate defines the predicate function used to validate the condition
  90826. */
  90827. constructor(actionManager: ActionManager,
  90828. /** defines the predicate function used to validate the condition */
  90829. predicate: () => boolean);
  90830. /**
  90831. * @returns the validity of the predicate condition
  90832. */
  90833. isValid(): boolean;
  90834. }
  90835. /**
  90836. * Defines a state condition as an extension of Condition
  90837. */
  90838. export class StateCondition extends Condition {
  90839. /** Value to compare with target state */
  90840. value: string;
  90841. /**
  90842. * Internal only - manager for action
  90843. * @hidden
  90844. */
  90845. _actionManager: ActionManager;
  90846. /**
  90847. * Internal only
  90848. * @hidden
  90849. */
  90850. private _target;
  90851. /**
  90852. * Creates a new StateCondition
  90853. * @param actionManager manager for the action the condition applies to
  90854. * @param target of the condition
  90855. * @param value to compare with target state
  90856. */
  90857. constructor(actionManager: ActionManager, target: any,
  90858. /** Value to compare with target state */
  90859. value: string);
  90860. /**
  90861. * Gets a boolean indicating if the current condition is met
  90862. * @returns the validity of the state
  90863. */
  90864. isValid(): boolean;
  90865. /**
  90866. * Serialize the StateCondition into a JSON compatible object
  90867. * @returns serialization object
  90868. */
  90869. serialize(): any;
  90870. }
  90871. }
  90872. declare module BABYLON {
  90873. /**
  90874. * This defines an action responsible to toggle a boolean once triggered.
  90875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90876. */
  90877. export class SwitchBooleanAction extends Action {
  90878. /**
  90879. * The path to the boolean property in the target object
  90880. */
  90881. propertyPath: string;
  90882. private _target;
  90883. private _effectiveTarget;
  90884. private _property;
  90885. /**
  90886. * Instantiate the action
  90887. * @param triggerOptions defines the trigger options
  90888. * @param target defines the object containing the boolean
  90889. * @param propertyPath defines the path to the boolean property in the target object
  90890. * @param condition defines the trigger related conditions
  90891. */
  90892. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90893. /** @hidden */
  90894. _prepare(): void;
  90895. /**
  90896. * Execute the action toggle the boolean value.
  90897. */
  90898. execute(): void;
  90899. /**
  90900. * Serializes the actions and its related information.
  90901. * @param parent defines the object to serialize in
  90902. * @returns the serialized object
  90903. */
  90904. serialize(parent: any): any;
  90905. }
  90906. /**
  90907. * This defines an action responsible to set a the state field of the target
  90908. * to a desired value once triggered.
  90909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90910. */
  90911. export class SetStateAction extends Action {
  90912. /**
  90913. * The value to store in the state field.
  90914. */
  90915. value: string;
  90916. private _target;
  90917. /**
  90918. * Instantiate the action
  90919. * @param triggerOptions defines the trigger options
  90920. * @param target defines the object containing the state property
  90921. * @param value defines the value to store in the state field
  90922. * @param condition defines the trigger related conditions
  90923. */
  90924. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90925. /**
  90926. * Execute the action and store the value on the target state property.
  90927. */
  90928. execute(): void;
  90929. /**
  90930. * Serializes the actions and its related information.
  90931. * @param parent defines the object to serialize in
  90932. * @returns the serialized object
  90933. */
  90934. serialize(parent: any): any;
  90935. }
  90936. /**
  90937. * This defines an action responsible to set a property of the target
  90938. * to a desired value once triggered.
  90939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90940. */
  90941. export class SetValueAction extends Action {
  90942. /**
  90943. * The path of the property to set in the target.
  90944. */
  90945. propertyPath: string;
  90946. /**
  90947. * The value to set in the property
  90948. */
  90949. value: any;
  90950. private _target;
  90951. private _effectiveTarget;
  90952. private _property;
  90953. /**
  90954. * Instantiate the action
  90955. * @param triggerOptions defines the trigger options
  90956. * @param target defines the object containing the property
  90957. * @param propertyPath defines the path of the property to set in the target
  90958. * @param value defines the value to set in the property
  90959. * @param condition defines the trigger related conditions
  90960. */
  90961. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90962. /** @hidden */
  90963. _prepare(): void;
  90964. /**
  90965. * Execute the action and set the targetted property to the desired value.
  90966. */
  90967. execute(): void;
  90968. /**
  90969. * Serializes the actions and its related information.
  90970. * @param parent defines the object to serialize in
  90971. * @returns the serialized object
  90972. */
  90973. serialize(parent: any): any;
  90974. }
  90975. /**
  90976. * This defines an action responsible to increment the target value
  90977. * to a desired value once triggered.
  90978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90979. */
  90980. export class IncrementValueAction extends Action {
  90981. /**
  90982. * The path of the property to increment in the target.
  90983. */
  90984. propertyPath: string;
  90985. /**
  90986. * The value we should increment the property by.
  90987. */
  90988. value: any;
  90989. private _target;
  90990. private _effectiveTarget;
  90991. private _property;
  90992. /**
  90993. * Instantiate the action
  90994. * @param triggerOptions defines the trigger options
  90995. * @param target defines the object containing the property
  90996. * @param propertyPath defines the path of the property to increment in the target
  90997. * @param value defines the value value we should increment the property by
  90998. * @param condition defines the trigger related conditions
  90999. */
  91000. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91001. /** @hidden */
  91002. _prepare(): void;
  91003. /**
  91004. * Execute the action and increment the target of the value amount.
  91005. */
  91006. execute(): void;
  91007. /**
  91008. * Serializes the actions and its related information.
  91009. * @param parent defines the object to serialize in
  91010. * @returns the serialized object
  91011. */
  91012. serialize(parent: any): any;
  91013. }
  91014. /**
  91015. * This defines an action responsible to start an animation once triggered.
  91016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91017. */
  91018. export class PlayAnimationAction extends Action {
  91019. /**
  91020. * Where the animation should start (animation frame)
  91021. */
  91022. from: number;
  91023. /**
  91024. * Where the animation should stop (animation frame)
  91025. */
  91026. to: number;
  91027. /**
  91028. * Define if the animation should loop or stop after the first play.
  91029. */
  91030. loop?: boolean;
  91031. private _target;
  91032. /**
  91033. * Instantiate the action
  91034. * @param triggerOptions defines the trigger options
  91035. * @param target defines the target animation or animation name
  91036. * @param from defines from where the animation should start (animation frame)
  91037. * @param end defines where the animation should stop (animation frame)
  91038. * @param loop defines if the animation should loop or stop after the first play
  91039. * @param condition defines the trigger related conditions
  91040. */
  91041. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91042. /** @hidden */
  91043. _prepare(): void;
  91044. /**
  91045. * Execute the action and play the animation.
  91046. */
  91047. execute(): void;
  91048. /**
  91049. * Serializes the actions and its related information.
  91050. * @param parent defines the object to serialize in
  91051. * @returns the serialized object
  91052. */
  91053. serialize(parent: any): any;
  91054. }
  91055. /**
  91056. * This defines an action responsible to stop an animation once triggered.
  91057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91058. */
  91059. export class StopAnimationAction extends Action {
  91060. private _target;
  91061. /**
  91062. * Instantiate the action
  91063. * @param triggerOptions defines the trigger options
  91064. * @param target defines the target animation or animation name
  91065. * @param condition defines the trigger related conditions
  91066. */
  91067. constructor(triggerOptions: any, target: any, condition?: Condition);
  91068. /** @hidden */
  91069. _prepare(): void;
  91070. /**
  91071. * Execute the action and stop the animation.
  91072. */
  91073. execute(): void;
  91074. /**
  91075. * Serializes the actions and its related information.
  91076. * @param parent defines the object to serialize in
  91077. * @returns the serialized object
  91078. */
  91079. serialize(parent: any): any;
  91080. }
  91081. /**
  91082. * This defines an action responsible that does nothing once triggered.
  91083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91084. */
  91085. export class DoNothingAction extends Action {
  91086. /**
  91087. * Instantiate the action
  91088. * @param triggerOptions defines the trigger options
  91089. * @param condition defines the trigger related conditions
  91090. */
  91091. constructor(triggerOptions?: any, condition?: Condition);
  91092. /**
  91093. * Execute the action and do nothing.
  91094. */
  91095. execute(): void;
  91096. /**
  91097. * Serializes the actions and its related information.
  91098. * @param parent defines the object to serialize in
  91099. * @returns the serialized object
  91100. */
  91101. serialize(parent: any): any;
  91102. }
  91103. /**
  91104. * This defines an action responsible to trigger several actions once triggered.
  91105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91106. */
  91107. export class CombineAction extends Action {
  91108. /**
  91109. * The list of aggregated animations to run.
  91110. */
  91111. children: Action[];
  91112. /**
  91113. * Instantiate the action
  91114. * @param triggerOptions defines the trigger options
  91115. * @param children defines the list of aggregated animations to run
  91116. * @param condition defines the trigger related conditions
  91117. */
  91118. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91119. /** @hidden */
  91120. _prepare(): void;
  91121. /**
  91122. * Execute the action and executes all the aggregated actions.
  91123. */
  91124. execute(evt: ActionEvent): void;
  91125. /**
  91126. * Serializes the actions and its related information.
  91127. * @param parent defines the object to serialize in
  91128. * @returns the serialized object
  91129. */
  91130. serialize(parent: any): any;
  91131. }
  91132. /**
  91133. * This defines an action responsible to run code (external event) once triggered.
  91134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91135. */
  91136. export class ExecuteCodeAction extends Action {
  91137. /**
  91138. * The callback function to run.
  91139. */
  91140. func: (evt: ActionEvent) => void;
  91141. /**
  91142. * Instantiate the action
  91143. * @param triggerOptions defines the trigger options
  91144. * @param func defines the callback function to run
  91145. * @param condition defines the trigger related conditions
  91146. */
  91147. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91148. /**
  91149. * Execute the action and run the attached code.
  91150. */
  91151. execute(evt: ActionEvent): void;
  91152. }
  91153. /**
  91154. * This defines an action responsible to set the parent property of the target once triggered.
  91155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91156. */
  91157. export class SetParentAction extends Action {
  91158. private _parent;
  91159. private _target;
  91160. /**
  91161. * Instantiate the action
  91162. * @param triggerOptions defines the trigger options
  91163. * @param target defines the target containing the parent property
  91164. * @param parent defines from where the animation should start (animation frame)
  91165. * @param condition defines the trigger related conditions
  91166. */
  91167. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91168. /** @hidden */
  91169. _prepare(): void;
  91170. /**
  91171. * Execute the action and set the parent property.
  91172. */
  91173. execute(): void;
  91174. /**
  91175. * Serializes the actions and its related information.
  91176. * @param parent defines the object to serialize in
  91177. * @returns the serialized object
  91178. */
  91179. serialize(parent: any): any;
  91180. }
  91181. }
  91182. declare module BABYLON {
  91183. /**
  91184. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91185. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91187. */
  91188. export class ActionManager extends AbstractActionManager {
  91189. /**
  91190. * Nothing
  91191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91192. */
  91193. static readonly NothingTrigger: number;
  91194. /**
  91195. * On pick
  91196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91197. */
  91198. static readonly OnPickTrigger: number;
  91199. /**
  91200. * On left pick
  91201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91202. */
  91203. static readonly OnLeftPickTrigger: number;
  91204. /**
  91205. * On right pick
  91206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91207. */
  91208. static readonly OnRightPickTrigger: number;
  91209. /**
  91210. * On center pick
  91211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91212. */
  91213. static readonly OnCenterPickTrigger: number;
  91214. /**
  91215. * On pick down
  91216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91217. */
  91218. static readonly OnPickDownTrigger: number;
  91219. /**
  91220. * On double pick
  91221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91222. */
  91223. static readonly OnDoublePickTrigger: number;
  91224. /**
  91225. * On pick up
  91226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91227. */
  91228. static readonly OnPickUpTrigger: number;
  91229. /**
  91230. * On pick out.
  91231. * This trigger will only be raised if you also declared a OnPickDown
  91232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91233. */
  91234. static readonly OnPickOutTrigger: number;
  91235. /**
  91236. * On long press
  91237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91238. */
  91239. static readonly OnLongPressTrigger: number;
  91240. /**
  91241. * On pointer over
  91242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91243. */
  91244. static readonly OnPointerOverTrigger: number;
  91245. /**
  91246. * On pointer out
  91247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91248. */
  91249. static readonly OnPointerOutTrigger: number;
  91250. /**
  91251. * On every frame
  91252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91253. */
  91254. static readonly OnEveryFrameTrigger: number;
  91255. /**
  91256. * On intersection enter
  91257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91258. */
  91259. static readonly OnIntersectionEnterTrigger: number;
  91260. /**
  91261. * On intersection exit
  91262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91263. */
  91264. static readonly OnIntersectionExitTrigger: number;
  91265. /**
  91266. * On key down
  91267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91268. */
  91269. static readonly OnKeyDownTrigger: number;
  91270. /**
  91271. * On key up
  91272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91273. */
  91274. static readonly OnKeyUpTrigger: number;
  91275. private _scene;
  91276. /**
  91277. * Creates a new action manager
  91278. * @param scene defines the hosting scene
  91279. */
  91280. constructor(scene: Scene);
  91281. /**
  91282. * Releases all associated resources
  91283. */
  91284. dispose(): void;
  91285. /**
  91286. * Gets hosting scene
  91287. * @returns the hosting scene
  91288. */
  91289. getScene(): Scene;
  91290. /**
  91291. * Does this action manager handles actions of any of the given triggers
  91292. * @param triggers defines the triggers to be tested
  91293. * @return a boolean indicating whether one (or more) of the triggers is handled
  91294. */
  91295. hasSpecificTriggers(triggers: number[]): boolean;
  91296. /**
  91297. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91298. * speed.
  91299. * @param triggerA defines the trigger to be tested
  91300. * @param triggerB defines the trigger to be tested
  91301. * @return a boolean indicating whether one (or more) of the triggers is handled
  91302. */
  91303. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91304. /**
  91305. * Does this action manager handles actions of a given trigger
  91306. * @param trigger defines the trigger to be tested
  91307. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91308. * @return whether the trigger is handled
  91309. */
  91310. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91311. /**
  91312. * Does this action manager has pointer triggers
  91313. */
  91314. get hasPointerTriggers(): boolean;
  91315. /**
  91316. * Does this action manager has pick triggers
  91317. */
  91318. get hasPickTriggers(): boolean;
  91319. /**
  91320. * Registers an action to this action manager
  91321. * @param action defines the action to be registered
  91322. * @return the action amended (prepared) after registration
  91323. */
  91324. registerAction(action: IAction): Nullable<IAction>;
  91325. /**
  91326. * Unregisters an action to this action manager
  91327. * @param action defines the action to be unregistered
  91328. * @return a boolean indicating whether the action has been unregistered
  91329. */
  91330. unregisterAction(action: IAction): Boolean;
  91331. /**
  91332. * Process a specific trigger
  91333. * @param trigger defines the trigger to process
  91334. * @param evt defines the event details to be processed
  91335. */
  91336. processTrigger(trigger: number, evt?: IActionEvent): void;
  91337. /** @hidden */
  91338. _getEffectiveTarget(target: any, propertyPath: string): any;
  91339. /** @hidden */
  91340. _getProperty(propertyPath: string): string;
  91341. /**
  91342. * Serialize this manager to a JSON object
  91343. * @param name defines the property name to store this manager
  91344. * @returns a JSON representation of this manager
  91345. */
  91346. serialize(name: string): any;
  91347. /**
  91348. * Creates a new ActionManager from a JSON data
  91349. * @param parsedActions defines the JSON data to read from
  91350. * @param object defines the hosting mesh
  91351. * @param scene defines the hosting scene
  91352. */
  91353. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91354. /**
  91355. * Get a trigger name by index
  91356. * @param trigger defines the trigger index
  91357. * @returns a trigger name
  91358. */
  91359. static GetTriggerName(trigger: number): string;
  91360. }
  91361. }
  91362. declare module BABYLON {
  91363. /**
  91364. * Class used to represent a sprite
  91365. * @see http://doc.babylonjs.com/babylon101/sprites
  91366. */
  91367. export class Sprite {
  91368. /** defines the name */
  91369. name: string;
  91370. /** Gets or sets the current world position */
  91371. position: Vector3;
  91372. /** Gets or sets the main color */
  91373. color: Color4;
  91374. /** Gets or sets the width */
  91375. width: number;
  91376. /** Gets or sets the height */
  91377. height: number;
  91378. /** Gets or sets rotation angle */
  91379. angle: number;
  91380. /** Gets or sets the cell index in the sprite sheet */
  91381. cellIndex: number;
  91382. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91383. cellRef: string;
  91384. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91385. invertU: number;
  91386. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91387. invertV: number;
  91388. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91389. disposeWhenFinishedAnimating: boolean;
  91390. /** Gets the list of attached animations */
  91391. animations: Animation[];
  91392. /** Gets or sets a boolean indicating if the sprite can be picked */
  91393. isPickable: boolean;
  91394. /**
  91395. * Gets or sets the associated action manager
  91396. */
  91397. actionManager: Nullable<ActionManager>;
  91398. private _animationStarted;
  91399. private _loopAnimation;
  91400. private _fromIndex;
  91401. private _toIndex;
  91402. private _delay;
  91403. private _direction;
  91404. private _manager;
  91405. private _time;
  91406. private _onAnimationEnd;
  91407. /**
  91408. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91409. */
  91410. isVisible: boolean;
  91411. /**
  91412. * Gets or sets the sprite size
  91413. */
  91414. get size(): number;
  91415. set size(value: number);
  91416. /**
  91417. * Creates a new Sprite
  91418. * @param name defines the name
  91419. * @param manager defines the manager
  91420. */
  91421. constructor(
  91422. /** defines the name */
  91423. name: string, manager: ISpriteManager);
  91424. /**
  91425. * Starts an animation
  91426. * @param from defines the initial key
  91427. * @param to defines the end key
  91428. * @param loop defines if the animation must loop
  91429. * @param delay defines the start delay (in ms)
  91430. * @param onAnimationEnd defines a callback to call when animation ends
  91431. */
  91432. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91433. /** Stops current animation (if any) */
  91434. stopAnimation(): void;
  91435. /** @hidden */
  91436. _animate(deltaTime: number): void;
  91437. /** Release associated resources */
  91438. dispose(): void;
  91439. }
  91440. }
  91441. declare module BABYLON {
  91442. /**
  91443. * Information about the result of picking within a scene
  91444. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91445. */
  91446. export class PickingInfo {
  91447. /** @hidden */
  91448. _pickingUnavailable: boolean;
  91449. /**
  91450. * If the pick collided with an object
  91451. */
  91452. hit: boolean;
  91453. /**
  91454. * Distance away where the pick collided
  91455. */
  91456. distance: number;
  91457. /**
  91458. * The location of pick collision
  91459. */
  91460. pickedPoint: Nullable<Vector3>;
  91461. /**
  91462. * The mesh corresponding the the pick collision
  91463. */
  91464. pickedMesh: Nullable<AbstractMesh>;
  91465. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91466. bu: number;
  91467. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91468. bv: number;
  91469. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91470. faceId: number;
  91471. /** Id of the the submesh that was picked */
  91472. subMeshId: number;
  91473. /** If a sprite was picked, this will be the sprite the pick collided with */
  91474. pickedSprite: Nullable<Sprite>;
  91475. /**
  91476. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91477. */
  91478. originMesh: Nullable<AbstractMesh>;
  91479. /**
  91480. * The ray that was used to perform the picking.
  91481. */
  91482. ray: Nullable<Ray>;
  91483. /**
  91484. * Gets the normal correspodning to the face the pick collided with
  91485. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91486. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91487. * @returns The normal correspodning to the face the pick collided with
  91488. */
  91489. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91490. /**
  91491. * Gets the texture coordinates of where the pick occured
  91492. * @returns the vector containing the coordnates of the texture
  91493. */
  91494. getTextureCoordinates(): Nullable<Vector2>;
  91495. }
  91496. }
  91497. declare module BABYLON {
  91498. /**
  91499. * Gather the list of pointer event types as constants.
  91500. */
  91501. export class PointerEventTypes {
  91502. /**
  91503. * 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.
  91504. */
  91505. static readonly POINTERDOWN: number;
  91506. /**
  91507. * The pointerup event is fired when a pointer is no longer active.
  91508. */
  91509. static readonly POINTERUP: number;
  91510. /**
  91511. * The pointermove event is fired when a pointer changes coordinates.
  91512. */
  91513. static readonly POINTERMOVE: number;
  91514. /**
  91515. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91516. */
  91517. static readonly POINTERWHEEL: number;
  91518. /**
  91519. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91520. */
  91521. static readonly POINTERPICK: number;
  91522. /**
  91523. * The pointertap event is fired when a the object has been touched and released without drag.
  91524. */
  91525. static readonly POINTERTAP: number;
  91526. /**
  91527. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91528. */
  91529. static readonly POINTERDOUBLETAP: number;
  91530. }
  91531. /**
  91532. * Base class of pointer info types.
  91533. */
  91534. export class PointerInfoBase {
  91535. /**
  91536. * Defines the type of event (PointerEventTypes)
  91537. */
  91538. type: number;
  91539. /**
  91540. * Defines the related dom event
  91541. */
  91542. event: PointerEvent | MouseWheelEvent;
  91543. /**
  91544. * Instantiates the base class of pointers info.
  91545. * @param type Defines the type of event (PointerEventTypes)
  91546. * @param event Defines the related dom event
  91547. */
  91548. constructor(
  91549. /**
  91550. * Defines the type of event (PointerEventTypes)
  91551. */
  91552. type: number,
  91553. /**
  91554. * Defines the related dom event
  91555. */
  91556. event: PointerEvent | MouseWheelEvent);
  91557. }
  91558. /**
  91559. * This class is used to store pointer related info for the onPrePointerObservable event.
  91560. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91561. */
  91562. export class PointerInfoPre extends PointerInfoBase {
  91563. /**
  91564. * Ray from a pointer if availible (eg. 6dof controller)
  91565. */
  91566. ray: Nullable<Ray>;
  91567. /**
  91568. * Defines the local position of the pointer on the canvas.
  91569. */
  91570. localPosition: Vector2;
  91571. /**
  91572. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91573. */
  91574. skipOnPointerObservable: boolean;
  91575. /**
  91576. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91577. * @param type Defines the type of event (PointerEventTypes)
  91578. * @param event Defines the related dom event
  91579. * @param localX Defines the local x coordinates of the pointer when the event occured
  91580. * @param localY Defines the local y coordinates of the pointer when the event occured
  91581. */
  91582. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91583. }
  91584. /**
  91585. * This type contains all the data related to a pointer event in Babylon.js.
  91586. * 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.
  91587. */
  91588. export class PointerInfo extends PointerInfoBase {
  91589. /**
  91590. * Defines the picking info associated to the info (if any)\
  91591. */
  91592. pickInfo: Nullable<PickingInfo>;
  91593. /**
  91594. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91595. * @param type Defines the type of event (PointerEventTypes)
  91596. * @param event Defines the related dom event
  91597. * @param pickInfo Defines the picking info associated to the info (if any)\
  91598. */
  91599. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91600. /**
  91601. * Defines the picking info associated to the info (if any)\
  91602. */
  91603. pickInfo: Nullable<PickingInfo>);
  91604. }
  91605. /**
  91606. * Data relating to a touch event on the screen.
  91607. */
  91608. export interface PointerTouch {
  91609. /**
  91610. * X coordinate of touch.
  91611. */
  91612. x: number;
  91613. /**
  91614. * Y coordinate of touch.
  91615. */
  91616. y: number;
  91617. /**
  91618. * Id of touch. Unique for each finger.
  91619. */
  91620. pointerId: number;
  91621. /**
  91622. * Event type passed from DOM.
  91623. */
  91624. type: any;
  91625. }
  91626. }
  91627. declare module BABYLON {
  91628. /**
  91629. * Manage the mouse inputs to control the movement of a free camera.
  91630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91631. */
  91632. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91633. /**
  91634. * Define if touch is enabled in the mouse input
  91635. */
  91636. touchEnabled: boolean;
  91637. /**
  91638. * Defines the camera the input is attached to.
  91639. */
  91640. camera: FreeCamera;
  91641. /**
  91642. * Defines the buttons associated with the input to handle camera move.
  91643. */
  91644. buttons: number[];
  91645. /**
  91646. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91647. */
  91648. angularSensibility: number;
  91649. private _pointerInput;
  91650. private _onMouseMove;
  91651. private _observer;
  91652. private previousPosition;
  91653. /**
  91654. * Observable for when a pointer move event occurs containing the move offset
  91655. */
  91656. onPointerMovedObservable: Observable<{
  91657. offsetX: number;
  91658. offsetY: number;
  91659. }>;
  91660. /**
  91661. * @hidden
  91662. * If the camera should be rotated automatically based on pointer movement
  91663. */
  91664. _allowCameraRotation: boolean;
  91665. /**
  91666. * Manage the mouse inputs to control the movement of a free camera.
  91667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91668. * @param touchEnabled Defines if touch is enabled or not
  91669. */
  91670. constructor(
  91671. /**
  91672. * Define if touch is enabled in the mouse input
  91673. */
  91674. touchEnabled?: boolean);
  91675. /**
  91676. * Attach the input controls to a specific dom element to get the input from.
  91677. * @param element Defines the element the controls should be listened from
  91678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91679. */
  91680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91681. /**
  91682. * Called on JS contextmenu event.
  91683. * Override this method to provide functionality.
  91684. */
  91685. protected onContextMenu(evt: PointerEvent): void;
  91686. /**
  91687. * Detach the current controls from the specified dom element.
  91688. * @param element Defines the element to stop listening the inputs from
  91689. */
  91690. detachControl(element: Nullable<HTMLElement>): void;
  91691. /**
  91692. * Gets the class name of the current intput.
  91693. * @returns the class name
  91694. */
  91695. getClassName(): string;
  91696. /**
  91697. * Get the friendly name associated with the input class.
  91698. * @returns the input friendly name
  91699. */
  91700. getSimpleName(): string;
  91701. }
  91702. }
  91703. declare module BABYLON {
  91704. /**
  91705. * Manage the touch inputs to control the movement of a free camera.
  91706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91707. */
  91708. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91709. /**
  91710. * Defines the camera the input is attached to.
  91711. */
  91712. camera: FreeCamera;
  91713. /**
  91714. * Defines the touch sensibility for rotation.
  91715. * The higher the faster.
  91716. */
  91717. touchAngularSensibility: number;
  91718. /**
  91719. * Defines the touch sensibility for move.
  91720. * The higher the faster.
  91721. */
  91722. touchMoveSensibility: number;
  91723. private _offsetX;
  91724. private _offsetY;
  91725. private _pointerPressed;
  91726. private _pointerInput;
  91727. private _observer;
  91728. private _onLostFocus;
  91729. /**
  91730. * Attach the input controls to a specific dom element to get the input from.
  91731. * @param element Defines the element the controls should be listened from
  91732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91733. */
  91734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91735. /**
  91736. * Detach the current controls from the specified dom element.
  91737. * @param element Defines the element to stop listening the inputs from
  91738. */
  91739. detachControl(element: Nullable<HTMLElement>): void;
  91740. /**
  91741. * Update the current camera state depending on the inputs that have been used this frame.
  91742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91743. */
  91744. checkInputs(): void;
  91745. /**
  91746. * Gets the class name of the current intput.
  91747. * @returns the class name
  91748. */
  91749. getClassName(): string;
  91750. /**
  91751. * Get the friendly name associated with the input class.
  91752. * @returns the input friendly name
  91753. */
  91754. getSimpleName(): string;
  91755. }
  91756. }
  91757. declare module BABYLON {
  91758. /**
  91759. * Default Inputs manager for the FreeCamera.
  91760. * It groups all the default supported inputs for ease of use.
  91761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91762. */
  91763. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91764. /**
  91765. * @hidden
  91766. */
  91767. _mouseInput: Nullable<FreeCameraMouseInput>;
  91768. /**
  91769. * Instantiates a new FreeCameraInputsManager.
  91770. * @param camera Defines the camera the inputs belong to
  91771. */
  91772. constructor(camera: FreeCamera);
  91773. /**
  91774. * Add keyboard input support to the input manager.
  91775. * @returns the current input manager
  91776. */
  91777. addKeyboard(): FreeCameraInputsManager;
  91778. /**
  91779. * Add mouse input support to the input manager.
  91780. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91781. * @returns the current input manager
  91782. */
  91783. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91784. /**
  91785. * Removes the mouse input support from the manager
  91786. * @returns the current input manager
  91787. */
  91788. removeMouse(): FreeCameraInputsManager;
  91789. /**
  91790. * Add touch input support to the input manager.
  91791. * @returns the current input manager
  91792. */
  91793. addTouch(): FreeCameraInputsManager;
  91794. /**
  91795. * Remove all attached input methods from a camera
  91796. */
  91797. clear(): void;
  91798. }
  91799. }
  91800. declare module BABYLON {
  91801. /**
  91802. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91803. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91804. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91805. */
  91806. export class FreeCamera extends TargetCamera {
  91807. /**
  91808. * Define the collision ellipsoid of the camera.
  91809. * This is helpful to simulate a camera body like the player body around the camera
  91810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91811. */
  91812. ellipsoid: Vector3;
  91813. /**
  91814. * Define an offset for the position of the ellipsoid around the camera.
  91815. * This can be helpful to determine the center of the body near the gravity center of the body
  91816. * instead of its head.
  91817. */
  91818. ellipsoidOffset: Vector3;
  91819. /**
  91820. * Enable or disable collisions of the camera with the rest of the scene objects.
  91821. */
  91822. checkCollisions: boolean;
  91823. /**
  91824. * Enable or disable gravity on the camera.
  91825. */
  91826. applyGravity: boolean;
  91827. /**
  91828. * Define the input manager associated to the camera.
  91829. */
  91830. inputs: FreeCameraInputsManager;
  91831. /**
  91832. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91833. * Higher values reduce sensitivity.
  91834. */
  91835. get angularSensibility(): number;
  91836. /**
  91837. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91838. * Higher values reduce sensitivity.
  91839. */
  91840. set angularSensibility(value: number);
  91841. /**
  91842. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91843. */
  91844. get keysUp(): number[];
  91845. set keysUp(value: number[]);
  91846. /**
  91847. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91848. */
  91849. get keysDown(): number[];
  91850. set keysDown(value: number[]);
  91851. /**
  91852. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91853. */
  91854. get keysLeft(): number[];
  91855. set keysLeft(value: number[]);
  91856. /**
  91857. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91858. */
  91859. get keysRight(): number[];
  91860. set keysRight(value: number[]);
  91861. /**
  91862. * Event raised when the camera collide with a mesh in the scene.
  91863. */
  91864. onCollide: (collidedMesh: AbstractMesh) => void;
  91865. private _collider;
  91866. private _needMoveForGravity;
  91867. private _oldPosition;
  91868. private _diffPosition;
  91869. private _newPosition;
  91870. /** @hidden */
  91871. _localDirection: Vector3;
  91872. /** @hidden */
  91873. _transformedDirection: Vector3;
  91874. /**
  91875. * Instantiates a Free Camera.
  91876. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91877. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91879. * @param name Define the name of the camera in the scene
  91880. * @param position Define the start position of the camera in the scene
  91881. * @param scene Define the scene the camera belongs to
  91882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91883. */
  91884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91885. /**
  91886. * Attached controls to the current camera.
  91887. * @param element Defines the element the controls should be listened from
  91888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91889. */
  91890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91891. /**
  91892. * Detach the current controls from the camera.
  91893. * The camera will stop reacting to inputs.
  91894. * @param element Defines the element to stop listening the inputs from
  91895. */
  91896. detachControl(element: HTMLElement): void;
  91897. private _collisionMask;
  91898. /**
  91899. * Define a collision mask to limit the list of object the camera can collide with
  91900. */
  91901. get collisionMask(): number;
  91902. set collisionMask(mask: number);
  91903. /** @hidden */
  91904. _collideWithWorld(displacement: Vector3): void;
  91905. private _onCollisionPositionChange;
  91906. /** @hidden */
  91907. _checkInputs(): void;
  91908. /** @hidden */
  91909. _decideIfNeedsToMove(): boolean;
  91910. /** @hidden */
  91911. _updatePosition(): void;
  91912. /**
  91913. * Destroy the camera and release the current resources hold by it.
  91914. */
  91915. dispose(): void;
  91916. /**
  91917. * Gets the current object class name.
  91918. * @return the class name
  91919. */
  91920. getClassName(): string;
  91921. }
  91922. }
  91923. declare module BABYLON {
  91924. /**
  91925. * Represents a gamepad control stick position
  91926. */
  91927. export class StickValues {
  91928. /**
  91929. * The x component of the control stick
  91930. */
  91931. x: number;
  91932. /**
  91933. * The y component of the control stick
  91934. */
  91935. y: number;
  91936. /**
  91937. * Initializes the gamepad x and y control stick values
  91938. * @param x The x component of the gamepad control stick value
  91939. * @param y The y component of the gamepad control stick value
  91940. */
  91941. constructor(
  91942. /**
  91943. * The x component of the control stick
  91944. */
  91945. x: number,
  91946. /**
  91947. * The y component of the control stick
  91948. */
  91949. y: number);
  91950. }
  91951. /**
  91952. * An interface which manages callbacks for gamepad button changes
  91953. */
  91954. export interface GamepadButtonChanges {
  91955. /**
  91956. * Called when a gamepad has been changed
  91957. */
  91958. changed: boolean;
  91959. /**
  91960. * Called when a gamepad press event has been triggered
  91961. */
  91962. pressChanged: boolean;
  91963. /**
  91964. * Called when a touch event has been triggered
  91965. */
  91966. touchChanged: boolean;
  91967. /**
  91968. * Called when a value has changed
  91969. */
  91970. valueChanged: boolean;
  91971. }
  91972. /**
  91973. * Represents a gamepad
  91974. */
  91975. export class Gamepad {
  91976. /**
  91977. * The id of the gamepad
  91978. */
  91979. id: string;
  91980. /**
  91981. * The index of the gamepad
  91982. */
  91983. index: number;
  91984. /**
  91985. * The browser gamepad
  91986. */
  91987. browserGamepad: any;
  91988. /**
  91989. * Specifies what type of gamepad this represents
  91990. */
  91991. type: number;
  91992. private _leftStick;
  91993. private _rightStick;
  91994. /** @hidden */
  91995. _isConnected: boolean;
  91996. private _leftStickAxisX;
  91997. private _leftStickAxisY;
  91998. private _rightStickAxisX;
  91999. private _rightStickAxisY;
  92000. /**
  92001. * Triggered when the left control stick has been changed
  92002. */
  92003. private _onleftstickchanged;
  92004. /**
  92005. * Triggered when the right control stick has been changed
  92006. */
  92007. private _onrightstickchanged;
  92008. /**
  92009. * Represents a gamepad controller
  92010. */
  92011. static GAMEPAD: number;
  92012. /**
  92013. * Represents a generic controller
  92014. */
  92015. static GENERIC: number;
  92016. /**
  92017. * Represents an XBox controller
  92018. */
  92019. static XBOX: number;
  92020. /**
  92021. * Represents a pose-enabled controller
  92022. */
  92023. static POSE_ENABLED: number;
  92024. /**
  92025. * Represents an Dual Shock controller
  92026. */
  92027. static DUALSHOCK: number;
  92028. /**
  92029. * Specifies whether the left control stick should be Y-inverted
  92030. */
  92031. protected _invertLeftStickY: boolean;
  92032. /**
  92033. * Specifies if the gamepad has been connected
  92034. */
  92035. get isConnected(): boolean;
  92036. /**
  92037. * Initializes the gamepad
  92038. * @param id The id of the gamepad
  92039. * @param index The index of the gamepad
  92040. * @param browserGamepad The browser gamepad
  92041. * @param leftStickX The x component of the left joystick
  92042. * @param leftStickY The y component of the left joystick
  92043. * @param rightStickX The x component of the right joystick
  92044. * @param rightStickY The y component of the right joystick
  92045. */
  92046. constructor(
  92047. /**
  92048. * The id of the gamepad
  92049. */
  92050. id: string,
  92051. /**
  92052. * The index of the gamepad
  92053. */
  92054. index: number,
  92055. /**
  92056. * The browser gamepad
  92057. */
  92058. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  92059. /**
  92060. * Callback triggered when the left joystick has changed
  92061. * @param callback
  92062. */
  92063. onleftstickchanged(callback: (values: StickValues) => void): void;
  92064. /**
  92065. * Callback triggered when the right joystick has changed
  92066. * @param callback
  92067. */
  92068. onrightstickchanged(callback: (values: StickValues) => void): void;
  92069. /**
  92070. * Gets the left joystick
  92071. */
  92072. get leftStick(): StickValues;
  92073. /**
  92074. * Sets the left joystick values
  92075. */
  92076. set leftStick(newValues: StickValues);
  92077. /**
  92078. * Gets the right joystick
  92079. */
  92080. get rightStick(): StickValues;
  92081. /**
  92082. * Sets the right joystick value
  92083. */
  92084. set rightStick(newValues: StickValues);
  92085. /**
  92086. * Updates the gamepad joystick positions
  92087. */
  92088. update(): void;
  92089. /**
  92090. * Disposes the gamepad
  92091. */
  92092. dispose(): void;
  92093. }
  92094. /**
  92095. * Represents a generic gamepad
  92096. */
  92097. export class GenericPad extends Gamepad {
  92098. private _buttons;
  92099. private _onbuttondown;
  92100. private _onbuttonup;
  92101. /**
  92102. * Observable triggered when a button has been pressed
  92103. */
  92104. onButtonDownObservable: Observable<number>;
  92105. /**
  92106. * Observable triggered when a button has been released
  92107. */
  92108. onButtonUpObservable: Observable<number>;
  92109. /**
  92110. * Callback triggered when a button has been pressed
  92111. * @param callback Called when a button has been pressed
  92112. */
  92113. onbuttondown(callback: (buttonPressed: number) => void): void;
  92114. /**
  92115. * Callback triggered when a button has been released
  92116. * @param callback Called when a button has been released
  92117. */
  92118. onbuttonup(callback: (buttonReleased: number) => void): void;
  92119. /**
  92120. * Initializes the generic gamepad
  92121. * @param id The id of the generic gamepad
  92122. * @param index The index of the generic gamepad
  92123. * @param browserGamepad The browser gamepad
  92124. */
  92125. constructor(id: string, index: number, browserGamepad: any);
  92126. private _setButtonValue;
  92127. /**
  92128. * Updates the generic gamepad
  92129. */
  92130. update(): void;
  92131. /**
  92132. * Disposes the generic gamepad
  92133. */
  92134. dispose(): void;
  92135. }
  92136. }
  92137. declare module BABYLON {
  92138. /**
  92139. * Defines the types of pose enabled controllers that are supported
  92140. */
  92141. export enum PoseEnabledControllerType {
  92142. /**
  92143. * HTC Vive
  92144. */
  92145. VIVE = 0,
  92146. /**
  92147. * Oculus Rift
  92148. */
  92149. OCULUS = 1,
  92150. /**
  92151. * Windows mixed reality
  92152. */
  92153. WINDOWS = 2,
  92154. /**
  92155. * Samsung gear VR
  92156. */
  92157. GEAR_VR = 3,
  92158. /**
  92159. * Google Daydream
  92160. */
  92161. DAYDREAM = 4,
  92162. /**
  92163. * Generic
  92164. */
  92165. GENERIC = 5
  92166. }
  92167. /**
  92168. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92169. */
  92170. export interface MutableGamepadButton {
  92171. /**
  92172. * Value of the button/trigger
  92173. */
  92174. value: number;
  92175. /**
  92176. * If the button/trigger is currently touched
  92177. */
  92178. touched: boolean;
  92179. /**
  92180. * If the button/trigger is currently pressed
  92181. */
  92182. pressed: boolean;
  92183. }
  92184. /**
  92185. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92186. * @hidden
  92187. */
  92188. export interface ExtendedGamepadButton extends GamepadButton {
  92189. /**
  92190. * If the button/trigger is currently pressed
  92191. */
  92192. readonly pressed: boolean;
  92193. /**
  92194. * If the button/trigger is currently touched
  92195. */
  92196. readonly touched: boolean;
  92197. /**
  92198. * Value of the button/trigger
  92199. */
  92200. readonly value: number;
  92201. }
  92202. /** @hidden */
  92203. export interface _GamePadFactory {
  92204. /**
  92205. * Returns whether or not the current gamepad can be created for this type of controller.
  92206. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92207. * @returns true if it can be created, otherwise false
  92208. */
  92209. canCreate(gamepadInfo: any): boolean;
  92210. /**
  92211. * Creates a new instance of the Gamepad.
  92212. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92213. * @returns the new gamepad instance
  92214. */
  92215. create(gamepadInfo: any): Gamepad;
  92216. }
  92217. /**
  92218. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92219. */
  92220. export class PoseEnabledControllerHelper {
  92221. /** @hidden */
  92222. static _ControllerFactories: _GamePadFactory[];
  92223. /** @hidden */
  92224. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92225. /**
  92226. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92227. * @param vrGamepad the gamepad to initialized
  92228. * @returns a vr controller of the type the gamepad identified as
  92229. */
  92230. static InitiateController(vrGamepad: any): Gamepad;
  92231. }
  92232. /**
  92233. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92234. */
  92235. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92236. /**
  92237. * If the controller is used in a webXR session
  92238. */
  92239. isXR: boolean;
  92240. private _deviceRoomPosition;
  92241. private _deviceRoomRotationQuaternion;
  92242. /**
  92243. * The device position in babylon space
  92244. */
  92245. devicePosition: Vector3;
  92246. /**
  92247. * The device rotation in babylon space
  92248. */
  92249. deviceRotationQuaternion: Quaternion;
  92250. /**
  92251. * The scale factor of the device in babylon space
  92252. */
  92253. deviceScaleFactor: number;
  92254. /**
  92255. * (Likely devicePosition should be used instead) The device position in its room space
  92256. */
  92257. position: Vector3;
  92258. /**
  92259. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92260. */
  92261. rotationQuaternion: Quaternion;
  92262. /**
  92263. * The type of controller (Eg. Windows mixed reality)
  92264. */
  92265. controllerType: PoseEnabledControllerType;
  92266. protected _calculatedPosition: Vector3;
  92267. private _calculatedRotation;
  92268. /**
  92269. * The raw pose from the device
  92270. */
  92271. rawPose: DevicePose;
  92272. private _trackPosition;
  92273. private _maxRotationDistFromHeadset;
  92274. private _draggedRoomRotation;
  92275. /**
  92276. * @hidden
  92277. */
  92278. _disableTrackPosition(fixedPosition: Vector3): void;
  92279. /**
  92280. * Internal, the mesh attached to the controller
  92281. * @hidden
  92282. */
  92283. _mesh: Nullable<AbstractMesh>;
  92284. private _poseControlledCamera;
  92285. private _leftHandSystemQuaternion;
  92286. /**
  92287. * Internal, matrix used to convert room space to babylon space
  92288. * @hidden
  92289. */
  92290. _deviceToWorld: Matrix;
  92291. /**
  92292. * Node to be used when casting a ray from the controller
  92293. * @hidden
  92294. */
  92295. _pointingPoseNode: Nullable<TransformNode>;
  92296. /**
  92297. * Name of the child mesh that can be used to cast a ray from the controller
  92298. */
  92299. static readonly POINTING_POSE: string;
  92300. /**
  92301. * Creates a new PoseEnabledController from a gamepad
  92302. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92303. */
  92304. constructor(browserGamepad: any);
  92305. private _workingMatrix;
  92306. /**
  92307. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92308. */
  92309. update(): void;
  92310. /**
  92311. * Updates only the pose device and mesh without doing any button event checking
  92312. */
  92313. protected _updatePoseAndMesh(): void;
  92314. /**
  92315. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92316. * @param poseData raw pose fromthe device
  92317. */
  92318. updateFromDevice(poseData: DevicePose): void;
  92319. /**
  92320. * @hidden
  92321. */
  92322. _meshAttachedObservable: Observable<AbstractMesh>;
  92323. /**
  92324. * Attaches a mesh to the controller
  92325. * @param mesh the mesh to be attached
  92326. */
  92327. attachToMesh(mesh: AbstractMesh): void;
  92328. /**
  92329. * Attaches the controllers mesh to a camera
  92330. * @param camera the camera the mesh should be attached to
  92331. */
  92332. attachToPoseControlledCamera(camera: TargetCamera): void;
  92333. /**
  92334. * Disposes of the controller
  92335. */
  92336. dispose(): void;
  92337. /**
  92338. * The mesh that is attached to the controller
  92339. */
  92340. get mesh(): Nullable<AbstractMesh>;
  92341. /**
  92342. * Gets the ray of the controller in the direction the controller is pointing
  92343. * @param length the length the resulting ray should be
  92344. * @returns a ray in the direction the controller is pointing
  92345. */
  92346. getForwardRay(length?: number): Ray;
  92347. }
  92348. }
  92349. declare module BABYLON {
  92350. /**
  92351. * Defines the WebVRController object that represents controllers tracked in 3D space
  92352. */
  92353. export abstract class WebVRController extends PoseEnabledController {
  92354. /**
  92355. * Internal, the default controller model for the controller
  92356. */
  92357. protected _defaultModel: Nullable<AbstractMesh>;
  92358. /**
  92359. * Fired when the trigger state has changed
  92360. */
  92361. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92362. /**
  92363. * Fired when the main button state has changed
  92364. */
  92365. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92366. /**
  92367. * Fired when the secondary button state has changed
  92368. */
  92369. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92370. /**
  92371. * Fired when the pad state has changed
  92372. */
  92373. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92374. /**
  92375. * Fired when controllers stick values have changed
  92376. */
  92377. onPadValuesChangedObservable: Observable<StickValues>;
  92378. /**
  92379. * Array of button availible on the controller
  92380. */
  92381. protected _buttons: Array<MutableGamepadButton>;
  92382. private _onButtonStateChange;
  92383. /**
  92384. * Fired when a controller button's state has changed
  92385. * @param callback the callback containing the button that was modified
  92386. */
  92387. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92388. /**
  92389. * X and Y axis corresponding to the controllers joystick
  92390. */
  92391. pad: StickValues;
  92392. /**
  92393. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92394. */
  92395. hand: string;
  92396. /**
  92397. * The default controller model for the controller
  92398. */
  92399. get defaultModel(): Nullable<AbstractMesh>;
  92400. /**
  92401. * Creates a new WebVRController from a gamepad
  92402. * @param vrGamepad the gamepad that the WebVRController should be created from
  92403. */
  92404. constructor(vrGamepad: any);
  92405. /**
  92406. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92407. */
  92408. update(): void;
  92409. /**
  92410. * Function to be called when a button is modified
  92411. */
  92412. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92413. /**
  92414. * Loads a mesh and attaches it to the controller
  92415. * @param scene the scene the mesh should be added to
  92416. * @param meshLoaded callback for when the mesh has been loaded
  92417. */
  92418. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92419. private _setButtonValue;
  92420. private _changes;
  92421. private _checkChanges;
  92422. /**
  92423. * Disposes of th webVRCOntroller
  92424. */
  92425. dispose(): void;
  92426. }
  92427. }
  92428. declare module BABYLON {
  92429. /**
  92430. * The HemisphericLight simulates the ambient environment light,
  92431. * so the passed direction is the light reflection direction, not the incoming direction.
  92432. */
  92433. export class HemisphericLight extends Light {
  92434. /**
  92435. * The groundColor is the light in the opposite direction to the one specified during creation.
  92436. * 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.
  92437. */
  92438. groundColor: Color3;
  92439. /**
  92440. * The light reflection direction, not the incoming direction.
  92441. */
  92442. direction: Vector3;
  92443. /**
  92444. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92445. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92446. * The HemisphericLight can't cast shadows.
  92447. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92448. * @param name The friendly name of the light
  92449. * @param direction The direction of the light reflection
  92450. * @param scene The scene the light belongs to
  92451. */
  92452. constructor(name: string, direction: Vector3, scene: Scene);
  92453. protected _buildUniformLayout(): void;
  92454. /**
  92455. * Returns the string "HemisphericLight".
  92456. * @return The class name
  92457. */
  92458. getClassName(): string;
  92459. /**
  92460. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92461. * Returns the updated direction.
  92462. * @param target The target the direction should point to
  92463. * @return The computed direction
  92464. */
  92465. setDirectionToTarget(target: Vector3): Vector3;
  92466. /**
  92467. * Returns the shadow generator associated to the light.
  92468. * @returns Always null for hemispheric lights because it does not support shadows.
  92469. */
  92470. getShadowGenerator(): Nullable<IShadowGenerator>;
  92471. /**
  92472. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92473. * @param effect The effect to update
  92474. * @param lightIndex The index of the light in the effect to update
  92475. * @returns The hemispheric light
  92476. */
  92477. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92478. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92479. /**
  92480. * Computes the world matrix of the node
  92481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92482. * @param useWasUpdatedFlag defines a reserved property
  92483. * @returns the world matrix
  92484. */
  92485. computeWorldMatrix(): Matrix;
  92486. /**
  92487. * Returns the integer 3.
  92488. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92489. */
  92490. getTypeID(): number;
  92491. /**
  92492. * Prepares the list of defines specific to the light type.
  92493. * @param defines the list of defines
  92494. * @param lightIndex defines the index of the light for the effect
  92495. */
  92496. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92497. }
  92498. }
  92499. declare module BABYLON {
  92500. /** @hidden */
  92501. export var vrMultiviewToSingleviewPixelShader: {
  92502. name: string;
  92503. shader: string;
  92504. };
  92505. }
  92506. declare module BABYLON {
  92507. /**
  92508. * Renders to multiple views with a single draw call
  92509. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92510. */
  92511. export class MultiviewRenderTarget extends RenderTargetTexture {
  92512. /**
  92513. * Creates a multiview render target
  92514. * @param scene scene used with the render target
  92515. * @param size the size of the render target (used for each view)
  92516. */
  92517. constructor(scene: Scene, size?: number | {
  92518. width: number;
  92519. height: number;
  92520. } | {
  92521. ratio: number;
  92522. });
  92523. /**
  92524. * @hidden
  92525. * @param faceIndex the face index, if its a cube texture
  92526. */
  92527. _bindFrameBuffer(faceIndex?: number): void;
  92528. /**
  92529. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92530. * @returns the view count
  92531. */
  92532. getViewCount(): number;
  92533. }
  92534. }
  92535. declare module BABYLON {
  92536. /**
  92537. * Represents a camera frustum
  92538. */
  92539. export class Frustum {
  92540. /**
  92541. * Gets the planes representing the frustum
  92542. * @param transform matrix to be applied to the returned planes
  92543. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92544. */
  92545. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92546. /**
  92547. * Gets the near frustum plane transformed by the transform matrix
  92548. * @param transform transformation matrix to be applied to the resulting frustum plane
  92549. * @param frustumPlane the resuling frustum plane
  92550. */
  92551. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92552. /**
  92553. * Gets the far frustum plane transformed by the transform matrix
  92554. * @param transform transformation matrix to be applied to the resulting frustum plane
  92555. * @param frustumPlane the resuling frustum plane
  92556. */
  92557. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92558. /**
  92559. * Gets the left frustum plane transformed by the transform matrix
  92560. * @param transform transformation matrix to be applied to the resulting frustum plane
  92561. * @param frustumPlane the resuling frustum plane
  92562. */
  92563. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92564. /**
  92565. * Gets the right frustum plane transformed by the transform matrix
  92566. * @param transform transformation matrix to be applied to the resulting frustum plane
  92567. * @param frustumPlane the resuling frustum plane
  92568. */
  92569. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92570. /**
  92571. * Gets the top frustum plane transformed by the transform matrix
  92572. * @param transform transformation matrix to be applied to the resulting frustum plane
  92573. * @param frustumPlane the resuling frustum plane
  92574. */
  92575. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92576. /**
  92577. * Gets the bottom frustum plane transformed by the transform matrix
  92578. * @param transform transformation matrix to be applied to the resulting frustum plane
  92579. * @param frustumPlane the resuling frustum plane
  92580. */
  92581. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92582. /**
  92583. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92584. * @param transform transformation matrix to be applied to the resulting frustum planes
  92585. * @param frustumPlanes the resuling frustum planes
  92586. */
  92587. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92588. }
  92589. }
  92590. declare module BABYLON {
  92591. interface Engine {
  92592. /**
  92593. * Creates a new multiview render target
  92594. * @param width defines the width of the texture
  92595. * @param height defines the height of the texture
  92596. * @returns the created multiview texture
  92597. */
  92598. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92599. /**
  92600. * Binds a multiview framebuffer to be drawn to
  92601. * @param multiviewTexture texture to bind
  92602. */
  92603. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92604. }
  92605. interface Camera {
  92606. /**
  92607. * @hidden
  92608. * 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)
  92609. */
  92610. _useMultiviewToSingleView: boolean;
  92611. /**
  92612. * @hidden
  92613. * 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)
  92614. */
  92615. _multiviewTexture: Nullable<RenderTargetTexture>;
  92616. /**
  92617. * @hidden
  92618. * ensures the multiview texture of the camera exists and has the specified width/height
  92619. * @param width height to set on the multiview texture
  92620. * @param height width to set on the multiview texture
  92621. */
  92622. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92623. }
  92624. interface Scene {
  92625. /** @hidden */
  92626. _transformMatrixR: Matrix;
  92627. /** @hidden */
  92628. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92629. /** @hidden */
  92630. _createMultiviewUbo(): void;
  92631. /** @hidden */
  92632. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92633. /** @hidden */
  92634. _renderMultiviewToSingleView(camera: Camera): void;
  92635. }
  92636. }
  92637. declare module BABYLON {
  92638. /**
  92639. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92640. * This will not be used for webXR as it supports displaying texture arrays directly
  92641. */
  92642. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92643. /**
  92644. * Initializes a VRMultiviewToSingleview
  92645. * @param name name of the post process
  92646. * @param camera camera to be applied to
  92647. * @param scaleFactor scaling factor to the size of the output texture
  92648. */
  92649. constructor(name: string, camera: Camera, scaleFactor: number);
  92650. }
  92651. }
  92652. declare module BABYLON {
  92653. /**
  92654. * Interface used to define additional presentation attributes
  92655. */
  92656. export interface IVRPresentationAttributes {
  92657. /**
  92658. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92659. */
  92660. highRefreshRate: boolean;
  92661. /**
  92662. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92663. */
  92664. foveationLevel: number;
  92665. }
  92666. interface Engine {
  92667. /** @hidden */
  92668. _vrDisplay: any;
  92669. /** @hidden */
  92670. _vrSupported: boolean;
  92671. /** @hidden */
  92672. _oldSize: Size;
  92673. /** @hidden */
  92674. _oldHardwareScaleFactor: number;
  92675. /** @hidden */
  92676. _vrExclusivePointerMode: boolean;
  92677. /** @hidden */
  92678. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92679. /** @hidden */
  92680. _onVRDisplayPointerRestricted: () => void;
  92681. /** @hidden */
  92682. _onVRDisplayPointerUnrestricted: () => void;
  92683. /** @hidden */
  92684. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92685. /** @hidden */
  92686. _onVrDisplayDisconnect: Nullable<() => void>;
  92687. /** @hidden */
  92688. _onVrDisplayPresentChange: Nullable<() => void>;
  92689. /**
  92690. * Observable signaled when VR display mode changes
  92691. */
  92692. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92693. /**
  92694. * Observable signaled when VR request present is complete
  92695. */
  92696. onVRRequestPresentComplete: Observable<boolean>;
  92697. /**
  92698. * Observable signaled when VR request present starts
  92699. */
  92700. onVRRequestPresentStart: Observable<Engine>;
  92701. /**
  92702. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92703. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92704. */
  92705. isInVRExclusivePointerMode: boolean;
  92706. /**
  92707. * Gets a boolean indicating if a webVR device was detected
  92708. * @returns true if a webVR device was detected
  92709. */
  92710. isVRDevicePresent(): boolean;
  92711. /**
  92712. * Gets the current webVR device
  92713. * @returns the current webVR device (or null)
  92714. */
  92715. getVRDevice(): any;
  92716. /**
  92717. * Initializes a webVR display and starts listening to display change events
  92718. * The onVRDisplayChangedObservable will be notified upon these changes
  92719. * @returns A promise containing a VRDisplay and if vr is supported
  92720. */
  92721. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92722. /** @hidden */
  92723. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92724. /**
  92725. * Gets or sets the presentation attributes used to configure VR rendering
  92726. */
  92727. vrPresentationAttributes?: IVRPresentationAttributes;
  92728. /**
  92729. * Call this function to switch to webVR mode
  92730. * Will do nothing if webVR is not supported or if there is no webVR device
  92731. * @param options the webvr options provided to the camera. mainly used for multiview
  92732. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92733. */
  92734. enableVR(options: WebVROptions): void;
  92735. /** @hidden */
  92736. _onVRFullScreenTriggered(): void;
  92737. }
  92738. }
  92739. declare module BABYLON {
  92740. /**
  92741. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92742. * IMPORTANT!! The data is right-hand data.
  92743. * @export
  92744. * @interface DevicePose
  92745. */
  92746. export interface DevicePose {
  92747. /**
  92748. * The position of the device, values in array are [x,y,z].
  92749. */
  92750. readonly position: Nullable<Float32Array>;
  92751. /**
  92752. * The linearVelocity of the device, values in array are [x,y,z].
  92753. */
  92754. readonly linearVelocity: Nullable<Float32Array>;
  92755. /**
  92756. * The linearAcceleration of the device, values in array are [x,y,z].
  92757. */
  92758. readonly linearAcceleration: Nullable<Float32Array>;
  92759. /**
  92760. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92761. */
  92762. readonly orientation: Nullable<Float32Array>;
  92763. /**
  92764. * The angularVelocity of the device, values in array are [x,y,z].
  92765. */
  92766. readonly angularVelocity: Nullable<Float32Array>;
  92767. /**
  92768. * The angularAcceleration of the device, values in array are [x,y,z].
  92769. */
  92770. readonly angularAcceleration: Nullable<Float32Array>;
  92771. }
  92772. /**
  92773. * Interface representing a pose controlled object in Babylon.
  92774. * A pose controlled object has both regular pose values as well as pose values
  92775. * from an external device such as a VR head mounted display
  92776. */
  92777. export interface PoseControlled {
  92778. /**
  92779. * The position of the object in babylon space.
  92780. */
  92781. position: Vector3;
  92782. /**
  92783. * The rotation quaternion of the object in babylon space.
  92784. */
  92785. rotationQuaternion: Quaternion;
  92786. /**
  92787. * The position of the device in babylon space.
  92788. */
  92789. devicePosition?: Vector3;
  92790. /**
  92791. * The rotation quaternion of the device in babylon space.
  92792. */
  92793. deviceRotationQuaternion: Quaternion;
  92794. /**
  92795. * The raw pose coming from the device.
  92796. */
  92797. rawPose: Nullable<DevicePose>;
  92798. /**
  92799. * The scale of the device to be used when translating from device space to babylon space.
  92800. */
  92801. deviceScaleFactor: number;
  92802. /**
  92803. * Updates the poseControlled values based on the input device pose.
  92804. * @param poseData the pose data to update the object with
  92805. */
  92806. updateFromDevice(poseData: DevicePose): void;
  92807. }
  92808. /**
  92809. * Set of options to customize the webVRCamera
  92810. */
  92811. export interface WebVROptions {
  92812. /**
  92813. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92814. */
  92815. trackPosition?: boolean;
  92816. /**
  92817. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92818. */
  92819. positionScale?: number;
  92820. /**
  92821. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92822. */
  92823. displayName?: string;
  92824. /**
  92825. * Should the native controller meshes be initialized. (default: true)
  92826. */
  92827. controllerMeshes?: boolean;
  92828. /**
  92829. * Creating a default HemiLight only on controllers. (default: true)
  92830. */
  92831. defaultLightingOnControllers?: boolean;
  92832. /**
  92833. * If you don't want to use the default VR button of the helper. (default: false)
  92834. */
  92835. useCustomVRButton?: boolean;
  92836. /**
  92837. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92838. */
  92839. customVRButton?: HTMLButtonElement;
  92840. /**
  92841. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92842. */
  92843. rayLength?: number;
  92844. /**
  92845. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92846. */
  92847. defaultHeight?: number;
  92848. /**
  92849. * If multiview should be used if availible (default: false)
  92850. */
  92851. useMultiview?: boolean;
  92852. }
  92853. /**
  92854. * This represents a WebVR camera.
  92855. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92856. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92857. */
  92858. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92859. private webVROptions;
  92860. /**
  92861. * @hidden
  92862. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92863. */
  92864. _vrDevice: any;
  92865. /**
  92866. * The rawPose of the vrDevice.
  92867. */
  92868. rawPose: Nullable<DevicePose>;
  92869. private _onVREnabled;
  92870. private _specsVersion;
  92871. private _attached;
  92872. private _frameData;
  92873. protected _descendants: Array<Node>;
  92874. private _deviceRoomPosition;
  92875. /** @hidden */
  92876. _deviceRoomRotationQuaternion: Quaternion;
  92877. private _standingMatrix;
  92878. /**
  92879. * Represents device position in babylon space.
  92880. */
  92881. devicePosition: Vector3;
  92882. /**
  92883. * Represents device rotation in babylon space.
  92884. */
  92885. deviceRotationQuaternion: Quaternion;
  92886. /**
  92887. * The scale of the device to be used when translating from device space to babylon space.
  92888. */
  92889. deviceScaleFactor: number;
  92890. private _deviceToWorld;
  92891. private _worldToDevice;
  92892. /**
  92893. * References to the webVR controllers for the vrDevice.
  92894. */
  92895. controllers: Array<WebVRController>;
  92896. /**
  92897. * Emits an event when a controller is attached.
  92898. */
  92899. onControllersAttachedObservable: Observable<WebVRController[]>;
  92900. /**
  92901. * Emits an event when a controller's mesh has been loaded;
  92902. */
  92903. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92904. /**
  92905. * Emits an event when the HMD's pose has been updated.
  92906. */
  92907. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92908. private _poseSet;
  92909. /**
  92910. * If the rig cameras be used as parent instead of this camera.
  92911. */
  92912. rigParenting: boolean;
  92913. private _lightOnControllers;
  92914. private _defaultHeight?;
  92915. /**
  92916. * Instantiates a WebVRFreeCamera.
  92917. * @param name The name of the WebVRFreeCamera
  92918. * @param position The starting anchor position for the camera
  92919. * @param scene The scene the camera belongs to
  92920. * @param webVROptions a set of customizable options for the webVRCamera
  92921. */
  92922. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92923. /**
  92924. * Gets the device distance from the ground in meters.
  92925. * @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.
  92926. */
  92927. deviceDistanceToRoomGround(): number;
  92928. /**
  92929. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92930. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92931. */
  92932. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92933. /**
  92934. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92935. * @returns A promise with a boolean set to if the standing matrix is supported.
  92936. */
  92937. useStandingMatrixAsync(): Promise<boolean>;
  92938. /**
  92939. * Disposes the camera
  92940. */
  92941. dispose(): void;
  92942. /**
  92943. * Gets a vrController by name.
  92944. * @param name The name of the controller to retreive
  92945. * @returns the controller matching the name specified or null if not found
  92946. */
  92947. getControllerByName(name: string): Nullable<WebVRController>;
  92948. private _leftController;
  92949. /**
  92950. * The controller corresponding to the users left hand.
  92951. */
  92952. get leftController(): Nullable<WebVRController>;
  92953. private _rightController;
  92954. /**
  92955. * The controller corresponding to the users right hand.
  92956. */
  92957. get rightController(): Nullable<WebVRController>;
  92958. /**
  92959. * Casts a ray forward from the vrCamera's gaze.
  92960. * @param length Length of the ray (default: 100)
  92961. * @returns the ray corresponding to the gaze
  92962. */
  92963. getForwardRay(length?: number): Ray;
  92964. /**
  92965. * @hidden
  92966. * Updates the camera based on device's frame data
  92967. */
  92968. _checkInputs(): void;
  92969. /**
  92970. * Updates the poseControlled values based on the input device pose.
  92971. * @param poseData Pose coming from the device
  92972. */
  92973. updateFromDevice(poseData: DevicePose): void;
  92974. private _htmlElementAttached;
  92975. private _detachIfAttached;
  92976. /**
  92977. * WebVR's attach control will start broadcasting frames to the device.
  92978. * Note that in certain browsers (chrome for example) this function must be called
  92979. * within a user-interaction callback. Example:
  92980. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92981. *
  92982. * @param element html element to attach the vrDevice to
  92983. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92984. */
  92985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92986. /**
  92987. * Detaches the camera from the html element and disables VR
  92988. *
  92989. * @param element html element to detach from
  92990. */
  92991. detachControl(element: HTMLElement): void;
  92992. /**
  92993. * @returns the name of this class
  92994. */
  92995. getClassName(): string;
  92996. /**
  92997. * Calls resetPose on the vrDisplay
  92998. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92999. */
  93000. resetToCurrentRotation(): void;
  93001. /**
  93002. * @hidden
  93003. * Updates the rig cameras (left and right eye)
  93004. */
  93005. _updateRigCameras(): void;
  93006. private _workingVector;
  93007. private _oneVector;
  93008. private _workingMatrix;
  93009. private updateCacheCalled;
  93010. private _correctPositionIfNotTrackPosition;
  93011. /**
  93012. * @hidden
  93013. * Updates the cached values of the camera
  93014. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93015. */
  93016. _updateCache(ignoreParentClass?: boolean): void;
  93017. /**
  93018. * @hidden
  93019. * Get current device position in babylon world
  93020. */
  93021. _computeDevicePosition(): void;
  93022. /**
  93023. * Updates the current device position and rotation in the babylon world
  93024. */
  93025. update(): void;
  93026. /**
  93027. * @hidden
  93028. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93029. * @returns an identity matrix
  93030. */
  93031. _getViewMatrix(): Matrix;
  93032. private _tmpMatrix;
  93033. /**
  93034. * This function is called by the two RIG cameras.
  93035. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93036. * @hidden
  93037. */
  93038. _getWebVRViewMatrix(): Matrix;
  93039. /** @hidden */
  93040. _getWebVRProjectionMatrix(): Matrix;
  93041. private _onGamepadConnectedObserver;
  93042. private _onGamepadDisconnectedObserver;
  93043. private _updateCacheWhenTrackingDisabledObserver;
  93044. /**
  93045. * Initializes the controllers and their meshes
  93046. */
  93047. initControllers(): void;
  93048. }
  93049. }
  93050. declare module BABYLON {
  93051. /**
  93052. * Size options for a post process
  93053. */
  93054. export type PostProcessOptions = {
  93055. width: number;
  93056. height: number;
  93057. };
  93058. /**
  93059. * PostProcess can be used to apply a shader to a texture after it has been rendered
  93060. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93061. */
  93062. export class PostProcess {
  93063. /** Name of the PostProcess. */
  93064. name: string;
  93065. /**
  93066. * Gets or sets the unique id of the post process
  93067. */
  93068. uniqueId: number;
  93069. /**
  93070. * Width of the texture to apply the post process on
  93071. */
  93072. width: number;
  93073. /**
  93074. * Height of the texture to apply the post process on
  93075. */
  93076. height: number;
  93077. /**
  93078. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93079. * @hidden
  93080. */
  93081. _outputTexture: Nullable<InternalTexture>;
  93082. /**
  93083. * Sampling mode used by the shader
  93084. * See https://doc.babylonjs.com/classes/3.1/texture
  93085. */
  93086. renderTargetSamplingMode: number;
  93087. /**
  93088. * Clear color to use when screen clearing
  93089. */
  93090. clearColor: Color4;
  93091. /**
  93092. * If the buffer needs to be cleared before applying the post process. (default: true)
  93093. * Should be set to false if shader will overwrite all previous pixels.
  93094. */
  93095. autoClear: boolean;
  93096. /**
  93097. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93098. */
  93099. alphaMode: number;
  93100. /**
  93101. * Sets the setAlphaBlendConstants of the babylon engine
  93102. */
  93103. alphaConstants: Color4;
  93104. /**
  93105. * Animations to be used for the post processing
  93106. */
  93107. animations: Animation[];
  93108. /**
  93109. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93110. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93111. */
  93112. enablePixelPerfectMode: boolean;
  93113. /**
  93114. * Force the postprocess to be applied without taking in account viewport
  93115. */
  93116. forceFullscreenViewport: boolean;
  93117. /**
  93118. * List of inspectable custom properties (used by the Inspector)
  93119. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93120. */
  93121. inspectableCustomProperties: IInspectable[];
  93122. /**
  93123. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93124. *
  93125. * | Value | Type | Description |
  93126. * | ----- | ----------------------------------- | ----------- |
  93127. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93128. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93129. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93130. *
  93131. */
  93132. scaleMode: number;
  93133. /**
  93134. * Force textures to be a power of two (default: false)
  93135. */
  93136. alwaysForcePOT: boolean;
  93137. private _samples;
  93138. /**
  93139. * Number of sample textures (default: 1)
  93140. */
  93141. get samples(): number;
  93142. set samples(n: number);
  93143. /**
  93144. * Modify the scale of the post process to be the same as the viewport (default: false)
  93145. */
  93146. adaptScaleToCurrentViewport: boolean;
  93147. private _camera;
  93148. private _scene;
  93149. private _engine;
  93150. private _options;
  93151. private _reusable;
  93152. private _textureType;
  93153. private _textureFormat;
  93154. /**
  93155. * Smart array of input and output textures for the post process.
  93156. * @hidden
  93157. */
  93158. _textures: SmartArray<InternalTexture>;
  93159. /**
  93160. * The index in _textures that corresponds to the output texture.
  93161. * @hidden
  93162. */
  93163. _currentRenderTextureInd: number;
  93164. private _effect;
  93165. private _samplers;
  93166. private _fragmentUrl;
  93167. private _vertexUrl;
  93168. private _parameters;
  93169. private _scaleRatio;
  93170. protected _indexParameters: any;
  93171. private _shareOutputWithPostProcess;
  93172. private _texelSize;
  93173. private _forcedOutputTexture;
  93174. /**
  93175. * Returns the fragment url or shader name used in the post process.
  93176. * @returns the fragment url or name in the shader store.
  93177. */
  93178. getEffectName(): string;
  93179. /**
  93180. * An event triggered when the postprocess is activated.
  93181. */
  93182. onActivateObservable: Observable<Camera>;
  93183. private _onActivateObserver;
  93184. /**
  93185. * A function that is added to the onActivateObservable
  93186. */
  93187. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93188. /**
  93189. * An event triggered when the postprocess changes its size.
  93190. */
  93191. onSizeChangedObservable: Observable<PostProcess>;
  93192. private _onSizeChangedObserver;
  93193. /**
  93194. * A function that is added to the onSizeChangedObservable
  93195. */
  93196. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93197. /**
  93198. * An event triggered when the postprocess applies its effect.
  93199. */
  93200. onApplyObservable: Observable<Effect>;
  93201. private _onApplyObserver;
  93202. /**
  93203. * A function that is added to the onApplyObservable
  93204. */
  93205. set onApply(callback: (effect: Effect) => void);
  93206. /**
  93207. * An event triggered before rendering the postprocess
  93208. */
  93209. onBeforeRenderObservable: Observable<Effect>;
  93210. private _onBeforeRenderObserver;
  93211. /**
  93212. * A function that is added to the onBeforeRenderObservable
  93213. */
  93214. set onBeforeRender(callback: (effect: Effect) => void);
  93215. /**
  93216. * An event triggered after rendering the postprocess
  93217. */
  93218. onAfterRenderObservable: Observable<Effect>;
  93219. private _onAfterRenderObserver;
  93220. /**
  93221. * A function that is added to the onAfterRenderObservable
  93222. */
  93223. set onAfterRender(callback: (efect: Effect) => void);
  93224. /**
  93225. * 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
  93226. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93227. */
  93228. get inputTexture(): InternalTexture;
  93229. set inputTexture(value: InternalTexture);
  93230. /**
  93231. * Gets the camera which post process is applied to.
  93232. * @returns The camera the post process is applied to.
  93233. */
  93234. getCamera(): Camera;
  93235. /**
  93236. * Gets the texel size of the postprocess.
  93237. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93238. */
  93239. get texelSize(): Vector2;
  93240. /**
  93241. * Creates a new instance PostProcess
  93242. * @param name The name of the PostProcess.
  93243. * @param fragmentUrl The url of the fragment shader to be used.
  93244. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93245. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93246. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93247. * @param camera The camera to apply the render pass to.
  93248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93249. * @param engine The engine which the post process will be applied. (default: current engine)
  93250. * @param reusable If the post process can be reused on the same frame. (default: false)
  93251. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93252. * @param textureType Type of textures used when performing the post process. (default: 0)
  93253. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93254. * @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
  93255. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93256. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93257. */
  93258. constructor(
  93259. /** Name of the PostProcess. */
  93260. 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);
  93261. /**
  93262. * Gets a string idenfifying the name of the class
  93263. * @returns "PostProcess" string
  93264. */
  93265. getClassName(): string;
  93266. /**
  93267. * Gets the engine which this post process belongs to.
  93268. * @returns The engine the post process was enabled with.
  93269. */
  93270. getEngine(): Engine;
  93271. /**
  93272. * The effect that is created when initializing the post process.
  93273. * @returns The created effect corresponding the the postprocess.
  93274. */
  93275. getEffect(): Effect;
  93276. /**
  93277. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93278. * @param postProcess The post process to share the output with.
  93279. * @returns This post process.
  93280. */
  93281. shareOutputWith(postProcess: PostProcess): PostProcess;
  93282. /**
  93283. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93284. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93285. */
  93286. useOwnOutput(): void;
  93287. /**
  93288. * Updates the effect with the current post process compile time values and recompiles the shader.
  93289. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93290. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93291. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93292. * @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
  93293. * @param onCompiled Called when the shader has been compiled.
  93294. * @param onError Called if there is an error when compiling a shader.
  93295. */
  93296. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93297. /**
  93298. * The post process is reusable if it can be used multiple times within one frame.
  93299. * @returns If the post process is reusable
  93300. */
  93301. isReusable(): boolean;
  93302. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93303. markTextureDirty(): void;
  93304. /**
  93305. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93306. * 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.
  93307. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93308. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93309. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93310. * @returns The target texture that was bound to be written to.
  93311. */
  93312. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93313. /**
  93314. * If the post process is supported.
  93315. */
  93316. get isSupported(): boolean;
  93317. /**
  93318. * The aspect ratio of the output texture.
  93319. */
  93320. get aspectRatio(): number;
  93321. /**
  93322. * Get a value indicating if the post-process is ready to be used
  93323. * @returns true if the post-process is ready (shader is compiled)
  93324. */
  93325. isReady(): boolean;
  93326. /**
  93327. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93328. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93329. */
  93330. apply(): Nullable<Effect>;
  93331. private _disposeTextures;
  93332. /**
  93333. * Disposes the post process.
  93334. * @param camera The camera to dispose the post process on.
  93335. */
  93336. dispose(camera?: Camera): void;
  93337. }
  93338. }
  93339. declare module BABYLON {
  93340. /** @hidden */
  93341. export var kernelBlurVaryingDeclaration: {
  93342. name: string;
  93343. shader: string;
  93344. };
  93345. }
  93346. declare module BABYLON {
  93347. /** @hidden */
  93348. export var kernelBlurFragment: {
  93349. name: string;
  93350. shader: string;
  93351. };
  93352. }
  93353. declare module BABYLON {
  93354. /** @hidden */
  93355. export var kernelBlurFragment2: {
  93356. name: string;
  93357. shader: string;
  93358. };
  93359. }
  93360. declare module BABYLON {
  93361. /** @hidden */
  93362. export var kernelBlurPixelShader: {
  93363. name: string;
  93364. shader: string;
  93365. };
  93366. }
  93367. declare module BABYLON {
  93368. /** @hidden */
  93369. export var kernelBlurVertex: {
  93370. name: string;
  93371. shader: string;
  93372. };
  93373. }
  93374. declare module BABYLON {
  93375. /** @hidden */
  93376. export var kernelBlurVertexShader: {
  93377. name: string;
  93378. shader: string;
  93379. };
  93380. }
  93381. declare module BABYLON {
  93382. /**
  93383. * The Blur Post Process which blurs an image based on a kernel and direction.
  93384. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93385. */
  93386. export class BlurPostProcess extends PostProcess {
  93387. /** The direction in which to blur the image. */
  93388. direction: Vector2;
  93389. private blockCompilation;
  93390. protected _kernel: number;
  93391. protected _idealKernel: number;
  93392. protected _packedFloat: boolean;
  93393. private _staticDefines;
  93394. /**
  93395. * Sets the length in pixels of the blur sample region
  93396. */
  93397. set kernel(v: number);
  93398. /**
  93399. * Gets the length in pixels of the blur sample region
  93400. */
  93401. get kernel(): number;
  93402. /**
  93403. * Sets wether or not the blur needs to unpack/repack floats
  93404. */
  93405. set packedFloat(v: boolean);
  93406. /**
  93407. * Gets wether or not the blur is unpacking/repacking floats
  93408. */
  93409. get packedFloat(): boolean;
  93410. /**
  93411. * Creates a new instance BlurPostProcess
  93412. * @param name The name of the effect.
  93413. * @param direction The direction in which to blur the image.
  93414. * @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.
  93415. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93416. * @param camera The camera to apply the render pass to.
  93417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93418. * @param engine The engine which the post process will be applied. (default: current engine)
  93419. * @param reusable If the post process can be reused on the same frame. (default: false)
  93420. * @param textureType Type of textures used when performing the post process. (default: 0)
  93421. * @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)
  93422. */
  93423. constructor(name: string,
  93424. /** The direction in which to blur the image. */
  93425. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93426. /**
  93427. * Updates the effect with the current post process compile time values and recompiles the shader.
  93428. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93429. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93430. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93431. * @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
  93432. * @param onCompiled Called when the shader has been compiled.
  93433. * @param onError Called if there is an error when compiling a shader.
  93434. */
  93435. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93436. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93437. /**
  93438. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93439. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93440. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93441. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93442. * The gaps between physical kernels are compensated for in the weighting of the samples
  93443. * @param idealKernel Ideal blur kernel.
  93444. * @return Nearest best kernel.
  93445. */
  93446. protected _nearestBestKernel(idealKernel: number): number;
  93447. /**
  93448. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93449. * @param x The point on the Gaussian distribution to sample.
  93450. * @return the value of the Gaussian function at x.
  93451. */
  93452. protected _gaussianWeight(x: number): number;
  93453. /**
  93454. * Generates a string that can be used as a floating point number in GLSL.
  93455. * @param x Value to print.
  93456. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93457. * @return GLSL float string.
  93458. */
  93459. protected _glslFloat(x: number, decimalFigures?: number): string;
  93460. }
  93461. }
  93462. declare module BABYLON {
  93463. /**
  93464. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93465. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93466. * You can then easily use it as a reflectionTexture on a flat surface.
  93467. * In case the surface is not a plane, please consider relying on reflection probes.
  93468. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93469. */
  93470. export class MirrorTexture extends RenderTargetTexture {
  93471. private scene;
  93472. /**
  93473. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93474. * 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.
  93475. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93476. */
  93477. mirrorPlane: Plane;
  93478. /**
  93479. * Define the blur ratio used to blur the reflection if needed.
  93480. */
  93481. set blurRatio(value: number);
  93482. get blurRatio(): number;
  93483. /**
  93484. * Define the adaptive blur kernel used to blur the reflection if needed.
  93485. * This will autocompute the closest best match for the `blurKernel`
  93486. */
  93487. set adaptiveBlurKernel(value: number);
  93488. /**
  93489. * Define the blur kernel used to blur the reflection if needed.
  93490. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93491. */
  93492. set blurKernel(value: number);
  93493. /**
  93494. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93495. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93496. */
  93497. set blurKernelX(value: number);
  93498. get blurKernelX(): number;
  93499. /**
  93500. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93501. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93502. */
  93503. set blurKernelY(value: number);
  93504. get blurKernelY(): number;
  93505. private _autoComputeBlurKernel;
  93506. protected _onRatioRescale(): void;
  93507. private _updateGammaSpace;
  93508. private _imageProcessingConfigChangeObserver;
  93509. private _transformMatrix;
  93510. private _mirrorMatrix;
  93511. private _savedViewMatrix;
  93512. private _blurX;
  93513. private _blurY;
  93514. private _adaptiveBlurKernel;
  93515. private _blurKernelX;
  93516. private _blurKernelY;
  93517. private _blurRatio;
  93518. /**
  93519. * Instantiates a Mirror Texture.
  93520. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93521. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93522. * You can then easily use it as a reflectionTexture on a flat surface.
  93523. * In case the surface is not a plane, please consider relying on reflection probes.
  93524. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93525. * @param name
  93526. * @param size
  93527. * @param scene
  93528. * @param generateMipMaps
  93529. * @param type
  93530. * @param samplingMode
  93531. * @param generateDepthBuffer
  93532. */
  93533. constructor(name: string, size: number | {
  93534. width: number;
  93535. height: number;
  93536. } | {
  93537. ratio: number;
  93538. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93539. private _preparePostProcesses;
  93540. /**
  93541. * Clone the mirror texture.
  93542. * @returns the cloned texture
  93543. */
  93544. clone(): MirrorTexture;
  93545. /**
  93546. * Serialize the texture to a JSON representation you could use in Parse later on
  93547. * @returns the serialized JSON representation
  93548. */
  93549. serialize(): any;
  93550. /**
  93551. * Dispose the texture and release its associated resources.
  93552. */
  93553. dispose(): void;
  93554. }
  93555. }
  93556. declare module BABYLON {
  93557. /**
  93558. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93559. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93560. */
  93561. export class Texture extends BaseTexture {
  93562. /**
  93563. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93564. */
  93565. static SerializeBuffers: boolean;
  93566. /** @hidden */
  93567. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93568. /** @hidden */
  93569. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93570. /** @hidden */
  93571. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93572. /** nearest is mag = nearest and min = nearest and mip = linear */
  93573. static readonly NEAREST_SAMPLINGMODE: number;
  93574. /** nearest is mag = nearest and min = nearest and mip = linear */
  93575. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93576. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93577. static readonly BILINEAR_SAMPLINGMODE: number;
  93578. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93579. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93580. /** Trilinear is mag = linear and min = linear and mip = linear */
  93581. static readonly TRILINEAR_SAMPLINGMODE: number;
  93582. /** Trilinear is mag = linear and min = linear and mip = linear */
  93583. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93584. /** mag = nearest and min = nearest and mip = nearest */
  93585. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93586. /** mag = nearest and min = linear and mip = nearest */
  93587. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93588. /** mag = nearest and min = linear and mip = linear */
  93589. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93590. /** mag = nearest and min = linear and mip = none */
  93591. static readonly NEAREST_LINEAR: number;
  93592. /** mag = nearest and min = nearest and mip = none */
  93593. static readonly NEAREST_NEAREST: number;
  93594. /** mag = linear and min = nearest and mip = nearest */
  93595. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93596. /** mag = linear and min = nearest and mip = linear */
  93597. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93598. /** mag = linear and min = linear and mip = none */
  93599. static readonly LINEAR_LINEAR: number;
  93600. /** mag = linear and min = nearest and mip = none */
  93601. static readonly LINEAR_NEAREST: number;
  93602. /** Explicit coordinates mode */
  93603. static readonly EXPLICIT_MODE: number;
  93604. /** Spherical coordinates mode */
  93605. static readonly SPHERICAL_MODE: number;
  93606. /** Planar coordinates mode */
  93607. static readonly PLANAR_MODE: number;
  93608. /** Cubic coordinates mode */
  93609. static readonly CUBIC_MODE: number;
  93610. /** Projection coordinates mode */
  93611. static readonly PROJECTION_MODE: number;
  93612. /** Inverse Cubic coordinates mode */
  93613. static readonly SKYBOX_MODE: number;
  93614. /** Inverse Cubic coordinates mode */
  93615. static readonly INVCUBIC_MODE: number;
  93616. /** Equirectangular coordinates mode */
  93617. static readonly EQUIRECTANGULAR_MODE: number;
  93618. /** Equirectangular Fixed coordinates mode */
  93619. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93620. /** Equirectangular Fixed Mirrored coordinates mode */
  93621. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93622. /** Texture is not repeating outside of 0..1 UVs */
  93623. static readonly CLAMP_ADDRESSMODE: number;
  93624. /** Texture is repeating outside of 0..1 UVs */
  93625. static readonly WRAP_ADDRESSMODE: number;
  93626. /** Texture is repeating and mirrored */
  93627. static readonly MIRROR_ADDRESSMODE: number;
  93628. /**
  93629. * 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
  93630. */
  93631. static UseSerializedUrlIfAny: boolean;
  93632. /**
  93633. * Define the url of the texture.
  93634. */
  93635. url: Nullable<string>;
  93636. /**
  93637. * Define an offset on the texture to offset the u coordinates of the UVs
  93638. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93639. */
  93640. uOffset: number;
  93641. /**
  93642. * Define an offset on the texture to offset the v coordinates of the UVs
  93643. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93644. */
  93645. vOffset: number;
  93646. /**
  93647. * Define an offset on the texture to scale the u coordinates of the UVs
  93648. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93649. */
  93650. uScale: number;
  93651. /**
  93652. * Define an offset on the texture to scale the v coordinates of the UVs
  93653. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93654. */
  93655. vScale: number;
  93656. /**
  93657. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93658. * @see http://doc.babylonjs.com/how_to/more_materials
  93659. */
  93660. uAng: number;
  93661. /**
  93662. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93663. * @see http://doc.babylonjs.com/how_to/more_materials
  93664. */
  93665. vAng: number;
  93666. /**
  93667. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93668. * @see http://doc.babylonjs.com/how_to/more_materials
  93669. */
  93670. wAng: number;
  93671. /**
  93672. * Defines the center of rotation (U)
  93673. */
  93674. uRotationCenter: number;
  93675. /**
  93676. * Defines the center of rotation (V)
  93677. */
  93678. vRotationCenter: number;
  93679. /**
  93680. * Defines the center of rotation (W)
  93681. */
  93682. wRotationCenter: number;
  93683. /**
  93684. * Are mip maps generated for this texture or not.
  93685. */
  93686. get noMipmap(): boolean;
  93687. /**
  93688. * List of inspectable custom properties (used by the Inspector)
  93689. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93690. */
  93691. inspectableCustomProperties: Nullable<IInspectable[]>;
  93692. private _noMipmap;
  93693. /** @hidden */
  93694. _invertY: boolean;
  93695. private _rowGenerationMatrix;
  93696. private _cachedTextureMatrix;
  93697. private _projectionModeMatrix;
  93698. private _t0;
  93699. private _t1;
  93700. private _t2;
  93701. private _cachedUOffset;
  93702. private _cachedVOffset;
  93703. private _cachedUScale;
  93704. private _cachedVScale;
  93705. private _cachedUAng;
  93706. private _cachedVAng;
  93707. private _cachedWAng;
  93708. private _cachedProjectionMatrixId;
  93709. private _cachedCoordinatesMode;
  93710. /** @hidden */
  93711. protected _initialSamplingMode: number;
  93712. /** @hidden */
  93713. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93714. private _deleteBuffer;
  93715. protected _format: Nullable<number>;
  93716. private _delayedOnLoad;
  93717. private _delayedOnError;
  93718. private _mimeType?;
  93719. /**
  93720. * Observable triggered once the texture has been loaded.
  93721. */
  93722. onLoadObservable: Observable<Texture>;
  93723. protected _isBlocking: boolean;
  93724. /**
  93725. * Is the texture preventing material to render while loading.
  93726. * If false, a default texture will be used instead of the loading one during the preparation step.
  93727. */
  93728. set isBlocking(value: boolean);
  93729. get isBlocking(): boolean;
  93730. /**
  93731. * Get the current sampling mode associated with the texture.
  93732. */
  93733. get samplingMode(): number;
  93734. /**
  93735. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93736. */
  93737. get invertY(): boolean;
  93738. /**
  93739. * Instantiates a new texture.
  93740. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93741. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93742. * @param url defines the url of the picture to load as a texture
  93743. * @param scene defines the scene or engine the texture will belong to
  93744. * @param noMipmap defines if the texture will require mip maps or not
  93745. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93746. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93747. * @param onLoad defines a callback triggered when the texture has been loaded
  93748. * @param onError defines a callback triggered when an error occurred during the loading session
  93749. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93750. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93751. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93752. * @param mimeType defines an optional mime type information
  93753. */
  93754. 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);
  93755. /**
  93756. * Update the url (and optional buffer) of this texture if url was null during construction.
  93757. * @param url the url of the texture
  93758. * @param buffer the buffer of the texture (defaults to null)
  93759. * @param onLoad callback called when the texture is loaded (defaults to null)
  93760. */
  93761. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93762. /**
  93763. * Finish the loading sequence of a texture flagged as delayed load.
  93764. * @hidden
  93765. */
  93766. delayLoad(): void;
  93767. private _prepareRowForTextureGeneration;
  93768. /**
  93769. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93770. * @returns the transform matrix of the texture.
  93771. */
  93772. getTextureMatrix(uBase?: number): Matrix;
  93773. /**
  93774. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93775. * @returns The reflection texture transform
  93776. */
  93777. getReflectionTextureMatrix(): Matrix;
  93778. /**
  93779. * Clones the texture.
  93780. * @returns the cloned texture
  93781. */
  93782. clone(): Texture;
  93783. /**
  93784. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93785. * @returns The JSON representation of the texture
  93786. */
  93787. serialize(): any;
  93788. /**
  93789. * Get the current class name of the texture useful for serialization or dynamic coding.
  93790. * @returns "Texture"
  93791. */
  93792. getClassName(): string;
  93793. /**
  93794. * Dispose the texture and release its associated resources.
  93795. */
  93796. dispose(): void;
  93797. /**
  93798. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93799. * @param parsedTexture Define the JSON representation of the texture
  93800. * @param scene Define the scene the parsed texture should be instantiated in
  93801. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93802. * @returns The parsed texture if successful
  93803. */
  93804. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93805. /**
  93806. * Creates a texture from its base 64 representation.
  93807. * @param data Define the base64 payload without the data: prefix
  93808. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93809. * @param scene Define the scene the texture should belong to
  93810. * @param noMipmap Forces the texture to not create mip map information if true
  93811. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93812. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93813. * @param onLoad define a callback triggered when the texture has been loaded
  93814. * @param onError define a callback triggered when an error occurred during the loading session
  93815. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93816. * @returns the created texture
  93817. */
  93818. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93819. /**
  93820. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93821. * @param data Define the base64 payload without the data: prefix
  93822. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93823. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93824. * @param scene Define the scene the texture should belong to
  93825. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93826. * @param noMipmap Forces the texture to not create mip map information if true
  93827. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93828. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93829. * @param onLoad define a callback triggered when the texture has been loaded
  93830. * @param onError define a callback triggered when an error occurred during the loading session
  93831. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93832. * @returns the created texture
  93833. */
  93834. 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;
  93835. }
  93836. }
  93837. declare module BABYLON {
  93838. /**
  93839. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93840. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93841. */
  93842. export class PostProcessManager {
  93843. private _scene;
  93844. private _indexBuffer;
  93845. private _vertexBuffers;
  93846. /**
  93847. * Creates a new instance PostProcess
  93848. * @param scene The scene that the post process is associated with.
  93849. */
  93850. constructor(scene: Scene);
  93851. private _prepareBuffers;
  93852. private _buildIndexBuffer;
  93853. /**
  93854. * Rebuilds the vertex buffers of the manager.
  93855. * @hidden
  93856. */
  93857. _rebuild(): void;
  93858. /**
  93859. * Prepares a frame to be run through a post process.
  93860. * @param sourceTexture The input texture to the post procesess. (default: null)
  93861. * @param postProcesses An array of post processes to be run. (default: null)
  93862. * @returns True if the post processes were able to be run.
  93863. * @hidden
  93864. */
  93865. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93866. /**
  93867. * Manually render a set of post processes to a texture.
  93868. * @param postProcesses An array of post processes to be run.
  93869. * @param targetTexture The target texture to render to.
  93870. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93871. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93872. * @param lodLevel defines which lod of the texture to render to
  93873. */
  93874. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93875. /**
  93876. * Finalize the result of the output of the postprocesses.
  93877. * @param doNotPresent If true the result will not be displayed to the screen.
  93878. * @param targetTexture The target texture to render to.
  93879. * @param faceIndex The index of the face to bind the target texture to.
  93880. * @param postProcesses The array of post processes to render.
  93881. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93882. * @hidden
  93883. */
  93884. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93885. /**
  93886. * Disposes of the post process manager.
  93887. */
  93888. dispose(): void;
  93889. }
  93890. }
  93891. declare module BABYLON {
  93892. /**
  93893. * This Helps creating a texture that will be created from a camera in your scene.
  93894. * It is basically a dynamic texture that could be used to create special effects for instance.
  93895. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93896. */
  93897. export class RenderTargetTexture extends Texture {
  93898. isCube: boolean;
  93899. /**
  93900. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93901. */
  93902. static readonly REFRESHRATE_RENDER_ONCE: number;
  93903. /**
  93904. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93905. */
  93906. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93907. /**
  93908. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93909. * the central point of your effect and can save a lot of performances.
  93910. */
  93911. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93912. /**
  93913. * Use this predicate to dynamically define the list of mesh you want to render.
  93914. * If set, the renderList property will be overwritten.
  93915. */
  93916. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93917. private _renderList;
  93918. /**
  93919. * Use this list to define the list of mesh you want to render.
  93920. */
  93921. get renderList(): Nullable<Array<AbstractMesh>>;
  93922. set renderList(value: Nullable<Array<AbstractMesh>>);
  93923. /**
  93924. * Use this function to overload the renderList array at rendering time.
  93925. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93926. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93927. * the cube (if the RTT is a cube, else layerOrFace=0).
  93928. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93929. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93930. * hold dummy elements!
  93931. */
  93932. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93933. private _hookArray;
  93934. /**
  93935. * Define if particles should be rendered in your texture.
  93936. */
  93937. renderParticles: boolean;
  93938. /**
  93939. * Define if sprites should be rendered in your texture.
  93940. */
  93941. renderSprites: boolean;
  93942. /**
  93943. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93944. */
  93945. coordinatesMode: number;
  93946. /**
  93947. * Define the camera used to render the texture.
  93948. */
  93949. activeCamera: Nullable<Camera>;
  93950. /**
  93951. * Override the render function of the texture with your own one.
  93952. */
  93953. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93954. /**
  93955. * Define if camera post processes should be use while rendering the texture.
  93956. */
  93957. useCameraPostProcesses: boolean;
  93958. /**
  93959. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93960. */
  93961. ignoreCameraViewport: boolean;
  93962. private _postProcessManager;
  93963. private _postProcesses;
  93964. private _resizeObserver;
  93965. /**
  93966. * An event triggered when the texture is unbind.
  93967. */
  93968. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93969. /**
  93970. * An event triggered when the texture is unbind.
  93971. */
  93972. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93973. private _onAfterUnbindObserver;
  93974. /**
  93975. * Set a after unbind callback in the texture.
  93976. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93977. */
  93978. set onAfterUnbind(callback: () => void);
  93979. /**
  93980. * An event triggered before rendering the texture
  93981. */
  93982. onBeforeRenderObservable: Observable<number>;
  93983. private _onBeforeRenderObserver;
  93984. /**
  93985. * Set a before render callback in the texture.
  93986. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93987. */
  93988. set onBeforeRender(callback: (faceIndex: number) => void);
  93989. /**
  93990. * An event triggered after rendering the texture
  93991. */
  93992. onAfterRenderObservable: Observable<number>;
  93993. private _onAfterRenderObserver;
  93994. /**
  93995. * Set a after render callback in the texture.
  93996. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93997. */
  93998. set onAfterRender(callback: (faceIndex: number) => void);
  93999. /**
  94000. * An event triggered after the texture clear
  94001. */
  94002. onClearObservable: Observable<Engine>;
  94003. private _onClearObserver;
  94004. /**
  94005. * Set a clear callback in the texture.
  94006. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94007. */
  94008. set onClear(callback: (Engine: Engine) => void);
  94009. /**
  94010. * An event triggered when the texture is resized.
  94011. */
  94012. onResizeObservable: Observable<RenderTargetTexture>;
  94013. /**
  94014. * Define the clear color of the Render Target if it should be different from the scene.
  94015. */
  94016. clearColor: Color4;
  94017. protected _size: number | {
  94018. width: number;
  94019. height: number;
  94020. layers?: number;
  94021. };
  94022. protected _initialSizeParameter: number | {
  94023. width: number;
  94024. height: number;
  94025. } | {
  94026. ratio: number;
  94027. };
  94028. protected _sizeRatio: Nullable<number>;
  94029. /** @hidden */
  94030. _generateMipMaps: boolean;
  94031. protected _renderingManager: RenderingManager;
  94032. /** @hidden */
  94033. _waitingRenderList: string[];
  94034. protected _doNotChangeAspectRatio: boolean;
  94035. protected _currentRefreshId: number;
  94036. protected _refreshRate: number;
  94037. protected _textureMatrix: Matrix;
  94038. protected _samples: number;
  94039. protected _renderTargetOptions: RenderTargetCreationOptions;
  94040. /**
  94041. * Gets render target creation options that were used.
  94042. */
  94043. get renderTargetOptions(): RenderTargetCreationOptions;
  94044. protected _engine: Engine;
  94045. protected _onRatioRescale(): void;
  94046. /**
  94047. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  94048. * It must define where the camera used to render the texture is set
  94049. */
  94050. boundingBoxPosition: Vector3;
  94051. private _boundingBoxSize;
  94052. /**
  94053. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  94054. * When defined, the cubemap will switch to local mode
  94055. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  94056. * @example https://www.babylonjs-playground.com/#RNASML
  94057. */
  94058. set boundingBoxSize(value: Vector3);
  94059. get boundingBoxSize(): Vector3;
  94060. /**
  94061. * In case the RTT has been created with a depth texture, get the associated
  94062. * depth texture.
  94063. * Otherwise, return null.
  94064. */
  94065. get depthStencilTexture(): Nullable<InternalTexture>;
  94066. /**
  94067. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  94068. * or used a shadow, depth texture...
  94069. * @param name The friendly name of the texture
  94070. * @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)
  94071. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  94072. * @param generateMipMaps True if mip maps need to be generated after render.
  94073. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  94074. * @param type The type of the buffer in the RTT (int, half float, float...)
  94075. * @param isCube True if a cube texture needs to be created
  94076. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94077. * @param generateDepthBuffer True to generate a depth buffer
  94078. * @param generateStencilBuffer True to generate a stencil buffer
  94079. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94080. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94081. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94082. */
  94083. constructor(name: string, size: number | {
  94084. width: number;
  94085. height: number;
  94086. layers?: number;
  94087. } | {
  94088. ratio: number;
  94089. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94090. /**
  94091. * Creates a depth stencil texture.
  94092. * This is only available in WebGL 2 or with the depth texture extension available.
  94093. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94094. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94095. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94096. */
  94097. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94098. private _processSizeParameter;
  94099. /**
  94100. * Define the number of samples to use in case of MSAA.
  94101. * It defaults to one meaning no MSAA has been enabled.
  94102. */
  94103. get samples(): number;
  94104. set samples(value: number);
  94105. /**
  94106. * Resets the refresh counter of the texture and start bak from scratch.
  94107. * Could be useful to regenerate the texture if it is setup to render only once.
  94108. */
  94109. resetRefreshCounter(): void;
  94110. /**
  94111. * Define the refresh rate of the texture or the rendering frequency.
  94112. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94113. */
  94114. get refreshRate(): number;
  94115. set refreshRate(value: number);
  94116. /**
  94117. * Adds a post process to the render target rendering passes.
  94118. * @param postProcess define the post process to add
  94119. */
  94120. addPostProcess(postProcess: PostProcess): void;
  94121. /**
  94122. * Clear all the post processes attached to the render target
  94123. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94124. */
  94125. clearPostProcesses(dispose?: boolean): void;
  94126. /**
  94127. * Remove one of the post process from the list of attached post processes to the texture
  94128. * @param postProcess define the post process to remove from the list
  94129. */
  94130. removePostProcess(postProcess: PostProcess): void;
  94131. /** @hidden */
  94132. _shouldRender(): boolean;
  94133. /**
  94134. * Gets the actual render size of the texture.
  94135. * @returns the width of the render size
  94136. */
  94137. getRenderSize(): number;
  94138. /**
  94139. * Gets the actual render width of the texture.
  94140. * @returns the width of the render size
  94141. */
  94142. getRenderWidth(): number;
  94143. /**
  94144. * Gets the actual render height of the texture.
  94145. * @returns the height of the render size
  94146. */
  94147. getRenderHeight(): number;
  94148. /**
  94149. * Gets the actual number of layers of the texture.
  94150. * @returns the number of layers
  94151. */
  94152. getRenderLayers(): number;
  94153. /**
  94154. * Get if the texture can be rescaled or not.
  94155. */
  94156. get canRescale(): boolean;
  94157. /**
  94158. * Resize the texture using a ratio.
  94159. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94160. */
  94161. scale(ratio: number): void;
  94162. /**
  94163. * Get the texture reflection matrix used to rotate/transform the reflection.
  94164. * @returns the reflection matrix
  94165. */
  94166. getReflectionTextureMatrix(): Matrix;
  94167. /**
  94168. * Resize the texture to a new desired size.
  94169. * Be carrefull as it will recreate all the data in the new texture.
  94170. * @param size Define the new size. It can be:
  94171. * - a number for squared texture,
  94172. * - an object containing { width: number, height: number }
  94173. * - or an object containing a ratio { ratio: number }
  94174. */
  94175. resize(size: number | {
  94176. width: number;
  94177. height: number;
  94178. } | {
  94179. ratio: number;
  94180. }): void;
  94181. private _defaultRenderListPrepared;
  94182. /**
  94183. * Renders all the objects from the render list into the texture.
  94184. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94185. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94186. */
  94187. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94188. private _bestReflectionRenderTargetDimension;
  94189. private _prepareRenderingManager;
  94190. /**
  94191. * @hidden
  94192. * @param faceIndex face index to bind to if this is a cubetexture
  94193. * @param layer defines the index of the texture to bind in the array
  94194. */
  94195. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94196. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94197. private renderToTarget;
  94198. /**
  94199. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94200. * This allowed control for front to back rendering or reversly depending of the special needs.
  94201. *
  94202. * @param renderingGroupId The rendering group id corresponding to its index
  94203. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94204. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94205. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94206. */
  94207. 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;
  94208. /**
  94209. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94210. *
  94211. * @param renderingGroupId The rendering group id corresponding to its index
  94212. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94213. */
  94214. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94215. /**
  94216. * Clones the texture.
  94217. * @returns the cloned texture
  94218. */
  94219. clone(): RenderTargetTexture;
  94220. /**
  94221. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94222. * @returns The JSON representation of the texture
  94223. */
  94224. serialize(): any;
  94225. /**
  94226. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94227. */
  94228. disposeFramebufferObjects(): void;
  94229. /**
  94230. * Dispose the texture and release its associated resources.
  94231. */
  94232. dispose(): void;
  94233. /** @hidden */
  94234. _rebuild(): void;
  94235. /**
  94236. * Clear the info related to rendering groups preventing retention point in material dispose.
  94237. */
  94238. freeRenderingGroups(): void;
  94239. /**
  94240. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94241. * @returns the view count
  94242. */
  94243. getViewCount(): number;
  94244. }
  94245. }
  94246. declare module BABYLON {
  94247. /**
  94248. * Options for compiling materials.
  94249. */
  94250. export interface IMaterialCompilationOptions {
  94251. /**
  94252. * Defines whether clip planes are enabled.
  94253. */
  94254. clipPlane: boolean;
  94255. /**
  94256. * Defines whether instances are enabled.
  94257. */
  94258. useInstances: boolean;
  94259. }
  94260. /**
  94261. * Base class for the main features of a material in Babylon.js
  94262. */
  94263. export class Material implements IAnimatable {
  94264. /**
  94265. * Returns the triangle fill mode
  94266. */
  94267. static readonly TriangleFillMode: number;
  94268. /**
  94269. * Returns the wireframe mode
  94270. */
  94271. static readonly WireFrameFillMode: number;
  94272. /**
  94273. * Returns the point fill mode
  94274. */
  94275. static readonly PointFillMode: number;
  94276. /**
  94277. * Returns the point list draw mode
  94278. */
  94279. static readonly PointListDrawMode: number;
  94280. /**
  94281. * Returns the line list draw mode
  94282. */
  94283. static readonly LineListDrawMode: number;
  94284. /**
  94285. * Returns the line loop draw mode
  94286. */
  94287. static readonly LineLoopDrawMode: number;
  94288. /**
  94289. * Returns the line strip draw mode
  94290. */
  94291. static readonly LineStripDrawMode: number;
  94292. /**
  94293. * Returns the triangle strip draw mode
  94294. */
  94295. static readonly TriangleStripDrawMode: number;
  94296. /**
  94297. * Returns the triangle fan draw mode
  94298. */
  94299. static readonly TriangleFanDrawMode: number;
  94300. /**
  94301. * Stores the clock-wise side orientation
  94302. */
  94303. static readonly ClockWiseSideOrientation: number;
  94304. /**
  94305. * Stores the counter clock-wise side orientation
  94306. */
  94307. static readonly CounterClockWiseSideOrientation: number;
  94308. /**
  94309. * The dirty texture flag value
  94310. */
  94311. static readonly TextureDirtyFlag: number;
  94312. /**
  94313. * The dirty light flag value
  94314. */
  94315. static readonly LightDirtyFlag: number;
  94316. /**
  94317. * The dirty fresnel flag value
  94318. */
  94319. static readonly FresnelDirtyFlag: number;
  94320. /**
  94321. * The dirty attribute flag value
  94322. */
  94323. static readonly AttributesDirtyFlag: number;
  94324. /**
  94325. * The dirty misc flag value
  94326. */
  94327. static readonly MiscDirtyFlag: number;
  94328. /**
  94329. * The all dirty flag value
  94330. */
  94331. static readonly AllDirtyFlag: number;
  94332. /**
  94333. * The ID of the material
  94334. */
  94335. id: string;
  94336. /**
  94337. * Gets or sets the unique id of the material
  94338. */
  94339. uniqueId: number;
  94340. /**
  94341. * The name of the material
  94342. */
  94343. name: string;
  94344. /**
  94345. * Gets or sets user defined metadata
  94346. */
  94347. metadata: any;
  94348. /**
  94349. * For internal use only. Please do not use.
  94350. */
  94351. reservedDataStore: any;
  94352. /**
  94353. * Specifies if the ready state should be checked on each call
  94354. */
  94355. checkReadyOnEveryCall: boolean;
  94356. /**
  94357. * Specifies if the ready state should be checked once
  94358. */
  94359. checkReadyOnlyOnce: boolean;
  94360. /**
  94361. * The state of the material
  94362. */
  94363. state: string;
  94364. /**
  94365. * The alpha value of the material
  94366. */
  94367. protected _alpha: number;
  94368. /**
  94369. * List of inspectable custom properties (used by the Inspector)
  94370. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94371. */
  94372. inspectableCustomProperties: IInspectable[];
  94373. /**
  94374. * Sets the alpha value of the material
  94375. */
  94376. set alpha(value: number);
  94377. /**
  94378. * Gets the alpha value of the material
  94379. */
  94380. get alpha(): number;
  94381. /**
  94382. * Specifies if back face culling is enabled
  94383. */
  94384. protected _backFaceCulling: boolean;
  94385. /**
  94386. * Sets the back-face culling state
  94387. */
  94388. set backFaceCulling(value: boolean);
  94389. /**
  94390. * Gets the back-face culling state
  94391. */
  94392. get backFaceCulling(): boolean;
  94393. /**
  94394. * Stores the value for side orientation
  94395. */
  94396. sideOrientation: number;
  94397. /**
  94398. * Callback triggered when the material is compiled
  94399. */
  94400. onCompiled: Nullable<(effect: Effect) => void>;
  94401. /**
  94402. * Callback triggered when an error occurs
  94403. */
  94404. onError: Nullable<(effect: Effect, errors: string) => void>;
  94405. /**
  94406. * Callback triggered to get the render target textures
  94407. */
  94408. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94409. /**
  94410. * Gets a boolean indicating that current material needs to register RTT
  94411. */
  94412. get hasRenderTargetTextures(): boolean;
  94413. /**
  94414. * Specifies if the material should be serialized
  94415. */
  94416. doNotSerialize: boolean;
  94417. /**
  94418. * @hidden
  94419. */
  94420. _storeEffectOnSubMeshes: boolean;
  94421. /**
  94422. * Stores the animations for the material
  94423. */
  94424. animations: Nullable<Array<Animation>>;
  94425. /**
  94426. * An event triggered when the material is disposed
  94427. */
  94428. onDisposeObservable: Observable<Material>;
  94429. /**
  94430. * An observer which watches for dispose events
  94431. */
  94432. private _onDisposeObserver;
  94433. private _onUnBindObservable;
  94434. /**
  94435. * Called during a dispose event
  94436. */
  94437. set onDispose(callback: () => void);
  94438. private _onBindObservable;
  94439. /**
  94440. * An event triggered when the material is bound
  94441. */
  94442. get onBindObservable(): Observable<AbstractMesh>;
  94443. /**
  94444. * An observer which watches for bind events
  94445. */
  94446. private _onBindObserver;
  94447. /**
  94448. * Called during a bind event
  94449. */
  94450. set onBind(callback: (Mesh: AbstractMesh) => void);
  94451. /**
  94452. * An event triggered when the material is unbound
  94453. */
  94454. get onUnBindObservable(): Observable<Material>;
  94455. /**
  94456. * Stores the value of the alpha mode
  94457. */
  94458. private _alphaMode;
  94459. /**
  94460. * Sets the value of the alpha mode.
  94461. *
  94462. * | Value | Type | Description |
  94463. * | --- | --- | --- |
  94464. * | 0 | ALPHA_DISABLE | |
  94465. * | 1 | ALPHA_ADD | |
  94466. * | 2 | ALPHA_COMBINE | |
  94467. * | 3 | ALPHA_SUBTRACT | |
  94468. * | 4 | ALPHA_MULTIPLY | |
  94469. * | 5 | ALPHA_MAXIMIZED | |
  94470. * | 6 | ALPHA_ONEONE | |
  94471. * | 7 | ALPHA_PREMULTIPLIED | |
  94472. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94473. * | 9 | ALPHA_INTERPOLATE | |
  94474. * | 10 | ALPHA_SCREENMODE | |
  94475. *
  94476. */
  94477. set alphaMode(value: number);
  94478. /**
  94479. * Gets the value of the alpha mode
  94480. */
  94481. get alphaMode(): number;
  94482. /**
  94483. * Stores the state of the need depth pre-pass value
  94484. */
  94485. private _needDepthPrePass;
  94486. /**
  94487. * Sets the need depth pre-pass value
  94488. */
  94489. set needDepthPrePass(value: boolean);
  94490. /**
  94491. * Gets the depth pre-pass value
  94492. */
  94493. get needDepthPrePass(): boolean;
  94494. /**
  94495. * Specifies if depth writing should be disabled
  94496. */
  94497. disableDepthWrite: boolean;
  94498. /**
  94499. * Specifies if depth writing should be forced
  94500. */
  94501. forceDepthWrite: boolean;
  94502. /**
  94503. * Specifies the depth function that should be used. 0 means the default engine function
  94504. */
  94505. depthFunction: number;
  94506. /**
  94507. * Specifies if there should be a separate pass for culling
  94508. */
  94509. separateCullingPass: boolean;
  94510. /**
  94511. * Stores the state specifing if fog should be enabled
  94512. */
  94513. private _fogEnabled;
  94514. /**
  94515. * Sets the state for enabling fog
  94516. */
  94517. set fogEnabled(value: boolean);
  94518. /**
  94519. * Gets the value of the fog enabled state
  94520. */
  94521. get fogEnabled(): boolean;
  94522. /**
  94523. * Stores the size of points
  94524. */
  94525. pointSize: number;
  94526. /**
  94527. * Stores the z offset value
  94528. */
  94529. zOffset: number;
  94530. /**
  94531. * Gets a value specifying if wireframe mode is enabled
  94532. */
  94533. get wireframe(): boolean;
  94534. /**
  94535. * Sets the state of wireframe mode
  94536. */
  94537. set wireframe(value: boolean);
  94538. /**
  94539. * Gets the value specifying if point clouds are enabled
  94540. */
  94541. get pointsCloud(): boolean;
  94542. /**
  94543. * Sets the state of point cloud mode
  94544. */
  94545. set pointsCloud(value: boolean);
  94546. /**
  94547. * Gets the material fill mode
  94548. */
  94549. get fillMode(): number;
  94550. /**
  94551. * Sets the material fill mode
  94552. */
  94553. set fillMode(value: number);
  94554. /**
  94555. * @hidden
  94556. * Stores the effects for the material
  94557. */
  94558. _effect: Nullable<Effect>;
  94559. /**
  94560. * Specifies if uniform buffers should be used
  94561. */
  94562. private _useUBO;
  94563. /**
  94564. * Stores a reference to the scene
  94565. */
  94566. private _scene;
  94567. /**
  94568. * Stores the fill mode state
  94569. */
  94570. private _fillMode;
  94571. /**
  94572. * Specifies if the depth write state should be cached
  94573. */
  94574. private _cachedDepthWriteState;
  94575. /**
  94576. * Specifies if the depth function state should be cached
  94577. */
  94578. private _cachedDepthFunctionState;
  94579. /**
  94580. * Stores the uniform buffer
  94581. */
  94582. protected _uniformBuffer: UniformBuffer;
  94583. /** @hidden */
  94584. _indexInSceneMaterialArray: number;
  94585. /** @hidden */
  94586. meshMap: Nullable<{
  94587. [id: string]: AbstractMesh | undefined;
  94588. }>;
  94589. /**
  94590. * Creates a material instance
  94591. * @param name defines the name of the material
  94592. * @param scene defines the scene to reference
  94593. * @param doNotAdd specifies if the material should be added to the scene
  94594. */
  94595. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94596. /**
  94597. * Returns a string representation of the current material
  94598. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94599. * @returns a string with material information
  94600. */
  94601. toString(fullDetails?: boolean): string;
  94602. /**
  94603. * Gets the class name of the material
  94604. * @returns a string with the class name of the material
  94605. */
  94606. getClassName(): string;
  94607. /**
  94608. * Specifies if updates for the material been locked
  94609. */
  94610. get isFrozen(): boolean;
  94611. /**
  94612. * Locks updates for the material
  94613. */
  94614. freeze(): void;
  94615. /**
  94616. * Unlocks updates for the material
  94617. */
  94618. unfreeze(): void;
  94619. /**
  94620. * Specifies if the material is ready to be used
  94621. * @param mesh defines the mesh to check
  94622. * @param useInstances specifies if instances should be used
  94623. * @returns a boolean indicating if the material is ready to be used
  94624. */
  94625. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94626. /**
  94627. * Specifies that the submesh is ready to be used
  94628. * @param mesh defines the mesh to check
  94629. * @param subMesh defines which submesh to check
  94630. * @param useInstances specifies that instances should be used
  94631. * @returns a boolean indicating that the submesh is ready or not
  94632. */
  94633. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94634. /**
  94635. * Returns the material effect
  94636. * @returns the effect associated with the material
  94637. */
  94638. getEffect(): Nullable<Effect>;
  94639. /**
  94640. * Returns the current scene
  94641. * @returns a Scene
  94642. */
  94643. getScene(): Scene;
  94644. /**
  94645. * Specifies if the material will require alpha blending
  94646. * @returns a boolean specifying if alpha blending is needed
  94647. */
  94648. needAlphaBlending(): boolean;
  94649. /**
  94650. * Specifies if the mesh will require alpha blending
  94651. * @param mesh defines the mesh to check
  94652. * @returns a boolean specifying if alpha blending is needed for the mesh
  94653. */
  94654. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94655. /**
  94656. * Specifies if this material should be rendered in alpha test mode
  94657. * @returns a boolean specifying if an alpha test is needed.
  94658. */
  94659. needAlphaTesting(): boolean;
  94660. /**
  94661. * Gets the texture used for the alpha test
  94662. * @returns the texture to use for alpha testing
  94663. */
  94664. getAlphaTestTexture(): Nullable<BaseTexture>;
  94665. /**
  94666. * Marks the material to indicate that it needs to be re-calculated
  94667. */
  94668. markDirty(): void;
  94669. /** @hidden */
  94670. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94671. /**
  94672. * Binds the material to the mesh
  94673. * @param world defines the world transformation matrix
  94674. * @param mesh defines the mesh to bind the material to
  94675. */
  94676. bind(world: Matrix, mesh?: Mesh): void;
  94677. /**
  94678. * Binds the submesh to the material
  94679. * @param world defines the world transformation matrix
  94680. * @param mesh defines the mesh containing the submesh
  94681. * @param subMesh defines the submesh to bind the material to
  94682. */
  94683. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94684. /**
  94685. * Binds the world matrix to the material
  94686. * @param world defines the world transformation matrix
  94687. */
  94688. bindOnlyWorldMatrix(world: Matrix): void;
  94689. /**
  94690. * Binds the scene's uniform buffer to the effect.
  94691. * @param effect defines the effect to bind to the scene uniform buffer
  94692. * @param sceneUbo defines the uniform buffer storing scene data
  94693. */
  94694. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94695. /**
  94696. * Binds the view matrix to the effect
  94697. * @param effect defines the effect to bind the view matrix to
  94698. */
  94699. bindView(effect: Effect): void;
  94700. /**
  94701. * Binds the view projection matrix to the effect
  94702. * @param effect defines the effect to bind the view projection matrix to
  94703. */
  94704. bindViewProjection(effect: Effect): void;
  94705. /**
  94706. * Specifies if material alpha testing should be turned on for the mesh
  94707. * @param mesh defines the mesh to check
  94708. */
  94709. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94710. /**
  94711. * Processes to execute after binding the material to a mesh
  94712. * @param mesh defines the rendered mesh
  94713. */
  94714. protected _afterBind(mesh?: Mesh): void;
  94715. /**
  94716. * Unbinds the material from the mesh
  94717. */
  94718. unbind(): void;
  94719. /**
  94720. * Gets the active textures from the material
  94721. * @returns an array of textures
  94722. */
  94723. getActiveTextures(): BaseTexture[];
  94724. /**
  94725. * Specifies if the material uses a texture
  94726. * @param texture defines the texture to check against the material
  94727. * @returns a boolean specifying if the material uses the texture
  94728. */
  94729. hasTexture(texture: BaseTexture): boolean;
  94730. /**
  94731. * Makes a duplicate of the material, and gives it a new name
  94732. * @param name defines the new name for the duplicated material
  94733. * @returns the cloned material
  94734. */
  94735. clone(name: string): Nullable<Material>;
  94736. /**
  94737. * Gets the meshes bound to the material
  94738. * @returns an array of meshes bound to the material
  94739. */
  94740. getBindedMeshes(): AbstractMesh[];
  94741. /**
  94742. * Force shader compilation
  94743. * @param mesh defines the mesh associated with this material
  94744. * @param onCompiled defines a function to execute once the material is compiled
  94745. * @param options defines the options to configure the compilation
  94746. * @param onError defines a function to execute if the material fails compiling
  94747. */
  94748. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94749. /**
  94750. * Force shader compilation
  94751. * @param mesh defines the mesh that will use this material
  94752. * @param options defines additional options for compiling the shaders
  94753. * @returns a promise that resolves when the compilation completes
  94754. */
  94755. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94756. private static readonly _AllDirtyCallBack;
  94757. private static readonly _ImageProcessingDirtyCallBack;
  94758. private static readonly _TextureDirtyCallBack;
  94759. private static readonly _FresnelDirtyCallBack;
  94760. private static readonly _MiscDirtyCallBack;
  94761. private static readonly _LightsDirtyCallBack;
  94762. private static readonly _AttributeDirtyCallBack;
  94763. private static _FresnelAndMiscDirtyCallBack;
  94764. private static _TextureAndMiscDirtyCallBack;
  94765. private static readonly _DirtyCallbackArray;
  94766. private static readonly _RunDirtyCallBacks;
  94767. /**
  94768. * Marks a define in the material to indicate that it needs to be re-computed
  94769. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94770. */
  94771. markAsDirty(flag: number): void;
  94772. /**
  94773. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94774. * @param func defines a function which checks material defines against the submeshes
  94775. */
  94776. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94777. /**
  94778. * Indicates that we need to re-calculated for all submeshes
  94779. */
  94780. protected _markAllSubMeshesAsAllDirty(): void;
  94781. /**
  94782. * Indicates that image processing needs to be re-calculated for all submeshes
  94783. */
  94784. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94785. /**
  94786. * Indicates that textures need to be re-calculated for all submeshes
  94787. */
  94788. protected _markAllSubMeshesAsTexturesDirty(): void;
  94789. /**
  94790. * Indicates that fresnel needs to be re-calculated for all submeshes
  94791. */
  94792. protected _markAllSubMeshesAsFresnelDirty(): void;
  94793. /**
  94794. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94795. */
  94796. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94797. /**
  94798. * Indicates that lights need to be re-calculated for all submeshes
  94799. */
  94800. protected _markAllSubMeshesAsLightsDirty(): void;
  94801. /**
  94802. * Indicates that attributes need to be re-calculated for all submeshes
  94803. */
  94804. protected _markAllSubMeshesAsAttributesDirty(): void;
  94805. /**
  94806. * Indicates that misc needs to be re-calculated for all submeshes
  94807. */
  94808. protected _markAllSubMeshesAsMiscDirty(): void;
  94809. /**
  94810. * Indicates that textures and misc need to be re-calculated for all submeshes
  94811. */
  94812. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94813. /**
  94814. * Disposes the material
  94815. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94816. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94817. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94818. */
  94819. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94820. /** @hidden */
  94821. private releaseVertexArrayObject;
  94822. /**
  94823. * Serializes this material
  94824. * @returns the serialized material object
  94825. */
  94826. serialize(): any;
  94827. /**
  94828. * Creates a material from parsed material data
  94829. * @param parsedMaterial defines parsed material data
  94830. * @param scene defines the hosting scene
  94831. * @param rootUrl defines the root URL to use to load textures
  94832. * @returns a new material
  94833. */
  94834. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94835. }
  94836. }
  94837. declare module BABYLON {
  94838. /**
  94839. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94840. * separate meshes. This can be use to improve performances.
  94841. * @see http://doc.babylonjs.com/how_to/multi_materials
  94842. */
  94843. export class MultiMaterial extends Material {
  94844. private _subMaterials;
  94845. /**
  94846. * Gets or Sets the list of Materials used within the multi material.
  94847. * They need to be ordered according to the submeshes order in the associated mesh
  94848. */
  94849. get subMaterials(): Nullable<Material>[];
  94850. set subMaterials(value: Nullable<Material>[]);
  94851. /**
  94852. * Function used to align with Node.getChildren()
  94853. * @returns the list of Materials used within the multi material
  94854. */
  94855. getChildren(): Nullable<Material>[];
  94856. /**
  94857. * Instantiates a new Multi Material
  94858. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94859. * separate meshes. This can be use to improve performances.
  94860. * @see http://doc.babylonjs.com/how_to/multi_materials
  94861. * @param name Define the name in the scene
  94862. * @param scene Define the scene the material belongs to
  94863. */
  94864. constructor(name: string, scene: Scene);
  94865. private _hookArray;
  94866. /**
  94867. * Get one of the submaterial by its index in the submaterials array
  94868. * @param index The index to look the sub material at
  94869. * @returns The Material if the index has been defined
  94870. */
  94871. getSubMaterial(index: number): Nullable<Material>;
  94872. /**
  94873. * Get the list of active textures for the whole sub materials list.
  94874. * @returns All the textures that will be used during the rendering
  94875. */
  94876. getActiveTextures(): BaseTexture[];
  94877. /**
  94878. * Gets the current class name of the material e.g. "MultiMaterial"
  94879. * Mainly use in serialization.
  94880. * @returns the class name
  94881. */
  94882. getClassName(): string;
  94883. /**
  94884. * Checks if the material is ready to render the requested sub mesh
  94885. * @param mesh Define the mesh the submesh belongs to
  94886. * @param subMesh Define the sub mesh to look readyness for
  94887. * @param useInstances Define whether or not the material is used with instances
  94888. * @returns true if ready, otherwise false
  94889. */
  94890. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94891. /**
  94892. * Clones the current material and its related sub materials
  94893. * @param name Define the name of the newly cloned material
  94894. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94895. * @returns the cloned material
  94896. */
  94897. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94898. /**
  94899. * Serializes the materials into a JSON representation.
  94900. * @returns the JSON representation
  94901. */
  94902. serialize(): any;
  94903. /**
  94904. * Dispose the material and release its associated resources
  94905. * @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)
  94906. * @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)
  94907. * @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)
  94908. */
  94909. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94910. /**
  94911. * Creates a MultiMaterial from parsed MultiMaterial data.
  94912. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94913. * @param scene defines the hosting scene
  94914. * @returns a new MultiMaterial
  94915. */
  94916. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94917. }
  94918. }
  94919. declare module BABYLON {
  94920. /**
  94921. * Base class for submeshes
  94922. */
  94923. export class BaseSubMesh {
  94924. /** @hidden */
  94925. _materialDefines: Nullable<MaterialDefines>;
  94926. /** @hidden */
  94927. _materialEffect: Nullable<Effect>;
  94928. /**
  94929. * Gets material defines used by the effect associated to the sub mesh
  94930. */
  94931. get materialDefines(): Nullable<MaterialDefines>;
  94932. /**
  94933. * Sets material defines used by the effect associated to the sub mesh
  94934. */
  94935. set materialDefines(defines: Nullable<MaterialDefines>);
  94936. /**
  94937. * Gets associated effect
  94938. */
  94939. get effect(): Nullable<Effect>;
  94940. /**
  94941. * Sets associated effect (effect used to render this submesh)
  94942. * @param effect defines the effect to associate with
  94943. * @param defines defines the set of defines used to compile this effect
  94944. */
  94945. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94946. }
  94947. /**
  94948. * Defines a subdivision inside a mesh
  94949. */
  94950. export class SubMesh extends BaseSubMesh implements ICullable {
  94951. /** the material index to use */
  94952. materialIndex: number;
  94953. /** vertex index start */
  94954. verticesStart: number;
  94955. /** vertices count */
  94956. verticesCount: number;
  94957. /** index start */
  94958. indexStart: number;
  94959. /** indices count */
  94960. indexCount: number;
  94961. /** @hidden */
  94962. _linesIndexCount: number;
  94963. private _mesh;
  94964. private _renderingMesh;
  94965. private _boundingInfo;
  94966. private _linesIndexBuffer;
  94967. /** @hidden */
  94968. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94969. /** @hidden */
  94970. _trianglePlanes: Plane[];
  94971. /** @hidden */
  94972. _lastColliderTransformMatrix: Nullable<Matrix>;
  94973. /** @hidden */
  94974. _renderId: number;
  94975. /** @hidden */
  94976. _alphaIndex: number;
  94977. /** @hidden */
  94978. _distanceToCamera: number;
  94979. /** @hidden */
  94980. _id: number;
  94981. private _currentMaterial;
  94982. /**
  94983. * Add a new submesh to a mesh
  94984. * @param materialIndex defines the material index to use
  94985. * @param verticesStart defines vertex index start
  94986. * @param verticesCount defines vertices count
  94987. * @param indexStart defines index start
  94988. * @param indexCount defines indices count
  94989. * @param mesh defines the parent mesh
  94990. * @param renderingMesh defines an optional rendering mesh
  94991. * @param createBoundingBox defines if bounding box should be created for this submesh
  94992. * @returns the new submesh
  94993. */
  94994. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94995. /**
  94996. * Creates a new submesh
  94997. * @param materialIndex defines the material index to use
  94998. * @param verticesStart defines vertex index start
  94999. * @param verticesCount defines vertices count
  95000. * @param indexStart defines index start
  95001. * @param indexCount defines indices count
  95002. * @param mesh defines the parent mesh
  95003. * @param renderingMesh defines an optional rendering mesh
  95004. * @param createBoundingBox defines if bounding box should be created for this submesh
  95005. */
  95006. constructor(
  95007. /** the material index to use */
  95008. materialIndex: number,
  95009. /** vertex index start */
  95010. verticesStart: number,
  95011. /** vertices count */
  95012. verticesCount: number,
  95013. /** index start */
  95014. indexStart: number,
  95015. /** indices count */
  95016. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  95017. /**
  95018. * Returns true if this submesh covers the entire parent mesh
  95019. * @ignorenaming
  95020. */
  95021. get IsGlobal(): boolean;
  95022. /**
  95023. * Returns the submesh BoudingInfo object
  95024. * @returns current bounding info (or mesh's one if the submesh is global)
  95025. */
  95026. getBoundingInfo(): BoundingInfo;
  95027. /**
  95028. * Sets the submesh BoundingInfo
  95029. * @param boundingInfo defines the new bounding info to use
  95030. * @returns the SubMesh
  95031. */
  95032. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  95033. /**
  95034. * Returns the mesh of the current submesh
  95035. * @return the parent mesh
  95036. */
  95037. getMesh(): AbstractMesh;
  95038. /**
  95039. * Returns the rendering mesh of the submesh
  95040. * @returns the rendering mesh (could be different from parent mesh)
  95041. */
  95042. getRenderingMesh(): Mesh;
  95043. /**
  95044. * Returns the submesh material
  95045. * @returns null or the current material
  95046. */
  95047. getMaterial(): Nullable<Material>;
  95048. /**
  95049. * Sets a new updated BoundingInfo object to the submesh
  95050. * @param data defines an optional position array to use to determine the bounding info
  95051. * @returns the SubMesh
  95052. */
  95053. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  95054. /** @hidden */
  95055. _checkCollision(collider: Collider): boolean;
  95056. /**
  95057. * Updates the submesh BoundingInfo
  95058. * @param world defines the world matrix to use to update the bounding info
  95059. * @returns the submesh
  95060. */
  95061. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  95062. /**
  95063. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  95064. * @param frustumPlanes defines the frustum planes
  95065. * @returns true if the submesh is intersecting with the frustum
  95066. */
  95067. isInFrustum(frustumPlanes: Plane[]): boolean;
  95068. /**
  95069. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95070. * @param frustumPlanes defines the frustum planes
  95071. * @returns true if the submesh is inside the frustum
  95072. */
  95073. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95074. /**
  95075. * Renders the submesh
  95076. * @param enableAlphaMode defines if alpha needs to be used
  95077. * @returns the submesh
  95078. */
  95079. render(enableAlphaMode: boolean): SubMesh;
  95080. /**
  95081. * @hidden
  95082. */
  95083. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95084. /**
  95085. * Checks if the submesh intersects with a ray
  95086. * @param ray defines the ray to test
  95087. * @returns true is the passed ray intersects the submesh bounding box
  95088. */
  95089. canIntersects(ray: Ray): boolean;
  95090. /**
  95091. * Intersects current submesh with a ray
  95092. * @param ray defines the ray to test
  95093. * @param positions defines mesh's positions array
  95094. * @param indices defines mesh's indices array
  95095. * @param fastCheck defines if only bounding info should be used
  95096. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95097. * @returns intersection info or null if no intersection
  95098. */
  95099. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95100. /** @hidden */
  95101. private _intersectLines;
  95102. /** @hidden */
  95103. private _intersectUnIndexedLines;
  95104. /** @hidden */
  95105. private _intersectTriangles;
  95106. /** @hidden */
  95107. private _intersectUnIndexedTriangles;
  95108. /** @hidden */
  95109. _rebuild(): void;
  95110. /**
  95111. * Creates a new submesh from the passed mesh
  95112. * @param newMesh defines the new hosting mesh
  95113. * @param newRenderingMesh defines an optional rendering mesh
  95114. * @returns the new submesh
  95115. */
  95116. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95117. /**
  95118. * Release associated resources
  95119. */
  95120. dispose(): void;
  95121. /**
  95122. * Gets the class name
  95123. * @returns the string "SubMesh".
  95124. */
  95125. getClassName(): string;
  95126. /**
  95127. * Creates a new submesh from indices data
  95128. * @param materialIndex the index of the main mesh material
  95129. * @param startIndex the index where to start the copy in the mesh indices array
  95130. * @param indexCount the number of indices to copy then from the startIndex
  95131. * @param mesh the main mesh to create the submesh from
  95132. * @param renderingMesh the optional rendering mesh
  95133. * @returns a new submesh
  95134. */
  95135. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95136. }
  95137. }
  95138. declare module BABYLON {
  95139. /**
  95140. * Class used to represent data loading progression
  95141. */
  95142. export class SceneLoaderFlags {
  95143. private static _ForceFullSceneLoadingForIncremental;
  95144. private static _ShowLoadingScreen;
  95145. private static _CleanBoneMatrixWeights;
  95146. private static _loggingLevel;
  95147. /**
  95148. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95149. */
  95150. static get ForceFullSceneLoadingForIncremental(): boolean;
  95151. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95152. /**
  95153. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95154. */
  95155. static get ShowLoadingScreen(): boolean;
  95156. static set ShowLoadingScreen(value: boolean);
  95157. /**
  95158. * Defines the current logging level (while loading the scene)
  95159. * @ignorenaming
  95160. */
  95161. static get loggingLevel(): number;
  95162. static set loggingLevel(value: number);
  95163. /**
  95164. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95165. */
  95166. static get CleanBoneMatrixWeights(): boolean;
  95167. static set CleanBoneMatrixWeights(value: boolean);
  95168. }
  95169. }
  95170. declare module BABYLON {
  95171. /**
  95172. * Class used to store geometry data (vertex buffers + index buffer)
  95173. */
  95174. export class Geometry implements IGetSetVerticesData {
  95175. /**
  95176. * Gets or sets the ID of the geometry
  95177. */
  95178. id: string;
  95179. /**
  95180. * Gets or sets the unique ID of the geometry
  95181. */
  95182. uniqueId: number;
  95183. /**
  95184. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95185. */
  95186. delayLoadState: number;
  95187. /**
  95188. * Gets the file containing the data to load when running in delay load state
  95189. */
  95190. delayLoadingFile: Nullable<string>;
  95191. /**
  95192. * Callback called when the geometry is updated
  95193. */
  95194. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95195. private _scene;
  95196. private _engine;
  95197. private _meshes;
  95198. private _totalVertices;
  95199. /** @hidden */
  95200. _indices: IndicesArray;
  95201. /** @hidden */
  95202. _vertexBuffers: {
  95203. [key: string]: VertexBuffer;
  95204. };
  95205. private _isDisposed;
  95206. private _extend;
  95207. private _boundingBias;
  95208. /** @hidden */
  95209. _delayInfo: Array<string>;
  95210. private _indexBuffer;
  95211. private _indexBufferIsUpdatable;
  95212. /** @hidden */
  95213. _boundingInfo: Nullable<BoundingInfo>;
  95214. /** @hidden */
  95215. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95216. /** @hidden */
  95217. _softwareSkinningFrameId: number;
  95218. private _vertexArrayObjects;
  95219. private _updatable;
  95220. /** @hidden */
  95221. _positions: Nullable<Vector3[]>;
  95222. /**
  95223. * 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
  95224. */
  95225. get boundingBias(): Vector2;
  95226. /**
  95227. * 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
  95228. */
  95229. set boundingBias(value: Vector2);
  95230. /**
  95231. * Static function used to attach a new empty geometry to a mesh
  95232. * @param mesh defines the mesh to attach the geometry to
  95233. * @returns the new Geometry
  95234. */
  95235. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95236. /**
  95237. * Creates a new geometry
  95238. * @param id defines the unique ID
  95239. * @param scene defines the hosting scene
  95240. * @param vertexData defines the VertexData used to get geometry data
  95241. * @param updatable defines if geometry must be updatable (false by default)
  95242. * @param mesh defines the mesh that will be associated with the geometry
  95243. */
  95244. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95245. /**
  95246. * Gets the current extend of the geometry
  95247. */
  95248. get extend(): {
  95249. minimum: Vector3;
  95250. maximum: Vector3;
  95251. };
  95252. /**
  95253. * Gets the hosting scene
  95254. * @returns the hosting Scene
  95255. */
  95256. getScene(): Scene;
  95257. /**
  95258. * Gets the hosting engine
  95259. * @returns the hosting Engine
  95260. */
  95261. getEngine(): Engine;
  95262. /**
  95263. * Defines if the geometry is ready to use
  95264. * @returns true if the geometry is ready to be used
  95265. */
  95266. isReady(): boolean;
  95267. /**
  95268. * Gets a value indicating that the geometry should not be serialized
  95269. */
  95270. get doNotSerialize(): boolean;
  95271. /** @hidden */
  95272. _rebuild(): void;
  95273. /**
  95274. * Affects all geometry data in one call
  95275. * @param vertexData defines the geometry data
  95276. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95277. */
  95278. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95279. /**
  95280. * Set specific vertex data
  95281. * @param kind defines the data kind (Position, normal, etc...)
  95282. * @param data defines the vertex data to use
  95283. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95284. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95285. */
  95286. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95287. /**
  95288. * Removes a specific vertex data
  95289. * @param kind defines the data kind (Position, normal, etc...)
  95290. */
  95291. removeVerticesData(kind: string): void;
  95292. /**
  95293. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95294. * @param buffer defines the vertex buffer to use
  95295. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95296. */
  95297. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95298. /**
  95299. * Update a specific vertex buffer
  95300. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95301. * It will do nothing if the buffer is not updatable
  95302. * @param kind defines the data kind (Position, normal, etc...)
  95303. * @param data defines the data to use
  95304. * @param offset defines the offset in the target buffer where to store the data
  95305. * @param useBytes set to true if the offset is in bytes
  95306. */
  95307. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95308. /**
  95309. * Update a specific vertex buffer
  95310. * This function will create a new buffer if the current one is not updatable
  95311. * @param kind defines the data kind (Position, normal, etc...)
  95312. * @param data defines the data to use
  95313. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95314. */
  95315. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95316. private _updateBoundingInfo;
  95317. /** @hidden */
  95318. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95319. /**
  95320. * Gets total number of vertices
  95321. * @returns the total number of vertices
  95322. */
  95323. getTotalVertices(): number;
  95324. /**
  95325. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95326. * @param kind defines the data kind (Position, normal, etc...)
  95327. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95328. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95329. * @returns a float array containing vertex data
  95330. */
  95331. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95332. /**
  95333. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95334. * @param kind defines the data kind (Position, normal, etc...)
  95335. * @returns true if the vertex buffer with the specified kind is updatable
  95336. */
  95337. isVertexBufferUpdatable(kind: string): boolean;
  95338. /**
  95339. * Gets a specific vertex buffer
  95340. * @param kind defines the data kind (Position, normal, etc...)
  95341. * @returns a VertexBuffer
  95342. */
  95343. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95344. /**
  95345. * Returns all vertex buffers
  95346. * @return an object holding all vertex buffers indexed by kind
  95347. */
  95348. getVertexBuffers(): Nullable<{
  95349. [key: string]: VertexBuffer;
  95350. }>;
  95351. /**
  95352. * Gets a boolean indicating if specific vertex buffer is present
  95353. * @param kind defines the data kind (Position, normal, etc...)
  95354. * @returns true if data is present
  95355. */
  95356. isVerticesDataPresent(kind: string): boolean;
  95357. /**
  95358. * Gets a list of all attached data kinds (Position, normal, etc...)
  95359. * @returns a list of string containing all kinds
  95360. */
  95361. getVerticesDataKinds(): string[];
  95362. /**
  95363. * Update index buffer
  95364. * @param indices defines the indices to store in the index buffer
  95365. * @param offset defines the offset in the target buffer where to store the data
  95366. * @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)
  95367. */
  95368. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95369. /**
  95370. * Creates a new index buffer
  95371. * @param indices defines the indices to store in the index buffer
  95372. * @param totalVertices defines the total number of vertices (could be null)
  95373. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95374. */
  95375. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95376. /**
  95377. * Return the total number of indices
  95378. * @returns the total number of indices
  95379. */
  95380. getTotalIndices(): number;
  95381. /**
  95382. * Gets the index buffer array
  95383. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95384. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95385. * @returns the index buffer array
  95386. */
  95387. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95388. /**
  95389. * Gets the index buffer
  95390. * @return the index buffer
  95391. */
  95392. getIndexBuffer(): Nullable<DataBuffer>;
  95393. /** @hidden */
  95394. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95395. /**
  95396. * Release the associated resources for a specific mesh
  95397. * @param mesh defines the source mesh
  95398. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95399. */
  95400. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95401. /**
  95402. * Apply current geometry to a given mesh
  95403. * @param mesh defines the mesh to apply geometry to
  95404. */
  95405. applyToMesh(mesh: Mesh): void;
  95406. private _updateExtend;
  95407. private _applyToMesh;
  95408. private notifyUpdate;
  95409. /**
  95410. * Load the geometry if it was flagged as delay loaded
  95411. * @param scene defines the hosting scene
  95412. * @param onLoaded defines a callback called when the geometry is loaded
  95413. */
  95414. load(scene: Scene, onLoaded?: () => void): void;
  95415. private _queueLoad;
  95416. /**
  95417. * Invert the geometry to move from a right handed system to a left handed one.
  95418. */
  95419. toLeftHanded(): void;
  95420. /** @hidden */
  95421. _resetPointsArrayCache(): void;
  95422. /** @hidden */
  95423. _generatePointsArray(): boolean;
  95424. /**
  95425. * Gets a value indicating if the geometry is disposed
  95426. * @returns true if the geometry was disposed
  95427. */
  95428. isDisposed(): boolean;
  95429. private _disposeVertexArrayObjects;
  95430. /**
  95431. * Free all associated resources
  95432. */
  95433. dispose(): void;
  95434. /**
  95435. * Clone the current geometry into a new geometry
  95436. * @param id defines the unique ID of the new geometry
  95437. * @returns a new geometry object
  95438. */
  95439. copy(id: string): Geometry;
  95440. /**
  95441. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95442. * @return a JSON representation of the current geometry data (without the vertices data)
  95443. */
  95444. serialize(): any;
  95445. private toNumberArray;
  95446. /**
  95447. * Serialize all vertices data into a JSON oject
  95448. * @returns a JSON representation of the current geometry data
  95449. */
  95450. serializeVerticeData(): any;
  95451. /**
  95452. * Extracts a clone of a mesh geometry
  95453. * @param mesh defines the source mesh
  95454. * @param id defines the unique ID of the new geometry object
  95455. * @returns the new geometry object
  95456. */
  95457. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95458. /**
  95459. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95460. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95461. * Be aware Math.random() could cause collisions, but:
  95462. * "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"
  95463. * @returns a string containing a new GUID
  95464. */
  95465. static RandomId(): string;
  95466. /** @hidden */
  95467. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95468. private static _CleanMatricesWeights;
  95469. /**
  95470. * Create a new geometry from persisted data (Using .babylon file format)
  95471. * @param parsedVertexData defines the persisted data
  95472. * @param scene defines the hosting scene
  95473. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95474. * @returns the new geometry object
  95475. */
  95476. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95477. }
  95478. }
  95479. declare module BABYLON {
  95480. /**
  95481. * Define an interface for all classes that will get and set the data on vertices
  95482. */
  95483. export interface IGetSetVerticesData {
  95484. /**
  95485. * Gets a boolean indicating if specific vertex data is present
  95486. * @param kind defines the vertex data kind to use
  95487. * @returns true is data kind is present
  95488. */
  95489. isVerticesDataPresent(kind: string): boolean;
  95490. /**
  95491. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95492. * @param kind defines the data kind (Position, normal, etc...)
  95493. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95494. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95495. * @returns a float array containing vertex data
  95496. */
  95497. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95498. /**
  95499. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95500. * @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.
  95501. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95502. * @returns the indices array or an empty array if the mesh has no geometry
  95503. */
  95504. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95505. /**
  95506. * Set specific vertex data
  95507. * @param kind defines the data kind (Position, normal, etc...)
  95508. * @param data defines the vertex data to use
  95509. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95510. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95511. */
  95512. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95513. /**
  95514. * Update a specific associated vertex buffer
  95515. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95516. * - VertexBuffer.PositionKind
  95517. * - VertexBuffer.UVKind
  95518. * - VertexBuffer.UV2Kind
  95519. * - VertexBuffer.UV3Kind
  95520. * - VertexBuffer.UV4Kind
  95521. * - VertexBuffer.UV5Kind
  95522. * - VertexBuffer.UV6Kind
  95523. * - VertexBuffer.ColorKind
  95524. * - VertexBuffer.MatricesIndicesKind
  95525. * - VertexBuffer.MatricesIndicesExtraKind
  95526. * - VertexBuffer.MatricesWeightsKind
  95527. * - VertexBuffer.MatricesWeightsExtraKind
  95528. * @param data defines the data source
  95529. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95530. * @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)
  95531. */
  95532. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95533. /**
  95534. * Creates a new index buffer
  95535. * @param indices defines the indices to store in the index buffer
  95536. * @param totalVertices defines the total number of vertices (could be null)
  95537. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95538. */
  95539. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95540. }
  95541. /**
  95542. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95543. */
  95544. export class VertexData {
  95545. /**
  95546. * Mesh side orientation : usually the external or front surface
  95547. */
  95548. static readonly FRONTSIDE: number;
  95549. /**
  95550. * Mesh side orientation : usually the internal or back surface
  95551. */
  95552. static readonly BACKSIDE: number;
  95553. /**
  95554. * Mesh side orientation : both internal and external or front and back surfaces
  95555. */
  95556. static readonly DOUBLESIDE: number;
  95557. /**
  95558. * Mesh side orientation : by default, `FRONTSIDE`
  95559. */
  95560. static readonly DEFAULTSIDE: number;
  95561. /**
  95562. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95563. */
  95564. positions: Nullable<FloatArray>;
  95565. /**
  95566. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95567. */
  95568. normals: Nullable<FloatArray>;
  95569. /**
  95570. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95571. */
  95572. tangents: Nullable<FloatArray>;
  95573. /**
  95574. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95575. */
  95576. uvs: Nullable<FloatArray>;
  95577. /**
  95578. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95579. */
  95580. uvs2: Nullable<FloatArray>;
  95581. /**
  95582. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95583. */
  95584. uvs3: Nullable<FloatArray>;
  95585. /**
  95586. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95587. */
  95588. uvs4: Nullable<FloatArray>;
  95589. /**
  95590. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95591. */
  95592. uvs5: Nullable<FloatArray>;
  95593. /**
  95594. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95595. */
  95596. uvs6: Nullable<FloatArray>;
  95597. /**
  95598. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95599. */
  95600. colors: Nullable<FloatArray>;
  95601. /**
  95602. * 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).
  95603. */
  95604. matricesIndices: Nullable<FloatArray>;
  95605. /**
  95606. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95607. */
  95608. matricesWeights: Nullable<FloatArray>;
  95609. /**
  95610. * An array extending the number of possible indices
  95611. */
  95612. matricesIndicesExtra: Nullable<FloatArray>;
  95613. /**
  95614. * An array extending the number of possible weights when the number of indices is extended
  95615. */
  95616. matricesWeightsExtra: Nullable<FloatArray>;
  95617. /**
  95618. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95619. */
  95620. indices: Nullable<IndicesArray>;
  95621. /**
  95622. * Uses the passed data array to set the set the values for the specified kind of data
  95623. * @param data a linear array of floating numbers
  95624. * @param kind the type of data that is being set, eg positions, colors etc
  95625. */
  95626. set(data: FloatArray, kind: string): void;
  95627. /**
  95628. * Associates the vertexData to the passed Mesh.
  95629. * Sets it as updatable or not (default `false`)
  95630. * @param mesh the mesh the vertexData is applied to
  95631. * @param updatable when used and having the value true allows new data to update the vertexData
  95632. * @returns the VertexData
  95633. */
  95634. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95635. /**
  95636. * Associates the vertexData to the passed Geometry.
  95637. * Sets it as updatable or not (default `false`)
  95638. * @param geometry the geometry the vertexData is applied to
  95639. * @param updatable when used and having the value true allows new data to update the vertexData
  95640. * @returns VertexData
  95641. */
  95642. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95643. /**
  95644. * Updates the associated mesh
  95645. * @param mesh the mesh to be updated
  95646. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95647. * @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
  95648. * @returns VertexData
  95649. */
  95650. updateMesh(mesh: Mesh): VertexData;
  95651. /**
  95652. * Updates the associated geometry
  95653. * @param geometry the geometry to be updated
  95654. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95655. * @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
  95656. * @returns VertexData.
  95657. */
  95658. updateGeometry(geometry: Geometry): VertexData;
  95659. private _applyTo;
  95660. private _update;
  95661. /**
  95662. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95663. * @param matrix the transforming matrix
  95664. * @returns the VertexData
  95665. */
  95666. transform(matrix: Matrix): VertexData;
  95667. /**
  95668. * Merges the passed VertexData into the current one
  95669. * @param other the VertexData to be merged into the current one
  95670. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95671. * @returns the modified VertexData
  95672. */
  95673. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95674. private _mergeElement;
  95675. private _validate;
  95676. /**
  95677. * Serializes the VertexData
  95678. * @returns a serialized object
  95679. */
  95680. serialize(): any;
  95681. /**
  95682. * Extracts the vertexData from a mesh
  95683. * @param mesh the mesh from which to extract the VertexData
  95684. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95685. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95686. * @returns the object VertexData associated to the passed mesh
  95687. */
  95688. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95689. /**
  95690. * Extracts the vertexData from the geometry
  95691. * @param geometry the geometry from which to extract the VertexData
  95692. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95693. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95694. * @returns the object VertexData associated to the passed mesh
  95695. */
  95696. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95697. private static _ExtractFrom;
  95698. /**
  95699. * Creates the VertexData for a Ribbon
  95700. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95701. * * pathArray array of paths, each of which an array of successive Vector3
  95702. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95703. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95704. * * 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
  95705. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95706. * * 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)
  95707. * * 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)
  95708. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95709. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95710. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95711. * @returns the VertexData of the ribbon
  95712. */
  95713. static CreateRibbon(options: {
  95714. pathArray: Vector3[][];
  95715. closeArray?: boolean;
  95716. closePath?: boolean;
  95717. offset?: number;
  95718. sideOrientation?: number;
  95719. frontUVs?: Vector4;
  95720. backUVs?: Vector4;
  95721. invertUV?: boolean;
  95722. uvs?: Vector2[];
  95723. colors?: Color4[];
  95724. }): VertexData;
  95725. /**
  95726. * Creates the VertexData for a box
  95727. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95728. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95729. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95730. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95731. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95732. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95733. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95734. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95735. * * 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)
  95736. * * 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)
  95737. * @returns the VertexData of the box
  95738. */
  95739. static CreateBox(options: {
  95740. size?: number;
  95741. width?: number;
  95742. height?: number;
  95743. depth?: number;
  95744. faceUV?: Vector4[];
  95745. faceColors?: Color4[];
  95746. sideOrientation?: number;
  95747. frontUVs?: Vector4;
  95748. backUVs?: Vector4;
  95749. }): VertexData;
  95750. /**
  95751. * Creates the VertexData for a tiled box
  95752. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95753. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95754. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95755. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95756. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95757. * @returns the VertexData of the box
  95758. */
  95759. static CreateTiledBox(options: {
  95760. pattern?: number;
  95761. width?: number;
  95762. height?: number;
  95763. depth?: number;
  95764. tileSize?: number;
  95765. tileWidth?: number;
  95766. tileHeight?: number;
  95767. alignHorizontal?: number;
  95768. alignVertical?: number;
  95769. faceUV?: Vector4[];
  95770. faceColors?: Color4[];
  95771. sideOrientation?: number;
  95772. }): VertexData;
  95773. /**
  95774. * Creates the VertexData for a tiled plane
  95775. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95776. * * pattern a limited pattern arrangement depending on the number
  95777. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95778. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95779. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95780. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95781. * * 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)
  95782. * * 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)
  95783. * @returns the VertexData of the tiled plane
  95784. */
  95785. static CreateTiledPlane(options: {
  95786. pattern?: number;
  95787. tileSize?: number;
  95788. tileWidth?: number;
  95789. tileHeight?: number;
  95790. size?: number;
  95791. width?: number;
  95792. height?: number;
  95793. alignHorizontal?: number;
  95794. alignVertical?: number;
  95795. sideOrientation?: number;
  95796. frontUVs?: Vector4;
  95797. backUVs?: Vector4;
  95798. }): VertexData;
  95799. /**
  95800. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95801. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95802. * * segments sets the number of horizontal strips optional, default 32
  95803. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95804. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95805. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95806. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95807. * * 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
  95808. * * 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
  95809. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95810. * * 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)
  95811. * * 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)
  95812. * @returns the VertexData of the ellipsoid
  95813. */
  95814. static CreateSphere(options: {
  95815. segments?: number;
  95816. diameter?: number;
  95817. diameterX?: number;
  95818. diameterY?: number;
  95819. diameterZ?: number;
  95820. arc?: number;
  95821. slice?: number;
  95822. sideOrientation?: number;
  95823. frontUVs?: Vector4;
  95824. backUVs?: Vector4;
  95825. }): VertexData;
  95826. /**
  95827. * Creates the VertexData for a cylinder, cone or prism
  95828. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95829. * * height sets the height (y direction) of the cylinder, optional, default 2
  95830. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95831. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95832. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95833. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95834. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95835. * * 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
  95836. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95837. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95838. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95839. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95841. * * 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)
  95842. * * 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)
  95843. * @returns the VertexData of the cylinder, cone or prism
  95844. */
  95845. static CreateCylinder(options: {
  95846. height?: number;
  95847. diameterTop?: number;
  95848. diameterBottom?: number;
  95849. diameter?: number;
  95850. tessellation?: number;
  95851. subdivisions?: number;
  95852. arc?: number;
  95853. faceColors?: Color4[];
  95854. faceUV?: Vector4[];
  95855. hasRings?: boolean;
  95856. enclose?: boolean;
  95857. sideOrientation?: number;
  95858. frontUVs?: Vector4;
  95859. backUVs?: Vector4;
  95860. }): VertexData;
  95861. /**
  95862. * Creates the VertexData for a torus
  95863. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95864. * * diameter the diameter of the torus, optional default 1
  95865. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95866. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95868. * * 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)
  95869. * * 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)
  95870. * @returns the VertexData of the torus
  95871. */
  95872. static CreateTorus(options: {
  95873. diameter?: number;
  95874. thickness?: number;
  95875. tessellation?: number;
  95876. sideOrientation?: number;
  95877. frontUVs?: Vector4;
  95878. backUVs?: Vector4;
  95879. }): VertexData;
  95880. /**
  95881. * Creates the VertexData of the LineSystem
  95882. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95883. * - lines an array of lines, each line being an array of successive Vector3
  95884. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95885. * @returns the VertexData of the LineSystem
  95886. */
  95887. static CreateLineSystem(options: {
  95888. lines: Vector3[][];
  95889. colors?: Nullable<Color4[][]>;
  95890. }): VertexData;
  95891. /**
  95892. * Create the VertexData for a DashedLines
  95893. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95894. * - points an array successive Vector3
  95895. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95896. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95897. * - dashNb the intended total number of dashes, optional, default 200
  95898. * @returns the VertexData for the DashedLines
  95899. */
  95900. static CreateDashedLines(options: {
  95901. points: Vector3[];
  95902. dashSize?: number;
  95903. gapSize?: number;
  95904. dashNb?: number;
  95905. }): VertexData;
  95906. /**
  95907. * Creates the VertexData for a Ground
  95908. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95909. * - width the width (x direction) of the ground, optional, default 1
  95910. * - height the height (z direction) of the ground, optional, default 1
  95911. * - subdivisions the number of subdivisions per side, optional, default 1
  95912. * @returns the VertexData of the Ground
  95913. */
  95914. static CreateGround(options: {
  95915. width?: number;
  95916. height?: number;
  95917. subdivisions?: number;
  95918. subdivisionsX?: number;
  95919. subdivisionsY?: number;
  95920. }): VertexData;
  95921. /**
  95922. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95923. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95924. * * xmin the ground minimum X coordinate, optional, default -1
  95925. * * zmin the ground minimum Z coordinate, optional, default -1
  95926. * * xmax the ground maximum X coordinate, optional, default 1
  95927. * * zmax the ground maximum Z coordinate, optional, default 1
  95928. * * 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}
  95929. * * 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}
  95930. * @returns the VertexData of the TiledGround
  95931. */
  95932. static CreateTiledGround(options: {
  95933. xmin: number;
  95934. zmin: number;
  95935. xmax: number;
  95936. zmax: number;
  95937. subdivisions?: {
  95938. w: number;
  95939. h: number;
  95940. };
  95941. precision?: {
  95942. w: number;
  95943. h: number;
  95944. };
  95945. }): VertexData;
  95946. /**
  95947. * Creates the VertexData of the Ground designed from a heightmap
  95948. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95949. * * width the width (x direction) of the ground
  95950. * * height the height (z direction) of the ground
  95951. * * subdivisions the number of subdivisions per side
  95952. * * minHeight the minimum altitude on the ground, optional, default 0
  95953. * * maxHeight the maximum altitude on the ground, optional default 1
  95954. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95955. * * buffer the array holding the image color data
  95956. * * bufferWidth the width of image
  95957. * * bufferHeight the height of image
  95958. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95959. * @returns the VertexData of the Ground designed from a heightmap
  95960. */
  95961. static CreateGroundFromHeightMap(options: {
  95962. width: number;
  95963. height: number;
  95964. subdivisions: number;
  95965. minHeight: number;
  95966. maxHeight: number;
  95967. colorFilter: Color3;
  95968. buffer: Uint8Array;
  95969. bufferWidth: number;
  95970. bufferHeight: number;
  95971. alphaFilter: number;
  95972. }): VertexData;
  95973. /**
  95974. * Creates the VertexData for a Plane
  95975. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95976. * * size sets the width and height of the plane to the value of size, optional default 1
  95977. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95978. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95980. * * 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)
  95981. * * 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)
  95982. * @returns the VertexData of the box
  95983. */
  95984. static CreatePlane(options: {
  95985. size?: number;
  95986. width?: number;
  95987. height?: number;
  95988. sideOrientation?: number;
  95989. frontUVs?: Vector4;
  95990. backUVs?: Vector4;
  95991. }): VertexData;
  95992. /**
  95993. * Creates the VertexData of the Disc or regular Polygon
  95994. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95995. * * radius the radius of the disc, optional default 0.5
  95996. * * tessellation the number of polygon sides, optional, default 64
  95997. * * 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
  95998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95999. * * 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)
  96000. * * 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)
  96001. * @returns the VertexData of the box
  96002. */
  96003. static CreateDisc(options: {
  96004. radius?: number;
  96005. tessellation?: number;
  96006. arc?: number;
  96007. sideOrientation?: number;
  96008. frontUVs?: Vector4;
  96009. backUVs?: Vector4;
  96010. }): VertexData;
  96011. /**
  96012. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  96013. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  96014. * @param polygon a mesh built from polygonTriangulation.build()
  96015. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96016. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96017. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96018. * @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)
  96019. * @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)
  96020. * @returns the VertexData of the Polygon
  96021. */
  96022. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  96023. /**
  96024. * Creates the VertexData of the IcoSphere
  96025. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  96026. * * radius the radius of the IcoSphere, optional default 1
  96027. * * radiusX allows stretching in the x direction, optional, default radius
  96028. * * radiusY allows stretching in the y direction, optional, default radius
  96029. * * radiusZ allows stretching in the z direction, optional, default radius
  96030. * * flat when true creates a flat shaded mesh, optional, default true
  96031. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96033. * * 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)
  96034. * * 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)
  96035. * @returns the VertexData of the IcoSphere
  96036. */
  96037. static CreateIcoSphere(options: {
  96038. radius?: number;
  96039. radiusX?: number;
  96040. radiusY?: number;
  96041. radiusZ?: number;
  96042. flat?: boolean;
  96043. subdivisions?: number;
  96044. sideOrientation?: number;
  96045. frontUVs?: Vector4;
  96046. backUVs?: Vector4;
  96047. }): VertexData;
  96048. /**
  96049. * Creates the VertexData for a Polyhedron
  96050. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  96051. * * type provided types are:
  96052. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  96053. * * 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)
  96054. * * size the size of the IcoSphere, optional default 1
  96055. * * sizeX allows stretching in the x direction, optional, default size
  96056. * * sizeY allows stretching in the y direction, optional, default size
  96057. * * sizeZ allows stretching in the z direction, optional, default size
  96058. * * 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
  96059. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96060. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96061. * * flat when true creates a flat shaded mesh, optional, default true
  96062. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96063. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96064. * * 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)
  96065. * * 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)
  96066. * @returns the VertexData of the Polyhedron
  96067. */
  96068. static CreatePolyhedron(options: {
  96069. type?: number;
  96070. size?: number;
  96071. sizeX?: number;
  96072. sizeY?: number;
  96073. sizeZ?: number;
  96074. custom?: any;
  96075. faceUV?: Vector4[];
  96076. faceColors?: Color4[];
  96077. flat?: boolean;
  96078. sideOrientation?: number;
  96079. frontUVs?: Vector4;
  96080. backUVs?: Vector4;
  96081. }): VertexData;
  96082. /**
  96083. * Creates the VertexData for a TorusKnot
  96084. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96085. * * radius the radius of the torus knot, optional, default 2
  96086. * * tube the thickness of the tube, optional, default 0.5
  96087. * * radialSegments the number of sides on each tube segments, optional, default 32
  96088. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96089. * * p the number of windings around the z axis, optional, default 2
  96090. * * q the number of windings around the x axis, optional, default 3
  96091. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96092. * * 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)
  96093. * * 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)
  96094. * @returns the VertexData of the Torus Knot
  96095. */
  96096. static CreateTorusKnot(options: {
  96097. radius?: number;
  96098. tube?: number;
  96099. radialSegments?: number;
  96100. tubularSegments?: number;
  96101. p?: number;
  96102. q?: number;
  96103. sideOrientation?: number;
  96104. frontUVs?: Vector4;
  96105. backUVs?: Vector4;
  96106. }): VertexData;
  96107. /**
  96108. * Compute normals for given positions and indices
  96109. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96110. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96111. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96112. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96113. * * facetNormals : optional array of facet normals (vector3)
  96114. * * facetPositions : optional array of facet positions (vector3)
  96115. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96116. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96117. * * bInfo : optional bounding info, required for facetPartitioning computation
  96118. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96119. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96120. * * useRightHandedSystem: optional boolean to for right handed system computation
  96121. * * depthSort : optional boolean to enable the facet depth sort computation
  96122. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96123. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96124. */
  96125. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96126. facetNormals?: any;
  96127. facetPositions?: any;
  96128. facetPartitioning?: any;
  96129. ratio?: number;
  96130. bInfo?: any;
  96131. bbSize?: Vector3;
  96132. subDiv?: any;
  96133. useRightHandedSystem?: boolean;
  96134. depthSort?: boolean;
  96135. distanceTo?: Vector3;
  96136. depthSortedFacets?: any;
  96137. }): void;
  96138. /** @hidden */
  96139. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96140. /**
  96141. * Applies VertexData created from the imported parameters to the geometry
  96142. * @param parsedVertexData the parsed data from an imported file
  96143. * @param geometry the geometry to apply the VertexData to
  96144. */
  96145. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96146. }
  96147. }
  96148. declare module BABYLON {
  96149. /**
  96150. * Defines a target to use with MorphTargetManager
  96151. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96152. */
  96153. export class MorphTarget implements IAnimatable {
  96154. /** defines the name of the target */
  96155. name: string;
  96156. /**
  96157. * Gets or sets the list of animations
  96158. */
  96159. animations: Animation[];
  96160. private _scene;
  96161. private _positions;
  96162. private _normals;
  96163. private _tangents;
  96164. private _uvs;
  96165. private _influence;
  96166. private _uniqueId;
  96167. /**
  96168. * Observable raised when the influence changes
  96169. */
  96170. onInfluenceChanged: Observable<boolean>;
  96171. /** @hidden */
  96172. _onDataLayoutChanged: Observable<void>;
  96173. /**
  96174. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96175. */
  96176. get influence(): number;
  96177. set influence(influence: number);
  96178. /**
  96179. * Gets or sets the id of the morph Target
  96180. */
  96181. id: string;
  96182. private _animationPropertiesOverride;
  96183. /**
  96184. * Gets or sets the animation properties override
  96185. */
  96186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96188. /**
  96189. * Creates a new MorphTarget
  96190. * @param name defines the name of the target
  96191. * @param influence defines the influence to use
  96192. * @param scene defines the scene the morphtarget belongs to
  96193. */
  96194. constructor(
  96195. /** defines the name of the target */
  96196. name: string, influence?: number, scene?: Nullable<Scene>);
  96197. /**
  96198. * Gets the unique ID of this manager
  96199. */
  96200. get uniqueId(): number;
  96201. /**
  96202. * Gets a boolean defining if the target contains position data
  96203. */
  96204. get hasPositions(): boolean;
  96205. /**
  96206. * Gets a boolean defining if the target contains normal data
  96207. */
  96208. get hasNormals(): boolean;
  96209. /**
  96210. * Gets a boolean defining if the target contains tangent data
  96211. */
  96212. get hasTangents(): boolean;
  96213. /**
  96214. * Gets a boolean defining if the target contains texture coordinates data
  96215. */
  96216. get hasUVs(): boolean;
  96217. /**
  96218. * Affects position data to this target
  96219. * @param data defines the position data to use
  96220. */
  96221. setPositions(data: Nullable<FloatArray>): void;
  96222. /**
  96223. * Gets the position data stored in this target
  96224. * @returns a FloatArray containing the position data (or null if not present)
  96225. */
  96226. getPositions(): Nullable<FloatArray>;
  96227. /**
  96228. * Affects normal data to this target
  96229. * @param data defines the normal data to use
  96230. */
  96231. setNormals(data: Nullable<FloatArray>): void;
  96232. /**
  96233. * Gets the normal data stored in this target
  96234. * @returns a FloatArray containing the normal data (or null if not present)
  96235. */
  96236. getNormals(): Nullable<FloatArray>;
  96237. /**
  96238. * Affects tangent data to this target
  96239. * @param data defines the tangent data to use
  96240. */
  96241. setTangents(data: Nullable<FloatArray>): void;
  96242. /**
  96243. * Gets the tangent data stored in this target
  96244. * @returns a FloatArray containing the tangent data (or null if not present)
  96245. */
  96246. getTangents(): Nullable<FloatArray>;
  96247. /**
  96248. * Affects texture coordinates data to this target
  96249. * @param data defines the texture coordinates data to use
  96250. */
  96251. setUVs(data: Nullable<FloatArray>): void;
  96252. /**
  96253. * Gets the texture coordinates data stored in this target
  96254. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96255. */
  96256. getUVs(): Nullable<FloatArray>;
  96257. /**
  96258. * Clone the current target
  96259. * @returns a new MorphTarget
  96260. */
  96261. clone(): MorphTarget;
  96262. /**
  96263. * Serializes the current target into a Serialization object
  96264. * @returns the serialized object
  96265. */
  96266. serialize(): any;
  96267. /**
  96268. * Returns the string "MorphTarget"
  96269. * @returns "MorphTarget"
  96270. */
  96271. getClassName(): string;
  96272. /**
  96273. * Creates a new target from serialized data
  96274. * @param serializationObject defines the serialized data to use
  96275. * @returns a new MorphTarget
  96276. */
  96277. static Parse(serializationObject: any): MorphTarget;
  96278. /**
  96279. * Creates a MorphTarget from mesh data
  96280. * @param mesh defines the source mesh
  96281. * @param name defines the name to use for the new target
  96282. * @param influence defines the influence to attach to the target
  96283. * @returns a new MorphTarget
  96284. */
  96285. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96286. }
  96287. }
  96288. declare module BABYLON {
  96289. /**
  96290. * This class is used to deform meshes using morphing between different targets
  96291. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96292. */
  96293. export class MorphTargetManager {
  96294. private _targets;
  96295. private _targetInfluenceChangedObservers;
  96296. private _targetDataLayoutChangedObservers;
  96297. private _activeTargets;
  96298. private _scene;
  96299. private _influences;
  96300. private _supportsNormals;
  96301. private _supportsTangents;
  96302. private _supportsUVs;
  96303. private _vertexCount;
  96304. private _uniqueId;
  96305. private _tempInfluences;
  96306. /**
  96307. * Gets or sets a boolean indicating if normals must be morphed
  96308. */
  96309. enableNormalMorphing: boolean;
  96310. /**
  96311. * Gets or sets a boolean indicating if tangents must be morphed
  96312. */
  96313. enableTangentMorphing: boolean;
  96314. /**
  96315. * Gets or sets a boolean indicating if UV must be morphed
  96316. */
  96317. enableUVMorphing: boolean;
  96318. /**
  96319. * Creates a new MorphTargetManager
  96320. * @param scene defines the current scene
  96321. */
  96322. constructor(scene?: Nullable<Scene>);
  96323. /**
  96324. * Gets the unique ID of this manager
  96325. */
  96326. get uniqueId(): number;
  96327. /**
  96328. * Gets the number of vertices handled by this manager
  96329. */
  96330. get vertexCount(): number;
  96331. /**
  96332. * Gets a boolean indicating if this manager supports morphing of normals
  96333. */
  96334. get supportsNormals(): boolean;
  96335. /**
  96336. * Gets a boolean indicating if this manager supports morphing of tangents
  96337. */
  96338. get supportsTangents(): boolean;
  96339. /**
  96340. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96341. */
  96342. get supportsUVs(): boolean;
  96343. /**
  96344. * Gets the number of targets stored in this manager
  96345. */
  96346. get numTargets(): number;
  96347. /**
  96348. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96349. */
  96350. get numInfluencers(): number;
  96351. /**
  96352. * Gets the list of influences (one per target)
  96353. */
  96354. get influences(): Float32Array;
  96355. /**
  96356. * Gets the active target at specified index. An active target is a target with an influence > 0
  96357. * @param index defines the index to check
  96358. * @returns the requested target
  96359. */
  96360. getActiveTarget(index: number): MorphTarget;
  96361. /**
  96362. * Gets the target at specified index
  96363. * @param index defines the index to check
  96364. * @returns the requested target
  96365. */
  96366. getTarget(index: number): MorphTarget;
  96367. /**
  96368. * Add a new target to this manager
  96369. * @param target defines the target to add
  96370. */
  96371. addTarget(target: MorphTarget): void;
  96372. /**
  96373. * Removes a target from the manager
  96374. * @param target defines the target to remove
  96375. */
  96376. removeTarget(target: MorphTarget): void;
  96377. /**
  96378. * Clone the current manager
  96379. * @returns a new MorphTargetManager
  96380. */
  96381. clone(): MorphTargetManager;
  96382. /**
  96383. * Serializes the current manager into a Serialization object
  96384. * @returns the serialized object
  96385. */
  96386. serialize(): any;
  96387. private _syncActiveTargets;
  96388. /**
  96389. * Syncrhonize the targets with all the meshes using this morph target manager
  96390. */
  96391. synchronize(): void;
  96392. /**
  96393. * Creates a new MorphTargetManager from serialized data
  96394. * @param serializationObject defines the serialized data
  96395. * @param scene defines the hosting scene
  96396. * @returns the new MorphTargetManager
  96397. */
  96398. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96399. }
  96400. }
  96401. declare module BABYLON {
  96402. /**
  96403. * Class used to represent a specific level of detail of a mesh
  96404. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96405. */
  96406. export class MeshLODLevel {
  96407. /** Defines the distance where this level should start being displayed */
  96408. distance: number;
  96409. /** Defines the mesh to use to render this level */
  96410. mesh: Nullable<Mesh>;
  96411. /**
  96412. * Creates a new LOD level
  96413. * @param distance defines the distance where this level should star being displayed
  96414. * @param mesh defines the mesh to use to render this level
  96415. */
  96416. constructor(
  96417. /** Defines the distance where this level should start being displayed */
  96418. distance: number,
  96419. /** Defines the mesh to use to render this level */
  96420. mesh: Nullable<Mesh>);
  96421. }
  96422. }
  96423. declare module BABYLON {
  96424. /**
  96425. * Mesh representing the gorund
  96426. */
  96427. export class GroundMesh extends Mesh {
  96428. /** If octree should be generated */
  96429. generateOctree: boolean;
  96430. private _heightQuads;
  96431. /** @hidden */
  96432. _subdivisionsX: number;
  96433. /** @hidden */
  96434. _subdivisionsY: number;
  96435. /** @hidden */
  96436. _width: number;
  96437. /** @hidden */
  96438. _height: number;
  96439. /** @hidden */
  96440. _minX: number;
  96441. /** @hidden */
  96442. _maxX: number;
  96443. /** @hidden */
  96444. _minZ: number;
  96445. /** @hidden */
  96446. _maxZ: number;
  96447. constructor(name: string, scene: Scene);
  96448. /**
  96449. * "GroundMesh"
  96450. * @returns "GroundMesh"
  96451. */
  96452. getClassName(): string;
  96453. /**
  96454. * The minimum of x and y subdivisions
  96455. */
  96456. get subdivisions(): number;
  96457. /**
  96458. * X subdivisions
  96459. */
  96460. get subdivisionsX(): number;
  96461. /**
  96462. * Y subdivisions
  96463. */
  96464. get subdivisionsY(): number;
  96465. /**
  96466. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96467. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96468. * @param chunksCount the number of subdivisions for x and y
  96469. * @param octreeBlocksSize (Default: 32)
  96470. */
  96471. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96472. /**
  96473. * Returns a height (y) value in the Worl system :
  96474. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96475. * @param x x coordinate
  96476. * @param z z coordinate
  96477. * @returns the ground y position if (x, z) are outside the ground surface.
  96478. */
  96479. getHeightAtCoordinates(x: number, z: number): number;
  96480. /**
  96481. * Returns a normalized vector (Vector3) orthogonal to the ground
  96482. * at the ground coordinates (x, z) expressed in the World system.
  96483. * @param x x coordinate
  96484. * @param z z coordinate
  96485. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96486. */
  96487. getNormalAtCoordinates(x: number, z: number): Vector3;
  96488. /**
  96489. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96490. * at the ground coordinates (x, z) expressed in the World system.
  96491. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96492. * @param x x coordinate
  96493. * @param z z coordinate
  96494. * @param ref vector to store the result
  96495. * @returns the GroundMesh.
  96496. */
  96497. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96498. /**
  96499. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96500. * if the ground has been updated.
  96501. * This can be used in the render loop.
  96502. * @returns the GroundMesh.
  96503. */
  96504. updateCoordinateHeights(): GroundMesh;
  96505. private _getFacetAt;
  96506. private _initHeightQuads;
  96507. private _computeHeightQuads;
  96508. /**
  96509. * Serializes this ground mesh
  96510. * @param serializationObject object to write serialization to
  96511. */
  96512. serialize(serializationObject: any): void;
  96513. /**
  96514. * Parses a serialized ground mesh
  96515. * @param parsedMesh the serialized mesh
  96516. * @param scene the scene to create the ground mesh in
  96517. * @returns the created ground mesh
  96518. */
  96519. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96520. }
  96521. }
  96522. declare module BABYLON {
  96523. /**
  96524. * Interface for Physics-Joint data
  96525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96526. */
  96527. export interface PhysicsJointData {
  96528. /**
  96529. * The main pivot of the joint
  96530. */
  96531. mainPivot?: Vector3;
  96532. /**
  96533. * The connected pivot of the joint
  96534. */
  96535. connectedPivot?: Vector3;
  96536. /**
  96537. * The main axis of the joint
  96538. */
  96539. mainAxis?: Vector3;
  96540. /**
  96541. * The connected axis of the joint
  96542. */
  96543. connectedAxis?: Vector3;
  96544. /**
  96545. * The collision of the joint
  96546. */
  96547. collision?: boolean;
  96548. /**
  96549. * Native Oimo/Cannon/Energy data
  96550. */
  96551. nativeParams?: any;
  96552. }
  96553. /**
  96554. * This is a holder class for the physics joint created by the physics plugin
  96555. * It holds a set of functions to control the underlying joint
  96556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96557. */
  96558. export class PhysicsJoint {
  96559. /**
  96560. * The type of the physics joint
  96561. */
  96562. type: number;
  96563. /**
  96564. * The data for the physics joint
  96565. */
  96566. jointData: PhysicsJointData;
  96567. private _physicsJoint;
  96568. protected _physicsPlugin: IPhysicsEnginePlugin;
  96569. /**
  96570. * Initializes the physics joint
  96571. * @param type The type of the physics joint
  96572. * @param jointData The data for the physics joint
  96573. */
  96574. constructor(
  96575. /**
  96576. * The type of the physics joint
  96577. */
  96578. type: number,
  96579. /**
  96580. * The data for the physics joint
  96581. */
  96582. jointData: PhysicsJointData);
  96583. /**
  96584. * Gets the physics joint
  96585. */
  96586. get physicsJoint(): any;
  96587. /**
  96588. * Sets the physics joint
  96589. */
  96590. set physicsJoint(newJoint: any);
  96591. /**
  96592. * Sets the physics plugin
  96593. */
  96594. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96595. /**
  96596. * Execute a function that is physics-plugin specific.
  96597. * @param {Function} func the function that will be executed.
  96598. * It accepts two parameters: the physics world and the physics joint
  96599. */
  96600. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96601. /**
  96602. * Distance-Joint type
  96603. */
  96604. static DistanceJoint: number;
  96605. /**
  96606. * Hinge-Joint type
  96607. */
  96608. static HingeJoint: number;
  96609. /**
  96610. * Ball-and-Socket joint type
  96611. */
  96612. static BallAndSocketJoint: number;
  96613. /**
  96614. * Wheel-Joint type
  96615. */
  96616. static WheelJoint: number;
  96617. /**
  96618. * Slider-Joint type
  96619. */
  96620. static SliderJoint: number;
  96621. /**
  96622. * Prismatic-Joint type
  96623. */
  96624. static PrismaticJoint: number;
  96625. /**
  96626. * Universal-Joint type
  96627. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96628. */
  96629. static UniversalJoint: number;
  96630. /**
  96631. * Hinge-Joint 2 type
  96632. */
  96633. static Hinge2Joint: number;
  96634. /**
  96635. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96636. */
  96637. static PointToPointJoint: number;
  96638. /**
  96639. * Spring-Joint type
  96640. */
  96641. static SpringJoint: number;
  96642. /**
  96643. * Lock-Joint type
  96644. */
  96645. static LockJoint: number;
  96646. }
  96647. /**
  96648. * A class representing a physics distance joint
  96649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96650. */
  96651. export class DistanceJoint extends PhysicsJoint {
  96652. /**
  96653. *
  96654. * @param jointData The data for the Distance-Joint
  96655. */
  96656. constructor(jointData: DistanceJointData);
  96657. /**
  96658. * Update the predefined distance.
  96659. * @param maxDistance The maximum preferred distance
  96660. * @param minDistance The minimum preferred distance
  96661. */
  96662. updateDistance(maxDistance: number, minDistance?: number): void;
  96663. }
  96664. /**
  96665. * Represents a Motor-Enabled Joint
  96666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96667. */
  96668. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96669. /**
  96670. * Initializes the Motor-Enabled Joint
  96671. * @param type The type of the joint
  96672. * @param jointData The physica joint data for the joint
  96673. */
  96674. constructor(type: number, jointData: PhysicsJointData);
  96675. /**
  96676. * Set the motor values.
  96677. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96678. * @param force the force to apply
  96679. * @param maxForce max force for this motor.
  96680. */
  96681. setMotor(force?: number, maxForce?: number): void;
  96682. /**
  96683. * Set the motor's limits.
  96684. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96685. * @param upperLimit The upper limit of the motor
  96686. * @param lowerLimit The lower limit of the motor
  96687. */
  96688. setLimit(upperLimit: number, lowerLimit?: number): void;
  96689. }
  96690. /**
  96691. * This class represents a single physics Hinge-Joint
  96692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96693. */
  96694. export class HingeJoint extends MotorEnabledJoint {
  96695. /**
  96696. * Initializes the Hinge-Joint
  96697. * @param jointData The joint data for the Hinge-Joint
  96698. */
  96699. constructor(jointData: PhysicsJointData);
  96700. /**
  96701. * Set the motor values.
  96702. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96703. * @param {number} force the force to apply
  96704. * @param {number} maxForce max force for this motor.
  96705. */
  96706. setMotor(force?: number, maxForce?: number): void;
  96707. /**
  96708. * Set the motor's limits.
  96709. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96710. * @param upperLimit The upper limit of the motor
  96711. * @param lowerLimit The lower limit of the motor
  96712. */
  96713. setLimit(upperLimit: number, lowerLimit?: number): void;
  96714. }
  96715. /**
  96716. * This class represents a dual hinge physics joint (same as wheel joint)
  96717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96718. */
  96719. export class Hinge2Joint extends MotorEnabledJoint {
  96720. /**
  96721. * Initializes the Hinge2-Joint
  96722. * @param jointData The joint data for the Hinge2-Joint
  96723. */
  96724. constructor(jointData: PhysicsJointData);
  96725. /**
  96726. * Set the motor values.
  96727. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96728. * @param {number} targetSpeed the speed the motor is to reach
  96729. * @param {number} maxForce max force for this motor.
  96730. * @param {motorIndex} the motor's index, 0 or 1.
  96731. */
  96732. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96733. /**
  96734. * Set the motor limits.
  96735. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96736. * @param {number} upperLimit the upper limit
  96737. * @param {number} lowerLimit lower limit
  96738. * @param {motorIndex} the motor's index, 0 or 1.
  96739. */
  96740. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96741. }
  96742. /**
  96743. * Interface for a motor enabled joint
  96744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96745. */
  96746. export interface IMotorEnabledJoint {
  96747. /**
  96748. * Physics joint
  96749. */
  96750. physicsJoint: any;
  96751. /**
  96752. * Sets the motor of the motor-enabled joint
  96753. * @param force The force of the motor
  96754. * @param maxForce The maximum force of the motor
  96755. * @param motorIndex The index of the motor
  96756. */
  96757. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96758. /**
  96759. * Sets the limit of the motor
  96760. * @param upperLimit The upper limit of the motor
  96761. * @param lowerLimit The lower limit of the motor
  96762. * @param motorIndex The index of the motor
  96763. */
  96764. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96765. }
  96766. /**
  96767. * Joint data for a Distance-Joint
  96768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96769. */
  96770. export interface DistanceJointData extends PhysicsJointData {
  96771. /**
  96772. * Max distance the 2 joint objects can be apart
  96773. */
  96774. maxDistance: number;
  96775. }
  96776. /**
  96777. * Joint data from a spring joint
  96778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96779. */
  96780. export interface SpringJointData extends PhysicsJointData {
  96781. /**
  96782. * Length of the spring
  96783. */
  96784. length: number;
  96785. /**
  96786. * Stiffness of the spring
  96787. */
  96788. stiffness: number;
  96789. /**
  96790. * Damping of the spring
  96791. */
  96792. damping: number;
  96793. /** this callback will be called when applying the force to the impostors. */
  96794. forceApplicationCallback: () => void;
  96795. }
  96796. }
  96797. declare module BABYLON {
  96798. /**
  96799. * Holds the data for the raycast result
  96800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96801. */
  96802. export class PhysicsRaycastResult {
  96803. private _hasHit;
  96804. private _hitDistance;
  96805. private _hitNormalWorld;
  96806. private _hitPointWorld;
  96807. private _rayFromWorld;
  96808. private _rayToWorld;
  96809. /**
  96810. * Gets if there was a hit
  96811. */
  96812. get hasHit(): boolean;
  96813. /**
  96814. * Gets the distance from the hit
  96815. */
  96816. get hitDistance(): number;
  96817. /**
  96818. * Gets the hit normal/direction in the world
  96819. */
  96820. get hitNormalWorld(): Vector3;
  96821. /**
  96822. * Gets the hit point in the world
  96823. */
  96824. get hitPointWorld(): Vector3;
  96825. /**
  96826. * Gets the ray "start point" of the ray in the world
  96827. */
  96828. get rayFromWorld(): Vector3;
  96829. /**
  96830. * Gets the ray "end point" of the ray in the world
  96831. */
  96832. get rayToWorld(): Vector3;
  96833. /**
  96834. * Sets the hit data (normal & point in world space)
  96835. * @param hitNormalWorld defines the normal in world space
  96836. * @param hitPointWorld defines the point in world space
  96837. */
  96838. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96839. /**
  96840. * Sets the distance from the start point to the hit point
  96841. * @param distance
  96842. */
  96843. setHitDistance(distance: number): void;
  96844. /**
  96845. * Calculates the distance manually
  96846. */
  96847. calculateHitDistance(): void;
  96848. /**
  96849. * Resets all the values to default
  96850. * @param from The from point on world space
  96851. * @param to The to point on world space
  96852. */
  96853. reset(from?: Vector3, to?: Vector3): void;
  96854. }
  96855. /**
  96856. * Interface for the size containing width and height
  96857. */
  96858. interface IXYZ {
  96859. /**
  96860. * X
  96861. */
  96862. x: number;
  96863. /**
  96864. * Y
  96865. */
  96866. y: number;
  96867. /**
  96868. * Z
  96869. */
  96870. z: number;
  96871. }
  96872. }
  96873. declare module BABYLON {
  96874. /**
  96875. * Interface used to describe a physics joint
  96876. */
  96877. export interface PhysicsImpostorJoint {
  96878. /** Defines the main impostor to which the joint is linked */
  96879. mainImpostor: PhysicsImpostor;
  96880. /** Defines the impostor that is connected to the main impostor using this joint */
  96881. connectedImpostor: PhysicsImpostor;
  96882. /** Defines the joint itself */
  96883. joint: PhysicsJoint;
  96884. }
  96885. /** @hidden */
  96886. export interface IPhysicsEnginePlugin {
  96887. world: any;
  96888. name: string;
  96889. setGravity(gravity: Vector3): void;
  96890. setTimeStep(timeStep: number): void;
  96891. getTimeStep(): number;
  96892. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96893. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96894. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96895. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96896. removePhysicsBody(impostor: PhysicsImpostor): void;
  96897. generateJoint(joint: PhysicsImpostorJoint): void;
  96898. removeJoint(joint: PhysicsImpostorJoint): void;
  96899. isSupported(): boolean;
  96900. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96901. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96902. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96903. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96904. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96905. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96906. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96907. getBodyMass(impostor: PhysicsImpostor): number;
  96908. getBodyFriction(impostor: PhysicsImpostor): number;
  96909. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96910. getBodyRestitution(impostor: PhysicsImpostor): number;
  96911. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96912. getBodyPressure?(impostor: PhysicsImpostor): number;
  96913. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96914. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96915. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96916. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96917. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96918. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96919. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96920. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96921. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96922. sleepBody(impostor: PhysicsImpostor): void;
  96923. wakeUpBody(impostor: PhysicsImpostor): void;
  96924. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96925. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96926. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96927. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96928. getRadius(impostor: PhysicsImpostor): number;
  96929. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96930. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96931. dispose(): void;
  96932. }
  96933. /**
  96934. * Interface used to define a physics engine
  96935. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96936. */
  96937. export interface IPhysicsEngine {
  96938. /**
  96939. * Gets the gravity vector used by the simulation
  96940. */
  96941. gravity: Vector3;
  96942. /**
  96943. * Sets the gravity vector used by the simulation
  96944. * @param gravity defines the gravity vector to use
  96945. */
  96946. setGravity(gravity: Vector3): void;
  96947. /**
  96948. * Set the time step of the physics engine.
  96949. * Default is 1/60.
  96950. * To slow it down, enter 1/600 for example.
  96951. * To speed it up, 1/30
  96952. * @param newTimeStep the new timestep to apply to this world.
  96953. */
  96954. setTimeStep(newTimeStep: number): void;
  96955. /**
  96956. * Get the time step of the physics engine.
  96957. * @returns the current time step
  96958. */
  96959. getTimeStep(): number;
  96960. /**
  96961. * Set the sub time step of the physics engine.
  96962. * Default is 0 meaning there is no sub steps
  96963. * To increase physics resolution precision, set a small value (like 1 ms)
  96964. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96965. */
  96966. setSubTimeStep(subTimeStep: number): void;
  96967. /**
  96968. * Get the sub time step of the physics engine.
  96969. * @returns the current sub time step
  96970. */
  96971. getSubTimeStep(): number;
  96972. /**
  96973. * Release all resources
  96974. */
  96975. dispose(): void;
  96976. /**
  96977. * Gets the name of the current physics plugin
  96978. * @returns the name of the plugin
  96979. */
  96980. getPhysicsPluginName(): string;
  96981. /**
  96982. * Adding a new impostor for the impostor tracking.
  96983. * This will be done by the impostor itself.
  96984. * @param impostor the impostor to add
  96985. */
  96986. addImpostor(impostor: PhysicsImpostor): void;
  96987. /**
  96988. * Remove an impostor from the engine.
  96989. * This impostor and its mesh will not longer be updated by the physics engine.
  96990. * @param impostor the impostor to remove
  96991. */
  96992. removeImpostor(impostor: PhysicsImpostor): void;
  96993. /**
  96994. * Add a joint to the physics engine
  96995. * @param mainImpostor defines the main impostor to which the joint is added.
  96996. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96997. * @param joint defines the joint that will connect both impostors.
  96998. */
  96999. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97000. /**
  97001. * Removes a joint from the simulation
  97002. * @param mainImpostor defines the impostor used with the joint
  97003. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  97004. * @param joint defines the joint to remove
  97005. */
  97006. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97007. /**
  97008. * Gets the current plugin used to run the simulation
  97009. * @returns current plugin
  97010. */
  97011. getPhysicsPlugin(): IPhysicsEnginePlugin;
  97012. /**
  97013. * Gets the list of physic impostors
  97014. * @returns an array of PhysicsImpostor
  97015. */
  97016. getImpostors(): Array<PhysicsImpostor>;
  97017. /**
  97018. * Gets the impostor for a physics enabled object
  97019. * @param object defines the object impersonated by the impostor
  97020. * @returns the PhysicsImpostor or null if not found
  97021. */
  97022. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97023. /**
  97024. * Gets the impostor for a physics body object
  97025. * @param body defines physics body used by the impostor
  97026. * @returns the PhysicsImpostor or null if not found
  97027. */
  97028. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  97029. /**
  97030. * Does a raycast in the physics world
  97031. * @param from when should the ray start?
  97032. * @param to when should the ray end?
  97033. * @returns PhysicsRaycastResult
  97034. */
  97035. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97036. /**
  97037. * Called by the scene. No need to call it.
  97038. * @param delta defines the timespam between frames
  97039. */
  97040. _step(delta: number): void;
  97041. }
  97042. }
  97043. declare module BABYLON {
  97044. /**
  97045. * The interface for the physics imposter parameters
  97046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97047. */
  97048. export interface PhysicsImpostorParameters {
  97049. /**
  97050. * The mass of the physics imposter
  97051. */
  97052. mass: number;
  97053. /**
  97054. * The friction of the physics imposter
  97055. */
  97056. friction?: number;
  97057. /**
  97058. * The coefficient of restitution of the physics imposter
  97059. */
  97060. restitution?: number;
  97061. /**
  97062. * The native options of the physics imposter
  97063. */
  97064. nativeOptions?: any;
  97065. /**
  97066. * Specifies if the parent should be ignored
  97067. */
  97068. ignoreParent?: boolean;
  97069. /**
  97070. * Specifies if bi-directional transformations should be disabled
  97071. */
  97072. disableBidirectionalTransformation?: boolean;
  97073. /**
  97074. * The pressure inside the physics imposter, soft object only
  97075. */
  97076. pressure?: number;
  97077. /**
  97078. * The stiffness the physics imposter, soft object only
  97079. */
  97080. stiffness?: number;
  97081. /**
  97082. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97083. */
  97084. velocityIterations?: number;
  97085. /**
  97086. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97087. */
  97088. positionIterations?: number;
  97089. /**
  97090. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97091. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97092. * Add to fix multiple points
  97093. */
  97094. fixedPoints?: number;
  97095. /**
  97096. * The collision margin around a soft object
  97097. */
  97098. margin?: number;
  97099. /**
  97100. * The collision margin around a soft object
  97101. */
  97102. damping?: number;
  97103. /**
  97104. * The path for a rope based on an extrusion
  97105. */
  97106. path?: any;
  97107. /**
  97108. * The shape of an extrusion used for a rope based on an extrusion
  97109. */
  97110. shape?: any;
  97111. }
  97112. /**
  97113. * Interface for a physics-enabled object
  97114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97115. */
  97116. export interface IPhysicsEnabledObject {
  97117. /**
  97118. * The position of the physics-enabled object
  97119. */
  97120. position: Vector3;
  97121. /**
  97122. * The rotation of the physics-enabled object
  97123. */
  97124. rotationQuaternion: Nullable<Quaternion>;
  97125. /**
  97126. * The scale of the physics-enabled object
  97127. */
  97128. scaling: Vector3;
  97129. /**
  97130. * The rotation of the physics-enabled object
  97131. */
  97132. rotation?: Vector3;
  97133. /**
  97134. * The parent of the physics-enabled object
  97135. */
  97136. parent?: any;
  97137. /**
  97138. * The bounding info of the physics-enabled object
  97139. * @returns The bounding info of the physics-enabled object
  97140. */
  97141. getBoundingInfo(): BoundingInfo;
  97142. /**
  97143. * Computes the world matrix
  97144. * @param force Specifies if the world matrix should be computed by force
  97145. * @returns A world matrix
  97146. */
  97147. computeWorldMatrix(force: boolean): Matrix;
  97148. /**
  97149. * Gets the world matrix
  97150. * @returns A world matrix
  97151. */
  97152. getWorldMatrix?(): Matrix;
  97153. /**
  97154. * Gets the child meshes
  97155. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97156. * @returns An array of abstract meshes
  97157. */
  97158. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97159. /**
  97160. * Gets the vertex data
  97161. * @param kind The type of vertex data
  97162. * @returns A nullable array of numbers, or a float32 array
  97163. */
  97164. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97165. /**
  97166. * Gets the indices from the mesh
  97167. * @returns A nullable array of index arrays
  97168. */
  97169. getIndices?(): Nullable<IndicesArray>;
  97170. /**
  97171. * Gets the scene from the mesh
  97172. * @returns the indices array or null
  97173. */
  97174. getScene?(): Scene;
  97175. /**
  97176. * Gets the absolute position from the mesh
  97177. * @returns the absolute position
  97178. */
  97179. getAbsolutePosition(): Vector3;
  97180. /**
  97181. * Gets the absolute pivot point from the mesh
  97182. * @returns the absolute pivot point
  97183. */
  97184. getAbsolutePivotPoint(): Vector3;
  97185. /**
  97186. * Rotates the mesh
  97187. * @param axis The axis of rotation
  97188. * @param amount The amount of rotation
  97189. * @param space The space of the rotation
  97190. * @returns The rotation transform node
  97191. */
  97192. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97193. /**
  97194. * Translates the mesh
  97195. * @param axis The axis of translation
  97196. * @param distance The distance of translation
  97197. * @param space The space of the translation
  97198. * @returns The transform node
  97199. */
  97200. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97201. /**
  97202. * Sets the absolute position of the mesh
  97203. * @param absolutePosition The absolute position of the mesh
  97204. * @returns The transform node
  97205. */
  97206. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97207. /**
  97208. * Gets the class name of the mesh
  97209. * @returns The class name
  97210. */
  97211. getClassName(): string;
  97212. }
  97213. /**
  97214. * Represents a physics imposter
  97215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97216. */
  97217. export class PhysicsImpostor {
  97218. /**
  97219. * The physics-enabled object used as the physics imposter
  97220. */
  97221. object: IPhysicsEnabledObject;
  97222. /**
  97223. * The type of the physics imposter
  97224. */
  97225. type: number;
  97226. private _options;
  97227. private _scene?;
  97228. /**
  97229. * The default object size of the imposter
  97230. */
  97231. static DEFAULT_OBJECT_SIZE: Vector3;
  97232. /**
  97233. * The identity quaternion of the imposter
  97234. */
  97235. static IDENTITY_QUATERNION: Quaternion;
  97236. /** @hidden */
  97237. _pluginData: any;
  97238. private _physicsEngine;
  97239. private _physicsBody;
  97240. private _bodyUpdateRequired;
  97241. private _onBeforePhysicsStepCallbacks;
  97242. private _onAfterPhysicsStepCallbacks;
  97243. /** @hidden */
  97244. _onPhysicsCollideCallbacks: Array<{
  97245. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97246. otherImpostors: Array<PhysicsImpostor>;
  97247. }>;
  97248. private _deltaPosition;
  97249. private _deltaRotation;
  97250. private _deltaRotationConjugated;
  97251. /** @hidden */
  97252. _isFromLine: boolean;
  97253. private _parent;
  97254. private _isDisposed;
  97255. private static _tmpVecs;
  97256. private static _tmpQuat;
  97257. /**
  97258. * Specifies if the physics imposter is disposed
  97259. */
  97260. get isDisposed(): boolean;
  97261. /**
  97262. * Gets the mass of the physics imposter
  97263. */
  97264. get mass(): number;
  97265. set mass(value: number);
  97266. /**
  97267. * Gets the coefficient of friction
  97268. */
  97269. get friction(): number;
  97270. /**
  97271. * Sets the coefficient of friction
  97272. */
  97273. set friction(value: number);
  97274. /**
  97275. * Gets the coefficient of restitution
  97276. */
  97277. get restitution(): number;
  97278. /**
  97279. * Sets the coefficient of restitution
  97280. */
  97281. set restitution(value: number);
  97282. /**
  97283. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97284. */
  97285. get pressure(): number;
  97286. /**
  97287. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97288. */
  97289. set pressure(value: number);
  97290. /**
  97291. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97292. */
  97293. get stiffness(): number;
  97294. /**
  97295. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97296. */
  97297. set stiffness(value: number);
  97298. /**
  97299. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97300. */
  97301. get velocityIterations(): number;
  97302. /**
  97303. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97304. */
  97305. set velocityIterations(value: number);
  97306. /**
  97307. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97308. */
  97309. get positionIterations(): number;
  97310. /**
  97311. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97312. */
  97313. set positionIterations(value: number);
  97314. /**
  97315. * The unique id of the physics imposter
  97316. * set by the physics engine when adding this impostor to the array
  97317. */
  97318. uniqueId: number;
  97319. /**
  97320. * @hidden
  97321. */
  97322. soft: boolean;
  97323. /**
  97324. * @hidden
  97325. */
  97326. segments: number;
  97327. private _joints;
  97328. /**
  97329. * Initializes the physics imposter
  97330. * @param object The physics-enabled object used as the physics imposter
  97331. * @param type The type of the physics imposter
  97332. * @param _options The options for the physics imposter
  97333. * @param _scene The Babylon scene
  97334. */
  97335. constructor(
  97336. /**
  97337. * The physics-enabled object used as the physics imposter
  97338. */
  97339. object: IPhysicsEnabledObject,
  97340. /**
  97341. * The type of the physics imposter
  97342. */
  97343. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97344. /**
  97345. * This function will completly initialize this impostor.
  97346. * It will create a new body - but only if this mesh has no parent.
  97347. * If it has, this impostor will not be used other than to define the impostor
  97348. * of the child mesh.
  97349. * @hidden
  97350. */
  97351. _init(): void;
  97352. private _getPhysicsParent;
  97353. /**
  97354. * Should a new body be generated.
  97355. * @returns boolean specifying if body initialization is required
  97356. */
  97357. isBodyInitRequired(): boolean;
  97358. /**
  97359. * Sets the updated scaling
  97360. * @param updated Specifies if the scaling is updated
  97361. */
  97362. setScalingUpdated(): void;
  97363. /**
  97364. * Force a regeneration of this or the parent's impostor's body.
  97365. * Use under cautious - This will remove all joints already implemented.
  97366. */
  97367. forceUpdate(): void;
  97368. /**
  97369. * Gets the body that holds this impostor. Either its own, or its parent.
  97370. */
  97371. get physicsBody(): any;
  97372. /**
  97373. * Get the parent of the physics imposter
  97374. * @returns Physics imposter or null
  97375. */
  97376. get parent(): Nullable<PhysicsImpostor>;
  97377. /**
  97378. * Sets the parent of the physics imposter
  97379. */
  97380. set parent(value: Nullable<PhysicsImpostor>);
  97381. /**
  97382. * Set the physics body. Used mainly by the physics engine/plugin
  97383. */
  97384. set physicsBody(physicsBody: any);
  97385. /**
  97386. * Resets the update flags
  97387. */
  97388. resetUpdateFlags(): void;
  97389. /**
  97390. * Gets the object extend size
  97391. * @returns the object extend size
  97392. */
  97393. getObjectExtendSize(): Vector3;
  97394. /**
  97395. * Gets the object center
  97396. * @returns The object center
  97397. */
  97398. getObjectCenter(): Vector3;
  97399. /**
  97400. * Get a specific parameter from the options parameters
  97401. * @param paramName The object parameter name
  97402. * @returns The object parameter
  97403. */
  97404. getParam(paramName: string): any;
  97405. /**
  97406. * Sets a specific parameter in the options given to the physics plugin
  97407. * @param paramName The parameter name
  97408. * @param value The value of the parameter
  97409. */
  97410. setParam(paramName: string, value: number): void;
  97411. /**
  97412. * Specifically change the body's mass option. Won't recreate the physics body object
  97413. * @param mass The mass of the physics imposter
  97414. */
  97415. setMass(mass: number): void;
  97416. /**
  97417. * Gets the linear velocity
  97418. * @returns linear velocity or null
  97419. */
  97420. getLinearVelocity(): Nullable<Vector3>;
  97421. /**
  97422. * Sets the linear velocity
  97423. * @param velocity linear velocity or null
  97424. */
  97425. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97426. /**
  97427. * Gets the angular velocity
  97428. * @returns angular velocity or null
  97429. */
  97430. getAngularVelocity(): Nullable<Vector3>;
  97431. /**
  97432. * Sets the angular velocity
  97433. * @param velocity The velocity or null
  97434. */
  97435. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97436. /**
  97437. * Execute a function with the physics plugin native code
  97438. * Provide a function the will have two variables - the world object and the physics body object
  97439. * @param func The function to execute with the physics plugin native code
  97440. */
  97441. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97442. /**
  97443. * Register a function that will be executed before the physics world is stepping forward
  97444. * @param func The function to execute before the physics world is stepped forward
  97445. */
  97446. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97447. /**
  97448. * Unregister a function that will be executed before the physics world is stepping forward
  97449. * @param func The function to execute before the physics world is stepped forward
  97450. */
  97451. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97452. /**
  97453. * Register a function that will be executed after the physics step
  97454. * @param func The function to execute after physics step
  97455. */
  97456. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97457. /**
  97458. * Unregisters a function that will be executed after the physics step
  97459. * @param func The function to execute after physics step
  97460. */
  97461. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97462. /**
  97463. * register a function that will be executed when this impostor collides against a different body
  97464. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97465. * @param func Callback that is executed on collision
  97466. */
  97467. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97468. /**
  97469. * Unregisters the physics imposter on contact
  97470. * @param collideAgainst The physics object to collide against
  97471. * @param func Callback to execute on collision
  97472. */
  97473. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97474. private _tmpQuat;
  97475. private _tmpQuat2;
  97476. /**
  97477. * Get the parent rotation
  97478. * @returns The parent rotation
  97479. */
  97480. getParentsRotation(): Quaternion;
  97481. /**
  97482. * this function is executed by the physics engine.
  97483. */
  97484. beforeStep: () => void;
  97485. /**
  97486. * this function is executed by the physics engine
  97487. */
  97488. afterStep: () => void;
  97489. /**
  97490. * Legacy collision detection event support
  97491. */
  97492. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97493. /**
  97494. * event and body object due to cannon's event-based architecture.
  97495. */
  97496. onCollide: (e: {
  97497. body: any;
  97498. }) => void;
  97499. /**
  97500. * Apply a force
  97501. * @param force The force to apply
  97502. * @param contactPoint The contact point for the force
  97503. * @returns The physics imposter
  97504. */
  97505. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97506. /**
  97507. * Apply an impulse
  97508. * @param force The impulse force
  97509. * @param contactPoint The contact point for the impulse force
  97510. * @returns The physics imposter
  97511. */
  97512. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97513. /**
  97514. * A help function to create a joint
  97515. * @param otherImpostor A physics imposter used to create a joint
  97516. * @param jointType The type of joint
  97517. * @param jointData The data for the joint
  97518. * @returns The physics imposter
  97519. */
  97520. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97521. /**
  97522. * Add a joint to this impostor with a different impostor
  97523. * @param otherImpostor A physics imposter used to add a joint
  97524. * @param joint The joint to add
  97525. * @returns The physics imposter
  97526. */
  97527. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97528. /**
  97529. * Add an anchor to a cloth impostor
  97530. * @param otherImpostor rigid impostor to anchor to
  97531. * @param width ratio across width from 0 to 1
  97532. * @param height ratio up height from 0 to 1
  97533. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97534. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97535. * @returns impostor the soft imposter
  97536. */
  97537. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97538. /**
  97539. * Add a hook to a rope impostor
  97540. * @param otherImpostor rigid impostor to anchor to
  97541. * @param length ratio across rope from 0 to 1
  97542. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97543. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97544. * @returns impostor the rope imposter
  97545. */
  97546. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97547. /**
  97548. * Will keep this body still, in a sleep mode.
  97549. * @returns the physics imposter
  97550. */
  97551. sleep(): PhysicsImpostor;
  97552. /**
  97553. * Wake the body up.
  97554. * @returns The physics imposter
  97555. */
  97556. wakeUp(): PhysicsImpostor;
  97557. /**
  97558. * Clones the physics imposter
  97559. * @param newObject The physics imposter clones to this physics-enabled object
  97560. * @returns A nullable physics imposter
  97561. */
  97562. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97563. /**
  97564. * Disposes the physics imposter
  97565. */
  97566. dispose(): void;
  97567. /**
  97568. * Sets the delta position
  97569. * @param position The delta position amount
  97570. */
  97571. setDeltaPosition(position: Vector3): void;
  97572. /**
  97573. * Sets the delta rotation
  97574. * @param rotation The delta rotation amount
  97575. */
  97576. setDeltaRotation(rotation: Quaternion): void;
  97577. /**
  97578. * Gets the box size of the physics imposter and stores the result in the input parameter
  97579. * @param result Stores the box size
  97580. * @returns The physics imposter
  97581. */
  97582. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97583. /**
  97584. * Gets the radius of the physics imposter
  97585. * @returns Radius of the physics imposter
  97586. */
  97587. getRadius(): number;
  97588. /**
  97589. * Sync a bone with this impostor
  97590. * @param bone The bone to sync to the impostor.
  97591. * @param boneMesh The mesh that the bone is influencing.
  97592. * @param jointPivot The pivot of the joint / bone in local space.
  97593. * @param distToJoint Optional distance from the impostor to the joint.
  97594. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97595. */
  97596. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97597. /**
  97598. * Sync impostor to a bone
  97599. * @param bone The bone that the impostor will be synced to.
  97600. * @param boneMesh The mesh that the bone is influencing.
  97601. * @param jointPivot The pivot of the joint / bone in local space.
  97602. * @param distToJoint Optional distance from the impostor to the joint.
  97603. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97604. * @param boneAxis Optional vector3 axis the bone is aligned with
  97605. */
  97606. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97607. /**
  97608. * No-Imposter type
  97609. */
  97610. static NoImpostor: number;
  97611. /**
  97612. * Sphere-Imposter type
  97613. */
  97614. static SphereImpostor: number;
  97615. /**
  97616. * Box-Imposter type
  97617. */
  97618. static BoxImpostor: number;
  97619. /**
  97620. * Plane-Imposter type
  97621. */
  97622. static PlaneImpostor: number;
  97623. /**
  97624. * Mesh-imposter type
  97625. */
  97626. static MeshImpostor: number;
  97627. /**
  97628. * Capsule-Impostor type (Ammo.js plugin only)
  97629. */
  97630. static CapsuleImpostor: number;
  97631. /**
  97632. * Cylinder-Imposter type
  97633. */
  97634. static CylinderImpostor: number;
  97635. /**
  97636. * Particle-Imposter type
  97637. */
  97638. static ParticleImpostor: number;
  97639. /**
  97640. * Heightmap-Imposter type
  97641. */
  97642. static HeightmapImpostor: number;
  97643. /**
  97644. * ConvexHull-Impostor type (Ammo.js plugin only)
  97645. */
  97646. static ConvexHullImpostor: number;
  97647. /**
  97648. * Custom-Imposter type (Ammo.js plugin only)
  97649. */
  97650. static CustomImpostor: number;
  97651. /**
  97652. * Rope-Imposter type
  97653. */
  97654. static RopeImpostor: number;
  97655. /**
  97656. * Cloth-Imposter type
  97657. */
  97658. static ClothImpostor: number;
  97659. /**
  97660. * Softbody-Imposter type
  97661. */
  97662. static SoftbodyImpostor: number;
  97663. }
  97664. }
  97665. declare module BABYLON {
  97666. /**
  97667. * @hidden
  97668. **/
  97669. export class _CreationDataStorage {
  97670. closePath?: boolean;
  97671. closeArray?: boolean;
  97672. idx: number[];
  97673. dashSize: number;
  97674. gapSize: number;
  97675. path3D: Path3D;
  97676. pathArray: Vector3[][];
  97677. arc: number;
  97678. radius: number;
  97679. cap: number;
  97680. tessellation: number;
  97681. }
  97682. /**
  97683. * @hidden
  97684. **/
  97685. class _InstanceDataStorage {
  97686. visibleInstances: any;
  97687. batchCache: _InstancesBatch;
  97688. instancesBufferSize: number;
  97689. instancesBuffer: Nullable<Buffer>;
  97690. instancesData: Float32Array;
  97691. overridenInstanceCount: number;
  97692. isFrozen: boolean;
  97693. previousBatch: Nullable<_InstancesBatch>;
  97694. hardwareInstancedRendering: boolean;
  97695. sideOrientation: number;
  97696. manualUpdate: boolean;
  97697. }
  97698. /**
  97699. * @hidden
  97700. **/
  97701. export class _InstancesBatch {
  97702. mustReturn: boolean;
  97703. visibleInstances: Nullable<InstancedMesh[]>[];
  97704. renderSelf: boolean[];
  97705. hardwareInstancedRendering: boolean[];
  97706. }
  97707. /**
  97708. * Class used to represent renderable models
  97709. */
  97710. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97711. /**
  97712. * Mesh side orientation : usually the external or front surface
  97713. */
  97714. static readonly FRONTSIDE: number;
  97715. /**
  97716. * Mesh side orientation : usually the internal or back surface
  97717. */
  97718. static readonly BACKSIDE: number;
  97719. /**
  97720. * Mesh side orientation : both internal and external or front and back surfaces
  97721. */
  97722. static readonly DOUBLESIDE: number;
  97723. /**
  97724. * Mesh side orientation : by default, `FRONTSIDE`
  97725. */
  97726. static readonly DEFAULTSIDE: number;
  97727. /**
  97728. * Mesh cap setting : no cap
  97729. */
  97730. static readonly NO_CAP: number;
  97731. /**
  97732. * Mesh cap setting : one cap at the beginning of the mesh
  97733. */
  97734. static readonly CAP_START: number;
  97735. /**
  97736. * Mesh cap setting : one cap at the end of the mesh
  97737. */
  97738. static readonly CAP_END: number;
  97739. /**
  97740. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97741. */
  97742. static readonly CAP_ALL: number;
  97743. /**
  97744. * Mesh pattern setting : no flip or rotate
  97745. */
  97746. static readonly NO_FLIP: number;
  97747. /**
  97748. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97749. */
  97750. static readonly FLIP_TILE: number;
  97751. /**
  97752. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97753. */
  97754. static readonly ROTATE_TILE: number;
  97755. /**
  97756. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97757. */
  97758. static readonly FLIP_ROW: number;
  97759. /**
  97760. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97761. */
  97762. static readonly ROTATE_ROW: number;
  97763. /**
  97764. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97765. */
  97766. static readonly FLIP_N_ROTATE_TILE: number;
  97767. /**
  97768. * Mesh pattern setting : rotate pattern and rotate
  97769. */
  97770. static readonly FLIP_N_ROTATE_ROW: number;
  97771. /**
  97772. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97773. */
  97774. static readonly CENTER: number;
  97775. /**
  97776. * Mesh tile positioning : part tiles on left
  97777. */
  97778. static readonly LEFT: number;
  97779. /**
  97780. * Mesh tile positioning : part tiles on right
  97781. */
  97782. static readonly RIGHT: number;
  97783. /**
  97784. * Mesh tile positioning : part tiles on top
  97785. */
  97786. static readonly TOP: number;
  97787. /**
  97788. * Mesh tile positioning : part tiles on bottom
  97789. */
  97790. static readonly BOTTOM: number;
  97791. /**
  97792. * Gets the default side orientation.
  97793. * @param orientation the orientation to value to attempt to get
  97794. * @returns the default orientation
  97795. * @hidden
  97796. */
  97797. static _GetDefaultSideOrientation(orientation?: number): number;
  97798. private _internalMeshDataInfo;
  97799. /**
  97800. * An event triggered before rendering the mesh
  97801. */
  97802. get onBeforeRenderObservable(): Observable<Mesh>;
  97803. /**
  97804. * An event triggered before binding the mesh
  97805. */
  97806. get onBeforeBindObservable(): Observable<Mesh>;
  97807. /**
  97808. * An event triggered after rendering the mesh
  97809. */
  97810. get onAfterRenderObservable(): Observable<Mesh>;
  97811. /**
  97812. * An event triggered before drawing the mesh
  97813. */
  97814. get onBeforeDrawObservable(): Observable<Mesh>;
  97815. private _onBeforeDrawObserver;
  97816. /**
  97817. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97818. */
  97819. set onBeforeDraw(callback: () => void);
  97820. get hasInstances(): boolean;
  97821. /**
  97822. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97823. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97824. */
  97825. delayLoadState: number;
  97826. /**
  97827. * Gets the list of instances created from this mesh
  97828. * it is not supposed to be modified manually.
  97829. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97830. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97831. */
  97832. instances: InstancedMesh[];
  97833. /**
  97834. * Gets the file containing delay loading data for this mesh
  97835. */
  97836. delayLoadingFile: string;
  97837. /** @hidden */
  97838. _binaryInfo: any;
  97839. /**
  97840. * User defined function used to change how LOD level selection is done
  97841. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97842. */
  97843. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97844. /**
  97845. * Gets or sets the morph target manager
  97846. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97847. */
  97848. get morphTargetManager(): Nullable<MorphTargetManager>;
  97849. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97850. /** @hidden */
  97851. _creationDataStorage: Nullable<_CreationDataStorage>;
  97852. /** @hidden */
  97853. _geometry: Nullable<Geometry>;
  97854. /** @hidden */
  97855. _delayInfo: Array<string>;
  97856. /** @hidden */
  97857. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97858. /** @hidden */
  97859. _instanceDataStorage: _InstanceDataStorage;
  97860. private _effectiveMaterial;
  97861. /** @hidden */
  97862. _shouldGenerateFlatShading: boolean;
  97863. /** @hidden */
  97864. _originalBuilderSideOrientation: number;
  97865. /**
  97866. * Use this property to change the original side orientation defined at construction time
  97867. */
  97868. overrideMaterialSideOrientation: Nullable<number>;
  97869. /**
  97870. * Gets the source mesh (the one used to clone this one from)
  97871. */
  97872. get source(): Nullable<Mesh>;
  97873. /**
  97874. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97875. */
  97876. get isUnIndexed(): boolean;
  97877. set isUnIndexed(value: boolean);
  97878. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97879. get worldMatrixInstancedBuffer(): Float32Array;
  97880. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97881. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97882. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97883. /**
  97884. * @constructor
  97885. * @param name The value used by scene.getMeshByName() to do a lookup.
  97886. * @param scene The scene to add this mesh to.
  97887. * @param parent The parent of this mesh, if it has one
  97888. * @param source An optional Mesh from which geometry is shared, cloned.
  97889. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97890. * When false, achieved by calling a clone(), also passing False.
  97891. * This will make creation of children, recursive.
  97892. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97893. */
  97894. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97895. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97896. doNotInstantiate: boolean;
  97897. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97898. /**
  97899. * Gets the class name
  97900. * @returns the string "Mesh".
  97901. */
  97902. getClassName(): string;
  97903. /** @hidden */
  97904. get _isMesh(): boolean;
  97905. /**
  97906. * Returns a description of this mesh
  97907. * @param fullDetails define if full details about this mesh must be used
  97908. * @returns a descriptive string representing this mesh
  97909. */
  97910. toString(fullDetails?: boolean): string;
  97911. /** @hidden */
  97912. _unBindEffect(): void;
  97913. /**
  97914. * Gets a boolean indicating if this mesh has LOD
  97915. */
  97916. get hasLODLevels(): boolean;
  97917. /**
  97918. * Gets the list of MeshLODLevel associated with the current mesh
  97919. * @returns an array of MeshLODLevel
  97920. */
  97921. getLODLevels(): MeshLODLevel[];
  97922. private _sortLODLevels;
  97923. /**
  97924. * Add a mesh as LOD level triggered at the given distance.
  97925. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97926. * @param distance The distance from the center of the object to show this level
  97927. * @param mesh The mesh to be added as LOD level (can be null)
  97928. * @return This mesh (for chaining)
  97929. */
  97930. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97931. /**
  97932. * Returns the LOD level mesh at the passed distance or null if not found.
  97933. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97934. * @param distance The distance from the center of the object to show this level
  97935. * @returns a Mesh or `null`
  97936. */
  97937. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97938. /**
  97939. * Remove a mesh from the LOD array
  97940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97941. * @param mesh defines the mesh to be removed
  97942. * @return This mesh (for chaining)
  97943. */
  97944. removeLODLevel(mesh: Mesh): Mesh;
  97945. /**
  97946. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97948. * @param camera defines the camera to use to compute distance
  97949. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97950. * @return This mesh (for chaining)
  97951. */
  97952. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97953. /**
  97954. * Gets the mesh internal Geometry object
  97955. */
  97956. get geometry(): Nullable<Geometry>;
  97957. /**
  97958. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97959. * @returns the total number of vertices
  97960. */
  97961. getTotalVertices(): number;
  97962. /**
  97963. * Returns the content of an associated vertex buffer
  97964. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97965. * - VertexBuffer.PositionKind
  97966. * - VertexBuffer.UVKind
  97967. * - VertexBuffer.UV2Kind
  97968. * - VertexBuffer.UV3Kind
  97969. * - VertexBuffer.UV4Kind
  97970. * - VertexBuffer.UV5Kind
  97971. * - VertexBuffer.UV6Kind
  97972. * - VertexBuffer.ColorKind
  97973. * - VertexBuffer.MatricesIndicesKind
  97974. * - VertexBuffer.MatricesIndicesExtraKind
  97975. * - VertexBuffer.MatricesWeightsKind
  97976. * - VertexBuffer.MatricesWeightsExtraKind
  97977. * @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
  97978. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97979. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97980. */
  97981. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97982. /**
  97983. * Returns the mesh VertexBuffer object from the requested `kind`
  97984. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97985. * - VertexBuffer.PositionKind
  97986. * - VertexBuffer.NormalKind
  97987. * - VertexBuffer.UVKind
  97988. * - VertexBuffer.UV2Kind
  97989. * - VertexBuffer.UV3Kind
  97990. * - VertexBuffer.UV4Kind
  97991. * - VertexBuffer.UV5Kind
  97992. * - VertexBuffer.UV6Kind
  97993. * - VertexBuffer.ColorKind
  97994. * - VertexBuffer.MatricesIndicesKind
  97995. * - VertexBuffer.MatricesIndicesExtraKind
  97996. * - VertexBuffer.MatricesWeightsKind
  97997. * - VertexBuffer.MatricesWeightsExtraKind
  97998. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97999. */
  98000. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98001. /**
  98002. * Tests if a specific vertex buffer is associated with this mesh
  98003. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98004. * - VertexBuffer.PositionKind
  98005. * - VertexBuffer.NormalKind
  98006. * - VertexBuffer.UVKind
  98007. * - VertexBuffer.UV2Kind
  98008. * - VertexBuffer.UV3Kind
  98009. * - VertexBuffer.UV4Kind
  98010. * - VertexBuffer.UV5Kind
  98011. * - VertexBuffer.UV6Kind
  98012. * - VertexBuffer.ColorKind
  98013. * - VertexBuffer.MatricesIndicesKind
  98014. * - VertexBuffer.MatricesIndicesExtraKind
  98015. * - VertexBuffer.MatricesWeightsKind
  98016. * - VertexBuffer.MatricesWeightsExtraKind
  98017. * @returns a boolean
  98018. */
  98019. isVerticesDataPresent(kind: string): boolean;
  98020. /**
  98021. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  98022. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98023. * - VertexBuffer.PositionKind
  98024. * - VertexBuffer.UVKind
  98025. * - VertexBuffer.UV2Kind
  98026. * - VertexBuffer.UV3Kind
  98027. * - VertexBuffer.UV4Kind
  98028. * - VertexBuffer.UV5Kind
  98029. * - VertexBuffer.UV6Kind
  98030. * - VertexBuffer.ColorKind
  98031. * - VertexBuffer.MatricesIndicesKind
  98032. * - VertexBuffer.MatricesIndicesExtraKind
  98033. * - VertexBuffer.MatricesWeightsKind
  98034. * - VertexBuffer.MatricesWeightsExtraKind
  98035. * @returns a boolean
  98036. */
  98037. isVertexBufferUpdatable(kind: string): boolean;
  98038. /**
  98039. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  98040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98041. * - VertexBuffer.PositionKind
  98042. * - VertexBuffer.NormalKind
  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. * @returns an array of strings
  98055. */
  98056. getVerticesDataKinds(): string[];
  98057. /**
  98058. * Returns a positive integer : the total number of indices in this mesh geometry.
  98059. * @returns the numner of indices or zero if the mesh has no geometry.
  98060. */
  98061. getTotalIndices(): number;
  98062. /**
  98063. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98064. * @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.
  98065. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98066. * @returns the indices array or an empty array if the mesh has no geometry
  98067. */
  98068. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98069. get isBlocked(): boolean;
  98070. /**
  98071. * Determine if the current mesh is ready to be rendered
  98072. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98073. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98074. * @returns true if all associated assets are ready (material, textures, shaders)
  98075. */
  98076. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98077. /**
  98078. * 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.
  98079. */
  98080. get areNormalsFrozen(): boolean;
  98081. /**
  98082. * 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.
  98083. * @returns the current mesh
  98084. */
  98085. freezeNormals(): Mesh;
  98086. /**
  98087. * 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
  98088. * @returns the current mesh
  98089. */
  98090. unfreezeNormals(): Mesh;
  98091. /**
  98092. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98093. */
  98094. set overridenInstanceCount(count: number);
  98095. /** @hidden */
  98096. _preActivate(): Mesh;
  98097. /** @hidden */
  98098. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98099. /** @hidden */
  98100. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98101. /**
  98102. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98103. * This means the mesh underlying bounding box and sphere are recomputed.
  98104. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98105. * @returns the current mesh
  98106. */
  98107. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98108. /** @hidden */
  98109. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98110. /**
  98111. * This function will subdivide the mesh into multiple submeshes
  98112. * @param count defines the expected number of submeshes
  98113. */
  98114. subdivide(count: number): void;
  98115. /**
  98116. * Copy a FloatArray into a specific associated vertex buffer
  98117. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98118. * - VertexBuffer.PositionKind
  98119. * - VertexBuffer.UVKind
  98120. * - VertexBuffer.UV2Kind
  98121. * - VertexBuffer.UV3Kind
  98122. * - VertexBuffer.UV4Kind
  98123. * - VertexBuffer.UV5Kind
  98124. * - VertexBuffer.UV6Kind
  98125. * - VertexBuffer.ColorKind
  98126. * - VertexBuffer.MatricesIndicesKind
  98127. * - VertexBuffer.MatricesIndicesExtraKind
  98128. * - VertexBuffer.MatricesWeightsKind
  98129. * - VertexBuffer.MatricesWeightsExtraKind
  98130. * @param data defines the data source
  98131. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98132. * @param stride defines the data stride size (can be null)
  98133. * @returns the current mesh
  98134. */
  98135. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98136. /**
  98137. * Delete a vertex buffer associated with this mesh
  98138. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98139. * - VertexBuffer.PositionKind
  98140. * - VertexBuffer.UVKind
  98141. * - VertexBuffer.UV2Kind
  98142. * - VertexBuffer.UV3Kind
  98143. * - VertexBuffer.UV4Kind
  98144. * - VertexBuffer.UV5Kind
  98145. * - VertexBuffer.UV6Kind
  98146. * - VertexBuffer.ColorKind
  98147. * - VertexBuffer.MatricesIndicesKind
  98148. * - VertexBuffer.MatricesIndicesExtraKind
  98149. * - VertexBuffer.MatricesWeightsKind
  98150. * - VertexBuffer.MatricesWeightsExtraKind
  98151. */
  98152. removeVerticesData(kind: string): void;
  98153. /**
  98154. * Flags an associated vertex buffer as updatable
  98155. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98156. * - VertexBuffer.PositionKind
  98157. * - VertexBuffer.UVKind
  98158. * - VertexBuffer.UV2Kind
  98159. * - VertexBuffer.UV3Kind
  98160. * - VertexBuffer.UV4Kind
  98161. * - VertexBuffer.UV5Kind
  98162. * - VertexBuffer.UV6Kind
  98163. * - VertexBuffer.ColorKind
  98164. * - VertexBuffer.MatricesIndicesKind
  98165. * - VertexBuffer.MatricesIndicesExtraKind
  98166. * - VertexBuffer.MatricesWeightsKind
  98167. * - VertexBuffer.MatricesWeightsExtraKind
  98168. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98169. */
  98170. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98171. /**
  98172. * Sets the mesh global Vertex Buffer
  98173. * @param buffer defines the buffer to use
  98174. * @returns the current mesh
  98175. */
  98176. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98177. /**
  98178. * Update a specific associated vertex buffer
  98179. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98180. * - VertexBuffer.PositionKind
  98181. * - VertexBuffer.UVKind
  98182. * - VertexBuffer.UV2Kind
  98183. * - VertexBuffer.UV3Kind
  98184. * - VertexBuffer.UV4Kind
  98185. * - VertexBuffer.UV5Kind
  98186. * - VertexBuffer.UV6Kind
  98187. * - VertexBuffer.ColorKind
  98188. * - VertexBuffer.MatricesIndicesKind
  98189. * - VertexBuffer.MatricesIndicesExtraKind
  98190. * - VertexBuffer.MatricesWeightsKind
  98191. * - VertexBuffer.MatricesWeightsExtraKind
  98192. * @param data defines the data source
  98193. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98194. * @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)
  98195. * @returns the current mesh
  98196. */
  98197. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98198. /**
  98199. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98200. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98201. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98202. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98203. * @returns the current mesh
  98204. */
  98205. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98206. /**
  98207. * Creates a un-shared specific occurence of the geometry for the mesh.
  98208. * @returns the current mesh
  98209. */
  98210. makeGeometryUnique(): Mesh;
  98211. /**
  98212. * Set the index buffer of this mesh
  98213. * @param indices defines the source data
  98214. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98215. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98216. * @returns the current mesh
  98217. */
  98218. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98219. /**
  98220. * Update the current index buffer
  98221. * @param indices defines the source data
  98222. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98223. * @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)
  98224. * @returns the current mesh
  98225. */
  98226. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98227. /**
  98228. * Invert the geometry to move from a right handed system to a left handed one.
  98229. * @returns the current mesh
  98230. */
  98231. toLeftHanded(): Mesh;
  98232. /** @hidden */
  98233. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98234. /** @hidden */
  98235. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98236. /**
  98237. * Registers for this mesh a javascript function called just before the rendering process
  98238. * @param func defines the function to call before rendering this mesh
  98239. * @returns the current mesh
  98240. */
  98241. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98242. /**
  98243. * Disposes a previously registered javascript function called before the rendering
  98244. * @param func defines the function to remove
  98245. * @returns the current mesh
  98246. */
  98247. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98248. /**
  98249. * Registers for this mesh a javascript function called just after the rendering is complete
  98250. * @param func defines the function to call after rendering this mesh
  98251. * @returns the current mesh
  98252. */
  98253. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98254. /**
  98255. * Disposes a previously registered javascript function called after the rendering.
  98256. * @param func defines the function to remove
  98257. * @returns the current mesh
  98258. */
  98259. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98260. /** @hidden */
  98261. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98262. /** @hidden */
  98263. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98264. /** @hidden */
  98265. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98266. /** @hidden */
  98267. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98268. /** @hidden */
  98269. _rebuild(): void;
  98270. /** @hidden */
  98271. _freeze(): void;
  98272. /** @hidden */
  98273. _unFreeze(): void;
  98274. /**
  98275. * 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
  98276. * @param subMesh defines the subMesh to render
  98277. * @param enableAlphaMode defines if alpha mode can be changed
  98278. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98279. * @returns the current mesh
  98280. */
  98281. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98282. private _onBeforeDraw;
  98283. /**
  98284. * Renormalize the mesh and patch it up if there are no weights
  98285. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98286. * However in the case of zero weights then we set just a single influence to 1.
  98287. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98288. */
  98289. cleanMatrixWeights(): void;
  98290. private normalizeSkinFourWeights;
  98291. private normalizeSkinWeightsAndExtra;
  98292. /**
  98293. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98294. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98295. * the user know there was an issue with importing the mesh
  98296. * @returns a validation object with skinned, valid and report string
  98297. */
  98298. validateSkinning(): {
  98299. skinned: boolean;
  98300. valid: boolean;
  98301. report: string;
  98302. };
  98303. /** @hidden */
  98304. _checkDelayState(): Mesh;
  98305. private _queueLoad;
  98306. /**
  98307. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98308. * A mesh is in the frustum if its bounding box intersects the frustum
  98309. * @param frustumPlanes defines the frustum to test
  98310. * @returns true if the mesh is in the frustum planes
  98311. */
  98312. isInFrustum(frustumPlanes: Plane[]): boolean;
  98313. /**
  98314. * Sets the mesh material by the material or multiMaterial `id` property
  98315. * @param id is a string identifying the material or the multiMaterial
  98316. * @returns the current mesh
  98317. */
  98318. setMaterialByID(id: string): Mesh;
  98319. /**
  98320. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98321. * @returns an array of IAnimatable
  98322. */
  98323. getAnimatables(): IAnimatable[];
  98324. /**
  98325. * Modifies the mesh geometry according to the passed transformation matrix.
  98326. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98327. * The mesh normals are modified using the same transformation.
  98328. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98329. * @param transform defines the transform matrix to use
  98330. * @see http://doc.babylonjs.com/resources/baking_transformations
  98331. * @returns the current mesh
  98332. */
  98333. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98334. /**
  98335. * Modifies the mesh geometry according to its own current World Matrix.
  98336. * The mesh World Matrix is then reset.
  98337. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98338. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98339. * @see http://doc.babylonjs.com/resources/baking_transformations
  98340. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98341. * @returns the current mesh
  98342. */
  98343. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98344. /** @hidden */
  98345. get _positions(): Nullable<Vector3[]>;
  98346. /** @hidden */
  98347. _resetPointsArrayCache(): Mesh;
  98348. /** @hidden */
  98349. _generatePointsArray(): boolean;
  98350. /**
  98351. * Returns a new Mesh object generated from the current mesh properties.
  98352. * This method must not get confused with createInstance()
  98353. * @param name is a string, the name given to the new mesh
  98354. * @param newParent can be any Node object (default `null`)
  98355. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98356. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98357. * @returns a new mesh
  98358. */
  98359. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98360. /**
  98361. * Releases resources associated with this mesh.
  98362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98364. */
  98365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98366. /** @hidden */
  98367. _disposeInstanceSpecificData(): void;
  98368. /**
  98369. * Modifies the mesh geometry according to a displacement map.
  98370. * 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.
  98371. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98372. * @param url is a string, the URL from the image file is to be downloaded.
  98373. * @param minHeight is the lower limit of the displacement.
  98374. * @param maxHeight is the upper limit of the displacement.
  98375. * @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.
  98376. * @param uvOffset is an optional vector2 used to offset UV.
  98377. * @param uvScale is an optional vector2 used to scale UV.
  98378. * @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.
  98379. * @returns the Mesh.
  98380. */
  98381. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98382. /**
  98383. * Modifies the mesh geometry according to a displacementMap buffer.
  98384. * 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.
  98385. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98386. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98387. * @param heightMapWidth is the width of the buffer image.
  98388. * @param heightMapHeight is the height of the buffer image.
  98389. * @param minHeight is the lower limit of the displacement.
  98390. * @param maxHeight is the upper limit of the displacement.
  98391. * @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.
  98392. * @param uvOffset is an optional vector2 used to offset UV.
  98393. * @param uvScale is an optional vector2 used to scale UV.
  98394. * @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.
  98395. * @returns the Mesh.
  98396. */
  98397. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98398. /**
  98399. * Modify the mesh to get a flat shading rendering.
  98400. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98401. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98402. * @returns current mesh
  98403. */
  98404. convertToFlatShadedMesh(): Mesh;
  98405. /**
  98406. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98407. * In other words, more vertices, no more indices and a single bigger VBO.
  98408. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98409. * @returns current mesh
  98410. */
  98411. convertToUnIndexedMesh(): Mesh;
  98412. /**
  98413. * Inverses facet orientations.
  98414. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98415. * @param flipNormals will also inverts the normals
  98416. * @returns current mesh
  98417. */
  98418. flipFaces(flipNormals?: boolean): Mesh;
  98419. /**
  98420. * Increase the number of facets and hence vertices in a mesh
  98421. * Vertex normals are interpolated from existing vertex normals
  98422. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98423. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98424. */
  98425. increaseVertices(numberPerEdge: number): void;
  98426. /**
  98427. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98428. * This will undo any application of covertToFlatShadedMesh
  98429. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98430. */
  98431. forceSharedVertices(): void;
  98432. /** @hidden */
  98433. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98434. /** @hidden */
  98435. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98436. /**
  98437. * Creates a new InstancedMesh object from the mesh model.
  98438. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98439. * @param name defines the name of the new instance
  98440. * @returns a new InstancedMesh
  98441. */
  98442. createInstance(name: string): InstancedMesh;
  98443. /**
  98444. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98445. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98446. * @returns the current mesh
  98447. */
  98448. synchronizeInstances(): Mesh;
  98449. /**
  98450. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98451. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98452. * This should be used together with the simplification to avoid disappearing triangles.
  98453. * @param successCallback an optional success callback to be called after the optimization finished.
  98454. * @returns the current mesh
  98455. */
  98456. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98457. /**
  98458. * Serialize current mesh
  98459. * @param serializationObject defines the object which will receive the serialization data
  98460. */
  98461. serialize(serializationObject: any): void;
  98462. /** @hidden */
  98463. _syncGeometryWithMorphTargetManager(): void;
  98464. /** @hidden */
  98465. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98466. /**
  98467. * Returns a new Mesh object parsed from the source provided.
  98468. * @param parsedMesh is the source
  98469. * @param scene defines the hosting scene
  98470. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98471. * @returns a new Mesh
  98472. */
  98473. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98474. /**
  98475. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98476. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98477. * @param name defines the name of the mesh to create
  98478. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98479. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98480. * @param closePath creates a seam between the first and the last points of each path of the path array
  98481. * @param offset is taken in account only if the `pathArray` is containing a single path
  98482. * @param scene defines the hosting scene
  98483. * @param updatable defines if the mesh must be flagged as updatable
  98484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98485. * @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)
  98486. * @returns a new Mesh
  98487. */
  98488. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98489. /**
  98490. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98491. * @param name defines the name of the mesh to create
  98492. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98493. * @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
  98494. * @param scene defines the hosting scene
  98495. * @param updatable defines if the mesh must be flagged as updatable
  98496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98497. * @returns a new Mesh
  98498. */
  98499. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98500. /**
  98501. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98502. * @param name defines the name of the mesh to create
  98503. * @param size sets the size (float) of each box side (default 1)
  98504. * @param scene defines the hosting scene
  98505. * @param updatable defines if the mesh must be flagged as updatable
  98506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98507. * @returns a new Mesh
  98508. */
  98509. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98510. /**
  98511. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98512. * @param name defines the name of the mesh to create
  98513. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98514. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98515. * @param scene defines the hosting scene
  98516. * @param updatable defines if the mesh must be flagged as updatable
  98517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98518. * @returns a new Mesh
  98519. */
  98520. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98521. /**
  98522. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98523. * @param name defines the name of the mesh to create
  98524. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98525. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98526. * @param scene defines the hosting scene
  98527. * @returns a new Mesh
  98528. */
  98529. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98530. /**
  98531. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98532. * @param name defines the name of the mesh to create
  98533. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98534. * @param diameterTop set the top cap diameter (floats, default 1)
  98535. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98536. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98537. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98538. * @param scene defines the hosting scene
  98539. * @param updatable defines if the mesh must be flagged as updatable
  98540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98541. * @returns a new Mesh
  98542. */
  98543. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98544. /**
  98545. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98546. * @param name defines the name of the mesh to create
  98547. * @param diameter sets the diameter size (float) of the torus (default 1)
  98548. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98549. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98550. * @param scene defines the hosting scene
  98551. * @param updatable defines if the mesh must be flagged as updatable
  98552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98553. * @returns a new Mesh
  98554. */
  98555. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98556. /**
  98557. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98558. * @param name defines the name of the mesh to create
  98559. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98560. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98561. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98562. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98563. * @param p the number of windings on X axis (positive integers, default 2)
  98564. * @param q the number of windings on Y axis (positive integers, default 3)
  98565. * @param scene defines the hosting scene
  98566. * @param updatable defines if the mesh must be flagged as updatable
  98567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98568. * @returns a new Mesh
  98569. */
  98570. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98571. /**
  98572. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98573. * @param name defines the name of the mesh to create
  98574. * @param points is an array successive Vector3
  98575. * @param scene defines the hosting scene
  98576. * @param updatable defines if the mesh must be flagged as updatable
  98577. * @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).
  98578. * @returns a new Mesh
  98579. */
  98580. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98581. /**
  98582. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98583. * @param name defines the name of the mesh to create
  98584. * @param points is an array successive Vector3
  98585. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98586. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98587. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98588. * @param scene defines the hosting scene
  98589. * @param updatable defines if the mesh must be flagged as updatable
  98590. * @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)
  98591. * @returns a new Mesh
  98592. */
  98593. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98594. /**
  98595. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98596. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98597. * 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.
  98598. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98599. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98600. * Remember you can only change the shape positions, not their number when updating a polygon.
  98601. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98602. * @param name defines the name of the mesh to create
  98603. * @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
  98604. * @param scene defines the hosting scene
  98605. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98606. * @param updatable defines if the mesh must be flagged as updatable
  98607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98608. * @param earcutInjection can be used to inject your own earcut reference
  98609. * @returns a new Mesh
  98610. */
  98611. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98612. /**
  98613. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98614. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98615. * @param name defines the name of the mesh to create
  98616. * @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
  98617. * @param depth defines the height of extrusion
  98618. * @param scene defines the hosting scene
  98619. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98620. * @param updatable defines if the mesh must be flagged as updatable
  98621. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98622. * @param earcutInjection can be used to inject your own earcut reference
  98623. * @returns a new Mesh
  98624. */
  98625. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98626. /**
  98627. * Creates an extruded shape mesh.
  98628. * 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
  98629. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98630. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98631. * @param name defines the name of the mesh to create
  98632. * @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
  98633. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98634. * @param scale is the value to scale the shape
  98635. * @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
  98636. * @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
  98637. * @param scene defines the hosting scene
  98638. * @param updatable defines if the mesh must be flagged as updatable
  98639. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98640. * @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)
  98641. * @returns a new Mesh
  98642. */
  98643. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98644. /**
  98645. * Creates an custom extruded shape mesh.
  98646. * The custom extrusion is a parametric shape.
  98647. * It has no predefined shape. Its final shape will depend on the input parameters.
  98648. * Please consider using the same method from the MeshBuilder class instead
  98649. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98650. * @param name defines the name of the mesh to create
  98651. * @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
  98652. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98653. * @param scaleFunction is a custom Javascript function called on each path point
  98654. * @param rotationFunction is a custom Javascript function called on each path point
  98655. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98656. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98657. * @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
  98658. * @param scene defines the hosting scene
  98659. * @param updatable defines if the mesh must be flagged as updatable
  98660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98661. * @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)
  98662. * @returns a new Mesh
  98663. */
  98664. 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;
  98665. /**
  98666. * Creates lathe mesh.
  98667. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98668. * Please consider using the same method from the MeshBuilder class instead
  98669. * @param name defines the name of the mesh to create
  98670. * @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
  98671. * @param radius is the radius value of the lathe
  98672. * @param tessellation is the side number of the lathe.
  98673. * @param scene defines the hosting scene
  98674. * @param updatable defines if the mesh must be flagged as updatable
  98675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98676. * @returns a new Mesh
  98677. */
  98678. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98679. /**
  98680. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98681. * @param name defines the name of the mesh to create
  98682. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98683. * @param scene defines the hosting scene
  98684. * @param updatable defines if the mesh must be flagged as updatable
  98685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98686. * @returns a new Mesh
  98687. */
  98688. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98689. /**
  98690. * Creates a ground mesh.
  98691. * Please consider using the same method from the MeshBuilder class instead
  98692. * @param name defines the name of the mesh to create
  98693. * @param width set the width of the ground
  98694. * @param height set the height of the ground
  98695. * @param subdivisions sets the number of subdivisions per side
  98696. * @param scene defines the hosting scene
  98697. * @param updatable defines if the mesh must be flagged as updatable
  98698. * @returns a new Mesh
  98699. */
  98700. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98701. /**
  98702. * Creates a tiled ground mesh.
  98703. * Please consider using the same method from the MeshBuilder class instead
  98704. * @param name defines the name of the mesh to create
  98705. * @param xmin set the ground minimum X coordinate
  98706. * @param zmin set the ground minimum Y coordinate
  98707. * @param xmax set the ground maximum X coordinate
  98708. * @param zmax set the ground maximum Z coordinate
  98709. * @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
  98710. * @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
  98711. * @param scene defines the hosting scene
  98712. * @param updatable defines if the mesh must be flagged as updatable
  98713. * @returns a new Mesh
  98714. */
  98715. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98716. w: number;
  98717. h: number;
  98718. }, precision: {
  98719. w: number;
  98720. h: number;
  98721. }, scene: Scene, updatable?: boolean): Mesh;
  98722. /**
  98723. * Creates a ground mesh from a height map.
  98724. * Please consider using the same method from the MeshBuilder class instead
  98725. * @see http://doc.babylonjs.com/babylon101/height_map
  98726. * @param name defines the name of the mesh to create
  98727. * @param url sets the URL of the height map image resource
  98728. * @param width set the ground width size
  98729. * @param height set the ground height size
  98730. * @param subdivisions sets the number of subdivision per side
  98731. * @param minHeight is the minimum altitude on the ground
  98732. * @param maxHeight is the maximum altitude on the ground
  98733. * @param scene defines the hosting scene
  98734. * @param updatable defines if the mesh must be flagged as updatable
  98735. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98736. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98737. * @returns a new Mesh
  98738. */
  98739. 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;
  98740. /**
  98741. * Creates a tube mesh.
  98742. * The tube is a parametric shape.
  98743. * It has no predefined shape. Its final shape will depend on the input parameters.
  98744. * Please consider using the same method from the MeshBuilder class instead
  98745. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98746. * @param name defines the name of the mesh to create
  98747. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98748. * @param radius sets the tube radius size
  98749. * @param tessellation is the number of sides on the tubular surface
  98750. * @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
  98751. * @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
  98752. * @param scene defines the hosting scene
  98753. * @param updatable defines if the mesh must be flagged as updatable
  98754. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98755. * @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)
  98756. * @returns a new Mesh
  98757. */
  98758. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98759. (i: number, distance: number): number;
  98760. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98761. /**
  98762. * Creates a polyhedron mesh.
  98763. * Please consider using the same method from the MeshBuilder class instead.
  98764. * * 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
  98765. * * The parameter `size` (positive float, default 1) sets the polygon size
  98766. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98767. * * 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`
  98768. * * 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
  98769. * * 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)`)
  98770. * * 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
  98771. * * 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
  98772. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98773. * * If you create a double-sided mesh, you can choose what parts of 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
  98774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98775. * @param name defines the name of the mesh to create
  98776. * @param options defines the options used to create the mesh
  98777. * @param scene defines the hosting scene
  98778. * @returns a new Mesh
  98779. */
  98780. static CreatePolyhedron(name: string, options: {
  98781. type?: number;
  98782. size?: number;
  98783. sizeX?: number;
  98784. sizeY?: number;
  98785. sizeZ?: number;
  98786. custom?: any;
  98787. faceUV?: Vector4[];
  98788. faceColors?: Color4[];
  98789. updatable?: boolean;
  98790. sideOrientation?: number;
  98791. }, scene: Scene): Mesh;
  98792. /**
  98793. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98794. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98795. * * 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`)
  98796. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98797. * * 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
  98798. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98799. * * If you create a double-sided mesh, you can choose what parts of 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
  98800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98801. * @param name defines the name of the mesh
  98802. * @param options defines the options used to create the mesh
  98803. * @param scene defines the hosting scene
  98804. * @returns a new Mesh
  98805. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98806. */
  98807. static CreateIcoSphere(name: string, options: {
  98808. radius?: number;
  98809. flat?: boolean;
  98810. subdivisions?: number;
  98811. sideOrientation?: number;
  98812. updatable?: boolean;
  98813. }, scene: Scene): Mesh;
  98814. /**
  98815. * Creates a decal mesh.
  98816. * Please consider using the same method from the MeshBuilder class instead.
  98817. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98818. * @param name defines the name of the mesh
  98819. * @param sourceMesh defines the mesh receiving the decal
  98820. * @param position sets the position of the decal in world coordinates
  98821. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98822. * @param size sets the decal scaling
  98823. * @param angle sets the angle to rotate the decal
  98824. * @returns a new Mesh
  98825. */
  98826. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98827. /**
  98828. * Prepare internal position array for software CPU skinning
  98829. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98830. */
  98831. setPositionsForCPUSkinning(): Float32Array;
  98832. /**
  98833. * Prepare internal normal array for software CPU skinning
  98834. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98835. */
  98836. setNormalsForCPUSkinning(): Float32Array;
  98837. /**
  98838. * Updates the vertex buffer by applying transformation from the bones
  98839. * @param skeleton defines the skeleton to apply to current mesh
  98840. * @returns the current mesh
  98841. */
  98842. applySkeleton(skeleton: Skeleton): Mesh;
  98843. /**
  98844. * 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
  98845. * @param meshes defines the list of meshes to scan
  98846. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98847. */
  98848. static MinMax(meshes: AbstractMesh[]): {
  98849. min: Vector3;
  98850. max: Vector3;
  98851. };
  98852. /**
  98853. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98854. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98855. * @returns a vector3
  98856. */
  98857. static Center(meshesOrMinMaxVector: {
  98858. min: Vector3;
  98859. max: Vector3;
  98860. } | AbstractMesh[]): Vector3;
  98861. /**
  98862. * Merge the array of meshes into a single mesh for performance reasons.
  98863. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98864. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98865. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98866. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98867. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98868. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98869. * @returns a new mesh
  98870. */
  98871. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98872. /** @hidden */
  98873. addInstance(instance: InstancedMesh): void;
  98874. /** @hidden */
  98875. removeInstance(instance: InstancedMesh): void;
  98876. }
  98877. }
  98878. declare module BABYLON {
  98879. /**
  98880. * This is the base class of all the camera used in the application.
  98881. * @see http://doc.babylonjs.com/features/cameras
  98882. */
  98883. export class Camera extends Node {
  98884. /** @hidden */
  98885. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98886. /**
  98887. * This is the default projection mode used by the cameras.
  98888. * It helps recreating a feeling of perspective and better appreciate depth.
  98889. * This is the best way to simulate real life cameras.
  98890. */
  98891. static readonly PERSPECTIVE_CAMERA: number;
  98892. /**
  98893. * This helps creating camera with an orthographic mode.
  98894. * 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.
  98895. */
  98896. static readonly ORTHOGRAPHIC_CAMERA: number;
  98897. /**
  98898. * This is the default FOV mode for perspective cameras.
  98899. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98900. */
  98901. static readonly FOVMODE_VERTICAL_FIXED: number;
  98902. /**
  98903. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98904. */
  98905. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98906. /**
  98907. * This specifies ther is no need for a camera rig.
  98908. * Basically only one eye is rendered corresponding to the camera.
  98909. */
  98910. static readonly RIG_MODE_NONE: number;
  98911. /**
  98912. * Simulates a camera Rig with one blue eye and one red eye.
  98913. * This can be use with 3d blue and red glasses.
  98914. */
  98915. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98916. /**
  98917. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98918. */
  98919. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98920. /**
  98921. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98922. */
  98923. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98924. /**
  98925. * Defines that both eyes of the camera will be rendered over under each other.
  98926. */
  98927. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98928. /**
  98929. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98930. */
  98931. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98932. /**
  98933. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98934. */
  98935. static readonly RIG_MODE_VR: number;
  98936. /**
  98937. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98938. */
  98939. static readonly RIG_MODE_WEBVR: number;
  98940. /**
  98941. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98942. */
  98943. static readonly RIG_MODE_CUSTOM: number;
  98944. /**
  98945. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98946. */
  98947. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98948. /**
  98949. * Define the input manager associated with the camera.
  98950. */
  98951. inputs: CameraInputsManager<Camera>;
  98952. /** @hidden */
  98953. _position: Vector3;
  98954. /**
  98955. * Define the current local position of the camera in the scene
  98956. */
  98957. get position(): Vector3;
  98958. set position(newPosition: Vector3);
  98959. /**
  98960. * The vector the camera should consider as up.
  98961. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98962. */
  98963. upVector: Vector3;
  98964. /**
  98965. * Define the current limit on the left side for an orthographic camera
  98966. * In scene unit
  98967. */
  98968. orthoLeft: Nullable<number>;
  98969. /**
  98970. * Define the current limit on the right side for an orthographic camera
  98971. * In scene unit
  98972. */
  98973. orthoRight: Nullable<number>;
  98974. /**
  98975. * Define the current limit on the bottom side for an orthographic camera
  98976. * In scene unit
  98977. */
  98978. orthoBottom: Nullable<number>;
  98979. /**
  98980. * Define the current limit on the top side for an orthographic camera
  98981. * In scene unit
  98982. */
  98983. orthoTop: Nullable<number>;
  98984. /**
  98985. * Field Of View is set in Radians. (default is 0.8)
  98986. */
  98987. fov: number;
  98988. /**
  98989. * Define the minimum distance the camera can see from.
  98990. * This is important to note that the depth buffer are not infinite and the closer it starts
  98991. * the more your scene might encounter depth fighting issue.
  98992. */
  98993. minZ: number;
  98994. /**
  98995. * Define the maximum distance the camera can see to.
  98996. * This is important to note that the depth buffer are not infinite and the further it end
  98997. * the more your scene might encounter depth fighting issue.
  98998. */
  98999. maxZ: number;
  99000. /**
  99001. * Define the default inertia of the camera.
  99002. * This helps giving a smooth feeling to the camera movement.
  99003. */
  99004. inertia: number;
  99005. /**
  99006. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  99007. */
  99008. mode: number;
  99009. /**
  99010. * Define whether the camera is intermediate.
  99011. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  99012. */
  99013. isIntermediate: boolean;
  99014. /**
  99015. * Define the viewport of the camera.
  99016. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  99017. */
  99018. viewport: Viewport;
  99019. /**
  99020. * Restricts the camera to viewing objects with the same layerMask.
  99021. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  99022. */
  99023. layerMask: number;
  99024. /**
  99025. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  99026. */
  99027. fovMode: number;
  99028. /**
  99029. * Rig mode of the camera.
  99030. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  99031. * This is normally controlled byt the camera themselves as internal use.
  99032. */
  99033. cameraRigMode: number;
  99034. /**
  99035. * Defines the distance between both "eyes" in case of a RIG
  99036. */
  99037. interaxialDistance: number;
  99038. /**
  99039. * Defines if stereoscopic rendering is done side by side or over under.
  99040. */
  99041. isStereoscopicSideBySide: boolean;
  99042. /**
  99043. * 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
  99044. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  99045. * else in the scene. (Eg. security camera)
  99046. *
  99047. * 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)
  99048. */
  99049. customRenderTargets: RenderTargetTexture[];
  99050. /**
  99051. * When set, the camera will render to this render target instead of the default canvas
  99052. *
  99053. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  99054. */
  99055. outputRenderTarget: Nullable<RenderTargetTexture>;
  99056. /**
  99057. * Observable triggered when the camera view matrix has changed.
  99058. */
  99059. onViewMatrixChangedObservable: Observable<Camera>;
  99060. /**
  99061. * Observable triggered when the camera Projection matrix has changed.
  99062. */
  99063. onProjectionMatrixChangedObservable: Observable<Camera>;
  99064. /**
  99065. * Observable triggered when the inputs have been processed.
  99066. */
  99067. onAfterCheckInputsObservable: Observable<Camera>;
  99068. /**
  99069. * Observable triggered when reset has been called and applied to the camera.
  99070. */
  99071. onRestoreStateObservable: Observable<Camera>;
  99072. /**
  99073. * Is this camera a part of a rig system?
  99074. */
  99075. isRigCamera: boolean;
  99076. /**
  99077. * If isRigCamera set to true this will be set with the parent camera.
  99078. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99079. */
  99080. rigParent?: Camera;
  99081. /** @hidden */
  99082. _cameraRigParams: any;
  99083. /** @hidden */
  99084. _rigCameras: Camera[];
  99085. /** @hidden */
  99086. _rigPostProcess: Nullable<PostProcess>;
  99087. protected _webvrViewMatrix: Matrix;
  99088. /** @hidden */
  99089. _skipRendering: boolean;
  99090. /** @hidden */
  99091. _projectionMatrix: Matrix;
  99092. /** @hidden */
  99093. _postProcesses: Nullable<PostProcess>[];
  99094. /** @hidden */
  99095. _activeMeshes: SmartArray<AbstractMesh>;
  99096. protected _globalPosition: Vector3;
  99097. /** @hidden */
  99098. _computedViewMatrix: Matrix;
  99099. private _doNotComputeProjectionMatrix;
  99100. private _transformMatrix;
  99101. private _frustumPlanes;
  99102. private _refreshFrustumPlanes;
  99103. private _storedFov;
  99104. private _stateStored;
  99105. /**
  99106. * Instantiates a new camera object.
  99107. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99108. * @see http://doc.babylonjs.com/features/cameras
  99109. * @param name Defines the name of the camera in the scene
  99110. * @param position Defines the position of the camera
  99111. * @param scene Defines the scene the camera belongs too
  99112. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99113. */
  99114. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99115. /**
  99116. * Store current camera state (fov, position, etc..)
  99117. * @returns the camera
  99118. */
  99119. storeState(): Camera;
  99120. /**
  99121. * Restores the camera state values if it has been stored. You must call storeState() first
  99122. */
  99123. protected _restoreStateValues(): boolean;
  99124. /**
  99125. * Restored camera state. You must call storeState() first.
  99126. * @returns true if restored and false otherwise
  99127. */
  99128. restoreState(): boolean;
  99129. /**
  99130. * Gets the class name of the camera.
  99131. * @returns the class name
  99132. */
  99133. getClassName(): string;
  99134. /** @hidden */
  99135. readonly _isCamera: boolean;
  99136. /**
  99137. * Gets a string representation of the camera useful for debug purpose.
  99138. * @param fullDetails Defines that a more verboe level of logging is required
  99139. * @returns the string representation
  99140. */
  99141. toString(fullDetails?: boolean): string;
  99142. /**
  99143. * Gets the current world space position of the camera.
  99144. */
  99145. get globalPosition(): Vector3;
  99146. /**
  99147. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99148. * @returns the active meshe list
  99149. */
  99150. getActiveMeshes(): SmartArray<AbstractMesh>;
  99151. /**
  99152. * Check whether a mesh is part of the current active mesh list of the camera
  99153. * @param mesh Defines the mesh to check
  99154. * @returns true if active, false otherwise
  99155. */
  99156. isActiveMesh(mesh: Mesh): boolean;
  99157. /**
  99158. * Is this camera ready to be used/rendered
  99159. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99160. * @return true if the camera is ready
  99161. */
  99162. isReady(completeCheck?: boolean): boolean;
  99163. /** @hidden */
  99164. _initCache(): void;
  99165. /** @hidden */
  99166. _updateCache(ignoreParentClass?: boolean): void;
  99167. /** @hidden */
  99168. _isSynchronized(): boolean;
  99169. /** @hidden */
  99170. _isSynchronizedViewMatrix(): boolean;
  99171. /** @hidden */
  99172. _isSynchronizedProjectionMatrix(): boolean;
  99173. /**
  99174. * Attach the input controls to a specific dom element to get the input from.
  99175. * @param element Defines the element the controls should be listened from
  99176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99177. */
  99178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99179. /**
  99180. * Detach the current controls from the specified dom element.
  99181. * @param element Defines the element to stop listening the inputs from
  99182. */
  99183. detachControl(element: HTMLElement): void;
  99184. /**
  99185. * Update the camera state according to the different inputs gathered during the frame.
  99186. */
  99187. update(): void;
  99188. /** @hidden */
  99189. _checkInputs(): void;
  99190. /** @hidden */
  99191. get rigCameras(): Camera[];
  99192. /**
  99193. * Gets the post process used by the rig cameras
  99194. */
  99195. get rigPostProcess(): Nullable<PostProcess>;
  99196. /**
  99197. * Internal, gets the first post proces.
  99198. * @returns the first post process to be run on this camera.
  99199. */
  99200. _getFirstPostProcess(): Nullable<PostProcess>;
  99201. private _cascadePostProcessesToRigCams;
  99202. /**
  99203. * Attach a post process to the camera.
  99204. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99205. * @param postProcess The post process to attach to the camera
  99206. * @param insertAt The position of the post process in case several of them are in use in the scene
  99207. * @returns the position the post process has been inserted at
  99208. */
  99209. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99210. /**
  99211. * Detach a post process to the camera.
  99212. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99213. * @param postProcess The post process to detach from the camera
  99214. */
  99215. detachPostProcess(postProcess: PostProcess): void;
  99216. /**
  99217. * Gets the current world matrix of the camera
  99218. */
  99219. getWorldMatrix(): Matrix;
  99220. /** @hidden */
  99221. _getViewMatrix(): Matrix;
  99222. /**
  99223. * Gets the current view matrix of the camera.
  99224. * @param force forces the camera to recompute the matrix without looking at the cached state
  99225. * @returns the view matrix
  99226. */
  99227. getViewMatrix(force?: boolean): Matrix;
  99228. /**
  99229. * Freeze the projection matrix.
  99230. * It will prevent the cache check of the camera projection compute and can speed up perf
  99231. * if no parameter of the camera are meant to change
  99232. * @param projection Defines manually a projection if necessary
  99233. */
  99234. freezeProjectionMatrix(projection?: Matrix): void;
  99235. /**
  99236. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99237. */
  99238. unfreezeProjectionMatrix(): void;
  99239. /**
  99240. * Gets the current projection matrix of the camera.
  99241. * @param force forces the camera to recompute the matrix without looking at the cached state
  99242. * @returns the projection matrix
  99243. */
  99244. getProjectionMatrix(force?: boolean): Matrix;
  99245. /**
  99246. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99247. * @returns a Matrix
  99248. */
  99249. getTransformationMatrix(): Matrix;
  99250. private _updateFrustumPlanes;
  99251. /**
  99252. * Checks if a cullable object (mesh...) is in the camera frustum
  99253. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99254. * @param target The object to check
  99255. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99256. * @returns true if the object is in frustum otherwise false
  99257. */
  99258. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99259. /**
  99260. * Checks if a cullable object (mesh...) is in the camera frustum
  99261. * Unlike isInFrustum this cheks the full bounding box
  99262. * @param target The object to check
  99263. * @returns true if the object is in frustum otherwise false
  99264. */
  99265. isCompletelyInFrustum(target: ICullable): boolean;
  99266. /**
  99267. * Gets a ray in the forward direction from the camera.
  99268. * @param length Defines the length of the ray to create
  99269. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99270. * @param origin Defines the start point of the ray which defaults to the camera position
  99271. * @returns the forward ray
  99272. */
  99273. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99274. /**
  99275. * Releases resources associated with this node.
  99276. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99277. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99278. */
  99279. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99280. /** @hidden */
  99281. _isLeftCamera: boolean;
  99282. /**
  99283. * Gets the left camera of a rig setup in case of Rigged Camera
  99284. */
  99285. get isLeftCamera(): boolean;
  99286. /** @hidden */
  99287. _isRightCamera: boolean;
  99288. /**
  99289. * Gets the right camera of a rig setup in case of Rigged Camera
  99290. */
  99291. get isRightCamera(): boolean;
  99292. /**
  99293. * Gets the left camera of a rig setup in case of Rigged Camera
  99294. */
  99295. get leftCamera(): Nullable<FreeCamera>;
  99296. /**
  99297. * Gets the right camera of a rig setup in case of Rigged Camera
  99298. */
  99299. get rightCamera(): Nullable<FreeCamera>;
  99300. /**
  99301. * Gets the left camera target of a rig setup in case of Rigged Camera
  99302. * @returns the target position
  99303. */
  99304. getLeftTarget(): Nullable<Vector3>;
  99305. /**
  99306. * Gets the right camera target of a rig setup in case of Rigged Camera
  99307. * @returns the target position
  99308. */
  99309. getRightTarget(): Nullable<Vector3>;
  99310. /**
  99311. * @hidden
  99312. */
  99313. setCameraRigMode(mode: number, rigParams: any): void;
  99314. /** @hidden */
  99315. static _setStereoscopicRigMode(camera: Camera): void;
  99316. /** @hidden */
  99317. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99318. /** @hidden */
  99319. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99320. /** @hidden */
  99321. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99322. /** @hidden */
  99323. _getVRProjectionMatrix(): Matrix;
  99324. protected _updateCameraRotationMatrix(): void;
  99325. protected _updateWebVRCameraRotationMatrix(): void;
  99326. /**
  99327. * This function MUST be overwritten by the different WebVR cameras available.
  99328. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99329. * @hidden
  99330. */
  99331. _getWebVRProjectionMatrix(): Matrix;
  99332. /**
  99333. * This function MUST be overwritten by the different WebVR cameras available.
  99334. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99335. * @hidden
  99336. */
  99337. _getWebVRViewMatrix(): Matrix;
  99338. /** @hidden */
  99339. setCameraRigParameter(name: string, value: any): void;
  99340. /**
  99341. * needs to be overridden by children so sub has required properties to be copied
  99342. * @hidden
  99343. */
  99344. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99345. /**
  99346. * May need to be overridden by children
  99347. * @hidden
  99348. */
  99349. _updateRigCameras(): void;
  99350. /** @hidden */
  99351. _setupInputs(): void;
  99352. /**
  99353. * Serialiaze the camera setup to a json represention
  99354. * @returns the JSON representation
  99355. */
  99356. serialize(): any;
  99357. /**
  99358. * Clones the current camera.
  99359. * @param name The cloned camera name
  99360. * @returns the cloned camera
  99361. */
  99362. clone(name: string): Camera;
  99363. /**
  99364. * Gets the direction of the camera relative to a given local axis.
  99365. * @param localAxis Defines the reference axis to provide a relative direction.
  99366. * @return the direction
  99367. */
  99368. getDirection(localAxis: Vector3): Vector3;
  99369. /**
  99370. * Returns the current camera absolute rotation
  99371. */
  99372. get absoluteRotation(): Quaternion;
  99373. /**
  99374. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99375. * @param localAxis Defines the reference axis to provide a relative direction.
  99376. * @param result Defines the vector to store the result in
  99377. */
  99378. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99379. /**
  99380. * Gets a camera constructor for a given camera type
  99381. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99382. * @param name The name of the camera the result will be able to instantiate
  99383. * @param scene The scene the result will construct the camera in
  99384. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99385. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99386. * @returns a factory method to construc the camera
  99387. */
  99388. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99389. /**
  99390. * Compute the world matrix of the camera.
  99391. * @returns the camera world matrix
  99392. */
  99393. computeWorldMatrix(): Matrix;
  99394. /**
  99395. * Parse a JSON and creates the camera from the parsed information
  99396. * @param parsedCamera The JSON to parse
  99397. * @param scene The scene to instantiate the camera in
  99398. * @returns the newly constructed camera
  99399. */
  99400. static Parse(parsedCamera: any, scene: Scene): Camera;
  99401. }
  99402. }
  99403. declare module BABYLON {
  99404. /**
  99405. * Class containing static functions to help procedurally build meshes
  99406. */
  99407. export class DiscBuilder {
  99408. /**
  99409. * Creates a plane polygonal mesh. By default, this is a disc
  99410. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99411. * * 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
  99412. * * 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
  99413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99416. * @param name defines the name of the mesh
  99417. * @param options defines the options used to create the mesh
  99418. * @param scene defines the hosting scene
  99419. * @returns the plane polygonal mesh
  99420. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99421. */
  99422. static CreateDisc(name: string, options: {
  99423. radius?: number;
  99424. tessellation?: number;
  99425. arc?: number;
  99426. updatable?: boolean;
  99427. sideOrientation?: number;
  99428. frontUVs?: Vector4;
  99429. backUVs?: Vector4;
  99430. }, scene?: Nullable<Scene>): Mesh;
  99431. }
  99432. }
  99433. declare module BABYLON {
  99434. /**
  99435. * This represents all the required information to add a fresnel effect on a material:
  99436. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99437. */
  99438. export class FresnelParameters {
  99439. private _isEnabled;
  99440. /**
  99441. * Define if the fresnel effect is enable or not.
  99442. */
  99443. get isEnabled(): boolean;
  99444. set isEnabled(value: boolean);
  99445. /**
  99446. * Define the color used on edges (grazing angle)
  99447. */
  99448. leftColor: Color3;
  99449. /**
  99450. * Define the color used on center
  99451. */
  99452. rightColor: Color3;
  99453. /**
  99454. * Define bias applied to computed fresnel term
  99455. */
  99456. bias: number;
  99457. /**
  99458. * Defined the power exponent applied to fresnel term
  99459. */
  99460. power: number;
  99461. /**
  99462. * Clones the current fresnel and its valuues
  99463. * @returns a clone fresnel configuration
  99464. */
  99465. clone(): FresnelParameters;
  99466. /**
  99467. * Serializes the current fresnel parameters to a JSON representation.
  99468. * @return the JSON serialization
  99469. */
  99470. serialize(): any;
  99471. /**
  99472. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99473. * @param parsedFresnelParameters Define the JSON representation
  99474. * @returns the parsed parameters
  99475. */
  99476. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99477. }
  99478. }
  99479. declare module BABYLON {
  99480. /**
  99481. * Base class of materials working in push mode in babylon JS
  99482. * @hidden
  99483. */
  99484. export class PushMaterial extends Material {
  99485. protected _activeEffect: Effect;
  99486. protected _normalMatrix: Matrix;
  99487. /**
  99488. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99489. * This means that the material can keep using a previous shader while a new one is being compiled.
  99490. * This is mostly used when shader parallel compilation is supported (true by default)
  99491. */
  99492. allowShaderHotSwapping: boolean;
  99493. constructor(name: string, scene: Scene);
  99494. getEffect(): Effect;
  99495. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99496. /**
  99497. * Binds the given world matrix to the active effect
  99498. *
  99499. * @param world the matrix to bind
  99500. */
  99501. bindOnlyWorldMatrix(world: Matrix): void;
  99502. /**
  99503. * Binds the given normal matrix to the active effect
  99504. *
  99505. * @param normalMatrix the matrix to bind
  99506. */
  99507. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99508. bind(world: Matrix, mesh?: Mesh): void;
  99509. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99510. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99511. }
  99512. }
  99513. declare module BABYLON {
  99514. /**
  99515. * This groups all the flags used to control the materials channel.
  99516. */
  99517. export class MaterialFlags {
  99518. private static _DiffuseTextureEnabled;
  99519. /**
  99520. * Are diffuse textures enabled in the application.
  99521. */
  99522. static get DiffuseTextureEnabled(): boolean;
  99523. static set DiffuseTextureEnabled(value: boolean);
  99524. private static _AmbientTextureEnabled;
  99525. /**
  99526. * Are ambient textures enabled in the application.
  99527. */
  99528. static get AmbientTextureEnabled(): boolean;
  99529. static set AmbientTextureEnabled(value: boolean);
  99530. private static _OpacityTextureEnabled;
  99531. /**
  99532. * Are opacity textures enabled in the application.
  99533. */
  99534. static get OpacityTextureEnabled(): boolean;
  99535. static set OpacityTextureEnabled(value: boolean);
  99536. private static _ReflectionTextureEnabled;
  99537. /**
  99538. * Are reflection textures enabled in the application.
  99539. */
  99540. static get ReflectionTextureEnabled(): boolean;
  99541. static set ReflectionTextureEnabled(value: boolean);
  99542. private static _EmissiveTextureEnabled;
  99543. /**
  99544. * Are emissive textures enabled in the application.
  99545. */
  99546. static get EmissiveTextureEnabled(): boolean;
  99547. static set EmissiveTextureEnabled(value: boolean);
  99548. private static _SpecularTextureEnabled;
  99549. /**
  99550. * Are specular textures enabled in the application.
  99551. */
  99552. static get SpecularTextureEnabled(): boolean;
  99553. static set SpecularTextureEnabled(value: boolean);
  99554. private static _BumpTextureEnabled;
  99555. /**
  99556. * Are bump textures enabled in the application.
  99557. */
  99558. static get BumpTextureEnabled(): boolean;
  99559. static set BumpTextureEnabled(value: boolean);
  99560. private static _LightmapTextureEnabled;
  99561. /**
  99562. * Are lightmap textures enabled in the application.
  99563. */
  99564. static get LightmapTextureEnabled(): boolean;
  99565. static set LightmapTextureEnabled(value: boolean);
  99566. private static _RefractionTextureEnabled;
  99567. /**
  99568. * Are refraction textures enabled in the application.
  99569. */
  99570. static get RefractionTextureEnabled(): boolean;
  99571. static set RefractionTextureEnabled(value: boolean);
  99572. private static _ColorGradingTextureEnabled;
  99573. /**
  99574. * Are color grading textures enabled in the application.
  99575. */
  99576. static get ColorGradingTextureEnabled(): boolean;
  99577. static set ColorGradingTextureEnabled(value: boolean);
  99578. private static _FresnelEnabled;
  99579. /**
  99580. * Are fresnels enabled in the application.
  99581. */
  99582. static get FresnelEnabled(): boolean;
  99583. static set FresnelEnabled(value: boolean);
  99584. private static _ClearCoatTextureEnabled;
  99585. /**
  99586. * Are clear coat textures enabled in the application.
  99587. */
  99588. static get ClearCoatTextureEnabled(): boolean;
  99589. static set ClearCoatTextureEnabled(value: boolean);
  99590. private static _ClearCoatBumpTextureEnabled;
  99591. /**
  99592. * Are clear coat bump textures enabled in the application.
  99593. */
  99594. static get ClearCoatBumpTextureEnabled(): boolean;
  99595. static set ClearCoatBumpTextureEnabled(value: boolean);
  99596. private static _ClearCoatTintTextureEnabled;
  99597. /**
  99598. * Are clear coat tint textures enabled in the application.
  99599. */
  99600. static get ClearCoatTintTextureEnabled(): boolean;
  99601. static set ClearCoatTintTextureEnabled(value: boolean);
  99602. private static _SheenTextureEnabled;
  99603. /**
  99604. * Are sheen textures enabled in the application.
  99605. */
  99606. static get SheenTextureEnabled(): boolean;
  99607. static set SheenTextureEnabled(value: boolean);
  99608. private static _AnisotropicTextureEnabled;
  99609. /**
  99610. * Are anisotropic textures enabled in the application.
  99611. */
  99612. static get AnisotropicTextureEnabled(): boolean;
  99613. static set AnisotropicTextureEnabled(value: boolean);
  99614. private static _ThicknessTextureEnabled;
  99615. /**
  99616. * Are thickness textures enabled in the application.
  99617. */
  99618. static get ThicknessTextureEnabled(): boolean;
  99619. static set ThicknessTextureEnabled(value: boolean);
  99620. }
  99621. }
  99622. declare module BABYLON {
  99623. /** @hidden */
  99624. export var defaultFragmentDeclaration: {
  99625. name: string;
  99626. shader: string;
  99627. };
  99628. }
  99629. declare module BABYLON {
  99630. /** @hidden */
  99631. export var defaultUboDeclaration: {
  99632. name: string;
  99633. shader: string;
  99634. };
  99635. }
  99636. declare module BABYLON {
  99637. /** @hidden */
  99638. export var lightFragmentDeclaration: {
  99639. name: string;
  99640. shader: string;
  99641. };
  99642. }
  99643. declare module BABYLON {
  99644. /** @hidden */
  99645. export var lightUboDeclaration: {
  99646. name: string;
  99647. shader: string;
  99648. };
  99649. }
  99650. declare module BABYLON {
  99651. /** @hidden */
  99652. export var lightsFragmentFunctions: {
  99653. name: string;
  99654. shader: string;
  99655. };
  99656. }
  99657. declare module BABYLON {
  99658. /** @hidden */
  99659. export var shadowsFragmentFunctions: {
  99660. name: string;
  99661. shader: string;
  99662. };
  99663. }
  99664. declare module BABYLON {
  99665. /** @hidden */
  99666. export var fresnelFunction: {
  99667. name: string;
  99668. shader: string;
  99669. };
  99670. }
  99671. declare module BABYLON {
  99672. /** @hidden */
  99673. export var reflectionFunction: {
  99674. name: string;
  99675. shader: string;
  99676. };
  99677. }
  99678. declare module BABYLON {
  99679. /** @hidden */
  99680. export var bumpFragmentFunctions: {
  99681. name: string;
  99682. shader: string;
  99683. };
  99684. }
  99685. declare module BABYLON {
  99686. /** @hidden */
  99687. export var logDepthDeclaration: {
  99688. name: string;
  99689. shader: string;
  99690. };
  99691. }
  99692. declare module BABYLON {
  99693. /** @hidden */
  99694. export var bumpFragment: {
  99695. name: string;
  99696. shader: string;
  99697. };
  99698. }
  99699. declare module BABYLON {
  99700. /** @hidden */
  99701. export var depthPrePass: {
  99702. name: string;
  99703. shader: string;
  99704. };
  99705. }
  99706. declare module BABYLON {
  99707. /** @hidden */
  99708. export var lightFragment: {
  99709. name: string;
  99710. shader: string;
  99711. };
  99712. }
  99713. declare module BABYLON {
  99714. /** @hidden */
  99715. export var logDepthFragment: {
  99716. name: string;
  99717. shader: string;
  99718. };
  99719. }
  99720. declare module BABYLON {
  99721. /** @hidden */
  99722. export var defaultPixelShader: {
  99723. name: string;
  99724. shader: string;
  99725. };
  99726. }
  99727. declare module BABYLON {
  99728. /** @hidden */
  99729. export var defaultVertexDeclaration: {
  99730. name: string;
  99731. shader: string;
  99732. };
  99733. }
  99734. declare module BABYLON {
  99735. /** @hidden */
  99736. export var bumpVertexDeclaration: {
  99737. name: string;
  99738. shader: string;
  99739. };
  99740. }
  99741. declare module BABYLON {
  99742. /** @hidden */
  99743. export var bumpVertex: {
  99744. name: string;
  99745. shader: string;
  99746. };
  99747. }
  99748. declare module BABYLON {
  99749. /** @hidden */
  99750. export var fogVertex: {
  99751. name: string;
  99752. shader: string;
  99753. };
  99754. }
  99755. declare module BABYLON {
  99756. /** @hidden */
  99757. export var shadowsVertex: {
  99758. name: string;
  99759. shader: string;
  99760. };
  99761. }
  99762. declare module BABYLON {
  99763. /** @hidden */
  99764. export var pointCloudVertex: {
  99765. name: string;
  99766. shader: string;
  99767. };
  99768. }
  99769. declare module BABYLON {
  99770. /** @hidden */
  99771. export var logDepthVertex: {
  99772. name: string;
  99773. shader: string;
  99774. };
  99775. }
  99776. declare module BABYLON {
  99777. /** @hidden */
  99778. export var defaultVertexShader: {
  99779. name: string;
  99780. shader: string;
  99781. };
  99782. }
  99783. declare module BABYLON {
  99784. /** @hidden */
  99785. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99786. MAINUV1: boolean;
  99787. MAINUV2: boolean;
  99788. DIFFUSE: boolean;
  99789. DIFFUSEDIRECTUV: number;
  99790. AMBIENT: boolean;
  99791. AMBIENTDIRECTUV: number;
  99792. OPACITY: boolean;
  99793. OPACITYDIRECTUV: number;
  99794. OPACITYRGB: boolean;
  99795. REFLECTION: boolean;
  99796. EMISSIVE: boolean;
  99797. EMISSIVEDIRECTUV: number;
  99798. SPECULAR: boolean;
  99799. SPECULARDIRECTUV: number;
  99800. BUMP: boolean;
  99801. BUMPDIRECTUV: number;
  99802. PARALLAX: boolean;
  99803. PARALLAXOCCLUSION: boolean;
  99804. SPECULAROVERALPHA: boolean;
  99805. CLIPPLANE: boolean;
  99806. CLIPPLANE2: boolean;
  99807. CLIPPLANE3: boolean;
  99808. CLIPPLANE4: boolean;
  99809. CLIPPLANE5: boolean;
  99810. CLIPPLANE6: boolean;
  99811. ALPHATEST: boolean;
  99812. DEPTHPREPASS: boolean;
  99813. ALPHAFROMDIFFUSE: boolean;
  99814. POINTSIZE: boolean;
  99815. FOG: boolean;
  99816. SPECULARTERM: boolean;
  99817. DIFFUSEFRESNEL: boolean;
  99818. OPACITYFRESNEL: boolean;
  99819. REFLECTIONFRESNEL: boolean;
  99820. REFRACTIONFRESNEL: boolean;
  99821. EMISSIVEFRESNEL: boolean;
  99822. FRESNEL: boolean;
  99823. NORMAL: boolean;
  99824. UV1: boolean;
  99825. UV2: boolean;
  99826. VERTEXCOLOR: boolean;
  99827. VERTEXALPHA: boolean;
  99828. NUM_BONE_INFLUENCERS: number;
  99829. BonesPerMesh: number;
  99830. BONETEXTURE: boolean;
  99831. INSTANCES: boolean;
  99832. GLOSSINESS: boolean;
  99833. ROUGHNESS: boolean;
  99834. EMISSIVEASILLUMINATION: boolean;
  99835. LINKEMISSIVEWITHDIFFUSE: boolean;
  99836. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99837. LIGHTMAP: boolean;
  99838. LIGHTMAPDIRECTUV: number;
  99839. OBJECTSPACE_NORMALMAP: boolean;
  99840. USELIGHTMAPASSHADOWMAP: boolean;
  99841. REFLECTIONMAP_3D: boolean;
  99842. REFLECTIONMAP_SPHERICAL: boolean;
  99843. REFLECTIONMAP_PLANAR: boolean;
  99844. REFLECTIONMAP_CUBIC: boolean;
  99845. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99846. REFLECTIONMAP_PROJECTION: boolean;
  99847. REFLECTIONMAP_SKYBOX: boolean;
  99848. REFLECTIONMAP_EXPLICIT: boolean;
  99849. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99850. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99851. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99852. INVERTCUBICMAP: boolean;
  99853. LOGARITHMICDEPTH: boolean;
  99854. REFRACTION: boolean;
  99855. REFRACTIONMAP_3D: boolean;
  99856. REFLECTIONOVERALPHA: boolean;
  99857. TWOSIDEDLIGHTING: boolean;
  99858. SHADOWFLOAT: boolean;
  99859. MORPHTARGETS: boolean;
  99860. MORPHTARGETS_NORMAL: boolean;
  99861. MORPHTARGETS_TANGENT: boolean;
  99862. MORPHTARGETS_UV: boolean;
  99863. NUM_MORPH_INFLUENCERS: number;
  99864. NONUNIFORMSCALING: boolean;
  99865. PREMULTIPLYALPHA: boolean;
  99866. IMAGEPROCESSING: boolean;
  99867. VIGNETTE: boolean;
  99868. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99869. VIGNETTEBLENDMODEOPAQUE: boolean;
  99870. TONEMAPPING: boolean;
  99871. TONEMAPPING_ACES: boolean;
  99872. CONTRAST: boolean;
  99873. COLORCURVES: boolean;
  99874. COLORGRADING: boolean;
  99875. COLORGRADING3D: boolean;
  99876. SAMPLER3DGREENDEPTH: boolean;
  99877. SAMPLER3DBGRMAP: boolean;
  99878. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99879. MULTIVIEW: boolean;
  99880. /**
  99881. * If the reflection texture on this material is in linear color space
  99882. * @hidden
  99883. */
  99884. IS_REFLECTION_LINEAR: boolean;
  99885. /**
  99886. * If the refraction texture on this material is in linear color space
  99887. * @hidden
  99888. */
  99889. IS_REFRACTION_LINEAR: boolean;
  99890. EXPOSURE: boolean;
  99891. constructor();
  99892. setReflectionMode(modeToEnable: string): void;
  99893. }
  99894. /**
  99895. * This is the default material used in Babylon. It is the best trade off between quality
  99896. * and performances.
  99897. * @see http://doc.babylonjs.com/babylon101/materials
  99898. */
  99899. export class StandardMaterial extends PushMaterial {
  99900. private _diffuseTexture;
  99901. /**
  99902. * The basic texture of the material as viewed under a light.
  99903. */
  99904. diffuseTexture: Nullable<BaseTexture>;
  99905. private _ambientTexture;
  99906. /**
  99907. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99908. */
  99909. ambientTexture: Nullable<BaseTexture>;
  99910. private _opacityTexture;
  99911. /**
  99912. * Define the transparency of the material from a texture.
  99913. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99914. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99915. */
  99916. opacityTexture: Nullable<BaseTexture>;
  99917. private _reflectionTexture;
  99918. /**
  99919. * Define the texture used to display the reflection.
  99920. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99921. */
  99922. reflectionTexture: Nullable<BaseTexture>;
  99923. private _emissiveTexture;
  99924. /**
  99925. * Define texture of the material as if self lit.
  99926. * This will be mixed in the final result even in the absence of light.
  99927. */
  99928. emissiveTexture: Nullable<BaseTexture>;
  99929. private _specularTexture;
  99930. /**
  99931. * Define how the color and intensity of the highlight given by the light in the material.
  99932. */
  99933. specularTexture: Nullable<BaseTexture>;
  99934. private _bumpTexture;
  99935. /**
  99936. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99937. * 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.
  99938. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99939. */
  99940. bumpTexture: Nullable<BaseTexture>;
  99941. private _lightmapTexture;
  99942. /**
  99943. * Complex lighting can be computationally expensive to compute at runtime.
  99944. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99945. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99946. */
  99947. lightmapTexture: Nullable<BaseTexture>;
  99948. private _refractionTexture;
  99949. /**
  99950. * Define the texture used to display the refraction.
  99951. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99952. */
  99953. refractionTexture: Nullable<BaseTexture>;
  99954. /**
  99955. * The color of the material lit by the environmental background lighting.
  99956. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99957. */
  99958. ambientColor: Color3;
  99959. /**
  99960. * The basic color of the material as viewed under a light.
  99961. */
  99962. diffuseColor: Color3;
  99963. /**
  99964. * Define how the color and intensity of the highlight given by the light in the material.
  99965. */
  99966. specularColor: Color3;
  99967. /**
  99968. * Define the color of the material as if self lit.
  99969. * This will be mixed in the final result even in the absence of light.
  99970. */
  99971. emissiveColor: Color3;
  99972. /**
  99973. * Defines how sharp are the highlights in the material.
  99974. * The bigger the value the sharper giving a more glossy feeling to the result.
  99975. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99976. */
  99977. specularPower: number;
  99978. private _useAlphaFromDiffuseTexture;
  99979. /**
  99980. * Does the transparency come from the diffuse texture alpha channel.
  99981. */
  99982. useAlphaFromDiffuseTexture: boolean;
  99983. private _useEmissiveAsIllumination;
  99984. /**
  99985. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99986. */
  99987. useEmissiveAsIllumination: boolean;
  99988. private _linkEmissiveWithDiffuse;
  99989. /**
  99990. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99991. * the emissive level when the final color is close to one.
  99992. */
  99993. linkEmissiveWithDiffuse: boolean;
  99994. private _useSpecularOverAlpha;
  99995. /**
  99996. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99997. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99998. */
  99999. useSpecularOverAlpha: boolean;
  100000. private _useReflectionOverAlpha;
  100001. /**
  100002. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100003. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100004. */
  100005. useReflectionOverAlpha: boolean;
  100006. private _disableLighting;
  100007. /**
  100008. * Does lights from the scene impacts this material.
  100009. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100010. */
  100011. disableLighting: boolean;
  100012. private _useObjectSpaceNormalMap;
  100013. /**
  100014. * Allows using an object space normal map (instead of tangent space).
  100015. */
  100016. useObjectSpaceNormalMap: boolean;
  100017. private _useParallax;
  100018. /**
  100019. * Is parallax enabled or not.
  100020. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100021. */
  100022. useParallax: boolean;
  100023. private _useParallaxOcclusion;
  100024. /**
  100025. * Is parallax occlusion enabled or not.
  100026. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100027. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100028. */
  100029. useParallaxOcclusion: boolean;
  100030. /**
  100031. * 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.
  100032. */
  100033. parallaxScaleBias: number;
  100034. private _roughness;
  100035. /**
  100036. * Helps to define how blurry the reflections should appears in the material.
  100037. */
  100038. roughness: number;
  100039. /**
  100040. * In case of refraction, define the value of the index of refraction.
  100041. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100042. */
  100043. indexOfRefraction: number;
  100044. /**
  100045. * Invert the refraction texture alongside the y axis.
  100046. * It can be useful with procedural textures or probe for instance.
  100047. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100048. */
  100049. invertRefractionY: boolean;
  100050. /**
  100051. * Defines the alpha limits in alpha test mode.
  100052. */
  100053. alphaCutOff: number;
  100054. private _useLightmapAsShadowmap;
  100055. /**
  100056. * In case of light mapping, define whether the map contains light or shadow informations.
  100057. */
  100058. useLightmapAsShadowmap: boolean;
  100059. private _diffuseFresnelParameters;
  100060. /**
  100061. * Define the diffuse fresnel parameters of the material.
  100062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100063. */
  100064. diffuseFresnelParameters: FresnelParameters;
  100065. private _opacityFresnelParameters;
  100066. /**
  100067. * Define the opacity fresnel parameters of the material.
  100068. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100069. */
  100070. opacityFresnelParameters: FresnelParameters;
  100071. private _reflectionFresnelParameters;
  100072. /**
  100073. * Define the reflection fresnel parameters of the material.
  100074. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100075. */
  100076. reflectionFresnelParameters: FresnelParameters;
  100077. private _refractionFresnelParameters;
  100078. /**
  100079. * Define the refraction fresnel parameters of the material.
  100080. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100081. */
  100082. refractionFresnelParameters: FresnelParameters;
  100083. private _emissiveFresnelParameters;
  100084. /**
  100085. * Define the emissive fresnel parameters of the material.
  100086. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100087. */
  100088. emissiveFresnelParameters: FresnelParameters;
  100089. private _useReflectionFresnelFromSpecular;
  100090. /**
  100091. * If true automatically deducts the fresnels values from the material specularity.
  100092. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100093. */
  100094. useReflectionFresnelFromSpecular: boolean;
  100095. private _useGlossinessFromSpecularMapAlpha;
  100096. /**
  100097. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100098. */
  100099. useGlossinessFromSpecularMapAlpha: boolean;
  100100. private _maxSimultaneousLights;
  100101. /**
  100102. * Defines the maximum number of lights that can be used in the material
  100103. */
  100104. maxSimultaneousLights: number;
  100105. private _invertNormalMapX;
  100106. /**
  100107. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100108. */
  100109. invertNormalMapX: boolean;
  100110. private _invertNormalMapY;
  100111. /**
  100112. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100113. */
  100114. invertNormalMapY: boolean;
  100115. private _twoSidedLighting;
  100116. /**
  100117. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100118. */
  100119. twoSidedLighting: boolean;
  100120. /**
  100121. * Default configuration related to image processing available in the standard Material.
  100122. */
  100123. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100124. /**
  100125. * Gets the image processing configuration used either in this material.
  100126. */
  100127. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100128. /**
  100129. * Sets the Default image processing configuration used either in the this material.
  100130. *
  100131. * If sets to null, the scene one is in use.
  100132. */
  100133. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100134. /**
  100135. * Keep track of the image processing observer to allow dispose and replace.
  100136. */
  100137. private _imageProcessingObserver;
  100138. /**
  100139. * Attaches a new image processing configuration to the Standard Material.
  100140. * @param configuration
  100141. */
  100142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100143. /**
  100144. * Gets wether the color curves effect is enabled.
  100145. */
  100146. get cameraColorCurvesEnabled(): boolean;
  100147. /**
  100148. * Sets wether the color curves effect is enabled.
  100149. */
  100150. set cameraColorCurvesEnabled(value: boolean);
  100151. /**
  100152. * Gets wether the color grading effect is enabled.
  100153. */
  100154. get cameraColorGradingEnabled(): boolean;
  100155. /**
  100156. * Gets wether the color grading effect is enabled.
  100157. */
  100158. set cameraColorGradingEnabled(value: boolean);
  100159. /**
  100160. * Gets wether tonemapping is enabled or not.
  100161. */
  100162. get cameraToneMappingEnabled(): boolean;
  100163. /**
  100164. * Sets wether tonemapping is enabled or not
  100165. */
  100166. set cameraToneMappingEnabled(value: boolean);
  100167. /**
  100168. * The camera exposure used on this material.
  100169. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100170. * This corresponds to a photographic exposure.
  100171. */
  100172. get cameraExposure(): number;
  100173. /**
  100174. * The camera exposure used on this material.
  100175. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100176. * This corresponds to a photographic exposure.
  100177. */
  100178. set cameraExposure(value: number);
  100179. /**
  100180. * Gets The camera contrast used on this material.
  100181. */
  100182. get cameraContrast(): number;
  100183. /**
  100184. * Sets The camera contrast used on this material.
  100185. */
  100186. set cameraContrast(value: number);
  100187. /**
  100188. * Gets the Color Grading 2D Lookup Texture.
  100189. */
  100190. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100191. /**
  100192. * Sets the Color Grading 2D Lookup Texture.
  100193. */
  100194. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100195. /**
  100196. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100197. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100198. * 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;
  100199. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100200. */
  100201. get cameraColorCurves(): Nullable<ColorCurves>;
  100202. /**
  100203. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100204. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100205. * 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;
  100206. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100207. */
  100208. set cameraColorCurves(value: Nullable<ColorCurves>);
  100209. /**
  100210. * Custom callback helping to override the default shader used in the material.
  100211. */
  100212. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100213. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100214. protected _worldViewProjectionMatrix: Matrix;
  100215. protected _globalAmbientColor: Color3;
  100216. protected _useLogarithmicDepth: boolean;
  100217. protected _rebuildInParallel: boolean;
  100218. /**
  100219. * Instantiates a new standard material.
  100220. * This is the default material used in Babylon. It is the best trade off between quality
  100221. * and performances.
  100222. * @see http://doc.babylonjs.com/babylon101/materials
  100223. * @param name Define the name of the material in the scene
  100224. * @param scene Define the scene the material belong to
  100225. */
  100226. constructor(name: string, scene: Scene);
  100227. /**
  100228. * Gets a boolean indicating that current material needs to register RTT
  100229. */
  100230. get hasRenderTargetTextures(): boolean;
  100231. /**
  100232. * Gets the current class name of the material e.g. "StandardMaterial"
  100233. * Mainly use in serialization.
  100234. * @returns the class name
  100235. */
  100236. getClassName(): string;
  100237. /**
  100238. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100239. * You can try switching to logarithmic depth.
  100240. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100241. */
  100242. get useLogarithmicDepth(): boolean;
  100243. set useLogarithmicDepth(value: boolean);
  100244. /**
  100245. * Specifies if the material will require alpha blending
  100246. * @returns a boolean specifying if alpha blending is needed
  100247. */
  100248. needAlphaBlending(): boolean;
  100249. /**
  100250. * Specifies if this material should be rendered in alpha test mode
  100251. * @returns a boolean specifying if an alpha test is needed.
  100252. */
  100253. needAlphaTesting(): boolean;
  100254. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100255. /**
  100256. * Get the texture used for alpha test purpose.
  100257. * @returns the diffuse texture in case of the standard material.
  100258. */
  100259. getAlphaTestTexture(): Nullable<BaseTexture>;
  100260. /**
  100261. * Get if the submesh is ready to be used and all its information available.
  100262. * Child classes can use it to update shaders
  100263. * @param mesh defines the mesh to check
  100264. * @param subMesh defines which submesh to check
  100265. * @param useInstances specifies that instances should be used
  100266. * @returns a boolean indicating that the submesh is ready or not
  100267. */
  100268. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100269. /**
  100270. * Builds the material UBO layouts.
  100271. * Used internally during the effect preparation.
  100272. */
  100273. buildUniformLayout(): void;
  100274. /**
  100275. * Unbinds the material from the mesh
  100276. */
  100277. unbind(): void;
  100278. /**
  100279. * Binds the submesh to this material by preparing the effect and shader to draw
  100280. * @param world defines the world transformation matrix
  100281. * @param mesh defines the mesh containing the submesh
  100282. * @param subMesh defines the submesh to bind the material to
  100283. */
  100284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100285. /**
  100286. * Get the list of animatables in the material.
  100287. * @returns the list of animatables object used in the material
  100288. */
  100289. getAnimatables(): IAnimatable[];
  100290. /**
  100291. * Gets the active textures from the material
  100292. * @returns an array of textures
  100293. */
  100294. getActiveTextures(): BaseTexture[];
  100295. /**
  100296. * Specifies if the material uses a texture
  100297. * @param texture defines the texture to check against the material
  100298. * @returns a boolean specifying if the material uses the texture
  100299. */
  100300. hasTexture(texture: BaseTexture): boolean;
  100301. /**
  100302. * Disposes the material
  100303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100305. */
  100306. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100307. /**
  100308. * Makes a duplicate of the material, and gives it a new name
  100309. * @param name defines the new name for the duplicated material
  100310. * @returns the cloned material
  100311. */
  100312. clone(name: string): StandardMaterial;
  100313. /**
  100314. * Serializes this material in a JSON representation
  100315. * @returns the serialized material object
  100316. */
  100317. serialize(): any;
  100318. /**
  100319. * Creates a standard material from parsed material data
  100320. * @param source defines the JSON representation of the material
  100321. * @param scene defines the hosting scene
  100322. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100323. * @returns a new standard material
  100324. */
  100325. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100326. /**
  100327. * Are diffuse textures enabled in the application.
  100328. */
  100329. static get DiffuseTextureEnabled(): boolean;
  100330. static set DiffuseTextureEnabled(value: boolean);
  100331. /**
  100332. * Are ambient textures enabled in the application.
  100333. */
  100334. static get AmbientTextureEnabled(): boolean;
  100335. static set AmbientTextureEnabled(value: boolean);
  100336. /**
  100337. * Are opacity textures enabled in the application.
  100338. */
  100339. static get OpacityTextureEnabled(): boolean;
  100340. static set OpacityTextureEnabled(value: boolean);
  100341. /**
  100342. * Are reflection textures enabled in the application.
  100343. */
  100344. static get ReflectionTextureEnabled(): boolean;
  100345. static set ReflectionTextureEnabled(value: boolean);
  100346. /**
  100347. * Are emissive textures enabled in the application.
  100348. */
  100349. static get EmissiveTextureEnabled(): boolean;
  100350. static set EmissiveTextureEnabled(value: boolean);
  100351. /**
  100352. * Are specular textures enabled in the application.
  100353. */
  100354. static get SpecularTextureEnabled(): boolean;
  100355. static set SpecularTextureEnabled(value: boolean);
  100356. /**
  100357. * Are bump textures enabled in the application.
  100358. */
  100359. static get BumpTextureEnabled(): boolean;
  100360. static set BumpTextureEnabled(value: boolean);
  100361. /**
  100362. * Are lightmap textures enabled in the application.
  100363. */
  100364. static get LightmapTextureEnabled(): boolean;
  100365. static set LightmapTextureEnabled(value: boolean);
  100366. /**
  100367. * Are refraction textures enabled in the application.
  100368. */
  100369. static get RefractionTextureEnabled(): boolean;
  100370. static set RefractionTextureEnabled(value: boolean);
  100371. /**
  100372. * Are color grading textures enabled in the application.
  100373. */
  100374. static get ColorGradingTextureEnabled(): boolean;
  100375. static set ColorGradingTextureEnabled(value: boolean);
  100376. /**
  100377. * Are fresnels enabled in the application.
  100378. */
  100379. static get FresnelEnabled(): boolean;
  100380. static set FresnelEnabled(value: boolean);
  100381. }
  100382. }
  100383. declare module BABYLON {
  100384. /**
  100385. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100386. *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.
  100387. * The SPS is also a particle system. It provides some methods to manage the particles.
  100388. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100389. *
  100390. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100391. */
  100392. export class SolidParticleSystem implements IDisposable {
  100393. /**
  100394. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100395. * Example : var p = SPS.particles[i];
  100396. */
  100397. particles: SolidParticle[];
  100398. /**
  100399. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100400. */
  100401. nbParticles: number;
  100402. /**
  100403. * If the particles must ever face the camera (default false). Useful for planar particles.
  100404. */
  100405. billboard: boolean;
  100406. /**
  100407. * Recompute normals when adding a shape
  100408. */
  100409. recomputeNormals: boolean;
  100410. /**
  100411. * This a counter ofr your own usage. It's not set by any SPS functions.
  100412. */
  100413. counter: number;
  100414. /**
  100415. * The SPS name. This name is also given to the underlying mesh.
  100416. */
  100417. name: string;
  100418. /**
  100419. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100420. */
  100421. mesh: Mesh;
  100422. /**
  100423. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100424. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100425. */
  100426. vars: any;
  100427. /**
  100428. * This array is populated when the SPS is set as 'pickable'.
  100429. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100430. * Each element of this array is an object `{idx: int, faceId: int}`.
  100431. * `idx` is the picked particle index in the `SPS.particles` array
  100432. * `faceId` is the picked face index counted within this particle.
  100433. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100434. */
  100435. pickedParticles: {
  100436. idx: number;
  100437. faceId: number;
  100438. }[];
  100439. /**
  100440. * This array is populated when `enableDepthSort` is set to true.
  100441. * Each element of this array is an instance of the class DepthSortedParticle.
  100442. */
  100443. depthSortedParticles: DepthSortedParticle[];
  100444. /**
  100445. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100446. * @hidden
  100447. */
  100448. _bSphereOnly: boolean;
  100449. /**
  100450. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100451. * @hidden
  100452. */
  100453. _bSphereRadiusFactor: number;
  100454. private _scene;
  100455. private _positions;
  100456. private _indices;
  100457. private _normals;
  100458. private _colors;
  100459. private _uvs;
  100460. private _indices32;
  100461. private _positions32;
  100462. private _normals32;
  100463. private _fixedNormal32;
  100464. private _colors32;
  100465. private _uvs32;
  100466. private _index;
  100467. private _updatable;
  100468. private _pickable;
  100469. private _isVisibilityBoxLocked;
  100470. private _alwaysVisible;
  100471. private _depthSort;
  100472. private _expandable;
  100473. private _shapeCounter;
  100474. private _copy;
  100475. private _color;
  100476. private _computeParticleColor;
  100477. private _computeParticleTexture;
  100478. private _computeParticleRotation;
  100479. private _computeParticleVertex;
  100480. private _computeBoundingBox;
  100481. private _depthSortParticles;
  100482. private _camera;
  100483. private _mustUnrotateFixedNormals;
  100484. private _particlesIntersect;
  100485. private _needs32Bits;
  100486. private _isNotBuilt;
  100487. private _lastParticleId;
  100488. private _idxOfId;
  100489. private _multimaterialEnabled;
  100490. private _useModelMaterial;
  100491. private _indicesByMaterial;
  100492. private _materialIndexes;
  100493. private _depthSortFunction;
  100494. private _materialSortFunction;
  100495. private _materials;
  100496. private _multimaterial;
  100497. private _materialIndexesById;
  100498. private _defaultMaterial;
  100499. private _autoUpdateSubMeshes;
  100500. /**
  100501. * Creates a SPS (Solid Particle System) object.
  100502. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100503. * @param scene (Scene) is the scene in which the SPS is added.
  100504. * @param options defines the options of the sps e.g.
  100505. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100506. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100507. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100508. * * 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.
  100509. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100510. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100511. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100512. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100513. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100514. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100515. */
  100516. constructor(name: string, scene: Scene, options?: {
  100517. updatable?: boolean;
  100518. isPickable?: boolean;
  100519. enableDepthSort?: boolean;
  100520. particleIntersection?: boolean;
  100521. boundingSphereOnly?: boolean;
  100522. bSphereRadiusFactor?: number;
  100523. expandable?: boolean;
  100524. useModelMaterial?: boolean;
  100525. enableMultiMaterial?: boolean;
  100526. });
  100527. /**
  100528. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100529. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100530. * @returns the created mesh
  100531. */
  100532. buildMesh(): Mesh;
  100533. /**
  100534. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100535. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100536. * Thus the particles generated from `digest()` have their property `position` set yet.
  100537. * @param mesh ( Mesh ) is the mesh to be digested
  100538. * @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
  100539. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100540. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100541. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100542. * @returns the current SPS
  100543. */
  100544. digest(mesh: Mesh, options?: {
  100545. facetNb?: number;
  100546. number?: number;
  100547. delta?: number;
  100548. storage?: [];
  100549. }): SolidParticleSystem;
  100550. /**
  100551. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100552. * @hidden
  100553. */
  100554. private _unrotateFixedNormals;
  100555. /**
  100556. * Resets the temporary working copy particle
  100557. * @hidden
  100558. */
  100559. private _resetCopy;
  100560. /**
  100561. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100562. * @param p the current index in the positions array to be updated
  100563. * @param ind the current index in the indices array
  100564. * @param shape a Vector3 array, the shape geometry
  100565. * @param positions the positions array to be updated
  100566. * @param meshInd the shape indices array
  100567. * @param indices the indices array to be updated
  100568. * @param meshUV the shape uv array
  100569. * @param uvs the uv array to be updated
  100570. * @param meshCol the shape color array
  100571. * @param colors the color array to be updated
  100572. * @param meshNor the shape normals array
  100573. * @param normals the normals array to be updated
  100574. * @param idx the particle index
  100575. * @param idxInShape the particle index in its shape
  100576. * @param options the addShape() method passed options
  100577. * @model the particle model
  100578. * @hidden
  100579. */
  100580. private _meshBuilder;
  100581. /**
  100582. * Returns a shape Vector3 array from positions float array
  100583. * @param positions float array
  100584. * @returns a vector3 array
  100585. * @hidden
  100586. */
  100587. private _posToShape;
  100588. /**
  100589. * Returns a shapeUV array from a float uvs (array deep copy)
  100590. * @param uvs as a float array
  100591. * @returns a shapeUV array
  100592. * @hidden
  100593. */
  100594. private _uvsToShapeUV;
  100595. /**
  100596. * Adds a new particle object in the particles array
  100597. * @param idx particle index in particles array
  100598. * @param id particle id
  100599. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100600. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100601. * @param model particle ModelShape object
  100602. * @param shapeId model shape identifier
  100603. * @param idxInShape index of the particle in the current model
  100604. * @param bInfo model bounding info object
  100605. * @param storage target storage array, if any
  100606. * @hidden
  100607. */
  100608. private _addParticle;
  100609. /**
  100610. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100611. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100612. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100613. * @param nb (positive integer) the number of particles to be created from this model
  100614. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100615. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100616. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100617. * @returns the number of shapes in the system
  100618. */
  100619. addShape(mesh: Mesh, nb: number, options?: {
  100620. positionFunction?: any;
  100621. vertexFunction?: any;
  100622. storage?: [];
  100623. }): number;
  100624. /**
  100625. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100626. * @hidden
  100627. */
  100628. private _rebuildParticle;
  100629. /**
  100630. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100631. * @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.
  100632. * @returns the SPS.
  100633. */
  100634. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100635. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100636. * Returns an array with the removed particles.
  100637. * 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.
  100638. * The SPS can't be empty so at least one particle needs to remain in place.
  100639. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100640. * @param start index of the first particle to remove
  100641. * @param end index of the last particle to remove (included)
  100642. * @returns an array populated with the removed particles
  100643. */
  100644. removeParticles(start: number, end: number): SolidParticle[];
  100645. /**
  100646. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100647. * @param solidParticleArray an array populated with Solid Particles objects
  100648. * @returns the SPS
  100649. */
  100650. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100651. /**
  100652. * Creates a new particle and modifies the SPS mesh geometry :
  100653. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100654. * - calls _addParticle() to populate the particle array
  100655. * factorized code from addShape() and insertParticlesFromArray()
  100656. * @param idx particle index in the particles array
  100657. * @param i particle index in its shape
  100658. * @param modelShape particle ModelShape object
  100659. * @param shape shape vertex array
  100660. * @param meshInd shape indices array
  100661. * @param meshUV shape uv array
  100662. * @param meshCol shape color array
  100663. * @param meshNor shape normals array
  100664. * @param bbInfo shape bounding info
  100665. * @param storage target particle storage
  100666. * @options addShape() passed options
  100667. * @hidden
  100668. */
  100669. private _insertNewParticle;
  100670. /**
  100671. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100672. * This method calls `updateParticle()` for each particle of the SPS.
  100673. * For an animated SPS, it is usually called within the render loop.
  100674. * 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.
  100675. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100676. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100677. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100678. * @returns the SPS.
  100679. */
  100680. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100681. /**
  100682. * Disposes the SPS.
  100683. */
  100684. dispose(): void;
  100685. /**
  100686. * Returns a SolidParticle object from its identifier : particle.id
  100687. * @param id (integer) the particle Id
  100688. * @returns the searched particle or null if not found in the SPS.
  100689. */
  100690. getParticleById(id: number): Nullable<SolidParticle>;
  100691. /**
  100692. * Returns a new array populated with the particles having the passed shapeId.
  100693. * @param shapeId (integer) the shape identifier
  100694. * @returns a new solid particle array
  100695. */
  100696. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100697. /**
  100698. * Populates the passed array "ref" with the particles having the passed shapeId.
  100699. * @param shapeId the shape identifier
  100700. * @returns the SPS
  100701. * @param ref
  100702. */
  100703. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100704. /**
  100705. * Computes the required SubMeshes according the materials assigned to the particles.
  100706. * @returns the solid particle system.
  100707. * Does nothing if called before the SPS mesh is built.
  100708. */
  100709. computeSubMeshes(): SolidParticleSystem;
  100710. /**
  100711. * Sorts the solid particles by material when MultiMaterial is enabled.
  100712. * Updates the indices32 array.
  100713. * Updates the indicesByMaterial array.
  100714. * Updates the mesh indices array.
  100715. * @returns the SPS
  100716. * @hidden
  100717. */
  100718. private _sortParticlesByMaterial;
  100719. /**
  100720. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100721. * @hidden
  100722. */
  100723. private _setMaterialIndexesById;
  100724. /**
  100725. * Returns an array with unique values of Materials from the passed array
  100726. * @param array the material array to be checked and filtered
  100727. * @hidden
  100728. */
  100729. private _filterUniqueMaterialId;
  100730. /**
  100731. * Sets a new Standard Material as _defaultMaterial if not already set.
  100732. * @hidden
  100733. */
  100734. private _setDefaultMaterial;
  100735. /**
  100736. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100738. * @returns the SPS.
  100739. */
  100740. refreshVisibleSize(): SolidParticleSystem;
  100741. /**
  100742. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100743. * @param size the size (float) of the visibility box
  100744. * note : this doesn't lock the SPS mesh bounding box.
  100745. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100746. */
  100747. setVisibilityBox(size: number): void;
  100748. /**
  100749. * Gets whether the SPS as always visible or not
  100750. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100751. */
  100752. get isAlwaysVisible(): boolean;
  100753. /**
  100754. * Sets the SPS as always visible or not
  100755. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100756. */
  100757. set isAlwaysVisible(val: boolean);
  100758. /**
  100759. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100760. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100761. */
  100762. set isVisibilityBoxLocked(val: boolean);
  100763. /**
  100764. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100765. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100766. */
  100767. get isVisibilityBoxLocked(): boolean;
  100768. /**
  100769. * Tells to `setParticles()` to compute the particle rotations or not.
  100770. * Default value : true. The SPS is faster when it's set to false.
  100771. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100772. */
  100773. set computeParticleRotation(val: boolean);
  100774. /**
  100775. * Tells to `setParticles()` to compute the particle colors or not.
  100776. * Default value : true. The SPS is faster when it's set to false.
  100777. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100778. */
  100779. set computeParticleColor(val: boolean);
  100780. set computeParticleTexture(val: boolean);
  100781. /**
  100782. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100783. * Default value : false. The SPS is faster when it's set to false.
  100784. * Note : the particle custom vertex positions aren't stored values.
  100785. */
  100786. set computeParticleVertex(val: boolean);
  100787. /**
  100788. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100789. */
  100790. set computeBoundingBox(val: boolean);
  100791. /**
  100792. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100793. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100794. * Default : `true`
  100795. */
  100796. set depthSortParticles(val: boolean);
  100797. /**
  100798. * Gets if `setParticles()` computes the particle rotations or not.
  100799. * Default value : true. The SPS is faster when it's set to false.
  100800. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100801. */
  100802. get computeParticleRotation(): boolean;
  100803. /**
  100804. * Gets if `setParticles()` computes the particle colors or not.
  100805. * Default value : true. The SPS is faster when it's set to false.
  100806. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100807. */
  100808. get computeParticleColor(): boolean;
  100809. /**
  100810. * Gets if `setParticles()` computes the particle textures or not.
  100811. * Default value : true. The SPS is faster when it's set to false.
  100812. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100813. */
  100814. get computeParticleTexture(): boolean;
  100815. /**
  100816. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100817. * Default value : false. The SPS is faster when it's set to false.
  100818. * Note : the particle custom vertex positions aren't stored values.
  100819. */
  100820. get computeParticleVertex(): boolean;
  100821. /**
  100822. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100823. */
  100824. get computeBoundingBox(): boolean;
  100825. /**
  100826. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100827. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100828. * Default : `true`
  100829. */
  100830. get depthSortParticles(): boolean;
  100831. /**
  100832. * Gets if the SPS is created as expandable at construction time.
  100833. * Default : `false`
  100834. */
  100835. get expandable(): boolean;
  100836. /**
  100837. * Gets if the SPS supports the Multi Materials
  100838. */
  100839. get multimaterialEnabled(): boolean;
  100840. /**
  100841. * Gets if the SPS uses the model materials for its own multimaterial.
  100842. */
  100843. get useModelMaterial(): boolean;
  100844. /**
  100845. * The SPS used material array.
  100846. */
  100847. get materials(): Material[];
  100848. /**
  100849. * Sets the SPS MultiMaterial from the passed materials.
  100850. * Note : the passed array is internally copied and not used then by reference.
  100851. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100852. */
  100853. setMultiMaterial(materials: Material[]): void;
  100854. /**
  100855. * The SPS computed multimaterial object
  100856. */
  100857. get multimaterial(): MultiMaterial;
  100858. set multimaterial(mm: MultiMaterial);
  100859. /**
  100860. * If the subMeshes must be updated on the next call to setParticles()
  100861. */
  100862. get autoUpdateSubMeshes(): boolean;
  100863. set autoUpdateSubMeshes(val: boolean);
  100864. /**
  100865. * This function does nothing. It may be overwritten to set all the particle first values.
  100866. * The SPS doesn't call this function, you may have to call it by your own.
  100867. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100868. */
  100869. initParticles(): void;
  100870. /**
  100871. * This function does nothing. It may be overwritten to recycle a particle.
  100872. * The SPS doesn't call this function, you may have to call it by your own.
  100873. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100874. * @param particle The particle to recycle
  100875. * @returns the recycled particle
  100876. */
  100877. recycleParticle(particle: SolidParticle): SolidParticle;
  100878. /**
  100879. * Updates a particle : this function should be overwritten by the user.
  100880. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100882. * @example : just set a particle position or velocity and recycle conditions
  100883. * @param particle The particle to update
  100884. * @returns the updated particle
  100885. */
  100886. updateParticle(particle: SolidParticle): SolidParticle;
  100887. /**
  100888. * Updates a vertex of a particle : it can be overwritten by the user.
  100889. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100890. * @param particle the current particle
  100891. * @param vertex the current index of the current particle
  100892. * @param pt the index of the current vertex in the particle shape
  100893. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100894. * @example : just set a vertex particle position
  100895. * @returns the updated vertex
  100896. */
  100897. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100898. /**
  100899. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100900. * This does nothing and may be overwritten by the user.
  100901. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100903. * @param update the boolean update value actually passed to setParticles()
  100904. */
  100905. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100906. /**
  100907. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100908. * This will be passed three parameters.
  100909. * This does nothing and may be overwritten by the user.
  100910. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100911. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100912. * @param update the boolean update value actually passed to setParticles()
  100913. */
  100914. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100915. }
  100916. }
  100917. declare module BABYLON {
  100918. /**
  100919. * Represents one particle of a solid particle system.
  100920. */
  100921. export class SolidParticle {
  100922. /**
  100923. * particle global index
  100924. */
  100925. idx: number;
  100926. /**
  100927. * particle identifier
  100928. */
  100929. id: number;
  100930. /**
  100931. * The color of the particle
  100932. */
  100933. color: Nullable<Color4>;
  100934. /**
  100935. * The world space position of the particle.
  100936. */
  100937. position: Vector3;
  100938. /**
  100939. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100940. */
  100941. rotation: Vector3;
  100942. /**
  100943. * The world space rotation quaternion of the particle.
  100944. */
  100945. rotationQuaternion: Nullable<Quaternion>;
  100946. /**
  100947. * The scaling of the particle.
  100948. */
  100949. scaling: Vector3;
  100950. /**
  100951. * The uvs of the particle.
  100952. */
  100953. uvs: Vector4;
  100954. /**
  100955. * The current speed of the particle.
  100956. */
  100957. velocity: Vector3;
  100958. /**
  100959. * The pivot point in the particle local space.
  100960. */
  100961. pivot: Vector3;
  100962. /**
  100963. * Must the particle be translated from its pivot point in its local space ?
  100964. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100965. * Default : false
  100966. */
  100967. translateFromPivot: boolean;
  100968. /**
  100969. * Is the particle active or not ?
  100970. */
  100971. alive: boolean;
  100972. /**
  100973. * Is the particle visible or not ?
  100974. */
  100975. isVisible: boolean;
  100976. /**
  100977. * Index of this particle in the global "positions" array (Internal use)
  100978. * @hidden
  100979. */
  100980. _pos: number;
  100981. /**
  100982. * @hidden Index of this particle in the global "indices" array (Internal use)
  100983. */
  100984. _ind: number;
  100985. /**
  100986. * @hidden ModelShape of this particle (Internal use)
  100987. */
  100988. _model: ModelShape;
  100989. /**
  100990. * ModelShape id of this particle
  100991. */
  100992. shapeId: number;
  100993. /**
  100994. * Index of the particle in its shape id
  100995. */
  100996. idxInShape: number;
  100997. /**
  100998. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100999. */
  101000. _modelBoundingInfo: BoundingInfo;
  101001. /**
  101002. * @hidden Particle BoundingInfo object (Internal use)
  101003. */
  101004. _boundingInfo: BoundingInfo;
  101005. /**
  101006. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  101007. */
  101008. _sps: SolidParticleSystem;
  101009. /**
  101010. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  101011. */
  101012. _stillInvisible: boolean;
  101013. /**
  101014. * @hidden Last computed particle rotation matrix
  101015. */
  101016. _rotationMatrix: number[];
  101017. /**
  101018. * Parent particle Id, if any.
  101019. * Default null.
  101020. */
  101021. parentId: Nullable<number>;
  101022. /**
  101023. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  101024. */
  101025. materialIndex: Nullable<number>;
  101026. /**
  101027. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  101028. * The possible values are :
  101029. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101030. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101033. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101034. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  101035. * */
  101036. cullingStrategy: number;
  101037. /**
  101038. * @hidden Internal global position in the SPS.
  101039. */
  101040. _globalPosition: Vector3;
  101041. /**
  101042. * Creates a Solid Particle object.
  101043. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  101044. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  101045. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  101046. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  101047. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  101048. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  101049. * @param shapeId (integer) is the model shape identifier in the SPS.
  101050. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  101051. * @param sps defines the sps it is associated to
  101052. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  101053. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  101054. */
  101055. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  101056. /**
  101057. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  101058. * @param target the particle target
  101059. * @returns the current particle
  101060. */
  101061. copyToRef(target: SolidParticle): SolidParticle;
  101062. /**
  101063. * Legacy support, changed scale to scaling
  101064. */
  101065. get scale(): Vector3;
  101066. /**
  101067. * Legacy support, changed scale to scaling
  101068. */
  101069. set scale(scale: Vector3);
  101070. /**
  101071. * Legacy support, changed quaternion to rotationQuaternion
  101072. */
  101073. get quaternion(): Nullable<Quaternion>;
  101074. /**
  101075. * Legacy support, changed quaternion to rotationQuaternion
  101076. */
  101077. set quaternion(q: Nullable<Quaternion>);
  101078. /**
  101079. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101080. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101081. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101082. * @returns true if it intersects
  101083. */
  101084. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101085. /**
  101086. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101087. * A particle is in the frustum if its bounding box intersects the frustum
  101088. * @param frustumPlanes defines the frustum to test
  101089. * @returns true if the particle is in the frustum planes
  101090. */
  101091. isInFrustum(frustumPlanes: Plane[]): boolean;
  101092. /**
  101093. * get the rotation matrix of the particle
  101094. * @hidden
  101095. */
  101096. getRotationMatrix(m: Matrix): void;
  101097. }
  101098. /**
  101099. * Represents the shape of the model used by one particle of a solid particle system.
  101100. * SPS internal tool, don't use it manually.
  101101. */
  101102. export class ModelShape {
  101103. /**
  101104. * The shape id
  101105. * @hidden
  101106. */
  101107. shapeID: number;
  101108. /**
  101109. * flat array of model positions (internal use)
  101110. * @hidden
  101111. */
  101112. _shape: Vector3[];
  101113. /**
  101114. * flat array of model UVs (internal use)
  101115. * @hidden
  101116. */
  101117. _shapeUV: number[];
  101118. /**
  101119. * color array of the model
  101120. * @hidden
  101121. */
  101122. _shapeColors: number[];
  101123. /**
  101124. * indices array of the model
  101125. * @hidden
  101126. */
  101127. _indices: number[];
  101128. /**
  101129. * normals array of the model
  101130. * @hidden
  101131. */
  101132. _normals: number[];
  101133. /**
  101134. * length of the shape in the model indices array (internal use)
  101135. * @hidden
  101136. */
  101137. _indicesLength: number;
  101138. /**
  101139. * Custom position function (internal use)
  101140. * @hidden
  101141. */
  101142. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  101143. /**
  101144. * Custom vertex function (internal use)
  101145. * @hidden
  101146. */
  101147. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  101148. /**
  101149. * Model material (internal use)
  101150. * @hidden
  101151. */
  101152. _material: Nullable<Material>;
  101153. /**
  101154. * 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.
  101155. * SPS internal tool, don't use it manually.
  101156. * @hidden
  101157. */
  101158. 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>);
  101159. }
  101160. /**
  101161. * Represents a Depth Sorted Particle in the solid particle system.
  101162. * @hidden
  101163. */
  101164. export class DepthSortedParticle {
  101165. /**
  101166. * Index of the particle in the "indices" array
  101167. */
  101168. ind: number;
  101169. /**
  101170. * Length of the particle shape in the "indices" array
  101171. */
  101172. indicesLength: number;
  101173. /**
  101174. * Squared distance from the particle to the camera
  101175. */
  101176. sqDistance: number;
  101177. /**
  101178. * Material index when used with MultiMaterials
  101179. */
  101180. materialIndex: number;
  101181. /**
  101182. * Creates a new sorted particle
  101183. * @param materialIndex
  101184. */
  101185. constructor(ind: number, indLength: number, materialIndex: number);
  101186. }
  101187. }
  101188. declare module BABYLON {
  101189. /**
  101190. * @hidden
  101191. */
  101192. export class _MeshCollisionData {
  101193. _checkCollisions: boolean;
  101194. _collisionMask: number;
  101195. _collisionGroup: number;
  101196. _collider: Nullable<Collider>;
  101197. _oldPositionForCollisions: Vector3;
  101198. _diffPositionForCollisions: Vector3;
  101199. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101200. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101201. }
  101202. }
  101203. declare module BABYLON {
  101204. /** @hidden */
  101205. class _FacetDataStorage {
  101206. facetPositions: Vector3[];
  101207. facetNormals: Vector3[];
  101208. facetPartitioning: number[][];
  101209. facetNb: number;
  101210. partitioningSubdivisions: number;
  101211. partitioningBBoxRatio: number;
  101212. facetDataEnabled: boolean;
  101213. facetParameters: any;
  101214. bbSize: Vector3;
  101215. subDiv: {
  101216. max: number;
  101217. X: number;
  101218. Y: number;
  101219. Z: number;
  101220. };
  101221. facetDepthSort: boolean;
  101222. facetDepthSortEnabled: boolean;
  101223. depthSortedIndices: IndicesArray;
  101224. depthSortedFacets: {
  101225. ind: number;
  101226. sqDistance: number;
  101227. }[];
  101228. facetDepthSortFunction: (f1: {
  101229. ind: number;
  101230. sqDistance: number;
  101231. }, f2: {
  101232. ind: number;
  101233. sqDistance: number;
  101234. }) => number;
  101235. facetDepthSortFrom: Vector3;
  101236. facetDepthSortOrigin: Vector3;
  101237. invertedMatrix: Matrix;
  101238. }
  101239. /**
  101240. * @hidden
  101241. **/
  101242. class _InternalAbstractMeshDataInfo {
  101243. _hasVertexAlpha: boolean;
  101244. _useVertexColors: boolean;
  101245. _numBoneInfluencers: number;
  101246. _applyFog: boolean;
  101247. _receiveShadows: boolean;
  101248. _facetData: _FacetDataStorage;
  101249. _visibility: number;
  101250. _skeleton: Nullable<Skeleton>;
  101251. _layerMask: number;
  101252. _computeBonesUsingShaders: boolean;
  101253. _isActive: boolean;
  101254. _onlyForInstances: boolean;
  101255. _isActiveIntermediate: boolean;
  101256. _onlyForInstancesIntermediate: boolean;
  101257. _actAsRegularMesh: boolean;
  101258. }
  101259. /**
  101260. * Class used to store all common mesh properties
  101261. */
  101262. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101263. /** No occlusion */
  101264. static OCCLUSION_TYPE_NONE: number;
  101265. /** Occlusion set to optimisitic */
  101266. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101267. /** Occlusion set to strict */
  101268. static OCCLUSION_TYPE_STRICT: number;
  101269. /** Use an accurante occlusion algorithm */
  101270. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101271. /** Use a conservative occlusion algorithm */
  101272. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101273. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101274. * Test order :
  101275. * Is the bounding sphere outside the frustum ?
  101276. * If not, are the bounding box vertices outside the frustum ?
  101277. * It not, then the cullable object is in the frustum.
  101278. */
  101279. static readonly CULLINGSTRATEGY_STANDARD: number;
  101280. /** Culling strategy : Bounding Sphere Only.
  101281. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101282. * It's also less accurate than the standard because some not visible objects can still be selected.
  101283. * Test : is the bounding sphere outside the frustum ?
  101284. * If not, then the cullable object is in the frustum.
  101285. */
  101286. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101287. /** Culling strategy : Optimistic Inclusion.
  101288. * This in an inclusion test first, then the standard exclusion test.
  101289. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101290. * 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.
  101291. * Anyway, it's as accurate as the standard strategy.
  101292. * Test :
  101293. * Is the cullable object bounding sphere center in the frustum ?
  101294. * If not, apply the default culling strategy.
  101295. */
  101296. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101297. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101298. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101299. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101300. * 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.
  101301. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101302. * Test :
  101303. * Is the cullable object bounding sphere center in the frustum ?
  101304. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101305. */
  101306. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101307. /**
  101308. * No billboard
  101309. */
  101310. static get BILLBOARDMODE_NONE(): number;
  101311. /** Billboard on X axis */
  101312. static get BILLBOARDMODE_X(): number;
  101313. /** Billboard on Y axis */
  101314. static get BILLBOARDMODE_Y(): number;
  101315. /** Billboard on Z axis */
  101316. static get BILLBOARDMODE_Z(): number;
  101317. /** Billboard on all axes */
  101318. static get BILLBOARDMODE_ALL(): number;
  101319. /** Billboard on using position instead of orientation */
  101320. static get BILLBOARDMODE_USE_POSITION(): number;
  101321. /** @hidden */
  101322. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101323. /**
  101324. * The culling strategy to use to check whether the mesh must be rendered or not.
  101325. * This value can be changed at any time and will be used on the next render mesh selection.
  101326. * The possible values are :
  101327. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101328. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101329. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101330. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101331. * Please read each static variable documentation to get details about the culling process.
  101332. * */
  101333. cullingStrategy: number;
  101334. /**
  101335. * Gets the number of facets in the mesh
  101336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101337. */
  101338. get facetNb(): number;
  101339. /**
  101340. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101342. */
  101343. get partitioningSubdivisions(): number;
  101344. set partitioningSubdivisions(nb: number);
  101345. /**
  101346. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101347. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101349. */
  101350. get partitioningBBoxRatio(): number;
  101351. set partitioningBBoxRatio(ratio: number);
  101352. /**
  101353. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101354. * Works only for updatable meshes.
  101355. * Doesn't work with multi-materials
  101356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101357. */
  101358. get mustDepthSortFacets(): boolean;
  101359. set mustDepthSortFacets(sort: boolean);
  101360. /**
  101361. * The location (Vector3) where the facet depth sort must be computed from.
  101362. * By default, the active camera position.
  101363. * Used only when facet depth sort is enabled
  101364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101365. */
  101366. get facetDepthSortFrom(): Vector3;
  101367. set facetDepthSortFrom(location: Vector3);
  101368. /**
  101369. * gets a boolean indicating if facetData is enabled
  101370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101371. */
  101372. get isFacetDataEnabled(): boolean;
  101373. /** @hidden */
  101374. _updateNonUniformScalingState(value: boolean): boolean;
  101375. /**
  101376. * An event triggered when this mesh collides with another one
  101377. */
  101378. onCollideObservable: Observable<AbstractMesh>;
  101379. /** Set a function to call when this mesh collides with another one */
  101380. set onCollide(callback: () => void);
  101381. /**
  101382. * An event triggered when the collision's position changes
  101383. */
  101384. onCollisionPositionChangeObservable: Observable<Vector3>;
  101385. /** Set a function to call when the collision's position changes */
  101386. set onCollisionPositionChange(callback: () => void);
  101387. /**
  101388. * An event triggered when material is changed
  101389. */
  101390. onMaterialChangedObservable: Observable<AbstractMesh>;
  101391. /**
  101392. * Gets or sets the orientation for POV movement & rotation
  101393. */
  101394. definedFacingForward: boolean;
  101395. /** @hidden */
  101396. _occlusionQuery: Nullable<WebGLQuery>;
  101397. /** @hidden */
  101398. _renderingGroup: Nullable<RenderingGroup>;
  101399. /**
  101400. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101401. */
  101402. get visibility(): number;
  101403. /**
  101404. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101405. */
  101406. set visibility(value: number);
  101407. /** Gets or sets the alpha index used to sort transparent meshes
  101408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101409. */
  101410. alphaIndex: number;
  101411. /**
  101412. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101413. */
  101414. isVisible: boolean;
  101415. /**
  101416. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101417. */
  101418. isPickable: boolean;
  101419. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101420. showSubMeshesBoundingBox: boolean;
  101421. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101422. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101423. */
  101424. isBlocker: boolean;
  101425. /**
  101426. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101427. */
  101428. enablePointerMoveEvents: boolean;
  101429. /**
  101430. * Specifies the rendering group id for this mesh (0 by default)
  101431. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101432. */
  101433. renderingGroupId: number;
  101434. private _material;
  101435. /** Gets or sets current material */
  101436. get material(): Nullable<Material>;
  101437. set material(value: Nullable<Material>);
  101438. /**
  101439. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101440. * @see http://doc.babylonjs.com/babylon101/shadows
  101441. */
  101442. get receiveShadows(): boolean;
  101443. set receiveShadows(value: boolean);
  101444. /** Defines color to use when rendering outline */
  101445. outlineColor: Color3;
  101446. /** Define width to use when rendering outline */
  101447. outlineWidth: number;
  101448. /** Defines color to use when rendering overlay */
  101449. overlayColor: Color3;
  101450. /** Defines alpha to use when rendering overlay */
  101451. overlayAlpha: number;
  101452. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101453. get hasVertexAlpha(): boolean;
  101454. set hasVertexAlpha(value: boolean);
  101455. /** 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) */
  101456. get useVertexColors(): boolean;
  101457. set useVertexColors(value: boolean);
  101458. /**
  101459. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101460. */
  101461. get computeBonesUsingShaders(): boolean;
  101462. set computeBonesUsingShaders(value: boolean);
  101463. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101464. get numBoneInfluencers(): number;
  101465. set numBoneInfluencers(value: number);
  101466. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101467. get applyFog(): boolean;
  101468. set applyFog(value: boolean);
  101469. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101470. useOctreeForRenderingSelection: boolean;
  101471. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101472. useOctreeForPicking: boolean;
  101473. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101474. useOctreeForCollisions: boolean;
  101475. /**
  101476. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101477. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101478. */
  101479. get layerMask(): number;
  101480. set layerMask(value: number);
  101481. /**
  101482. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101483. */
  101484. alwaysSelectAsActiveMesh: boolean;
  101485. /**
  101486. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101487. */
  101488. doNotSyncBoundingInfo: boolean;
  101489. /**
  101490. * Gets or sets the current action manager
  101491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101492. */
  101493. actionManager: Nullable<AbstractActionManager>;
  101494. private _meshCollisionData;
  101495. /**
  101496. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101498. */
  101499. ellipsoid: Vector3;
  101500. /**
  101501. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101503. */
  101504. ellipsoidOffset: Vector3;
  101505. /**
  101506. * Gets or sets a collision mask used to mask collisions (default is -1).
  101507. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101508. */
  101509. get collisionMask(): number;
  101510. set collisionMask(mask: number);
  101511. /**
  101512. * Gets or sets the current collision group mask (-1 by default).
  101513. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101514. */
  101515. get collisionGroup(): number;
  101516. set collisionGroup(mask: number);
  101517. /**
  101518. * Defines edge width used when edgesRenderer is enabled
  101519. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101520. */
  101521. edgesWidth: number;
  101522. /**
  101523. * Defines edge color used when edgesRenderer is enabled
  101524. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101525. */
  101526. edgesColor: Color4;
  101527. /** @hidden */
  101528. _edgesRenderer: Nullable<IEdgesRenderer>;
  101529. /** @hidden */
  101530. _masterMesh: Nullable<AbstractMesh>;
  101531. /** @hidden */
  101532. _boundingInfo: Nullable<BoundingInfo>;
  101533. /** @hidden */
  101534. _renderId: number;
  101535. /**
  101536. * Gets or sets the list of subMeshes
  101537. * @see http://doc.babylonjs.com/how_to/multi_materials
  101538. */
  101539. subMeshes: SubMesh[];
  101540. /** @hidden */
  101541. _intersectionsInProgress: AbstractMesh[];
  101542. /** @hidden */
  101543. _unIndexed: boolean;
  101544. /** @hidden */
  101545. _lightSources: Light[];
  101546. /** Gets the list of lights affecting that mesh */
  101547. get lightSources(): Light[];
  101548. /** @hidden */
  101549. get _positions(): Nullable<Vector3[]>;
  101550. /** @hidden */
  101551. _waitingData: {
  101552. lods: Nullable<any>;
  101553. actions: Nullable<any>;
  101554. freezeWorldMatrix: Nullable<boolean>;
  101555. };
  101556. /** @hidden */
  101557. _bonesTransformMatrices: Nullable<Float32Array>;
  101558. /** @hidden */
  101559. _transformMatrixTexture: Nullable<RawTexture>;
  101560. /**
  101561. * Gets or sets a skeleton to apply skining transformations
  101562. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101563. */
  101564. set skeleton(value: Nullable<Skeleton>);
  101565. get skeleton(): Nullable<Skeleton>;
  101566. /**
  101567. * An event triggered when the mesh is rebuilt.
  101568. */
  101569. onRebuildObservable: Observable<AbstractMesh>;
  101570. /**
  101571. * Creates a new AbstractMesh
  101572. * @param name defines the name of the mesh
  101573. * @param scene defines the hosting scene
  101574. */
  101575. constructor(name: string, scene?: Nullable<Scene>);
  101576. /**
  101577. * Returns the string "AbstractMesh"
  101578. * @returns "AbstractMesh"
  101579. */
  101580. getClassName(): string;
  101581. /**
  101582. * Gets a string representation of the current mesh
  101583. * @param fullDetails defines a boolean indicating if full details must be included
  101584. * @returns a string representation of the current mesh
  101585. */
  101586. toString(fullDetails?: boolean): string;
  101587. /**
  101588. * @hidden
  101589. */
  101590. protected _getEffectiveParent(): Nullable<Node>;
  101591. /** @hidden */
  101592. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101593. /** @hidden */
  101594. _rebuild(): void;
  101595. /** @hidden */
  101596. _resyncLightSources(): void;
  101597. /** @hidden */
  101598. _resyncLightSource(light: Light): void;
  101599. /** @hidden */
  101600. _unBindEffect(): void;
  101601. /** @hidden */
  101602. _removeLightSource(light: Light, dispose: boolean): void;
  101603. private _markSubMeshesAsDirty;
  101604. /** @hidden */
  101605. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101606. /** @hidden */
  101607. _markSubMeshesAsAttributesDirty(): void;
  101608. /** @hidden */
  101609. _markSubMeshesAsMiscDirty(): void;
  101610. /**
  101611. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101612. */
  101613. get scaling(): Vector3;
  101614. set scaling(newScaling: Vector3);
  101615. /**
  101616. * Returns true if the mesh is blocked. Implemented by child classes
  101617. */
  101618. get isBlocked(): boolean;
  101619. /**
  101620. * Returns the mesh itself by default. Implemented by child classes
  101621. * @param camera defines the camera to use to pick the right LOD level
  101622. * @returns the currentAbstractMesh
  101623. */
  101624. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101625. /**
  101626. * Returns 0 by default. Implemented by child classes
  101627. * @returns an integer
  101628. */
  101629. getTotalVertices(): number;
  101630. /**
  101631. * Returns a positive integer : the total number of indices in this mesh geometry.
  101632. * @returns the numner of indices or zero if the mesh has no geometry.
  101633. */
  101634. getTotalIndices(): number;
  101635. /**
  101636. * Returns null by default. Implemented by child classes
  101637. * @returns null
  101638. */
  101639. getIndices(): Nullable<IndicesArray>;
  101640. /**
  101641. * Returns the array of the requested vertex data kind. Implemented by child classes
  101642. * @param kind defines the vertex data kind to use
  101643. * @returns null
  101644. */
  101645. getVerticesData(kind: string): Nullable<FloatArray>;
  101646. /**
  101647. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101648. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101649. * Note that a new underlying VertexBuffer object is created each call.
  101650. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101651. * @param kind defines vertex data kind:
  101652. * * VertexBuffer.PositionKind
  101653. * * VertexBuffer.UVKind
  101654. * * VertexBuffer.UV2Kind
  101655. * * VertexBuffer.UV3Kind
  101656. * * VertexBuffer.UV4Kind
  101657. * * VertexBuffer.UV5Kind
  101658. * * VertexBuffer.UV6Kind
  101659. * * VertexBuffer.ColorKind
  101660. * * VertexBuffer.MatricesIndicesKind
  101661. * * VertexBuffer.MatricesIndicesExtraKind
  101662. * * VertexBuffer.MatricesWeightsKind
  101663. * * VertexBuffer.MatricesWeightsExtraKind
  101664. * @param data defines the data source
  101665. * @param updatable defines if the data must be flagged as updatable (or static)
  101666. * @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
  101667. * @returns the current mesh
  101668. */
  101669. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101670. /**
  101671. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101672. * If the mesh has no geometry, it is simply returned as it is.
  101673. * @param kind defines vertex data kind:
  101674. * * VertexBuffer.PositionKind
  101675. * * VertexBuffer.UVKind
  101676. * * VertexBuffer.UV2Kind
  101677. * * VertexBuffer.UV3Kind
  101678. * * VertexBuffer.UV4Kind
  101679. * * VertexBuffer.UV5Kind
  101680. * * VertexBuffer.UV6Kind
  101681. * * VertexBuffer.ColorKind
  101682. * * VertexBuffer.MatricesIndicesKind
  101683. * * VertexBuffer.MatricesIndicesExtraKind
  101684. * * VertexBuffer.MatricesWeightsKind
  101685. * * VertexBuffer.MatricesWeightsExtraKind
  101686. * @param data defines the data source
  101687. * @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
  101688. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101689. * @returns the current mesh
  101690. */
  101691. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101692. /**
  101693. * Sets the mesh indices,
  101694. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101695. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101696. * @param totalVertices Defines the total number of vertices
  101697. * @returns the current mesh
  101698. */
  101699. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101700. /**
  101701. * Gets a boolean indicating if specific vertex data is present
  101702. * @param kind defines the vertex data kind to use
  101703. * @returns true is data kind is present
  101704. */
  101705. isVerticesDataPresent(kind: string): boolean;
  101706. /**
  101707. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101708. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101709. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101710. * @returns a BoundingInfo
  101711. */
  101712. getBoundingInfo(): BoundingInfo;
  101713. /**
  101714. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101715. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101716. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101717. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101718. * @returns the current mesh
  101719. */
  101720. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101721. /**
  101722. * Overwrite the current bounding info
  101723. * @param boundingInfo defines the new bounding info
  101724. * @returns the current mesh
  101725. */
  101726. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101727. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101728. get useBones(): boolean;
  101729. /** @hidden */
  101730. _preActivate(): void;
  101731. /** @hidden */
  101732. _preActivateForIntermediateRendering(renderId: number): void;
  101733. /** @hidden */
  101734. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101735. /** @hidden */
  101736. _postActivate(): void;
  101737. /** @hidden */
  101738. _freeze(): void;
  101739. /** @hidden */
  101740. _unFreeze(): void;
  101741. /**
  101742. * Gets the current world matrix
  101743. * @returns a Matrix
  101744. */
  101745. getWorldMatrix(): Matrix;
  101746. /** @hidden */
  101747. _getWorldMatrixDeterminant(): number;
  101748. /**
  101749. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101750. */
  101751. get isAnInstance(): boolean;
  101752. /**
  101753. * Gets a boolean indicating if this mesh has instances
  101754. */
  101755. get hasInstances(): boolean;
  101756. /**
  101757. * Perform relative position change from the point of view of behind the front of the mesh.
  101758. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101759. * Supports definition of mesh facing forward or backward
  101760. * @param amountRight defines the distance on the right axis
  101761. * @param amountUp defines the distance on the up axis
  101762. * @param amountForward defines the distance on the forward axis
  101763. * @returns the current mesh
  101764. */
  101765. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101766. /**
  101767. * Calculate relative position change from the point of view of behind the front of the mesh.
  101768. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101769. * Supports definition of mesh facing forward or backward
  101770. * @param amountRight defines the distance on the right axis
  101771. * @param amountUp defines the distance on the up axis
  101772. * @param amountForward defines the distance on the forward axis
  101773. * @returns the new displacement vector
  101774. */
  101775. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101776. /**
  101777. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101778. * Supports definition of mesh facing forward or backward
  101779. * @param flipBack defines the flip
  101780. * @param twirlClockwise defines the twirl
  101781. * @param tiltRight defines the tilt
  101782. * @returns the current mesh
  101783. */
  101784. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101785. /**
  101786. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101787. * Supports definition of mesh facing forward or backward.
  101788. * @param flipBack defines the flip
  101789. * @param twirlClockwise defines the twirl
  101790. * @param tiltRight defines the tilt
  101791. * @returns the new rotation vector
  101792. */
  101793. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101794. /**
  101795. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101796. * This means the mesh underlying bounding box and sphere are recomputed.
  101797. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101798. * @returns the current mesh
  101799. */
  101800. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101801. /** @hidden */
  101802. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101803. /** @hidden */
  101804. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101805. /** @hidden */
  101806. _updateBoundingInfo(): AbstractMesh;
  101807. /** @hidden */
  101808. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101809. /** @hidden */
  101810. protected _afterComputeWorldMatrix(): void;
  101811. /** @hidden */
  101812. get _effectiveMesh(): AbstractMesh;
  101813. /**
  101814. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101815. * A mesh is in the frustum if its bounding box intersects the frustum
  101816. * @param frustumPlanes defines the frustum to test
  101817. * @returns true if the mesh is in the frustum planes
  101818. */
  101819. isInFrustum(frustumPlanes: Plane[]): boolean;
  101820. /**
  101821. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101822. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101823. * @param frustumPlanes defines the frustum to test
  101824. * @returns true if the mesh is completely in the frustum planes
  101825. */
  101826. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101827. /**
  101828. * True if the mesh intersects another mesh or a SolidParticle object
  101829. * @param mesh defines a target mesh or SolidParticle to test
  101830. * @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)
  101831. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101832. * @returns true if there is an intersection
  101833. */
  101834. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101835. /**
  101836. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101837. * @param point defines the point to test
  101838. * @returns true if there is an intersection
  101839. */
  101840. intersectsPoint(point: Vector3): boolean;
  101841. /**
  101842. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101843. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101844. */
  101845. get checkCollisions(): boolean;
  101846. set checkCollisions(collisionEnabled: boolean);
  101847. /**
  101848. * Gets Collider object used to compute collisions (not physics)
  101849. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101850. */
  101851. get collider(): Nullable<Collider>;
  101852. /**
  101853. * Move the mesh using collision engine
  101854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101855. * @param displacement defines the requested displacement vector
  101856. * @returns the current mesh
  101857. */
  101858. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101859. private _onCollisionPositionChange;
  101860. /** @hidden */
  101861. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101862. /** @hidden */
  101863. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101864. /** @hidden */
  101865. _checkCollision(collider: Collider): AbstractMesh;
  101866. /** @hidden */
  101867. _generatePointsArray(): boolean;
  101868. /**
  101869. * Checks if the passed Ray intersects with the mesh
  101870. * @param ray defines the ray to use
  101871. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101872. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101873. * @returns the picking info
  101874. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101875. */
  101876. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101877. /**
  101878. * Clones the current mesh
  101879. * @param name defines the mesh name
  101880. * @param newParent defines the new mesh parent
  101881. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101882. * @returns the new mesh
  101883. */
  101884. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101885. /**
  101886. * Disposes all the submeshes of the current meshnp
  101887. * @returns the current mesh
  101888. */
  101889. releaseSubMeshes(): AbstractMesh;
  101890. /**
  101891. * Releases resources associated with this abstract mesh.
  101892. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101893. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101894. */
  101895. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101896. /**
  101897. * Adds the passed mesh as a child to the current mesh
  101898. * @param mesh defines the child mesh
  101899. * @returns the current mesh
  101900. */
  101901. addChild(mesh: AbstractMesh): AbstractMesh;
  101902. /**
  101903. * Removes the passed mesh from the current mesh children list
  101904. * @param mesh defines the child mesh
  101905. * @returns the current mesh
  101906. */
  101907. removeChild(mesh: AbstractMesh): AbstractMesh;
  101908. /** @hidden */
  101909. private _initFacetData;
  101910. /**
  101911. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101912. * This method can be called within the render loop.
  101913. * 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
  101914. * @returns the current mesh
  101915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101916. */
  101917. updateFacetData(): AbstractMesh;
  101918. /**
  101919. * Returns the facetLocalNormals array.
  101920. * The normals are expressed in the mesh local spac
  101921. * @returns an array of Vector3
  101922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101923. */
  101924. getFacetLocalNormals(): Vector3[];
  101925. /**
  101926. * Returns the facetLocalPositions array.
  101927. * The facet positions are expressed in the mesh local space
  101928. * @returns an array of Vector3
  101929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101930. */
  101931. getFacetLocalPositions(): Vector3[];
  101932. /**
  101933. * Returns the facetLocalPartioning array
  101934. * @returns an array of array of numbers
  101935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101936. */
  101937. getFacetLocalPartitioning(): number[][];
  101938. /**
  101939. * Returns the i-th facet position in the world system.
  101940. * This method allocates a new Vector3 per call
  101941. * @param i defines the facet index
  101942. * @returns a new Vector3
  101943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101944. */
  101945. getFacetPosition(i: number): Vector3;
  101946. /**
  101947. * Sets the reference Vector3 with the i-th facet position in the world system
  101948. * @param i defines the facet index
  101949. * @param ref defines the target vector
  101950. * @returns the current mesh
  101951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101952. */
  101953. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101954. /**
  101955. * Returns the i-th facet normal in the world system.
  101956. * This method allocates a new Vector3 per call
  101957. * @param i defines the facet index
  101958. * @returns a new Vector3
  101959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101960. */
  101961. getFacetNormal(i: number): Vector3;
  101962. /**
  101963. * Sets the reference Vector3 with the i-th facet normal in the world system
  101964. * @param i defines the facet index
  101965. * @param ref defines the target vector
  101966. * @returns the current mesh
  101967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101968. */
  101969. getFacetNormalToRef(i: number, ref: Vector3): this;
  101970. /**
  101971. * 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)
  101972. * @param x defines x coordinate
  101973. * @param y defines y coordinate
  101974. * @param z defines z coordinate
  101975. * @returns the array of facet indexes
  101976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101977. */
  101978. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101979. /**
  101980. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101981. * @param projected sets as the (x,y,z) world projection on the facet
  101982. * @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
  101983. * @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
  101984. * @param x defines x coordinate
  101985. * @param y defines y coordinate
  101986. * @param z defines z coordinate
  101987. * @returns the face index if found (or null instead)
  101988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101989. */
  101990. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101991. /**
  101992. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101993. * @param projected sets as the (x,y,z) local projection on the facet
  101994. * @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
  101995. * @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
  101996. * @param x defines x coordinate
  101997. * @param y defines y coordinate
  101998. * @param z defines z coordinate
  101999. * @returns the face index if found (or null instead)
  102000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102001. */
  102002. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102003. /**
  102004. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  102005. * @returns the parameters
  102006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102007. */
  102008. getFacetDataParameters(): any;
  102009. /**
  102010. * Disables the feature FacetData and frees the related memory
  102011. * @returns the current mesh
  102012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102013. */
  102014. disableFacetData(): AbstractMesh;
  102015. /**
  102016. * Updates the AbstractMesh indices array
  102017. * @param indices defines the data source
  102018. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  102019. * @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)
  102020. * @returns the current mesh
  102021. */
  102022. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  102023. /**
  102024. * Creates new normals data for the mesh
  102025. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  102026. * @returns the current mesh
  102027. */
  102028. createNormals(updatable: boolean): AbstractMesh;
  102029. /**
  102030. * Align the mesh with a normal
  102031. * @param normal defines the normal to use
  102032. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  102033. * @returns the current mesh
  102034. */
  102035. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  102036. /** @hidden */
  102037. _checkOcclusionQuery(): boolean;
  102038. /**
  102039. * Disables the mesh edge rendering mode
  102040. * @returns the currentAbstractMesh
  102041. */
  102042. disableEdgesRendering(): AbstractMesh;
  102043. /**
  102044. * Enables the edge rendering mode on the mesh.
  102045. * This mode makes the mesh edges visible
  102046. * @param epsilon defines the maximal distance between two angles to detect a face
  102047. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  102048. * @returns the currentAbstractMesh
  102049. * @see https://www.babylonjs-playground.com/#19O9TU#0
  102050. */
  102051. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  102052. }
  102053. }
  102054. declare module BABYLON {
  102055. /**
  102056. * Interface used to define ActionEvent
  102057. */
  102058. export interface IActionEvent {
  102059. /** The mesh or sprite that triggered the action */
  102060. source: any;
  102061. /** The X mouse cursor position at the time of the event */
  102062. pointerX: number;
  102063. /** The Y mouse cursor position at the time of the event */
  102064. pointerY: number;
  102065. /** The mesh that is currently pointed at (can be null) */
  102066. meshUnderPointer: Nullable<AbstractMesh>;
  102067. /** the original (browser) event that triggered the ActionEvent */
  102068. sourceEvent?: any;
  102069. /** additional data for the event */
  102070. additionalData?: any;
  102071. }
  102072. /**
  102073. * ActionEvent is the event being sent when an action is triggered.
  102074. */
  102075. export class ActionEvent implements IActionEvent {
  102076. /** The mesh or sprite that triggered the action */
  102077. source: any;
  102078. /** The X mouse cursor position at the time of the event */
  102079. pointerX: number;
  102080. /** The Y mouse cursor position at the time of the event */
  102081. pointerY: number;
  102082. /** The mesh that is currently pointed at (can be null) */
  102083. meshUnderPointer: Nullable<AbstractMesh>;
  102084. /** the original (browser) event that triggered the ActionEvent */
  102085. sourceEvent?: any;
  102086. /** additional data for the event */
  102087. additionalData?: any;
  102088. /**
  102089. * Creates a new ActionEvent
  102090. * @param source The mesh or sprite that triggered the action
  102091. * @param pointerX The X mouse cursor position at the time of the event
  102092. * @param pointerY The Y mouse cursor position at the time of the event
  102093. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102094. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102095. * @param additionalData additional data for the event
  102096. */
  102097. constructor(
  102098. /** The mesh or sprite that triggered the action */
  102099. source: any,
  102100. /** The X mouse cursor position at the time of the event */
  102101. pointerX: number,
  102102. /** The Y mouse cursor position at the time of the event */
  102103. pointerY: number,
  102104. /** The mesh that is currently pointed at (can be null) */
  102105. meshUnderPointer: Nullable<AbstractMesh>,
  102106. /** the original (browser) event that triggered the ActionEvent */
  102107. sourceEvent?: any,
  102108. /** additional data for the event */
  102109. additionalData?: any);
  102110. /**
  102111. * Helper function to auto-create an ActionEvent from a source mesh.
  102112. * @param source The source mesh that triggered the event
  102113. * @param evt The original (browser) event
  102114. * @param additionalData additional data for the event
  102115. * @returns the new ActionEvent
  102116. */
  102117. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  102118. /**
  102119. * Helper function to auto-create an ActionEvent from a source sprite
  102120. * @param source The source sprite that triggered the event
  102121. * @param scene Scene associated with the sprite
  102122. * @param evt The original (browser) event
  102123. * @param additionalData additional data for the event
  102124. * @returns the new ActionEvent
  102125. */
  102126. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  102127. /**
  102128. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  102129. * @param scene the scene where the event occurred
  102130. * @param evt The original (browser) event
  102131. * @returns the new ActionEvent
  102132. */
  102133. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  102134. /**
  102135. * Helper function to auto-create an ActionEvent from a primitive
  102136. * @param prim defines the target primitive
  102137. * @param pointerPos defines the pointer position
  102138. * @param evt The original (browser) event
  102139. * @param additionalData additional data for the event
  102140. * @returns the new ActionEvent
  102141. */
  102142. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  102143. }
  102144. }
  102145. declare module BABYLON {
  102146. /**
  102147. * Abstract class used to decouple action Manager from scene and meshes.
  102148. * Do not instantiate.
  102149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102150. */
  102151. export abstract class AbstractActionManager implements IDisposable {
  102152. /** Gets the list of active triggers */
  102153. static Triggers: {
  102154. [key: string]: number;
  102155. };
  102156. /** Gets the cursor to use when hovering items */
  102157. hoverCursor: string;
  102158. /** Gets the list of actions */
  102159. actions: IAction[];
  102160. /**
  102161. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  102162. */
  102163. isRecursive: boolean;
  102164. /**
  102165. * Releases all associated resources
  102166. */
  102167. abstract dispose(): void;
  102168. /**
  102169. * Does this action manager has pointer triggers
  102170. */
  102171. abstract get hasPointerTriggers(): boolean;
  102172. /**
  102173. * Does this action manager has pick triggers
  102174. */
  102175. abstract get hasPickTriggers(): boolean;
  102176. /**
  102177. * Process a specific trigger
  102178. * @param trigger defines the trigger to process
  102179. * @param evt defines the event details to be processed
  102180. */
  102181. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102182. /**
  102183. * Does this action manager handles actions of any of the given triggers
  102184. * @param triggers defines the triggers to be tested
  102185. * @return a boolean indicating whether one (or more) of the triggers is handled
  102186. */
  102187. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102188. /**
  102189. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102190. * speed.
  102191. * @param triggerA defines the trigger to be tested
  102192. * @param triggerB defines the trigger to be tested
  102193. * @return a boolean indicating whether one (or more) of the triggers is handled
  102194. */
  102195. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102196. /**
  102197. * Does this action manager handles actions of a given trigger
  102198. * @param trigger defines the trigger to be tested
  102199. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102200. * @return whether the trigger is handled
  102201. */
  102202. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102203. /**
  102204. * Serialize this manager to a JSON object
  102205. * @param name defines the property name to store this manager
  102206. * @returns a JSON representation of this manager
  102207. */
  102208. abstract serialize(name: string): any;
  102209. /**
  102210. * Registers an action to this action manager
  102211. * @param action defines the action to be registered
  102212. * @return the action amended (prepared) after registration
  102213. */
  102214. abstract registerAction(action: IAction): Nullable<IAction>;
  102215. /**
  102216. * Unregisters an action to this action manager
  102217. * @param action defines the action to be unregistered
  102218. * @return a boolean indicating whether the action has been unregistered
  102219. */
  102220. abstract unregisterAction(action: IAction): Boolean;
  102221. /**
  102222. * Does exist one action manager with at least one trigger
  102223. **/
  102224. static get HasTriggers(): boolean;
  102225. /**
  102226. * Does exist one action manager with at least one pick trigger
  102227. **/
  102228. static get HasPickTriggers(): boolean;
  102229. /**
  102230. * Does exist one action manager that handles actions of a given trigger
  102231. * @param trigger defines the trigger to be tested
  102232. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102233. **/
  102234. static HasSpecificTrigger(trigger: number): boolean;
  102235. }
  102236. }
  102237. declare module BABYLON {
  102238. /**
  102239. * Defines how a node can be built from a string name.
  102240. */
  102241. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102242. /**
  102243. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102244. */
  102245. export class Node implements IBehaviorAware<Node> {
  102246. /** @hidden */
  102247. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102248. private static _NodeConstructors;
  102249. /**
  102250. * Add a new node constructor
  102251. * @param type defines the type name of the node to construct
  102252. * @param constructorFunc defines the constructor function
  102253. */
  102254. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102255. /**
  102256. * Returns a node constructor based on type name
  102257. * @param type defines the type name
  102258. * @param name defines the new node name
  102259. * @param scene defines the hosting scene
  102260. * @param options defines optional options to transmit to constructors
  102261. * @returns the new constructor or null
  102262. */
  102263. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102264. /**
  102265. * Gets or sets the name of the node
  102266. */
  102267. name: string;
  102268. /**
  102269. * Gets or sets the id of the node
  102270. */
  102271. id: string;
  102272. /**
  102273. * Gets or sets the unique id of the node
  102274. */
  102275. uniqueId: number;
  102276. /**
  102277. * Gets or sets a string used to store user defined state for the node
  102278. */
  102279. state: string;
  102280. /**
  102281. * Gets or sets an object used to store user defined information for the node
  102282. */
  102283. metadata: any;
  102284. /**
  102285. * For internal use only. Please do not use.
  102286. */
  102287. reservedDataStore: any;
  102288. /**
  102289. * List of inspectable custom properties (used by the Inspector)
  102290. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102291. */
  102292. inspectableCustomProperties: IInspectable[];
  102293. private _doNotSerialize;
  102294. /**
  102295. * Gets or sets a boolean used to define if the node must be serialized
  102296. */
  102297. get doNotSerialize(): boolean;
  102298. set doNotSerialize(value: boolean);
  102299. /** @hidden */
  102300. _isDisposed: boolean;
  102301. /**
  102302. * Gets a list of Animations associated with the node
  102303. */
  102304. animations: Animation[];
  102305. protected _ranges: {
  102306. [name: string]: Nullable<AnimationRange>;
  102307. };
  102308. /**
  102309. * Callback raised when the node is ready to be used
  102310. */
  102311. onReady: Nullable<(node: Node) => void>;
  102312. private _isEnabled;
  102313. private _isParentEnabled;
  102314. private _isReady;
  102315. /** @hidden */
  102316. _currentRenderId: number;
  102317. private _parentUpdateId;
  102318. /** @hidden */
  102319. _childUpdateId: number;
  102320. /** @hidden */
  102321. _waitingParentId: Nullable<string>;
  102322. /** @hidden */
  102323. _scene: Scene;
  102324. /** @hidden */
  102325. _cache: any;
  102326. private _parentNode;
  102327. private _children;
  102328. /** @hidden */
  102329. _worldMatrix: Matrix;
  102330. /** @hidden */
  102331. _worldMatrixDeterminant: number;
  102332. /** @hidden */
  102333. _worldMatrixDeterminantIsDirty: boolean;
  102334. /** @hidden */
  102335. private _sceneRootNodesIndex;
  102336. /**
  102337. * Gets a boolean indicating if the node has been disposed
  102338. * @returns true if the node was disposed
  102339. */
  102340. isDisposed(): boolean;
  102341. /**
  102342. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102343. * @see https://doc.babylonjs.com/how_to/parenting
  102344. */
  102345. set parent(parent: Nullable<Node>);
  102346. get parent(): Nullable<Node>;
  102347. /** @hidden */
  102348. _addToSceneRootNodes(): void;
  102349. /** @hidden */
  102350. _removeFromSceneRootNodes(): void;
  102351. private _animationPropertiesOverride;
  102352. /**
  102353. * Gets or sets the animation properties override
  102354. */
  102355. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102356. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102357. /**
  102358. * Gets a string idenfifying the name of the class
  102359. * @returns "Node" string
  102360. */
  102361. getClassName(): string;
  102362. /** @hidden */
  102363. readonly _isNode: boolean;
  102364. /**
  102365. * An event triggered when the mesh is disposed
  102366. */
  102367. onDisposeObservable: Observable<Node>;
  102368. private _onDisposeObserver;
  102369. /**
  102370. * Sets a callback that will be raised when the node will be disposed
  102371. */
  102372. set onDispose(callback: () => void);
  102373. /**
  102374. * Creates a new Node
  102375. * @param name the name and id to be given to this node
  102376. * @param scene the scene this node will be added to
  102377. */
  102378. constructor(name: string, scene?: Nullable<Scene>);
  102379. /**
  102380. * Gets the scene of the node
  102381. * @returns a scene
  102382. */
  102383. getScene(): Scene;
  102384. /**
  102385. * Gets the engine of the node
  102386. * @returns a Engine
  102387. */
  102388. getEngine(): Engine;
  102389. private _behaviors;
  102390. /**
  102391. * Attach a behavior to the node
  102392. * @see http://doc.babylonjs.com/features/behaviour
  102393. * @param behavior defines the behavior to attach
  102394. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102395. * @returns the current Node
  102396. */
  102397. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102398. /**
  102399. * Remove an attached behavior
  102400. * @see http://doc.babylonjs.com/features/behaviour
  102401. * @param behavior defines the behavior to attach
  102402. * @returns the current Node
  102403. */
  102404. removeBehavior(behavior: Behavior<Node>): Node;
  102405. /**
  102406. * Gets the list of attached behaviors
  102407. * @see http://doc.babylonjs.com/features/behaviour
  102408. */
  102409. get behaviors(): Behavior<Node>[];
  102410. /**
  102411. * Gets an attached behavior by name
  102412. * @param name defines the name of the behavior to look for
  102413. * @see http://doc.babylonjs.com/features/behaviour
  102414. * @returns null if behavior was not found else the requested behavior
  102415. */
  102416. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102417. /**
  102418. * Returns the latest update of the World matrix
  102419. * @returns a Matrix
  102420. */
  102421. getWorldMatrix(): Matrix;
  102422. /** @hidden */
  102423. _getWorldMatrixDeterminant(): number;
  102424. /**
  102425. * Returns directly the latest state of the mesh World matrix.
  102426. * A Matrix is returned.
  102427. */
  102428. get worldMatrixFromCache(): Matrix;
  102429. /** @hidden */
  102430. _initCache(): void;
  102431. /** @hidden */
  102432. updateCache(force?: boolean): void;
  102433. /** @hidden */
  102434. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102435. /** @hidden */
  102436. _updateCache(ignoreParentClass?: boolean): void;
  102437. /** @hidden */
  102438. _isSynchronized(): boolean;
  102439. /** @hidden */
  102440. _markSyncedWithParent(): void;
  102441. /** @hidden */
  102442. isSynchronizedWithParent(): boolean;
  102443. /** @hidden */
  102444. isSynchronized(): boolean;
  102445. /**
  102446. * Is this node ready to be used/rendered
  102447. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102448. * @return true if the node is ready
  102449. */
  102450. isReady(completeCheck?: boolean): boolean;
  102451. /**
  102452. * Is this node enabled?
  102453. * 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
  102454. * @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
  102455. * @return whether this node (and its parent) is enabled
  102456. */
  102457. isEnabled(checkAncestors?: boolean): boolean;
  102458. /** @hidden */
  102459. protected _syncParentEnabledState(): void;
  102460. /**
  102461. * Set the enabled state of this node
  102462. * @param value defines the new enabled state
  102463. */
  102464. setEnabled(value: boolean): void;
  102465. /**
  102466. * Is this node a descendant of the given node?
  102467. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102468. * @param ancestor defines the parent node to inspect
  102469. * @returns a boolean indicating if this node is a descendant of the given node
  102470. */
  102471. isDescendantOf(ancestor: Node): boolean;
  102472. /** @hidden */
  102473. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102474. /**
  102475. * Will return all nodes that have this node as ascendant
  102476. * @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
  102477. * @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
  102478. * @return all children nodes of all types
  102479. */
  102480. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102481. /**
  102482. * Get all child-meshes of this node
  102483. * @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)
  102484. * @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
  102485. * @returns an array of AbstractMesh
  102486. */
  102487. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102488. /**
  102489. * Get all direct children of this node
  102490. * @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
  102491. * @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)
  102492. * @returns an array of Node
  102493. */
  102494. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102495. /** @hidden */
  102496. _setReady(state: boolean): void;
  102497. /**
  102498. * Get an animation by name
  102499. * @param name defines the name of the animation to look for
  102500. * @returns null if not found else the requested animation
  102501. */
  102502. getAnimationByName(name: string): Nullable<Animation>;
  102503. /**
  102504. * Creates an animation range for this node
  102505. * @param name defines the name of the range
  102506. * @param from defines the starting key
  102507. * @param to defines the end key
  102508. */
  102509. createAnimationRange(name: string, from: number, to: number): void;
  102510. /**
  102511. * Delete a specific animation range
  102512. * @param name defines the name of the range to delete
  102513. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102514. */
  102515. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102516. /**
  102517. * Get an animation range by name
  102518. * @param name defines the name of the animation range to look for
  102519. * @returns null if not found else the requested animation range
  102520. */
  102521. getAnimationRange(name: string): Nullable<AnimationRange>;
  102522. /**
  102523. * Gets the list of all animation ranges defined on this node
  102524. * @returns an array
  102525. */
  102526. getAnimationRanges(): Nullable<AnimationRange>[];
  102527. /**
  102528. * Will start the animation sequence
  102529. * @param name defines the range frames for animation sequence
  102530. * @param loop defines if the animation should loop (false by default)
  102531. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102532. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102533. * @returns the object created for this animation. If range does not exist, it will return null
  102534. */
  102535. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102536. /**
  102537. * Serialize animation ranges into a JSON compatible object
  102538. * @returns serialization object
  102539. */
  102540. serializeAnimationRanges(): any;
  102541. /**
  102542. * Computes the world matrix of the node
  102543. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102544. * @returns the world matrix
  102545. */
  102546. computeWorldMatrix(force?: boolean): Matrix;
  102547. /**
  102548. * Releases resources associated with this node.
  102549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102551. */
  102552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102553. /**
  102554. * Parse animation range data from a serialization object and store them into a given node
  102555. * @param node defines where to store the animation ranges
  102556. * @param parsedNode defines the serialization object to read data from
  102557. * @param scene defines the hosting scene
  102558. */
  102559. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102560. /**
  102561. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102562. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102563. * @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
  102564. * @returns the new bounding vectors
  102565. */
  102566. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102567. min: Vector3;
  102568. max: Vector3;
  102569. };
  102570. }
  102571. }
  102572. declare module BABYLON {
  102573. /**
  102574. * @hidden
  102575. */
  102576. export class _IAnimationState {
  102577. key: number;
  102578. repeatCount: number;
  102579. workValue?: any;
  102580. loopMode?: number;
  102581. offsetValue?: any;
  102582. highLimitValue?: any;
  102583. }
  102584. /**
  102585. * Class used to store any kind of animation
  102586. */
  102587. export class Animation {
  102588. /**Name of the animation */
  102589. name: string;
  102590. /**Property to animate */
  102591. targetProperty: string;
  102592. /**The frames per second of the animation */
  102593. framePerSecond: number;
  102594. /**The data type of the animation */
  102595. dataType: number;
  102596. /**The loop mode of the animation */
  102597. loopMode?: number | undefined;
  102598. /**Specifies if blending should be enabled */
  102599. enableBlending?: boolean | undefined;
  102600. /**
  102601. * Use matrix interpolation instead of using direct key value when animating matrices
  102602. */
  102603. static AllowMatricesInterpolation: boolean;
  102604. /**
  102605. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102606. */
  102607. static AllowMatrixDecomposeForInterpolation: boolean;
  102608. /**
  102609. * Stores the key frames of the animation
  102610. */
  102611. private _keys;
  102612. /**
  102613. * Stores the easing function of the animation
  102614. */
  102615. private _easingFunction;
  102616. /**
  102617. * @hidden Internal use only
  102618. */
  102619. _runtimeAnimations: RuntimeAnimation[];
  102620. /**
  102621. * The set of event that will be linked to this animation
  102622. */
  102623. private _events;
  102624. /**
  102625. * Stores an array of target property paths
  102626. */
  102627. targetPropertyPath: string[];
  102628. /**
  102629. * Stores the blending speed of the animation
  102630. */
  102631. blendingSpeed: number;
  102632. /**
  102633. * Stores the animation ranges for the animation
  102634. */
  102635. private _ranges;
  102636. /**
  102637. * @hidden Internal use
  102638. */
  102639. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102640. /**
  102641. * Sets up an animation
  102642. * @param property The property to animate
  102643. * @param animationType The animation type to apply
  102644. * @param framePerSecond The frames per second of the animation
  102645. * @param easingFunction The easing function used in the animation
  102646. * @returns The created animation
  102647. */
  102648. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102649. /**
  102650. * Create and start an animation on a node
  102651. * @param name defines the name of the global animation that will be run on all nodes
  102652. * @param node defines the root node where the animation will take place
  102653. * @param targetProperty defines property to animate
  102654. * @param framePerSecond defines the number of frame per second yo use
  102655. * @param totalFrame defines the number of frames in total
  102656. * @param from defines the initial value
  102657. * @param to defines the final value
  102658. * @param loopMode defines which loop mode you want to use (off by default)
  102659. * @param easingFunction defines the easing function to use (linear by default)
  102660. * @param onAnimationEnd defines the callback to call when animation end
  102661. * @returns the animatable created for this animation
  102662. */
  102663. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102664. /**
  102665. * Create and start an animation on a node and its descendants
  102666. * @param name defines the name of the global animation that will be run on all nodes
  102667. * @param node defines the root node where the animation will take place
  102668. * @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
  102669. * @param targetProperty defines property to animate
  102670. * @param framePerSecond defines the number of frame per second to use
  102671. * @param totalFrame defines the number of frames in total
  102672. * @param from defines the initial value
  102673. * @param to defines the final value
  102674. * @param loopMode defines which loop mode you want to use (off by default)
  102675. * @param easingFunction defines the easing function to use (linear by default)
  102676. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102677. * @returns the list of animatables created for all nodes
  102678. * @example https://www.babylonjs-playground.com/#MH0VLI
  102679. */
  102680. 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[]>;
  102681. /**
  102682. * Creates a new animation, merges it with the existing animations and starts it
  102683. * @param name Name of the animation
  102684. * @param node Node which contains the scene that begins the animations
  102685. * @param targetProperty Specifies which property to animate
  102686. * @param framePerSecond The frames per second of the animation
  102687. * @param totalFrame The total number of frames
  102688. * @param from The frame at the beginning of the animation
  102689. * @param to The frame at the end of the animation
  102690. * @param loopMode Specifies the loop mode of the animation
  102691. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102692. * @param onAnimationEnd Callback to run once the animation is complete
  102693. * @returns Nullable animation
  102694. */
  102695. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102696. /**
  102697. * Transition property of an host to the target Value
  102698. * @param property The property to transition
  102699. * @param targetValue The target Value of the property
  102700. * @param host The object where the property to animate belongs
  102701. * @param scene Scene used to run the animation
  102702. * @param frameRate Framerate (in frame/s) to use
  102703. * @param transition The transition type we want to use
  102704. * @param duration The duration of the animation, in milliseconds
  102705. * @param onAnimationEnd Callback trigger at the end of the animation
  102706. * @returns Nullable animation
  102707. */
  102708. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102709. /**
  102710. * Return the array of runtime animations currently using this animation
  102711. */
  102712. get runtimeAnimations(): RuntimeAnimation[];
  102713. /**
  102714. * Specifies if any of the runtime animations are currently running
  102715. */
  102716. get hasRunningRuntimeAnimations(): boolean;
  102717. /**
  102718. * Initializes the animation
  102719. * @param name Name of the animation
  102720. * @param targetProperty Property to animate
  102721. * @param framePerSecond The frames per second of the animation
  102722. * @param dataType The data type of the animation
  102723. * @param loopMode The loop mode of the animation
  102724. * @param enableBlending Specifies if blending should be enabled
  102725. */
  102726. constructor(
  102727. /**Name of the animation */
  102728. name: string,
  102729. /**Property to animate */
  102730. targetProperty: string,
  102731. /**The frames per second of the animation */
  102732. framePerSecond: number,
  102733. /**The data type of the animation */
  102734. dataType: number,
  102735. /**The loop mode of the animation */
  102736. loopMode?: number | undefined,
  102737. /**Specifies if blending should be enabled */
  102738. enableBlending?: boolean | undefined);
  102739. /**
  102740. * Converts the animation to a string
  102741. * @param fullDetails support for multiple levels of logging within scene loading
  102742. * @returns String form of the animation
  102743. */
  102744. toString(fullDetails?: boolean): string;
  102745. /**
  102746. * Add an event to this animation
  102747. * @param event Event to add
  102748. */
  102749. addEvent(event: AnimationEvent): void;
  102750. /**
  102751. * Remove all events found at the given frame
  102752. * @param frame The frame to remove events from
  102753. */
  102754. removeEvents(frame: number): void;
  102755. /**
  102756. * Retrieves all the events from the animation
  102757. * @returns Events from the animation
  102758. */
  102759. getEvents(): AnimationEvent[];
  102760. /**
  102761. * Creates an animation range
  102762. * @param name Name of the animation range
  102763. * @param from Starting frame of the animation range
  102764. * @param to Ending frame of the animation
  102765. */
  102766. createRange(name: string, from: number, to: number): void;
  102767. /**
  102768. * Deletes an animation range by name
  102769. * @param name Name of the animation range to delete
  102770. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102771. */
  102772. deleteRange(name: string, deleteFrames?: boolean): void;
  102773. /**
  102774. * Gets the animation range by name, or null if not defined
  102775. * @param name Name of the animation range
  102776. * @returns Nullable animation range
  102777. */
  102778. getRange(name: string): Nullable<AnimationRange>;
  102779. /**
  102780. * Gets the key frames from the animation
  102781. * @returns The key frames of the animation
  102782. */
  102783. getKeys(): Array<IAnimationKey>;
  102784. /**
  102785. * Gets the highest frame rate of the animation
  102786. * @returns Highest frame rate of the animation
  102787. */
  102788. getHighestFrame(): number;
  102789. /**
  102790. * Gets the easing function of the animation
  102791. * @returns Easing function of the animation
  102792. */
  102793. getEasingFunction(): IEasingFunction;
  102794. /**
  102795. * Sets the easing function of the animation
  102796. * @param easingFunction A custom mathematical formula for animation
  102797. */
  102798. setEasingFunction(easingFunction: EasingFunction): void;
  102799. /**
  102800. * Interpolates a scalar linearly
  102801. * @param startValue Start value of the animation curve
  102802. * @param endValue End value of the animation curve
  102803. * @param gradient Scalar amount to interpolate
  102804. * @returns Interpolated scalar value
  102805. */
  102806. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102807. /**
  102808. * Interpolates a scalar cubically
  102809. * @param startValue Start value of the animation curve
  102810. * @param outTangent End tangent of the animation
  102811. * @param endValue End value of the animation curve
  102812. * @param inTangent Start tangent of the animation curve
  102813. * @param gradient Scalar amount to interpolate
  102814. * @returns Interpolated scalar value
  102815. */
  102816. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102817. /**
  102818. * Interpolates a quaternion using a spherical linear interpolation
  102819. * @param startValue Start value of the animation curve
  102820. * @param endValue End value of the animation curve
  102821. * @param gradient Scalar amount to interpolate
  102822. * @returns Interpolated quaternion value
  102823. */
  102824. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102825. /**
  102826. * Interpolates a quaternion cubically
  102827. * @param startValue Start value of the animation curve
  102828. * @param outTangent End tangent of the animation curve
  102829. * @param endValue End value of the animation curve
  102830. * @param inTangent Start tangent of the animation curve
  102831. * @param gradient Scalar amount to interpolate
  102832. * @returns Interpolated quaternion value
  102833. */
  102834. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102835. /**
  102836. * Interpolates a Vector3 linearl
  102837. * @param startValue Start value of the animation curve
  102838. * @param endValue End value of the animation curve
  102839. * @param gradient Scalar amount to interpolate
  102840. * @returns Interpolated scalar value
  102841. */
  102842. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102843. /**
  102844. * Interpolates a Vector3 cubically
  102845. * @param startValue Start value of the animation curve
  102846. * @param outTangent End tangent of the animation
  102847. * @param endValue End value of the animation curve
  102848. * @param inTangent Start tangent of the animation curve
  102849. * @param gradient Scalar amount to interpolate
  102850. * @returns InterpolatedVector3 value
  102851. */
  102852. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102853. /**
  102854. * Interpolates a Vector2 linearly
  102855. * @param startValue Start value of the animation curve
  102856. * @param endValue End value of the animation curve
  102857. * @param gradient Scalar amount to interpolate
  102858. * @returns Interpolated Vector2 value
  102859. */
  102860. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102861. /**
  102862. * Interpolates a Vector2 cubically
  102863. * @param startValue Start value of the animation curve
  102864. * @param outTangent End tangent of the animation
  102865. * @param endValue End value of the animation curve
  102866. * @param inTangent Start tangent of the animation curve
  102867. * @param gradient Scalar amount to interpolate
  102868. * @returns Interpolated Vector2 value
  102869. */
  102870. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102871. /**
  102872. * Interpolates a size linearly
  102873. * @param startValue Start value of the animation curve
  102874. * @param endValue End value of the animation curve
  102875. * @param gradient Scalar amount to interpolate
  102876. * @returns Interpolated Size value
  102877. */
  102878. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102879. /**
  102880. * Interpolates a Color3 linearly
  102881. * @param startValue Start value of the animation curve
  102882. * @param endValue End value of the animation curve
  102883. * @param gradient Scalar amount to interpolate
  102884. * @returns Interpolated Color3 value
  102885. */
  102886. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102887. /**
  102888. * Interpolates a Color4 linearly
  102889. * @param startValue Start value of the animation curve
  102890. * @param endValue End value of the animation curve
  102891. * @param gradient Scalar amount to interpolate
  102892. * @returns Interpolated Color3 value
  102893. */
  102894. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102895. /**
  102896. * @hidden Internal use only
  102897. */
  102898. _getKeyValue(value: any): any;
  102899. /**
  102900. * @hidden Internal use only
  102901. */
  102902. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102903. /**
  102904. * Defines the function to use to interpolate matrices
  102905. * @param startValue defines the start matrix
  102906. * @param endValue defines the end matrix
  102907. * @param gradient defines the gradient between both matrices
  102908. * @param result defines an optional target matrix where to store the interpolation
  102909. * @returns the interpolated matrix
  102910. */
  102911. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102912. /**
  102913. * Makes a copy of the animation
  102914. * @returns Cloned animation
  102915. */
  102916. clone(): Animation;
  102917. /**
  102918. * Sets the key frames of the animation
  102919. * @param values The animation key frames to set
  102920. */
  102921. setKeys(values: Array<IAnimationKey>): void;
  102922. /**
  102923. * Serializes the animation to an object
  102924. * @returns Serialized object
  102925. */
  102926. serialize(): any;
  102927. /**
  102928. * Float animation type
  102929. */
  102930. static readonly ANIMATIONTYPE_FLOAT: number;
  102931. /**
  102932. * Vector3 animation type
  102933. */
  102934. static readonly ANIMATIONTYPE_VECTOR3: number;
  102935. /**
  102936. * Quaternion animation type
  102937. */
  102938. static readonly ANIMATIONTYPE_QUATERNION: number;
  102939. /**
  102940. * Matrix animation type
  102941. */
  102942. static readonly ANIMATIONTYPE_MATRIX: number;
  102943. /**
  102944. * Color3 animation type
  102945. */
  102946. static readonly ANIMATIONTYPE_COLOR3: number;
  102947. /**
  102948. * Color3 animation type
  102949. */
  102950. static readonly ANIMATIONTYPE_COLOR4: number;
  102951. /**
  102952. * Vector2 animation type
  102953. */
  102954. static readonly ANIMATIONTYPE_VECTOR2: number;
  102955. /**
  102956. * Size animation type
  102957. */
  102958. static readonly ANIMATIONTYPE_SIZE: number;
  102959. /**
  102960. * Relative Loop Mode
  102961. */
  102962. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102963. /**
  102964. * Cycle Loop Mode
  102965. */
  102966. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102967. /**
  102968. * Constant Loop Mode
  102969. */
  102970. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102971. /** @hidden */
  102972. static _UniversalLerp(left: any, right: any, amount: number): any;
  102973. /**
  102974. * Parses an animation object and creates an animation
  102975. * @param parsedAnimation Parsed animation object
  102976. * @returns Animation object
  102977. */
  102978. static Parse(parsedAnimation: any): Animation;
  102979. /**
  102980. * Appends the serialized animations from the source animations
  102981. * @param source Source containing the animations
  102982. * @param destination Target to store the animations
  102983. */
  102984. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102985. }
  102986. }
  102987. declare module BABYLON {
  102988. /**
  102989. * Interface containing an array of animations
  102990. */
  102991. export interface IAnimatable {
  102992. /**
  102993. * Array of animations
  102994. */
  102995. animations: Nullable<Array<Animation>>;
  102996. }
  102997. }
  102998. declare module BABYLON {
  102999. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  103000. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103001. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103002. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103003. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103004. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103005. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103006. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103007. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103008. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103009. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103010. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103011. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103012. /**
  103013. * Decorator used to define property that can be serialized as reference to a camera
  103014. * @param sourceName defines the name of the property to decorate
  103015. */
  103016. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103017. /**
  103018. * Class used to help serialization objects
  103019. */
  103020. export class SerializationHelper {
  103021. /** @hidden */
  103022. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  103023. /** @hidden */
  103024. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  103025. /** @hidden */
  103026. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  103027. /** @hidden */
  103028. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  103029. /**
  103030. * Appends the serialized animations from the source animations
  103031. * @param source Source containing the animations
  103032. * @param destination Target to store the animations
  103033. */
  103034. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103035. /**
  103036. * Static function used to serialized a specific entity
  103037. * @param entity defines the entity to serialize
  103038. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  103039. * @returns a JSON compatible object representing the serialization of the entity
  103040. */
  103041. static Serialize<T>(entity: T, serializationObject?: any): any;
  103042. /**
  103043. * Creates a new entity from a serialization data object
  103044. * @param creationFunction defines a function used to instanciated the new entity
  103045. * @param source defines the source serialization data
  103046. * @param scene defines the hosting scene
  103047. * @param rootUrl defines the root url for resources
  103048. * @returns a new entity
  103049. */
  103050. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  103051. /**
  103052. * Clones an object
  103053. * @param creationFunction defines the function used to instanciate the new object
  103054. * @param source defines the source object
  103055. * @returns the cloned object
  103056. */
  103057. static Clone<T>(creationFunction: () => T, source: T): T;
  103058. /**
  103059. * Instanciates a new object based on a source one (some data will be shared between both object)
  103060. * @param creationFunction defines the function used to instanciate the new object
  103061. * @param source defines the source object
  103062. * @returns the new object
  103063. */
  103064. static Instanciate<T>(creationFunction: () => T, source: T): T;
  103065. }
  103066. }
  103067. declare module BABYLON {
  103068. /**
  103069. * Class used to manipulate GUIDs
  103070. */
  103071. export class GUID {
  103072. /**
  103073. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103074. * Be aware Math.random() could cause collisions, but:
  103075. * "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"
  103076. * @returns a pseudo random id
  103077. */
  103078. static RandomId(): string;
  103079. }
  103080. }
  103081. declare module BABYLON {
  103082. /**
  103083. * Base class of all the textures in babylon.
  103084. * It groups all the common properties the materials, post process, lights... might need
  103085. * in order to make a correct use of the texture.
  103086. */
  103087. export class BaseTexture implements IAnimatable {
  103088. /**
  103089. * Default anisotropic filtering level for the application.
  103090. * It is set to 4 as a good tradeoff between perf and quality.
  103091. */
  103092. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  103093. /**
  103094. * Gets or sets the unique id of the texture
  103095. */
  103096. uniqueId: number;
  103097. /**
  103098. * Define the name of the texture.
  103099. */
  103100. name: string;
  103101. /**
  103102. * Gets or sets an object used to store user defined information.
  103103. */
  103104. metadata: any;
  103105. /**
  103106. * For internal use only. Please do not use.
  103107. */
  103108. reservedDataStore: any;
  103109. private _hasAlpha;
  103110. /**
  103111. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  103112. */
  103113. set hasAlpha(value: boolean);
  103114. get hasAlpha(): boolean;
  103115. /**
  103116. * Defines if the alpha value should be determined via the rgb values.
  103117. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  103118. */
  103119. getAlphaFromRGB: boolean;
  103120. /**
  103121. * Intensity or strength of the texture.
  103122. * It is commonly used by materials to fine tune the intensity of the texture
  103123. */
  103124. level: number;
  103125. /**
  103126. * Define the UV chanel to use starting from 0 and defaulting to 0.
  103127. * This is part of the texture as textures usually maps to one uv set.
  103128. */
  103129. coordinatesIndex: number;
  103130. private _coordinatesMode;
  103131. /**
  103132. * How a texture is mapped.
  103133. *
  103134. * | Value | Type | Description |
  103135. * | ----- | ----------------------------------- | ----------- |
  103136. * | 0 | EXPLICIT_MODE | |
  103137. * | 1 | SPHERICAL_MODE | |
  103138. * | 2 | PLANAR_MODE | |
  103139. * | 3 | CUBIC_MODE | |
  103140. * | 4 | PROJECTION_MODE | |
  103141. * | 5 | SKYBOX_MODE | |
  103142. * | 6 | INVCUBIC_MODE | |
  103143. * | 7 | EQUIRECTANGULAR_MODE | |
  103144. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  103145. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  103146. */
  103147. set coordinatesMode(value: number);
  103148. get coordinatesMode(): number;
  103149. /**
  103150. * | Value | Type | Description |
  103151. * | ----- | ------------------ | ----------- |
  103152. * | 0 | CLAMP_ADDRESSMODE | |
  103153. * | 1 | WRAP_ADDRESSMODE | |
  103154. * | 2 | MIRROR_ADDRESSMODE | |
  103155. */
  103156. wrapU: number;
  103157. /**
  103158. * | Value | Type | Description |
  103159. * | ----- | ------------------ | ----------- |
  103160. * | 0 | CLAMP_ADDRESSMODE | |
  103161. * | 1 | WRAP_ADDRESSMODE | |
  103162. * | 2 | MIRROR_ADDRESSMODE | |
  103163. */
  103164. wrapV: number;
  103165. /**
  103166. * | Value | Type | Description |
  103167. * | ----- | ------------------ | ----------- |
  103168. * | 0 | CLAMP_ADDRESSMODE | |
  103169. * | 1 | WRAP_ADDRESSMODE | |
  103170. * | 2 | MIRROR_ADDRESSMODE | |
  103171. */
  103172. wrapR: number;
  103173. /**
  103174. * With compliant hardware and browser (supporting anisotropic filtering)
  103175. * this defines the level of anisotropic filtering in the texture.
  103176. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103177. */
  103178. anisotropicFilteringLevel: number;
  103179. /**
  103180. * Define if the texture is a cube texture or if false a 2d texture.
  103181. */
  103182. get isCube(): boolean;
  103183. set isCube(value: boolean);
  103184. /**
  103185. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103186. */
  103187. get is3D(): boolean;
  103188. set is3D(value: boolean);
  103189. /**
  103190. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103191. */
  103192. get is2DArray(): boolean;
  103193. set is2DArray(value: boolean);
  103194. /**
  103195. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103196. * HDR texture are usually stored in linear space.
  103197. * This only impacts the PBR and Background materials
  103198. */
  103199. gammaSpace: boolean;
  103200. /**
  103201. * Gets or sets whether or not the texture contains RGBD data.
  103202. */
  103203. get isRGBD(): boolean;
  103204. set isRGBD(value: boolean);
  103205. /**
  103206. * Is Z inverted in the texture (useful in a cube texture).
  103207. */
  103208. invertZ: boolean;
  103209. /**
  103210. * Are mip maps generated for this texture or not.
  103211. */
  103212. get noMipmap(): boolean;
  103213. /**
  103214. * @hidden
  103215. */
  103216. lodLevelInAlpha: boolean;
  103217. /**
  103218. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103219. */
  103220. get lodGenerationOffset(): number;
  103221. set lodGenerationOffset(value: number);
  103222. /**
  103223. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103224. */
  103225. get lodGenerationScale(): number;
  103226. set lodGenerationScale(value: number);
  103227. /**
  103228. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103229. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103230. * average roughness values.
  103231. */
  103232. get linearSpecularLOD(): boolean;
  103233. set linearSpecularLOD(value: boolean);
  103234. /**
  103235. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103236. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103237. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103238. */
  103239. get irradianceTexture(): Nullable<BaseTexture>;
  103240. set irradianceTexture(value: Nullable<BaseTexture>);
  103241. /**
  103242. * Define if the texture is a render target.
  103243. */
  103244. isRenderTarget: boolean;
  103245. /**
  103246. * Define the unique id of the texture in the scene.
  103247. */
  103248. get uid(): string;
  103249. /**
  103250. * Return a string representation of the texture.
  103251. * @returns the texture as a string
  103252. */
  103253. toString(): string;
  103254. /**
  103255. * Get the class name of the texture.
  103256. * @returns "BaseTexture"
  103257. */
  103258. getClassName(): string;
  103259. /**
  103260. * Define the list of animation attached to the texture.
  103261. */
  103262. animations: Animation[];
  103263. /**
  103264. * An event triggered when the texture is disposed.
  103265. */
  103266. onDisposeObservable: Observable<BaseTexture>;
  103267. private _onDisposeObserver;
  103268. /**
  103269. * Callback triggered when the texture has been disposed.
  103270. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103271. */
  103272. set onDispose(callback: () => void);
  103273. /**
  103274. * Define the current state of the loading sequence when in delayed load mode.
  103275. */
  103276. delayLoadState: number;
  103277. private _scene;
  103278. /** @hidden */
  103279. _texture: Nullable<InternalTexture>;
  103280. private _uid;
  103281. /**
  103282. * Define if the texture is preventinga material to render or not.
  103283. * If not and the texture is not ready, the engine will use a default black texture instead.
  103284. */
  103285. get isBlocking(): boolean;
  103286. /**
  103287. * Instantiates a new BaseTexture.
  103288. * Base class of all the textures in babylon.
  103289. * It groups all the common properties the materials, post process, lights... might need
  103290. * in order to make a correct use of the texture.
  103291. * @param scene Define the scene the texture blongs to
  103292. */
  103293. constructor(scene: Nullable<Scene>);
  103294. /**
  103295. * Get the scene the texture belongs to.
  103296. * @returns the scene or null if undefined
  103297. */
  103298. getScene(): Nullable<Scene>;
  103299. /**
  103300. * Get the texture transform matrix used to offset tile the texture for istance.
  103301. * @returns the transformation matrix
  103302. */
  103303. getTextureMatrix(): Matrix;
  103304. /**
  103305. * Get the texture reflection matrix used to rotate/transform the reflection.
  103306. * @returns the reflection matrix
  103307. */
  103308. getReflectionTextureMatrix(): Matrix;
  103309. /**
  103310. * Get the underlying lower level texture from Babylon.
  103311. * @returns the insternal texture
  103312. */
  103313. getInternalTexture(): Nullable<InternalTexture>;
  103314. /**
  103315. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103316. * @returns true if ready or not blocking
  103317. */
  103318. isReadyOrNotBlocking(): boolean;
  103319. /**
  103320. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103321. * @returns true if fully ready
  103322. */
  103323. isReady(): boolean;
  103324. private _cachedSize;
  103325. /**
  103326. * Get the size of the texture.
  103327. * @returns the texture size.
  103328. */
  103329. getSize(): ISize;
  103330. /**
  103331. * Get the base size of the texture.
  103332. * It can be different from the size if the texture has been resized for POT for instance
  103333. * @returns the base size
  103334. */
  103335. getBaseSize(): ISize;
  103336. /**
  103337. * Update the sampling mode of the texture.
  103338. * Default is Trilinear mode.
  103339. *
  103340. * | Value | Type | Description |
  103341. * | ----- | ------------------ | ----------- |
  103342. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103343. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103344. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103345. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103346. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103347. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103348. * | 7 | NEAREST_LINEAR | |
  103349. * | 8 | NEAREST_NEAREST | |
  103350. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103351. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103352. * | 11 | LINEAR_LINEAR | |
  103353. * | 12 | LINEAR_NEAREST | |
  103354. *
  103355. * > _mag_: magnification filter (close to the viewer)
  103356. * > _min_: minification filter (far from the viewer)
  103357. * > _mip_: filter used between mip map levels
  103358. *@param samplingMode Define the new sampling mode of the texture
  103359. */
  103360. updateSamplingMode(samplingMode: number): void;
  103361. /**
  103362. * Scales the texture if is `canRescale()`
  103363. * @param ratio the resize factor we want to use to rescale
  103364. */
  103365. scale(ratio: number): void;
  103366. /**
  103367. * Get if the texture can rescale.
  103368. */
  103369. get canRescale(): boolean;
  103370. /** @hidden */
  103371. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103372. /** @hidden */
  103373. _rebuild(): void;
  103374. /**
  103375. * Triggers the load sequence in delayed load mode.
  103376. */
  103377. delayLoad(): void;
  103378. /**
  103379. * Clones the texture.
  103380. * @returns the cloned texture
  103381. */
  103382. clone(): Nullable<BaseTexture>;
  103383. /**
  103384. * Get the texture underlying type (INT, FLOAT...)
  103385. */
  103386. get textureType(): number;
  103387. /**
  103388. * Get the texture underlying format (RGB, RGBA...)
  103389. */
  103390. get textureFormat(): number;
  103391. /**
  103392. * Indicates that textures need to be re-calculated for all materials
  103393. */
  103394. protected _markAllSubMeshesAsTexturesDirty(): void;
  103395. /**
  103396. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103397. * This will returns an RGBA array buffer containing either in values (0-255) or
  103398. * float values (0-1) depending of the underlying buffer type.
  103399. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103400. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103401. * @param buffer defines a user defined buffer to fill with data (can be null)
  103402. * @returns The Array buffer containing the pixels data.
  103403. */
  103404. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103405. /**
  103406. * Release and destroy the underlying lower level texture aka internalTexture.
  103407. */
  103408. releaseInternalTexture(): void;
  103409. /** @hidden */
  103410. get _lodTextureHigh(): Nullable<BaseTexture>;
  103411. /** @hidden */
  103412. get _lodTextureMid(): Nullable<BaseTexture>;
  103413. /** @hidden */
  103414. get _lodTextureLow(): Nullable<BaseTexture>;
  103415. /**
  103416. * Dispose the texture and release its associated resources.
  103417. */
  103418. dispose(): void;
  103419. /**
  103420. * Serialize the texture into a JSON representation that can be parsed later on.
  103421. * @returns the JSON representation of the texture
  103422. */
  103423. serialize(): any;
  103424. /**
  103425. * Helper function to be called back once a list of texture contains only ready textures.
  103426. * @param textures Define the list of textures to wait for
  103427. * @param callback Define the callback triggered once the entire list will be ready
  103428. */
  103429. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103430. }
  103431. }
  103432. declare module BABYLON {
  103433. /**
  103434. * Options to be used when creating an effect.
  103435. */
  103436. export interface IEffectCreationOptions {
  103437. /**
  103438. * Atrributes that will be used in the shader.
  103439. */
  103440. attributes: string[];
  103441. /**
  103442. * Uniform varible names that will be set in the shader.
  103443. */
  103444. uniformsNames: string[];
  103445. /**
  103446. * Uniform buffer variable names that will be set in the shader.
  103447. */
  103448. uniformBuffersNames: string[];
  103449. /**
  103450. * Sampler texture variable names that will be set in the shader.
  103451. */
  103452. samplers: string[];
  103453. /**
  103454. * Define statements that will be set in the shader.
  103455. */
  103456. defines: any;
  103457. /**
  103458. * Possible fallbacks for this effect to improve performance when needed.
  103459. */
  103460. fallbacks: Nullable<IEffectFallbacks>;
  103461. /**
  103462. * Callback that will be called when the shader is compiled.
  103463. */
  103464. onCompiled: Nullable<(effect: Effect) => void>;
  103465. /**
  103466. * Callback that will be called if an error occurs during shader compilation.
  103467. */
  103468. onError: Nullable<(effect: Effect, errors: string) => void>;
  103469. /**
  103470. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103471. */
  103472. indexParameters?: any;
  103473. /**
  103474. * Max number of lights that can be used in the shader.
  103475. */
  103476. maxSimultaneousLights?: number;
  103477. /**
  103478. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103479. */
  103480. transformFeedbackVaryings?: Nullable<string[]>;
  103481. }
  103482. /**
  103483. * Effect containing vertex and fragment shader that can be executed on an object.
  103484. */
  103485. export class Effect implements IDisposable {
  103486. /**
  103487. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103488. */
  103489. static ShadersRepository: string;
  103490. /**
  103491. * Enable logging of the shader code when a compilation error occurs
  103492. */
  103493. static LogShaderCodeOnCompilationError: boolean;
  103494. /**
  103495. * Name of the effect.
  103496. */
  103497. name: any;
  103498. /**
  103499. * String container all the define statements that should be set on the shader.
  103500. */
  103501. defines: string;
  103502. /**
  103503. * Callback that will be called when the shader is compiled.
  103504. */
  103505. onCompiled: Nullable<(effect: Effect) => void>;
  103506. /**
  103507. * Callback that will be called if an error occurs during shader compilation.
  103508. */
  103509. onError: Nullable<(effect: Effect, errors: string) => void>;
  103510. /**
  103511. * Callback that will be called when effect is bound.
  103512. */
  103513. onBind: Nullable<(effect: Effect) => void>;
  103514. /**
  103515. * Unique ID of the effect.
  103516. */
  103517. uniqueId: number;
  103518. /**
  103519. * Observable that will be called when the shader is compiled.
  103520. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103521. */
  103522. onCompileObservable: Observable<Effect>;
  103523. /**
  103524. * Observable that will be called if an error occurs during shader compilation.
  103525. */
  103526. onErrorObservable: Observable<Effect>;
  103527. /** @hidden */
  103528. _onBindObservable: Nullable<Observable<Effect>>;
  103529. /**
  103530. * @hidden
  103531. * Specifies if the effect was previously ready
  103532. */
  103533. _wasPreviouslyReady: boolean;
  103534. /**
  103535. * Observable that will be called when effect is bound.
  103536. */
  103537. get onBindObservable(): Observable<Effect>;
  103538. /** @hidden */
  103539. _bonesComputationForcedToCPU: boolean;
  103540. private static _uniqueIdSeed;
  103541. private _engine;
  103542. private _uniformBuffersNames;
  103543. private _uniformsNames;
  103544. private _samplerList;
  103545. private _samplers;
  103546. private _isReady;
  103547. private _compilationError;
  103548. private _allFallbacksProcessed;
  103549. private _attributesNames;
  103550. private _attributes;
  103551. private _attributeLocationByName;
  103552. private _uniforms;
  103553. /**
  103554. * Key for the effect.
  103555. * @hidden
  103556. */
  103557. _key: string;
  103558. private _indexParameters;
  103559. private _fallbacks;
  103560. private _vertexSourceCode;
  103561. private _fragmentSourceCode;
  103562. private _vertexSourceCodeOverride;
  103563. private _fragmentSourceCodeOverride;
  103564. private _transformFeedbackVaryings;
  103565. /**
  103566. * Compiled shader to webGL program.
  103567. * @hidden
  103568. */
  103569. _pipelineContext: Nullable<IPipelineContext>;
  103570. private _valueCache;
  103571. private static _baseCache;
  103572. /**
  103573. * Instantiates an effect.
  103574. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103575. * @param baseName Name of the effect.
  103576. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103577. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103578. * @param samplers List of sampler variables that will be passed to the shader.
  103579. * @param engine Engine to be used to render the effect
  103580. * @param defines Define statements to be added to the shader.
  103581. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103582. * @param onCompiled Callback that will be called when the shader is compiled.
  103583. * @param onError Callback that will be called if an error occurs during shader compilation.
  103584. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103585. */
  103586. 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);
  103587. private _useFinalCode;
  103588. /**
  103589. * Unique key for this effect
  103590. */
  103591. get key(): string;
  103592. /**
  103593. * If the effect has been compiled and prepared.
  103594. * @returns if the effect is compiled and prepared.
  103595. */
  103596. isReady(): boolean;
  103597. private _isReadyInternal;
  103598. /**
  103599. * The engine the effect was initialized with.
  103600. * @returns the engine.
  103601. */
  103602. getEngine(): Engine;
  103603. /**
  103604. * The pipeline context for this effect
  103605. * @returns the associated pipeline context
  103606. */
  103607. getPipelineContext(): Nullable<IPipelineContext>;
  103608. /**
  103609. * The set of names of attribute variables for the shader.
  103610. * @returns An array of attribute names.
  103611. */
  103612. getAttributesNames(): string[];
  103613. /**
  103614. * Returns the attribute at the given index.
  103615. * @param index The index of the attribute.
  103616. * @returns The location of the attribute.
  103617. */
  103618. getAttributeLocation(index: number): number;
  103619. /**
  103620. * Returns the attribute based on the name of the variable.
  103621. * @param name of the attribute to look up.
  103622. * @returns the attribute location.
  103623. */
  103624. getAttributeLocationByName(name: string): number;
  103625. /**
  103626. * The number of attributes.
  103627. * @returns the numnber of attributes.
  103628. */
  103629. getAttributesCount(): number;
  103630. /**
  103631. * Gets the index of a uniform variable.
  103632. * @param uniformName of the uniform to look up.
  103633. * @returns the index.
  103634. */
  103635. getUniformIndex(uniformName: string): number;
  103636. /**
  103637. * Returns the attribute based on the name of the variable.
  103638. * @param uniformName of the uniform to look up.
  103639. * @returns the location of the uniform.
  103640. */
  103641. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103642. /**
  103643. * Returns an array of sampler variable names
  103644. * @returns The array of sampler variable neames.
  103645. */
  103646. getSamplers(): string[];
  103647. /**
  103648. * The error from the last compilation.
  103649. * @returns the error string.
  103650. */
  103651. getCompilationError(): string;
  103652. /**
  103653. * Gets a boolean indicating that all fallbacks were used during compilation
  103654. * @returns true if all fallbacks were used
  103655. */
  103656. allFallbacksProcessed(): boolean;
  103657. /**
  103658. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103659. * @param func The callback to be used.
  103660. */
  103661. executeWhenCompiled(func: (effect: Effect) => void): void;
  103662. private _checkIsReady;
  103663. private _loadShader;
  103664. /**
  103665. * Recompiles the webGL program
  103666. * @param vertexSourceCode The source code for the vertex shader.
  103667. * @param fragmentSourceCode The source code for the fragment shader.
  103668. * @param onCompiled Callback called when completed.
  103669. * @param onError Callback called on error.
  103670. * @hidden
  103671. */
  103672. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103673. /**
  103674. * Prepares the effect
  103675. * @hidden
  103676. */
  103677. _prepareEffect(): void;
  103678. private _getShaderCodeAndErrorLine;
  103679. private _processCompilationErrors;
  103680. /**
  103681. * Checks if the effect is supported. (Must be called after compilation)
  103682. */
  103683. get isSupported(): boolean;
  103684. /**
  103685. * Binds a texture to the engine to be used as output of the shader.
  103686. * @param channel Name of the output variable.
  103687. * @param texture Texture to bind.
  103688. * @hidden
  103689. */
  103690. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103691. /**
  103692. * Sets a texture on the engine to be used in the shader.
  103693. * @param channel Name of the sampler variable.
  103694. * @param texture Texture to set.
  103695. */
  103696. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103697. /**
  103698. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103699. * @param channel Name of the sampler variable.
  103700. * @param texture Texture to set.
  103701. */
  103702. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103703. /**
  103704. * Sets an array of textures on the engine to be used in the shader.
  103705. * @param channel Name of the variable.
  103706. * @param textures Textures to set.
  103707. */
  103708. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103709. /**
  103710. * 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)
  103711. * @param channel Name of the sampler variable.
  103712. * @param postProcess Post process to get the input texture from.
  103713. */
  103714. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103715. /**
  103716. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103717. * 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)
  103718. * @param channel Name of the sampler variable.
  103719. * @param postProcess Post process to get the output texture from.
  103720. */
  103721. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103722. /** @hidden */
  103723. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103724. /** @hidden */
  103725. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103726. /** @hidden */
  103727. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103728. /** @hidden */
  103729. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103730. /**
  103731. * Binds a buffer to a uniform.
  103732. * @param buffer Buffer to bind.
  103733. * @param name Name of the uniform variable to bind to.
  103734. */
  103735. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103736. /**
  103737. * Binds block to a uniform.
  103738. * @param blockName Name of the block to bind.
  103739. * @param index Index to bind.
  103740. */
  103741. bindUniformBlock(blockName: string, index: number): void;
  103742. /**
  103743. * Sets an interger value on a uniform variable.
  103744. * @param uniformName Name of the variable.
  103745. * @param value Value to be set.
  103746. * @returns this effect.
  103747. */
  103748. setInt(uniformName: string, value: number): Effect;
  103749. /**
  103750. * Sets an int array on a uniform variable.
  103751. * @param uniformName Name of the variable.
  103752. * @param array array to be set.
  103753. * @returns this effect.
  103754. */
  103755. setIntArray(uniformName: string, array: Int32Array): Effect;
  103756. /**
  103757. * 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)
  103758. * @param uniformName Name of the variable.
  103759. * @param array array to be set.
  103760. * @returns this effect.
  103761. */
  103762. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103763. /**
  103764. * 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)
  103765. * @param uniformName Name of the variable.
  103766. * @param array array to be set.
  103767. * @returns this effect.
  103768. */
  103769. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103770. /**
  103771. * 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)
  103772. * @param uniformName Name of the variable.
  103773. * @param array array to be set.
  103774. * @returns this effect.
  103775. */
  103776. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103777. /**
  103778. * Sets an float array on a uniform variable.
  103779. * @param uniformName Name of the variable.
  103780. * @param array array to be set.
  103781. * @returns this effect.
  103782. */
  103783. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103784. /**
  103785. * 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)
  103786. * @param uniformName Name of the variable.
  103787. * @param array array to be set.
  103788. * @returns this effect.
  103789. */
  103790. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103791. /**
  103792. * 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)
  103793. * @param uniformName Name of the variable.
  103794. * @param array array to be set.
  103795. * @returns this effect.
  103796. */
  103797. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103798. /**
  103799. * 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)
  103800. * @param uniformName Name of the variable.
  103801. * @param array array to be set.
  103802. * @returns this effect.
  103803. */
  103804. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103805. /**
  103806. * Sets an array on a uniform variable.
  103807. * @param uniformName Name of the variable.
  103808. * @param array array to be set.
  103809. * @returns this effect.
  103810. */
  103811. setArray(uniformName: string, array: number[]): Effect;
  103812. /**
  103813. * 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)
  103814. * @param uniformName Name of the variable.
  103815. * @param array array to be set.
  103816. * @returns this effect.
  103817. */
  103818. setArray2(uniformName: string, array: number[]): Effect;
  103819. /**
  103820. * 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)
  103821. * @param uniformName Name of the variable.
  103822. * @param array array to be set.
  103823. * @returns this effect.
  103824. */
  103825. setArray3(uniformName: string, array: number[]): Effect;
  103826. /**
  103827. * 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)
  103828. * @param uniformName Name of the variable.
  103829. * @param array array to be set.
  103830. * @returns this effect.
  103831. */
  103832. setArray4(uniformName: string, array: number[]): Effect;
  103833. /**
  103834. * Sets matrices on a uniform variable.
  103835. * @param uniformName Name of the variable.
  103836. * @param matrices matrices to be set.
  103837. * @returns this effect.
  103838. */
  103839. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103840. /**
  103841. * Sets matrix on a uniform variable.
  103842. * @param uniformName Name of the variable.
  103843. * @param matrix matrix to be set.
  103844. * @returns this effect.
  103845. */
  103846. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103847. /**
  103848. * 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)
  103849. * @param uniformName Name of the variable.
  103850. * @param matrix matrix to be set.
  103851. * @returns this effect.
  103852. */
  103853. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103854. /**
  103855. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103856. * @param uniformName Name of the variable.
  103857. * @param matrix matrix to be set.
  103858. * @returns this effect.
  103859. */
  103860. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103861. /**
  103862. * Sets a float on a uniform variable.
  103863. * @param uniformName Name of the variable.
  103864. * @param value value to be set.
  103865. * @returns this effect.
  103866. */
  103867. setFloat(uniformName: string, value: number): Effect;
  103868. /**
  103869. * Sets a boolean on a uniform variable.
  103870. * @param uniformName Name of the variable.
  103871. * @param bool value to be set.
  103872. * @returns this effect.
  103873. */
  103874. setBool(uniformName: string, bool: boolean): Effect;
  103875. /**
  103876. * Sets a Vector2 on a uniform variable.
  103877. * @param uniformName Name of the variable.
  103878. * @param vector2 vector2 to be set.
  103879. * @returns this effect.
  103880. */
  103881. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103882. /**
  103883. * Sets a float2 on a uniform variable.
  103884. * @param uniformName Name of the variable.
  103885. * @param x First float in float2.
  103886. * @param y Second float in float2.
  103887. * @returns this effect.
  103888. */
  103889. setFloat2(uniformName: string, x: number, y: number): Effect;
  103890. /**
  103891. * Sets a Vector3 on a uniform variable.
  103892. * @param uniformName Name of the variable.
  103893. * @param vector3 Value to be set.
  103894. * @returns this effect.
  103895. */
  103896. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103897. /**
  103898. * Sets a float3 on a uniform variable.
  103899. * @param uniformName Name of the variable.
  103900. * @param x First float in float3.
  103901. * @param y Second float in float3.
  103902. * @param z Third float in float3.
  103903. * @returns this effect.
  103904. */
  103905. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103906. /**
  103907. * Sets a Vector4 on a uniform variable.
  103908. * @param uniformName Name of the variable.
  103909. * @param vector4 Value to be set.
  103910. * @returns this effect.
  103911. */
  103912. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103913. /**
  103914. * Sets a float4 on a uniform variable.
  103915. * @param uniformName Name of the variable.
  103916. * @param x First float in float4.
  103917. * @param y Second float in float4.
  103918. * @param z Third float in float4.
  103919. * @param w Fourth float in float4.
  103920. * @returns this effect.
  103921. */
  103922. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103923. /**
  103924. * Sets a Color3 on a uniform variable.
  103925. * @param uniformName Name of the variable.
  103926. * @param color3 Value to be set.
  103927. * @returns this effect.
  103928. */
  103929. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103930. /**
  103931. * Sets a Color4 on a uniform variable.
  103932. * @param uniformName Name of the variable.
  103933. * @param color3 Value to be set.
  103934. * @param alpha Alpha value to be set.
  103935. * @returns this effect.
  103936. */
  103937. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103938. /**
  103939. * Sets a Color4 on a uniform variable
  103940. * @param uniformName defines the name of the variable
  103941. * @param color4 defines the value to be set
  103942. * @returns this effect.
  103943. */
  103944. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103945. /** Release all associated resources */
  103946. dispose(): void;
  103947. /**
  103948. * This function will add a new shader to the shader store
  103949. * @param name the name of the shader
  103950. * @param pixelShader optional pixel shader content
  103951. * @param vertexShader optional vertex shader content
  103952. */
  103953. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103954. /**
  103955. * Store of each shader (The can be looked up using effect.key)
  103956. */
  103957. static ShadersStore: {
  103958. [key: string]: string;
  103959. };
  103960. /**
  103961. * Store of each included file for a shader (The can be looked up using effect.key)
  103962. */
  103963. static IncludesShadersStore: {
  103964. [key: string]: string;
  103965. };
  103966. /**
  103967. * Resets the cache of effects.
  103968. */
  103969. static ResetCache(): void;
  103970. }
  103971. }
  103972. declare module BABYLON {
  103973. /**
  103974. * Interface used to describe the capabilities of the engine relatively to the current browser
  103975. */
  103976. export interface EngineCapabilities {
  103977. /** Maximum textures units per fragment shader */
  103978. maxTexturesImageUnits: number;
  103979. /** Maximum texture units per vertex shader */
  103980. maxVertexTextureImageUnits: number;
  103981. /** Maximum textures units in the entire pipeline */
  103982. maxCombinedTexturesImageUnits: number;
  103983. /** Maximum texture size */
  103984. maxTextureSize: number;
  103985. /** Maximum texture samples */
  103986. maxSamples?: number;
  103987. /** Maximum cube texture size */
  103988. maxCubemapTextureSize: number;
  103989. /** Maximum render texture size */
  103990. maxRenderTextureSize: number;
  103991. /** Maximum number of vertex attributes */
  103992. maxVertexAttribs: number;
  103993. /** Maximum number of varyings */
  103994. maxVaryingVectors: number;
  103995. /** Maximum number of uniforms per vertex shader */
  103996. maxVertexUniformVectors: number;
  103997. /** Maximum number of uniforms per fragment shader */
  103998. maxFragmentUniformVectors: number;
  103999. /** Defines if standard derivates (dx/dy) are supported */
  104000. standardDerivatives: boolean;
  104001. /** Defines if s3tc texture compression is supported */
  104002. s3tc?: WEBGL_compressed_texture_s3tc;
  104003. /** Defines if pvrtc texture compression is supported */
  104004. pvrtc: any;
  104005. /** Defines if etc1 texture compression is supported */
  104006. etc1: any;
  104007. /** Defines if etc2 texture compression is supported */
  104008. etc2: any;
  104009. /** Defines if astc texture compression is supported */
  104010. astc: any;
  104011. /** Defines if float textures are supported */
  104012. textureFloat: boolean;
  104013. /** Defines if vertex array objects are supported */
  104014. vertexArrayObject: boolean;
  104015. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  104016. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  104017. /** Gets the maximum level of anisotropy supported */
  104018. maxAnisotropy: number;
  104019. /** Defines if instancing is supported */
  104020. instancedArrays: boolean;
  104021. /** Defines if 32 bits indices are supported */
  104022. uintIndices: boolean;
  104023. /** Defines if high precision shaders are supported */
  104024. highPrecisionShaderSupported: boolean;
  104025. /** Defines if depth reading in the fragment shader is supported */
  104026. fragmentDepthSupported: boolean;
  104027. /** Defines if float texture linear filtering is supported*/
  104028. textureFloatLinearFiltering: boolean;
  104029. /** Defines if rendering to float textures is supported */
  104030. textureFloatRender: boolean;
  104031. /** Defines if half float textures are supported*/
  104032. textureHalfFloat: boolean;
  104033. /** Defines if half float texture linear filtering is supported*/
  104034. textureHalfFloatLinearFiltering: boolean;
  104035. /** Defines if rendering to half float textures is supported */
  104036. textureHalfFloatRender: boolean;
  104037. /** Defines if textureLOD shader command is supported */
  104038. textureLOD: boolean;
  104039. /** Defines if draw buffers extension is supported */
  104040. drawBuffersExtension: boolean;
  104041. /** Defines if depth textures are supported */
  104042. depthTextureExtension: boolean;
  104043. /** Defines if float color buffer are supported */
  104044. colorBufferFloat: boolean;
  104045. /** Gets disjoint timer query extension (null if not supported) */
  104046. timerQuery?: EXT_disjoint_timer_query;
  104047. /** Defines if timestamp can be used with timer query */
  104048. canUseTimestampForTimerQuery: boolean;
  104049. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  104050. multiview?: any;
  104051. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  104052. oculusMultiview?: any;
  104053. /** Function used to let the system compiles shaders in background */
  104054. parallelShaderCompile?: {
  104055. COMPLETION_STATUS_KHR: number;
  104056. };
  104057. /** Max number of texture samples for MSAA */
  104058. maxMSAASamples: number;
  104059. /** Defines if the blend min max extension is supported */
  104060. blendMinMax: boolean;
  104061. }
  104062. }
  104063. declare module BABYLON {
  104064. /**
  104065. * @hidden
  104066. **/
  104067. export class DepthCullingState {
  104068. private _isDepthTestDirty;
  104069. private _isDepthMaskDirty;
  104070. private _isDepthFuncDirty;
  104071. private _isCullFaceDirty;
  104072. private _isCullDirty;
  104073. private _isZOffsetDirty;
  104074. private _isFrontFaceDirty;
  104075. private _depthTest;
  104076. private _depthMask;
  104077. private _depthFunc;
  104078. private _cull;
  104079. private _cullFace;
  104080. private _zOffset;
  104081. private _frontFace;
  104082. /**
  104083. * Initializes the state.
  104084. */
  104085. constructor();
  104086. get isDirty(): boolean;
  104087. get zOffset(): number;
  104088. set zOffset(value: number);
  104089. get cullFace(): Nullable<number>;
  104090. set cullFace(value: Nullable<number>);
  104091. get cull(): Nullable<boolean>;
  104092. set cull(value: Nullable<boolean>);
  104093. get depthFunc(): Nullable<number>;
  104094. set depthFunc(value: Nullable<number>);
  104095. get depthMask(): boolean;
  104096. set depthMask(value: boolean);
  104097. get depthTest(): boolean;
  104098. set depthTest(value: boolean);
  104099. get frontFace(): Nullable<number>;
  104100. set frontFace(value: Nullable<number>);
  104101. reset(): void;
  104102. apply(gl: WebGLRenderingContext): void;
  104103. }
  104104. }
  104105. declare module BABYLON {
  104106. /**
  104107. * @hidden
  104108. **/
  104109. export class StencilState {
  104110. /** 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 */
  104111. static readonly ALWAYS: number;
  104112. /** Passed to stencilOperation to specify that stencil value must be kept */
  104113. static readonly KEEP: number;
  104114. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104115. static readonly REPLACE: number;
  104116. private _isStencilTestDirty;
  104117. private _isStencilMaskDirty;
  104118. private _isStencilFuncDirty;
  104119. private _isStencilOpDirty;
  104120. private _stencilTest;
  104121. private _stencilMask;
  104122. private _stencilFunc;
  104123. private _stencilFuncRef;
  104124. private _stencilFuncMask;
  104125. private _stencilOpStencilFail;
  104126. private _stencilOpDepthFail;
  104127. private _stencilOpStencilDepthPass;
  104128. get isDirty(): boolean;
  104129. get stencilFunc(): number;
  104130. set stencilFunc(value: number);
  104131. get stencilFuncRef(): number;
  104132. set stencilFuncRef(value: number);
  104133. get stencilFuncMask(): number;
  104134. set stencilFuncMask(value: number);
  104135. get stencilOpStencilFail(): number;
  104136. set stencilOpStencilFail(value: number);
  104137. get stencilOpDepthFail(): number;
  104138. set stencilOpDepthFail(value: number);
  104139. get stencilOpStencilDepthPass(): number;
  104140. set stencilOpStencilDepthPass(value: number);
  104141. get stencilMask(): number;
  104142. set stencilMask(value: number);
  104143. get stencilTest(): boolean;
  104144. set stencilTest(value: boolean);
  104145. constructor();
  104146. reset(): void;
  104147. apply(gl: WebGLRenderingContext): void;
  104148. }
  104149. }
  104150. declare module BABYLON {
  104151. /**
  104152. * @hidden
  104153. **/
  104154. export class AlphaState {
  104155. private _isAlphaBlendDirty;
  104156. private _isBlendFunctionParametersDirty;
  104157. private _isBlendEquationParametersDirty;
  104158. private _isBlendConstantsDirty;
  104159. private _alphaBlend;
  104160. private _blendFunctionParameters;
  104161. private _blendEquationParameters;
  104162. private _blendConstants;
  104163. /**
  104164. * Initializes the state.
  104165. */
  104166. constructor();
  104167. get isDirty(): boolean;
  104168. get alphaBlend(): boolean;
  104169. set alphaBlend(value: boolean);
  104170. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  104171. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  104172. setAlphaEquationParameters(rgb: number, alpha: number): void;
  104173. reset(): void;
  104174. apply(gl: WebGLRenderingContext): void;
  104175. }
  104176. }
  104177. declare module BABYLON {
  104178. /** @hidden */
  104179. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104180. attributeProcessor(attribute: string): string;
  104181. varyingProcessor(varying: string, isFragment: boolean): string;
  104182. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104183. }
  104184. }
  104185. declare module BABYLON {
  104186. /**
  104187. * Interface for attribute information associated with buffer instanciation
  104188. */
  104189. export interface InstancingAttributeInfo {
  104190. /**
  104191. * Name of the GLSL attribute
  104192. * if attribute index is not specified, this is used to retrieve the index from the effect
  104193. */
  104194. attributeName: string;
  104195. /**
  104196. * Index/offset of the attribute in the vertex shader
  104197. * if not specified, this will be computes from the name.
  104198. */
  104199. index?: number;
  104200. /**
  104201. * size of the attribute, 1, 2, 3 or 4
  104202. */
  104203. attributeSize: number;
  104204. /**
  104205. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104206. */
  104207. offset: number;
  104208. /**
  104209. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104210. * default to 1
  104211. */
  104212. divisor?: number;
  104213. /**
  104214. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104215. * default is FLOAT
  104216. */
  104217. attributeType?: number;
  104218. /**
  104219. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104220. */
  104221. normalized?: boolean;
  104222. }
  104223. }
  104224. declare module BABYLON {
  104225. interface ThinEngine {
  104226. /**
  104227. * Update a video texture
  104228. * @param texture defines the texture to update
  104229. * @param video defines the video element to use
  104230. * @param invertY defines if data must be stored with Y axis inverted
  104231. */
  104232. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104233. }
  104234. }
  104235. declare module BABYLON {
  104236. /**
  104237. * Settings for finer control over video usage
  104238. */
  104239. export interface VideoTextureSettings {
  104240. /**
  104241. * Applies `autoplay` to video, if specified
  104242. */
  104243. autoPlay?: boolean;
  104244. /**
  104245. * Applies `loop` to video, if specified
  104246. */
  104247. loop?: boolean;
  104248. /**
  104249. * Automatically updates internal texture from video at every frame in the render loop
  104250. */
  104251. autoUpdateTexture: boolean;
  104252. /**
  104253. * Image src displayed during the video loading or until the user interacts with the video.
  104254. */
  104255. poster?: string;
  104256. }
  104257. /**
  104258. * If you want to display a video in your scene, this is the special texture for that.
  104259. * This special texture works similar to other textures, with the exception of a few parameters.
  104260. * @see https://doc.babylonjs.com/how_to/video_texture
  104261. */
  104262. export class VideoTexture extends Texture {
  104263. /**
  104264. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104265. */
  104266. readonly autoUpdateTexture: boolean;
  104267. /**
  104268. * The video instance used by the texture internally
  104269. */
  104270. readonly video: HTMLVideoElement;
  104271. private _onUserActionRequestedObservable;
  104272. /**
  104273. * Event triggerd when a dom action is required by the user to play the video.
  104274. * This happens due to recent changes in browser policies preventing video to auto start.
  104275. */
  104276. get onUserActionRequestedObservable(): Observable<Texture>;
  104277. private _generateMipMaps;
  104278. private _engine;
  104279. private _stillImageCaptured;
  104280. private _displayingPosterTexture;
  104281. private _settings;
  104282. private _createInternalTextureOnEvent;
  104283. private _frameId;
  104284. private _currentSrc;
  104285. /**
  104286. * Creates a video texture.
  104287. * If you want to display a video in your scene, this is the special texture for that.
  104288. * This special texture works similar to other textures, with the exception of a few parameters.
  104289. * @see https://doc.babylonjs.com/how_to/video_texture
  104290. * @param name optional name, will detect from video source, if not defined
  104291. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104292. * @param scene is obviously the current scene.
  104293. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104294. * @param invertY is false by default but can be used to invert video on Y axis
  104295. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104296. * @param settings allows finer control over video usage
  104297. */
  104298. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104299. private _getName;
  104300. private _getVideo;
  104301. private _createInternalTexture;
  104302. private reset;
  104303. /**
  104304. * @hidden Internal method to initiate `update`.
  104305. */
  104306. _rebuild(): void;
  104307. /**
  104308. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104309. */
  104310. update(): void;
  104311. /**
  104312. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104313. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104314. */
  104315. updateTexture(isVisible: boolean): void;
  104316. protected _updateInternalTexture: () => void;
  104317. /**
  104318. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104319. * @param url New url.
  104320. */
  104321. updateURL(url: string): void;
  104322. /**
  104323. * Clones the texture.
  104324. * @returns the cloned texture
  104325. */
  104326. clone(): VideoTexture;
  104327. /**
  104328. * Dispose the texture and release its associated resources.
  104329. */
  104330. dispose(): void;
  104331. /**
  104332. * Creates a video texture straight from a stream.
  104333. * @param scene Define the scene the texture should be created in
  104334. * @param stream Define the stream the texture should be created from
  104335. * @returns The created video texture as a promise
  104336. */
  104337. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104338. /**
  104339. * Creates a video texture straight from your WebCam video feed.
  104340. * @param scene Define the scene the texture should be created in
  104341. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104342. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104343. * @returns The created video texture as a promise
  104344. */
  104345. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104346. minWidth: number;
  104347. maxWidth: number;
  104348. minHeight: number;
  104349. maxHeight: number;
  104350. deviceId: string;
  104351. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104352. /**
  104353. * Creates a video texture straight from your WebCam video feed.
  104354. * @param scene Define the scene the texture should be created in
  104355. * @param onReady Define a callback to triggered once the texture will be ready
  104356. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104357. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104358. */
  104359. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104360. minWidth: number;
  104361. maxWidth: number;
  104362. minHeight: number;
  104363. maxHeight: number;
  104364. deviceId: string;
  104365. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104366. }
  104367. }
  104368. declare module BABYLON {
  104369. /**
  104370. * Defines the interface used by objects working like Scene
  104371. * @hidden
  104372. */
  104373. export interface ISceneLike {
  104374. _addPendingData(data: any): void;
  104375. _removePendingData(data: any): void;
  104376. offlineProvider: IOfflineProvider;
  104377. }
  104378. /** Interface defining initialization parameters for Engine class */
  104379. export interface EngineOptions extends WebGLContextAttributes {
  104380. /**
  104381. * Defines if the engine should no exceed a specified device ratio
  104382. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104383. */
  104384. limitDeviceRatio?: number;
  104385. /**
  104386. * Defines if webvr should be enabled automatically
  104387. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104388. */
  104389. autoEnableWebVR?: boolean;
  104390. /**
  104391. * Defines if webgl2 should be turned off even if supported
  104392. * @see http://doc.babylonjs.com/features/webgl2
  104393. */
  104394. disableWebGL2Support?: boolean;
  104395. /**
  104396. * Defines if webaudio should be initialized as well
  104397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104398. */
  104399. audioEngine?: boolean;
  104400. /**
  104401. * Defines if animations should run using a deterministic lock step
  104402. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104403. */
  104404. deterministicLockstep?: boolean;
  104405. /** Defines the maximum steps to use with deterministic lock step mode */
  104406. lockstepMaxSteps?: number;
  104407. /** Defines the seconds between each deterministic lock step */
  104408. timeStep?: number;
  104409. /**
  104410. * Defines that engine should ignore context lost events
  104411. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104412. */
  104413. doNotHandleContextLost?: boolean;
  104414. /**
  104415. * Defines that engine should ignore modifying touch action attribute and style
  104416. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104417. */
  104418. doNotHandleTouchAction?: boolean;
  104419. /**
  104420. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104421. */
  104422. useHighPrecisionFloats?: boolean;
  104423. }
  104424. /**
  104425. * The base engine class (root of all engines)
  104426. */
  104427. export class ThinEngine {
  104428. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104429. static ExceptionList: ({
  104430. key: string;
  104431. capture: string;
  104432. captureConstraint: number;
  104433. targets: string[];
  104434. } | {
  104435. key: string;
  104436. capture: null;
  104437. captureConstraint: null;
  104438. targets: string[];
  104439. })[];
  104440. /** @hidden */
  104441. static _TextureLoaders: IInternalTextureLoader[];
  104442. /**
  104443. * Returns the current npm package of the sdk
  104444. */
  104445. static get NpmPackage(): string;
  104446. /**
  104447. * Returns the current version of the framework
  104448. */
  104449. static get Version(): string;
  104450. /**
  104451. * Returns a string describing the current engine
  104452. */
  104453. get description(): string;
  104454. /**
  104455. * Gets or sets the epsilon value used by collision engine
  104456. */
  104457. static CollisionsEpsilon: number;
  104458. /**
  104459. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104460. */
  104461. static get ShadersRepository(): string;
  104462. static set ShadersRepository(value: string);
  104463. /** @hidden */
  104464. _shaderProcessor: IShaderProcessor;
  104465. /**
  104466. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104467. */
  104468. forcePOTTextures: boolean;
  104469. /**
  104470. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104471. */
  104472. isFullscreen: boolean;
  104473. /**
  104474. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104475. */
  104476. cullBackFaces: boolean;
  104477. /**
  104478. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104479. */
  104480. renderEvenInBackground: boolean;
  104481. /**
  104482. * Gets or sets a boolean indicating that cache can be kept between frames
  104483. */
  104484. preventCacheWipeBetweenFrames: boolean;
  104485. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104486. validateShaderPrograms: boolean;
  104487. /**
  104488. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104489. * This can provide greater z depth for distant objects.
  104490. */
  104491. useReverseDepthBuffer: boolean;
  104492. /**
  104493. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104494. */
  104495. disableUniformBuffers: boolean;
  104496. /** @hidden */
  104497. _uniformBuffers: UniformBuffer[];
  104498. /**
  104499. * Gets a boolean indicating that the engine supports uniform buffers
  104500. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104501. */
  104502. get supportsUniformBuffers(): boolean;
  104503. /** @hidden */
  104504. _gl: WebGLRenderingContext;
  104505. /** @hidden */
  104506. _webGLVersion: number;
  104507. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104508. protected _windowIsBackground: boolean;
  104509. protected _creationOptions: EngineOptions;
  104510. protected _highPrecisionShadersAllowed: boolean;
  104511. /** @hidden */
  104512. get _shouldUseHighPrecisionShader(): boolean;
  104513. /**
  104514. * Gets a boolean indicating that only power of 2 textures are supported
  104515. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104516. */
  104517. get needPOTTextures(): boolean;
  104518. /** @hidden */
  104519. _badOS: boolean;
  104520. /** @hidden */
  104521. _badDesktopOS: boolean;
  104522. private _hardwareScalingLevel;
  104523. /** @hidden */
  104524. _caps: EngineCapabilities;
  104525. private _isStencilEnable;
  104526. private _glVersion;
  104527. private _glRenderer;
  104528. private _glVendor;
  104529. /** @hidden */
  104530. _videoTextureSupported: boolean;
  104531. protected _renderingQueueLaunched: boolean;
  104532. protected _activeRenderLoops: (() => void)[];
  104533. /**
  104534. * Observable signaled when a context lost event is raised
  104535. */
  104536. onContextLostObservable: Observable<ThinEngine>;
  104537. /**
  104538. * Observable signaled when a context restored event is raised
  104539. */
  104540. onContextRestoredObservable: Observable<ThinEngine>;
  104541. private _onContextLost;
  104542. private _onContextRestored;
  104543. protected _contextWasLost: boolean;
  104544. /** @hidden */
  104545. _doNotHandleContextLost: boolean;
  104546. /**
  104547. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104549. */
  104550. get doNotHandleContextLost(): boolean;
  104551. set doNotHandleContextLost(value: boolean);
  104552. /**
  104553. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104554. */
  104555. disableVertexArrayObjects: boolean;
  104556. /** @hidden */
  104557. protected _colorWrite: boolean;
  104558. /** @hidden */
  104559. protected _colorWriteChanged: boolean;
  104560. /** @hidden */
  104561. protected _depthCullingState: DepthCullingState;
  104562. /** @hidden */
  104563. protected _stencilState: StencilState;
  104564. /** @hidden */
  104565. _alphaState: AlphaState;
  104566. /** @hidden */
  104567. _alphaMode: number;
  104568. /** @hidden */
  104569. _alphaEquation: number;
  104570. /** @hidden */
  104571. _internalTexturesCache: InternalTexture[];
  104572. /** @hidden */
  104573. protected _activeChannel: number;
  104574. private _currentTextureChannel;
  104575. /** @hidden */
  104576. protected _boundTexturesCache: {
  104577. [key: string]: Nullable<InternalTexture>;
  104578. };
  104579. /** @hidden */
  104580. protected _currentEffect: Nullable<Effect>;
  104581. /** @hidden */
  104582. protected _currentProgram: Nullable<WebGLProgram>;
  104583. private _compiledEffects;
  104584. private _vertexAttribArraysEnabled;
  104585. /** @hidden */
  104586. protected _cachedViewport: Nullable<IViewportLike>;
  104587. private _cachedVertexArrayObject;
  104588. /** @hidden */
  104589. protected _cachedVertexBuffers: any;
  104590. /** @hidden */
  104591. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104592. /** @hidden */
  104593. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104594. /** @hidden */
  104595. _currentRenderTarget: Nullable<InternalTexture>;
  104596. private _uintIndicesCurrentlySet;
  104597. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104598. /** @hidden */
  104599. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104600. private _currentBufferPointers;
  104601. private _currentInstanceLocations;
  104602. private _currentInstanceBuffers;
  104603. private _textureUnits;
  104604. /** @hidden */
  104605. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104606. /** @hidden */
  104607. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104608. /** @hidden */
  104609. _boundRenderFunction: any;
  104610. private _vaoRecordInProgress;
  104611. private _mustWipeVertexAttributes;
  104612. private _emptyTexture;
  104613. private _emptyCubeTexture;
  104614. private _emptyTexture3D;
  104615. private _emptyTexture2DArray;
  104616. /** @hidden */
  104617. _frameHandler: number;
  104618. private _nextFreeTextureSlots;
  104619. private _maxSimultaneousTextures;
  104620. private _activeRequests;
  104621. protected _texturesSupported: string[];
  104622. /** @hidden */
  104623. _textureFormatInUse: Nullable<string>;
  104624. protected get _supportsHardwareTextureRescaling(): boolean;
  104625. private _framebufferDimensionsObject;
  104626. /**
  104627. * sets the object from which width and height will be taken from when getting render width and height
  104628. * Will fallback to the gl object
  104629. * @param dimensions the framebuffer width and height that will be used.
  104630. */
  104631. set framebufferDimensionsObject(dimensions: Nullable<{
  104632. framebufferWidth: number;
  104633. framebufferHeight: number;
  104634. }>);
  104635. /**
  104636. * Gets the list of texture formats supported
  104637. */
  104638. get texturesSupported(): Array<string>;
  104639. /**
  104640. * Gets the list of texture formats in use
  104641. */
  104642. get textureFormatInUse(): Nullable<string>;
  104643. /**
  104644. * Gets the current viewport
  104645. */
  104646. get currentViewport(): Nullable<IViewportLike>;
  104647. /**
  104648. * Gets the default empty texture
  104649. */
  104650. get emptyTexture(): InternalTexture;
  104651. /**
  104652. * Gets the default empty 3D texture
  104653. */
  104654. get emptyTexture3D(): InternalTexture;
  104655. /**
  104656. * Gets the default empty 2D array texture
  104657. */
  104658. get emptyTexture2DArray(): InternalTexture;
  104659. /**
  104660. * Gets the default empty cube texture
  104661. */
  104662. get emptyCubeTexture(): InternalTexture;
  104663. /**
  104664. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104665. */
  104666. readonly premultipliedAlpha: boolean;
  104667. /**
  104668. * Observable event triggered before each texture is initialized
  104669. */
  104670. onBeforeTextureInitObservable: Observable<Texture>;
  104671. /**
  104672. * Creates a new engine
  104673. * @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
  104674. * @param antialias defines enable antialiasing (default: false)
  104675. * @param options defines further options to be sent to the getContext() function
  104676. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104677. */
  104678. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104679. private _rebuildInternalTextures;
  104680. private _rebuildEffects;
  104681. /**
  104682. * Gets a boolean indicating if all created effects are ready
  104683. * @returns true if all effects are ready
  104684. */
  104685. areAllEffectsReady(): boolean;
  104686. protected _rebuildBuffers(): void;
  104687. private _initGLContext;
  104688. /**
  104689. * Gets version of the current webGL context
  104690. */
  104691. get webGLVersion(): number;
  104692. /**
  104693. * Gets a string idenfifying the name of the class
  104694. * @returns "Engine" string
  104695. */
  104696. getClassName(): string;
  104697. /**
  104698. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104699. */
  104700. get isStencilEnable(): boolean;
  104701. /** @hidden */
  104702. _prepareWorkingCanvas(): void;
  104703. /**
  104704. * Reset the texture cache to empty state
  104705. */
  104706. resetTextureCache(): void;
  104707. /**
  104708. * Gets an object containing information about the current webGL context
  104709. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104710. */
  104711. getGlInfo(): {
  104712. vendor: string;
  104713. renderer: string;
  104714. version: string;
  104715. };
  104716. /**
  104717. * Defines the hardware scaling level.
  104718. * By default the hardware scaling level is computed from the window device ratio.
  104719. * 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.
  104720. * @param level defines the level to use
  104721. */
  104722. setHardwareScalingLevel(level: number): void;
  104723. /**
  104724. * Gets the current hardware scaling level.
  104725. * By default the hardware scaling level is computed from the window device ratio.
  104726. * 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.
  104727. * @returns a number indicating the current hardware scaling level
  104728. */
  104729. getHardwareScalingLevel(): number;
  104730. /**
  104731. * Gets the list of loaded textures
  104732. * @returns an array containing all loaded textures
  104733. */
  104734. getLoadedTexturesCache(): InternalTexture[];
  104735. /**
  104736. * Gets the object containing all engine capabilities
  104737. * @returns the EngineCapabilities object
  104738. */
  104739. getCaps(): EngineCapabilities;
  104740. /**
  104741. * stop executing a render loop function and remove it from the execution array
  104742. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104743. */
  104744. stopRenderLoop(renderFunction?: () => void): void;
  104745. /** @hidden */
  104746. _renderLoop(): void;
  104747. /**
  104748. * Gets the HTML canvas attached with the current webGL context
  104749. * @returns a HTML canvas
  104750. */
  104751. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104752. /**
  104753. * Gets host window
  104754. * @returns the host window object
  104755. */
  104756. getHostWindow(): Nullable<Window>;
  104757. /**
  104758. * Gets the current render width
  104759. * @param useScreen defines if screen size must be used (or the current render target if any)
  104760. * @returns a number defining the current render width
  104761. */
  104762. getRenderWidth(useScreen?: boolean): number;
  104763. /**
  104764. * Gets the current render height
  104765. * @param useScreen defines if screen size must be used (or the current render target if any)
  104766. * @returns a number defining the current render height
  104767. */
  104768. getRenderHeight(useScreen?: boolean): number;
  104769. /**
  104770. * Can be used to override the current requestAnimationFrame requester.
  104771. * @hidden
  104772. */
  104773. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104774. /**
  104775. * Register and execute a render loop. The engine can have more than one render function
  104776. * @param renderFunction defines the function to continuously execute
  104777. */
  104778. runRenderLoop(renderFunction: () => void): void;
  104779. /**
  104780. * Clear the current render buffer or the current render target (if any is set up)
  104781. * @param color defines the color to use
  104782. * @param backBuffer defines if the back buffer must be cleared
  104783. * @param depth defines if the depth buffer must be cleared
  104784. * @param stencil defines if the stencil buffer must be cleared
  104785. */
  104786. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104787. private _viewportCached;
  104788. /** @hidden */
  104789. _viewport(x: number, y: number, width: number, height: number): void;
  104790. /**
  104791. * Set the WebGL's viewport
  104792. * @param viewport defines the viewport element to be used
  104793. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104794. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104795. */
  104796. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104797. /**
  104798. * Begin a new frame
  104799. */
  104800. beginFrame(): void;
  104801. /**
  104802. * Enf the current frame
  104803. */
  104804. endFrame(): void;
  104805. /**
  104806. * Resize the view according to the canvas' size
  104807. */
  104808. resize(): void;
  104809. /**
  104810. * Force a specific size of the canvas
  104811. * @param width defines the new canvas' width
  104812. * @param height defines the new canvas' height
  104813. */
  104814. setSize(width: number, height: number): void;
  104815. /**
  104816. * Binds the frame buffer to the specified texture.
  104817. * @param texture The texture to render to or null for the default canvas
  104818. * @param faceIndex The face of the texture to render to in case of cube texture
  104819. * @param requiredWidth The width of the target to render to
  104820. * @param requiredHeight The height of the target to render to
  104821. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104822. * @param lodLevel defines the lod level to bind to the frame buffer
  104823. * @param layer defines the 2d array index to bind to frame buffer to
  104824. */
  104825. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104826. /** @hidden */
  104827. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104828. /**
  104829. * Unbind the current render target texture from the webGL context
  104830. * @param texture defines the render target texture to unbind
  104831. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104832. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104833. */
  104834. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104835. /**
  104836. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104837. */
  104838. flushFramebuffer(): void;
  104839. /**
  104840. * Unbind the current render target and bind the default framebuffer
  104841. */
  104842. restoreDefaultFramebuffer(): void;
  104843. /** @hidden */
  104844. protected _resetVertexBufferBinding(): void;
  104845. /**
  104846. * Creates a vertex buffer
  104847. * @param data the data for the vertex buffer
  104848. * @returns the new WebGL static buffer
  104849. */
  104850. createVertexBuffer(data: DataArray): DataBuffer;
  104851. private _createVertexBuffer;
  104852. /**
  104853. * Creates a dynamic vertex buffer
  104854. * @param data the data for the dynamic vertex buffer
  104855. * @returns the new WebGL dynamic buffer
  104856. */
  104857. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104858. protected _resetIndexBufferBinding(): void;
  104859. /**
  104860. * Creates a new index buffer
  104861. * @param indices defines the content of the index buffer
  104862. * @param updatable defines if the index buffer must be updatable
  104863. * @returns a new webGL buffer
  104864. */
  104865. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104866. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104867. /**
  104868. * Bind a webGL buffer to the webGL context
  104869. * @param buffer defines the buffer to bind
  104870. */
  104871. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104872. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104873. private bindBuffer;
  104874. /**
  104875. * update the bound buffer with the given data
  104876. * @param data defines the data to update
  104877. */
  104878. updateArrayBuffer(data: Float32Array): void;
  104879. private _vertexAttribPointer;
  104880. /** @hidden */
  104881. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104882. private _bindVertexBuffersAttributes;
  104883. /**
  104884. * Records a vertex array object
  104885. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104886. * @param vertexBuffers defines the list of vertex buffers to store
  104887. * @param indexBuffer defines the index buffer to store
  104888. * @param effect defines the effect to store
  104889. * @returns the new vertex array object
  104890. */
  104891. recordVertexArrayObject(vertexBuffers: {
  104892. [key: string]: VertexBuffer;
  104893. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104894. /**
  104895. * Bind a specific vertex array object
  104896. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104897. * @param vertexArrayObject defines the vertex array object to bind
  104898. * @param indexBuffer defines the index buffer to bind
  104899. */
  104900. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104901. /**
  104902. * Bind webGl buffers directly to the webGL context
  104903. * @param vertexBuffer defines the vertex buffer to bind
  104904. * @param indexBuffer defines the index buffer to bind
  104905. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104906. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104907. * @param effect defines the effect associated with the vertex buffer
  104908. */
  104909. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104910. private _unbindVertexArrayObject;
  104911. /**
  104912. * Bind a list of vertex buffers to the webGL context
  104913. * @param vertexBuffers defines the list of vertex buffers to bind
  104914. * @param indexBuffer defines the index buffer to bind
  104915. * @param effect defines the effect associated with the vertex buffers
  104916. */
  104917. bindBuffers(vertexBuffers: {
  104918. [key: string]: Nullable<VertexBuffer>;
  104919. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104920. /**
  104921. * Unbind all instance attributes
  104922. */
  104923. unbindInstanceAttributes(): void;
  104924. /**
  104925. * Release and free the memory of a vertex array object
  104926. * @param vao defines the vertex array object to delete
  104927. */
  104928. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104929. /** @hidden */
  104930. _releaseBuffer(buffer: DataBuffer): boolean;
  104931. protected _deleteBuffer(buffer: DataBuffer): void;
  104932. /**
  104933. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104934. * @param instancesBuffer defines the webGL buffer to update and bind
  104935. * @param data defines the data to store in the buffer
  104936. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104937. */
  104938. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104939. /**
  104940. * Bind the content of a webGL buffer used with instantiation
  104941. * @param instancesBuffer defines the webGL buffer to bind
  104942. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104943. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104944. */
  104945. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104946. /**
  104947. * Disable the instance attribute corresponding to the name in parameter
  104948. * @param name defines the name of the attribute to disable
  104949. */
  104950. disableInstanceAttributeByName(name: string): void;
  104951. /**
  104952. * Disable the instance attribute corresponding to the location in parameter
  104953. * @param attributeLocation defines the attribute location of the attribute to disable
  104954. */
  104955. disableInstanceAttribute(attributeLocation: number): void;
  104956. /**
  104957. * Disable the attribute corresponding to the location in parameter
  104958. * @param attributeLocation defines the attribute location of the attribute to disable
  104959. */
  104960. disableAttributeByIndex(attributeLocation: number): void;
  104961. /**
  104962. * Send a draw order
  104963. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104964. * @param indexStart defines the starting index
  104965. * @param indexCount defines the number of index to draw
  104966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104967. */
  104968. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104969. /**
  104970. * Draw a list of points
  104971. * @param verticesStart defines the index of first vertex to draw
  104972. * @param verticesCount defines the count of vertices to draw
  104973. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104974. */
  104975. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104976. /**
  104977. * Draw a list of unindexed primitives
  104978. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104979. * @param verticesStart defines the index of first vertex to draw
  104980. * @param verticesCount defines the count of vertices to draw
  104981. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104982. */
  104983. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104984. /**
  104985. * Draw a list of indexed primitives
  104986. * @param fillMode defines the primitive to use
  104987. * @param indexStart defines the starting index
  104988. * @param indexCount defines the number of index to draw
  104989. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104990. */
  104991. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104992. /**
  104993. * Draw a list of unindexed primitives
  104994. * @param fillMode defines the primitive to use
  104995. * @param verticesStart defines the index of first vertex to draw
  104996. * @param verticesCount defines the count of vertices to draw
  104997. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104998. */
  104999. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105000. private _drawMode;
  105001. /** @hidden */
  105002. protected _reportDrawCall(): void;
  105003. /** @hidden */
  105004. _releaseEffect(effect: Effect): void;
  105005. /** @hidden */
  105006. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  105007. /**
  105008. * Create a new effect (used to store vertex/fragment shaders)
  105009. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  105010. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  105011. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  105012. * @param samplers defines an array of string used to represent textures
  105013. * @param defines defines the string containing the defines to use to compile the shaders
  105014. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105015. * @param onCompiled defines a function to call when the effect creation is successful
  105016. * @param onError defines a function to call when the effect creation has failed
  105017. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  105018. * @returns the new Effect
  105019. */
  105020. 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;
  105021. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  105022. private _compileShader;
  105023. private _compileRawShader;
  105024. /** @hidden */
  105025. _getShaderSource(shader: WebGLShader): Nullable<string>;
  105026. /**
  105027. * Directly creates a webGL program
  105028. * @param pipelineContext defines the pipeline context to attach to
  105029. * @param vertexCode defines the vertex shader code to use
  105030. * @param fragmentCode defines the fragment shader code to use
  105031. * @param context defines the webGL context to use (if not set, the current one will be used)
  105032. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105033. * @returns the new webGL program
  105034. */
  105035. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105036. /**
  105037. * Creates a webGL program
  105038. * @param pipelineContext defines the pipeline context to attach to
  105039. * @param vertexCode defines the vertex shader code to use
  105040. * @param fragmentCode defines the fragment shader code to use
  105041. * @param defines defines the string containing the defines to use to compile the shaders
  105042. * @param context defines the webGL context to use (if not set, the current one will be used)
  105043. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105044. * @returns the new webGL program
  105045. */
  105046. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105047. /**
  105048. * Creates a new pipeline context
  105049. * @returns the new pipeline
  105050. */
  105051. createPipelineContext(): IPipelineContext;
  105052. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105053. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  105054. /** @hidden */
  105055. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  105056. /** @hidden */
  105057. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  105058. /** @hidden */
  105059. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  105060. /**
  105061. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  105062. * @param pipelineContext defines the pipeline context to use
  105063. * @param uniformsNames defines the list of uniform names
  105064. * @returns an array of webGL uniform locations
  105065. */
  105066. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105067. /**
  105068. * Gets the lsit of active attributes for a given webGL program
  105069. * @param pipelineContext defines the pipeline context to use
  105070. * @param attributesNames defines the list of attribute names to get
  105071. * @returns an array of indices indicating the offset of each attribute
  105072. */
  105073. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105074. /**
  105075. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105076. * @param effect defines the effect to activate
  105077. */
  105078. enableEffect(effect: Nullable<Effect>): void;
  105079. /**
  105080. * Set the value of an uniform to a number (int)
  105081. * @param uniform defines the webGL uniform location where to store the value
  105082. * @param value defines the int number to store
  105083. */
  105084. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105085. /**
  105086. * Set the value of an uniform to an array of int32
  105087. * @param uniform defines the webGL uniform location where to store the value
  105088. * @param array defines the array of int32 to store
  105089. */
  105090. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105091. /**
  105092. * Set the value of an uniform to an array of int32 (stored as vec2)
  105093. * @param uniform defines the webGL uniform location where to store the value
  105094. * @param array defines the array of int32 to store
  105095. */
  105096. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105097. /**
  105098. * Set the value of an uniform to an array of int32 (stored as vec3)
  105099. * @param uniform defines the webGL uniform location where to store the value
  105100. * @param array defines the array of int32 to store
  105101. */
  105102. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105103. /**
  105104. * Set the value of an uniform to an array of int32 (stored as vec4)
  105105. * @param uniform defines the webGL uniform location where to store the value
  105106. * @param array defines the array of int32 to store
  105107. */
  105108. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105109. /**
  105110. * Set the value of an uniform to an array of number
  105111. * @param uniform defines the webGL uniform location where to store the value
  105112. * @param array defines the array of number to store
  105113. */
  105114. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105115. /**
  105116. * Set the value of an uniform to an array of number (stored as vec2)
  105117. * @param uniform defines the webGL uniform location where to store the value
  105118. * @param array defines the array of number to store
  105119. */
  105120. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105121. /**
  105122. * Set the value of an uniform to an array of number (stored as vec3)
  105123. * @param uniform defines the webGL uniform location where to store the value
  105124. * @param array defines the array of number to store
  105125. */
  105126. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105127. /**
  105128. * Set the value of an uniform to an array of number (stored as vec4)
  105129. * @param uniform defines the webGL uniform location where to store the value
  105130. * @param array defines the array of number to store
  105131. */
  105132. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105133. /**
  105134. * Set the value of an uniform to an array of float32 (stored as matrices)
  105135. * @param uniform defines the webGL uniform location where to store the value
  105136. * @param matrices defines the array of float32 to store
  105137. */
  105138. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  105139. /**
  105140. * Set the value of an uniform to a matrix (3x3)
  105141. * @param uniform defines the webGL uniform location where to store the value
  105142. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  105143. */
  105144. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105145. /**
  105146. * Set the value of an uniform to a matrix (2x2)
  105147. * @param uniform defines the webGL uniform location where to store the value
  105148. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  105149. */
  105150. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105151. /**
  105152. * Set the value of an uniform to a number (float)
  105153. * @param uniform defines the webGL uniform location where to store the value
  105154. * @param value defines the float number to store
  105155. */
  105156. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105157. /**
  105158. * Set the value of an uniform to a vec2
  105159. * @param uniform defines the webGL uniform location where to store the value
  105160. * @param x defines the 1st component of the value
  105161. * @param y defines the 2nd component of the value
  105162. */
  105163. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  105164. /**
  105165. * Set the value of an uniform to a vec3
  105166. * @param uniform defines the webGL uniform location where to store the value
  105167. * @param x defines the 1st component of the value
  105168. * @param y defines the 2nd component of the value
  105169. * @param z defines the 3rd component of the value
  105170. */
  105171. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  105172. /**
  105173. * Set the value of an uniform to a vec4
  105174. * @param uniform defines the webGL uniform location where to store the value
  105175. * @param x defines the 1st component of the value
  105176. * @param y defines the 2nd component of the value
  105177. * @param z defines the 3rd component of the value
  105178. * @param w defines the 4th component of the value
  105179. */
  105180. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105181. /**
  105182. * Apply all cached states (depth, culling, stencil and alpha)
  105183. */
  105184. applyStates(): void;
  105185. /**
  105186. * Enable or disable color writing
  105187. * @param enable defines the state to set
  105188. */
  105189. setColorWrite(enable: boolean): void;
  105190. /**
  105191. * Gets a boolean indicating if color writing is enabled
  105192. * @returns the current color writing state
  105193. */
  105194. getColorWrite(): boolean;
  105195. /**
  105196. * Gets the depth culling state manager
  105197. */
  105198. get depthCullingState(): DepthCullingState;
  105199. /**
  105200. * Gets the alpha state manager
  105201. */
  105202. get alphaState(): AlphaState;
  105203. /**
  105204. * Gets the stencil state manager
  105205. */
  105206. get stencilState(): StencilState;
  105207. /**
  105208. * Clears the list of texture accessible through engine.
  105209. * This can help preventing texture load conflict due to name collision.
  105210. */
  105211. clearInternalTexturesCache(): void;
  105212. /**
  105213. * Force the entire cache to be cleared
  105214. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105215. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105216. */
  105217. wipeCaches(bruteForce?: boolean): void;
  105218. /** @hidden */
  105219. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105220. min: number;
  105221. mag: number;
  105222. };
  105223. /** @hidden */
  105224. _createTexture(): WebGLTexture;
  105225. /**
  105226. * Usually called from Texture.ts.
  105227. * Passed information to create a WebGLTexture
  105228. * @param urlArg defines a value which contains one of the following:
  105229. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105230. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105231. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105232. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105233. * @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)
  105234. * @param scene needed for loading to the correct scene
  105235. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105236. * @param onLoad optional callback to be called upon successful completion
  105237. * @param onError optional callback to be called upon failure
  105238. * @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
  105239. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105240. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105241. * @param forcedExtension defines the extension to use to pick the right loader
  105242. * @param mimeType defines an optional mime type
  105243. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105244. */
  105245. 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;
  105246. /**
  105247. * Loads an image as an HTMLImageElement.
  105248. * @param input url string, ArrayBuffer, or Blob to load
  105249. * @param onLoad callback called when the image successfully loads
  105250. * @param onError callback called when the image fails to load
  105251. * @param offlineProvider offline provider for caching
  105252. * @param mimeType optional mime type
  105253. * @returns the HTMLImageElement of the loaded image
  105254. * @hidden
  105255. */
  105256. 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>;
  105257. /**
  105258. * @hidden
  105259. */
  105260. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105261. /**
  105262. * Creates a raw texture
  105263. * @param data defines the data to store in the texture
  105264. * @param width defines the width of the texture
  105265. * @param height defines the height of the texture
  105266. * @param format defines the format of the data
  105267. * @param generateMipMaps defines if the engine should generate the mip levels
  105268. * @param invertY defines if data must be stored with Y axis inverted
  105269. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105270. * @param compression defines the compression used (null by default)
  105271. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105272. * @returns the raw texture inside an InternalTexture
  105273. */
  105274. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105275. /**
  105276. * Creates a new raw cube texture
  105277. * @param data defines the array of data to use to create each face
  105278. * @param size defines the size of the textures
  105279. * @param format defines the format of the data
  105280. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105281. * @param generateMipMaps defines if the engine should generate the mip levels
  105282. * @param invertY defines if data must be stored with Y axis inverted
  105283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105284. * @param compression defines the compression used (null by default)
  105285. * @returns the cube texture as an InternalTexture
  105286. */
  105287. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105288. /**
  105289. * Creates a new raw 3D texture
  105290. * @param data defines the data used to create the texture
  105291. * @param width defines the width of the texture
  105292. * @param height defines the height of the texture
  105293. * @param depth defines the depth of the texture
  105294. * @param format defines the format of the texture
  105295. * @param generateMipMaps defines if the engine must generate mip levels
  105296. * @param invertY defines if data must be stored with Y axis inverted
  105297. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105298. * @param compression defines the compressed used (can be null)
  105299. * @param textureType defines the compressed used (can be null)
  105300. * @returns a new raw 3D texture (stored in an InternalTexture)
  105301. */
  105302. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105303. /**
  105304. * Creates a new raw 2D array texture
  105305. * @param data defines the data used to create the texture
  105306. * @param width defines the width of the texture
  105307. * @param height defines the height of the texture
  105308. * @param depth defines the number of layers of the texture
  105309. * @param format defines the format of the texture
  105310. * @param generateMipMaps defines if the engine must generate mip levels
  105311. * @param invertY defines if data must be stored with Y axis inverted
  105312. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105313. * @param compression defines the compressed used (can be null)
  105314. * @param textureType defines the compressed used (can be null)
  105315. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105316. */
  105317. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105318. private _unpackFlipYCached;
  105319. /**
  105320. * In case you are sharing the context with other applications, it might
  105321. * be interested to not cache the unpack flip y state to ensure a consistent
  105322. * value would be set.
  105323. */
  105324. enableUnpackFlipYCached: boolean;
  105325. /** @hidden */
  105326. _unpackFlipY(value: boolean): void;
  105327. /** @hidden */
  105328. _getUnpackAlignement(): number;
  105329. private _getTextureTarget;
  105330. /**
  105331. * Update the sampling mode of a given texture
  105332. * @param samplingMode defines the required sampling mode
  105333. * @param texture defines the texture to update
  105334. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105335. */
  105336. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105337. /**
  105338. * Update the sampling mode of a given texture
  105339. * @param texture defines the texture to update
  105340. * @param wrapU defines the texture wrap mode of the u coordinates
  105341. * @param wrapV defines the texture wrap mode of the v coordinates
  105342. * @param wrapR defines the texture wrap mode of the r coordinates
  105343. */
  105344. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105345. /** @hidden */
  105346. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105347. width: number;
  105348. height: number;
  105349. layers?: number;
  105350. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105351. /** @hidden */
  105352. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105353. /** @hidden */
  105354. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105355. /**
  105356. * Update a portion of an internal texture
  105357. * @param texture defines the texture to update
  105358. * @param imageData defines the data to store into the texture
  105359. * @param xOffset defines the x coordinates of the update rectangle
  105360. * @param yOffset defines the y coordinates of the update rectangle
  105361. * @param width defines the width of the update rectangle
  105362. * @param height defines the height of the update rectangle
  105363. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105364. * @param lod defines the lod level to update (0 by default)
  105365. */
  105366. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105367. /** @hidden */
  105368. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105369. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105370. private _prepareWebGLTexture;
  105371. /** @hidden */
  105372. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105373. private _getDepthStencilBuffer;
  105374. /** @hidden */
  105375. _releaseFramebufferObjects(texture: InternalTexture): void;
  105376. /** @hidden */
  105377. _releaseTexture(texture: InternalTexture): void;
  105378. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105379. protected _setProgram(program: WebGLProgram): void;
  105380. protected _boundUniforms: {
  105381. [key: number]: WebGLUniformLocation;
  105382. };
  105383. /**
  105384. * Binds an effect to the webGL context
  105385. * @param effect defines the effect to bind
  105386. */
  105387. bindSamplers(effect: Effect): void;
  105388. private _activateCurrentTexture;
  105389. /** @hidden */
  105390. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105391. /** @hidden */
  105392. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105393. /**
  105394. * Unbind all textures from the webGL context
  105395. */
  105396. unbindAllTextures(): void;
  105397. /**
  105398. * Sets a texture to the according uniform.
  105399. * @param channel The texture channel
  105400. * @param uniform The uniform to set
  105401. * @param texture The texture to apply
  105402. */
  105403. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105404. private _bindSamplerUniformToChannel;
  105405. private _getTextureWrapMode;
  105406. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105407. /**
  105408. * Sets an array of texture to the webGL context
  105409. * @param channel defines the channel where the texture array must be set
  105410. * @param uniform defines the associated uniform location
  105411. * @param textures defines the array of textures to bind
  105412. */
  105413. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105414. /** @hidden */
  105415. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105416. private _setTextureParameterFloat;
  105417. private _setTextureParameterInteger;
  105418. /**
  105419. * Unbind all vertex attributes from the webGL context
  105420. */
  105421. unbindAllAttributes(): void;
  105422. /**
  105423. * 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
  105424. */
  105425. releaseEffects(): void;
  105426. /**
  105427. * Dispose and release all associated resources
  105428. */
  105429. dispose(): void;
  105430. /**
  105431. * Attach a new callback raised when context lost event is fired
  105432. * @param callback defines the callback to call
  105433. */
  105434. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105435. /**
  105436. * Attach a new callback raised when context restored event is fired
  105437. * @param callback defines the callback to call
  105438. */
  105439. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105440. /**
  105441. * Get the current error code of the webGL context
  105442. * @returns the error code
  105443. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105444. */
  105445. getError(): number;
  105446. private _canRenderToFloatFramebuffer;
  105447. private _canRenderToHalfFloatFramebuffer;
  105448. private _canRenderToFramebuffer;
  105449. /** @hidden */
  105450. _getWebGLTextureType(type: number): number;
  105451. /** @hidden */
  105452. _getInternalFormat(format: number): number;
  105453. /** @hidden */
  105454. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105455. /** @hidden */
  105456. _getRGBAMultiSampleBufferFormat(type: number): number;
  105457. /** @hidden */
  105458. _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;
  105459. /**
  105460. * Loads a file from a url
  105461. * @param url url to load
  105462. * @param onSuccess callback called when the file successfully loads
  105463. * @param onProgress callback called while file is loading (if the server supports this mode)
  105464. * @param offlineProvider defines the offline provider for caching
  105465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105466. * @param onError callback called when the file fails to load
  105467. * @returns a file request object
  105468. * @hidden
  105469. */
  105470. 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;
  105471. /**
  105472. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105473. * @param x defines the x coordinate of the rectangle where pixels must be read
  105474. * @param y defines the y coordinate of the rectangle where pixels must be read
  105475. * @param width defines the width of the rectangle where pixels must be read
  105476. * @param height defines the height of the rectangle where pixels must be read
  105477. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105478. * @returns a Uint8Array containing RGBA colors
  105479. */
  105480. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105481. private static _isSupported;
  105482. /**
  105483. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105484. * @returns true if the engine can be created
  105485. * @ignorenaming
  105486. */
  105487. static isSupported(): boolean;
  105488. /**
  105489. * Find the next highest power of two.
  105490. * @param x Number to start search from.
  105491. * @return Next highest power of two.
  105492. */
  105493. static CeilingPOT(x: number): number;
  105494. /**
  105495. * Find the next lowest power of two.
  105496. * @param x Number to start search from.
  105497. * @return Next lowest power of two.
  105498. */
  105499. static FloorPOT(x: number): number;
  105500. /**
  105501. * Find the nearest power of two.
  105502. * @param x Number to start search from.
  105503. * @return Next nearest power of two.
  105504. */
  105505. static NearestPOT(x: number): number;
  105506. /**
  105507. * Get the closest exponent of two
  105508. * @param value defines the value to approximate
  105509. * @param max defines the maximum value to return
  105510. * @param mode defines how to define the closest value
  105511. * @returns closest exponent of two of the given value
  105512. */
  105513. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105514. /**
  105515. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105516. * @param func - the function to be called
  105517. * @param requester - the object that will request the next frame. Falls back to window.
  105518. * @returns frame number
  105519. */
  105520. static QueueNewFrame(func: () => void, requester?: any): number;
  105521. /**
  105522. * Gets host document
  105523. * @returns the host document object
  105524. */
  105525. getHostDocument(): Nullable<Document>;
  105526. }
  105527. }
  105528. declare module BABYLON {
  105529. /**
  105530. * Class representing spherical harmonics coefficients to the 3rd degree
  105531. */
  105532. export class SphericalHarmonics {
  105533. /**
  105534. * Defines whether or not the harmonics have been prescaled for rendering.
  105535. */
  105536. preScaled: boolean;
  105537. /**
  105538. * The l0,0 coefficients of the spherical harmonics
  105539. */
  105540. l00: Vector3;
  105541. /**
  105542. * The l1,-1 coefficients of the spherical harmonics
  105543. */
  105544. l1_1: Vector3;
  105545. /**
  105546. * The l1,0 coefficients of the spherical harmonics
  105547. */
  105548. l10: Vector3;
  105549. /**
  105550. * The l1,1 coefficients of the spherical harmonics
  105551. */
  105552. l11: Vector3;
  105553. /**
  105554. * The l2,-2 coefficients of the spherical harmonics
  105555. */
  105556. l2_2: Vector3;
  105557. /**
  105558. * The l2,-1 coefficients of the spherical harmonics
  105559. */
  105560. l2_1: Vector3;
  105561. /**
  105562. * The l2,0 coefficients of the spherical harmonics
  105563. */
  105564. l20: Vector3;
  105565. /**
  105566. * The l2,1 coefficients of the spherical harmonics
  105567. */
  105568. l21: Vector3;
  105569. /**
  105570. * The l2,2 coefficients of the spherical harmonics
  105571. */
  105572. l22: Vector3;
  105573. /**
  105574. * Adds a light to the spherical harmonics
  105575. * @param direction the direction of the light
  105576. * @param color the color of the light
  105577. * @param deltaSolidAngle the delta solid angle of the light
  105578. */
  105579. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105580. /**
  105581. * Scales the spherical harmonics by the given amount
  105582. * @param scale the amount to scale
  105583. */
  105584. scaleInPlace(scale: number): void;
  105585. /**
  105586. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105587. *
  105588. * ```
  105589. * E_lm = A_l * L_lm
  105590. * ```
  105591. *
  105592. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105593. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105594. * the scaling factors are given in equation 9.
  105595. */
  105596. convertIncidentRadianceToIrradiance(): void;
  105597. /**
  105598. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105599. *
  105600. * ```
  105601. * L = (1/pi) * E * rho
  105602. * ```
  105603. *
  105604. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105605. */
  105606. convertIrradianceToLambertianRadiance(): void;
  105607. /**
  105608. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105609. * required operations at run time.
  105610. *
  105611. * This is simply done by scaling back the SH with Ylm constants parameter.
  105612. * The trigonometric part being applied by the shader at run time.
  105613. */
  105614. preScaleForRendering(): void;
  105615. /**
  105616. * Constructs a spherical harmonics from an array.
  105617. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105618. * @returns the spherical harmonics
  105619. */
  105620. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105621. /**
  105622. * Gets the spherical harmonics from polynomial
  105623. * @param polynomial the spherical polynomial
  105624. * @returns the spherical harmonics
  105625. */
  105626. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105627. }
  105628. /**
  105629. * Class representing spherical polynomial coefficients to the 3rd degree
  105630. */
  105631. export class SphericalPolynomial {
  105632. private _harmonics;
  105633. /**
  105634. * The spherical harmonics used to create the polynomials.
  105635. */
  105636. get preScaledHarmonics(): SphericalHarmonics;
  105637. /**
  105638. * The x coefficients of the spherical polynomial
  105639. */
  105640. x: Vector3;
  105641. /**
  105642. * The y coefficients of the spherical polynomial
  105643. */
  105644. y: Vector3;
  105645. /**
  105646. * The z coefficients of the spherical polynomial
  105647. */
  105648. z: Vector3;
  105649. /**
  105650. * The xx coefficients of the spherical polynomial
  105651. */
  105652. xx: Vector3;
  105653. /**
  105654. * The yy coefficients of the spherical polynomial
  105655. */
  105656. yy: Vector3;
  105657. /**
  105658. * The zz coefficients of the spherical polynomial
  105659. */
  105660. zz: Vector3;
  105661. /**
  105662. * The xy coefficients of the spherical polynomial
  105663. */
  105664. xy: Vector3;
  105665. /**
  105666. * The yz coefficients of the spherical polynomial
  105667. */
  105668. yz: Vector3;
  105669. /**
  105670. * The zx coefficients of the spherical polynomial
  105671. */
  105672. zx: Vector3;
  105673. /**
  105674. * Adds an ambient color to the spherical polynomial
  105675. * @param color the color to add
  105676. */
  105677. addAmbient(color: Color3): void;
  105678. /**
  105679. * Scales the spherical polynomial by the given amount
  105680. * @param scale the amount to scale
  105681. */
  105682. scaleInPlace(scale: number): void;
  105683. /**
  105684. * Gets the spherical polynomial from harmonics
  105685. * @param harmonics the spherical harmonics
  105686. * @returns the spherical polynomial
  105687. */
  105688. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105689. /**
  105690. * Constructs a spherical polynomial from an array.
  105691. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105692. * @returns the spherical polynomial
  105693. */
  105694. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105695. }
  105696. }
  105697. declare module BABYLON {
  105698. /**
  105699. * Defines the source of the internal texture
  105700. */
  105701. export enum InternalTextureSource {
  105702. /**
  105703. * The source of the texture data is unknown
  105704. */
  105705. Unknown = 0,
  105706. /**
  105707. * Texture data comes from an URL
  105708. */
  105709. Url = 1,
  105710. /**
  105711. * Texture data is only used for temporary storage
  105712. */
  105713. Temp = 2,
  105714. /**
  105715. * Texture data comes from raw data (ArrayBuffer)
  105716. */
  105717. Raw = 3,
  105718. /**
  105719. * Texture content is dynamic (video or dynamic texture)
  105720. */
  105721. Dynamic = 4,
  105722. /**
  105723. * Texture content is generated by rendering to it
  105724. */
  105725. RenderTarget = 5,
  105726. /**
  105727. * Texture content is part of a multi render target process
  105728. */
  105729. MultiRenderTarget = 6,
  105730. /**
  105731. * Texture data comes from a cube data file
  105732. */
  105733. Cube = 7,
  105734. /**
  105735. * Texture data comes from a raw cube data
  105736. */
  105737. CubeRaw = 8,
  105738. /**
  105739. * Texture data come from a prefiltered cube data file
  105740. */
  105741. CubePrefiltered = 9,
  105742. /**
  105743. * Texture content is raw 3D data
  105744. */
  105745. Raw3D = 10,
  105746. /**
  105747. * Texture content is raw 2D array data
  105748. */
  105749. Raw2DArray = 11,
  105750. /**
  105751. * Texture content is a depth texture
  105752. */
  105753. Depth = 12,
  105754. /**
  105755. * Texture data comes from a raw cube data encoded with RGBD
  105756. */
  105757. CubeRawRGBD = 13
  105758. }
  105759. /**
  105760. * Class used to store data associated with WebGL texture data for the engine
  105761. * This class should not be used directly
  105762. */
  105763. export class InternalTexture {
  105764. /** @hidden */
  105765. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105766. /**
  105767. * Defines if the texture is ready
  105768. */
  105769. isReady: boolean;
  105770. /**
  105771. * Defines if the texture is a cube texture
  105772. */
  105773. isCube: boolean;
  105774. /**
  105775. * Defines if the texture contains 3D data
  105776. */
  105777. is3D: boolean;
  105778. /**
  105779. * Defines if the texture contains 2D array data
  105780. */
  105781. is2DArray: boolean;
  105782. /**
  105783. * Defines if the texture contains multiview data
  105784. */
  105785. isMultiview: boolean;
  105786. /**
  105787. * Gets the URL used to load this texture
  105788. */
  105789. url: string;
  105790. /**
  105791. * Gets the sampling mode of the texture
  105792. */
  105793. samplingMode: number;
  105794. /**
  105795. * Gets a boolean indicating if the texture needs mipmaps generation
  105796. */
  105797. generateMipMaps: boolean;
  105798. /**
  105799. * Gets the number of samples used by the texture (WebGL2+ only)
  105800. */
  105801. samples: number;
  105802. /**
  105803. * Gets the type of the texture (int, float...)
  105804. */
  105805. type: number;
  105806. /**
  105807. * Gets the format of the texture (RGB, RGBA...)
  105808. */
  105809. format: number;
  105810. /**
  105811. * Observable called when the texture is loaded
  105812. */
  105813. onLoadedObservable: Observable<InternalTexture>;
  105814. /**
  105815. * Gets the width of the texture
  105816. */
  105817. width: number;
  105818. /**
  105819. * Gets the height of the texture
  105820. */
  105821. height: number;
  105822. /**
  105823. * Gets the depth of the texture
  105824. */
  105825. depth: number;
  105826. /**
  105827. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105828. */
  105829. baseWidth: number;
  105830. /**
  105831. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105832. */
  105833. baseHeight: number;
  105834. /**
  105835. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105836. */
  105837. baseDepth: number;
  105838. /**
  105839. * Gets a boolean indicating if the texture is inverted on Y axis
  105840. */
  105841. invertY: boolean;
  105842. /** @hidden */
  105843. _invertVScale: boolean;
  105844. /** @hidden */
  105845. _associatedChannel: number;
  105846. /** @hidden */
  105847. _source: InternalTextureSource;
  105848. /** @hidden */
  105849. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105850. /** @hidden */
  105851. _bufferView: Nullable<ArrayBufferView>;
  105852. /** @hidden */
  105853. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105854. /** @hidden */
  105855. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105856. /** @hidden */
  105857. _size: number;
  105858. /** @hidden */
  105859. _extension: string;
  105860. /** @hidden */
  105861. _files: Nullable<string[]>;
  105862. /** @hidden */
  105863. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105864. /** @hidden */
  105865. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105866. /** @hidden */
  105867. _framebuffer: Nullable<WebGLFramebuffer>;
  105868. /** @hidden */
  105869. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105870. /** @hidden */
  105871. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105872. /** @hidden */
  105873. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105874. /** @hidden */
  105875. _attachments: Nullable<number[]>;
  105876. /** @hidden */
  105877. _cachedCoordinatesMode: Nullable<number>;
  105878. /** @hidden */
  105879. _cachedWrapU: Nullable<number>;
  105880. /** @hidden */
  105881. _cachedWrapV: Nullable<number>;
  105882. /** @hidden */
  105883. _cachedWrapR: Nullable<number>;
  105884. /** @hidden */
  105885. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105886. /** @hidden */
  105887. _isDisabled: boolean;
  105888. /** @hidden */
  105889. _compression: Nullable<string>;
  105890. /** @hidden */
  105891. _generateStencilBuffer: boolean;
  105892. /** @hidden */
  105893. _generateDepthBuffer: boolean;
  105894. /** @hidden */
  105895. _comparisonFunction: number;
  105896. /** @hidden */
  105897. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105898. /** @hidden */
  105899. _lodGenerationScale: number;
  105900. /** @hidden */
  105901. _lodGenerationOffset: number;
  105902. /** @hidden */
  105903. _depthStencilTexture: Nullable<InternalTexture>;
  105904. /** @hidden */
  105905. _colorTextureArray: Nullable<WebGLTexture>;
  105906. /** @hidden */
  105907. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105908. /** @hidden */
  105909. _lodTextureHigh: Nullable<BaseTexture>;
  105910. /** @hidden */
  105911. _lodTextureMid: Nullable<BaseTexture>;
  105912. /** @hidden */
  105913. _lodTextureLow: Nullable<BaseTexture>;
  105914. /** @hidden */
  105915. _isRGBD: boolean;
  105916. /** @hidden */
  105917. _linearSpecularLOD: boolean;
  105918. /** @hidden */
  105919. _irradianceTexture: Nullable<BaseTexture>;
  105920. /** @hidden */
  105921. _webGLTexture: Nullable<WebGLTexture>;
  105922. /** @hidden */
  105923. _references: number;
  105924. private _engine;
  105925. /**
  105926. * Gets the Engine the texture belongs to.
  105927. * @returns The babylon engine
  105928. */
  105929. getEngine(): ThinEngine;
  105930. /**
  105931. * Gets the data source type of the texture
  105932. */
  105933. get source(): InternalTextureSource;
  105934. /**
  105935. * Creates a new InternalTexture
  105936. * @param engine defines the engine to use
  105937. * @param source defines the type of data that will be used
  105938. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105939. */
  105940. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105941. /**
  105942. * Increments the number of references (ie. the number of Texture that point to it)
  105943. */
  105944. incrementReferences(): void;
  105945. /**
  105946. * Change the size of the texture (not the size of the content)
  105947. * @param width defines the new width
  105948. * @param height defines the new height
  105949. * @param depth defines the new depth (1 by default)
  105950. */
  105951. updateSize(width: int, height: int, depth?: int): void;
  105952. /** @hidden */
  105953. _rebuild(): void;
  105954. /** @hidden */
  105955. _swapAndDie(target: InternalTexture): void;
  105956. /**
  105957. * Dispose the current allocated resources
  105958. */
  105959. dispose(): void;
  105960. }
  105961. }
  105962. declare module BABYLON {
  105963. /**
  105964. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105966. */
  105967. export class Analyser {
  105968. /**
  105969. * Gets or sets the smoothing
  105970. * @ignorenaming
  105971. */
  105972. SMOOTHING: number;
  105973. /**
  105974. * Gets or sets the FFT table size
  105975. * @ignorenaming
  105976. */
  105977. FFT_SIZE: number;
  105978. /**
  105979. * Gets or sets the bar graph amplitude
  105980. * @ignorenaming
  105981. */
  105982. BARGRAPHAMPLITUDE: number;
  105983. /**
  105984. * Gets or sets the position of the debug canvas
  105985. * @ignorenaming
  105986. */
  105987. DEBUGCANVASPOS: {
  105988. x: number;
  105989. y: number;
  105990. };
  105991. /**
  105992. * Gets or sets the debug canvas size
  105993. * @ignorenaming
  105994. */
  105995. DEBUGCANVASSIZE: {
  105996. width: number;
  105997. height: number;
  105998. };
  105999. private _byteFreqs;
  106000. private _byteTime;
  106001. private _floatFreqs;
  106002. private _webAudioAnalyser;
  106003. private _debugCanvas;
  106004. private _debugCanvasContext;
  106005. private _scene;
  106006. private _registerFunc;
  106007. private _audioEngine;
  106008. /**
  106009. * Creates a new analyser
  106010. * @param scene defines hosting scene
  106011. */
  106012. constructor(scene: Scene);
  106013. /**
  106014. * Get the number of data values you will have to play with for the visualization
  106015. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  106016. * @returns a number
  106017. */
  106018. getFrequencyBinCount(): number;
  106019. /**
  106020. * Gets the current frequency data as a byte array
  106021. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106022. * @returns a Uint8Array
  106023. */
  106024. getByteFrequencyData(): Uint8Array;
  106025. /**
  106026. * Gets the current waveform as a byte array
  106027. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  106028. * @returns a Uint8Array
  106029. */
  106030. getByteTimeDomainData(): Uint8Array;
  106031. /**
  106032. * Gets the current frequency data as a float array
  106033. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106034. * @returns a Float32Array
  106035. */
  106036. getFloatFrequencyData(): Float32Array;
  106037. /**
  106038. * Renders the debug canvas
  106039. */
  106040. drawDebugCanvas(): void;
  106041. /**
  106042. * Stops rendering the debug canvas and removes it
  106043. */
  106044. stopDebugCanvas(): void;
  106045. /**
  106046. * Connects two audio nodes
  106047. * @param inputAudioNode defines first node to connect
  106048. * @param outputAudioNode defines second node to connect
  106049. */
  106050. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  106051. /**
  106052. * Releases all associated resources
  106053. */
  106054. dispose(): void;
  106055. }
  106056. }
  106057. declare module BABYLON {
  106058. /**
  106059. * This represents an audio engine and it is responsible
  106060. * to play, synchronize and analyse sounds throughout the application.
  106061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106062. */
  106063. export interface IAudioEngine extends IDisposable {
  106064. /**
  106065. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106066. */
  106067. readonly canUseWebAudio: boolean;
  106068. /**
  106069. * Gets the current AudioContext if available.
  106070. */
  106071. readonly audioContext: Nullable<AudioContext>;
  106072. /**
  106073. * The master gain node defines the global audio volume of your audio engine.
  106074. */
  106075. readonly masterGain: GainNode;
  106076. /**
  106077. * Gets whether or not mp3 are supported by your browser.
  106078. */
  106079. readonly isMP3supported: boolean;
  106080. /**
  106081. * Gets whether or not ogg are supported by your browser.
  106082. */
  106083. readonly isOGGsupported: boolean;
  106084. /**
  106085. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106086. * @ignoreNaming
  106087. */
  106088. WarnedWebAudioUnsupported: boolean;
  106089. /**
  106090. * Defines if the audio engine relies on a custom unlocked button.
  106091. * In this case, the embedded button will not be displayed.
  106092. */
  106093. useCustomUnlockedButton: boolean;
  106094. /**
  106095. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  106096. */
  106097. readonly unlocked: boolean;
  106098. /**
  106099. * Event raised when audio has been unlocked on the browser.
  106100. */
  106101. onAudioUnlockedObservable: Observable<AudioEngine>;
  106102. /**
  106103. * Event raised when audio has been locked on the browser.
  106104. */
  106105. onAudioLockedObservable: Observable<AudioEngine>;
  106106. /**
  106107. * Flags the audio engine in Locked state.
  106108. * This happens due to new browser policies preventing audio to autoplay.
  106109. */
  106110. lock(): void;
  106111. /**
  106112. * Unlocks the audio engine once a user action has been done on the dom.
  106113. * This is helpful to resume play once browser policies have been satisfied.
  106114. */
  106115. unlock(): void;
  106116. /**
  106117. * Gets the global volume sets on the master gain.
  106118. * @returns the global volume if set or -1 otherwise
  106119. */
  106120. getGlobalVolume(): number;
  106121. /**
  106122. * Sets the global volume of your experience (sets on the master gain).
  106123. * @param newVolume Defines the new global volume of the application
  106124. */
  106125. setGlobalVolume(newVolume: number): void;
  106126. /**
  106127. * Connect the audio engine to an audio analyser allowing some amazing
  106128. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106130. * @param analyser The analyser to connect to the engine
  106131. */
  106132. connectToAnalyser(analyser: Analyser): void;
  106133. }
  106134. /**
  106135. * This represents the default audio engine used in babylon.
  106136. * It is responsible to play, synchronize and analyse sounds throughout the application.
  106137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106138. */
  106139. export class AudioEngine implements IAudioEngine {
  106140. private _audioContext;
  106141. private _audioContextInitialized;
  106142. private _muteButton;
  106143. private _hostElement;
  106144. /**
  106145. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106146. */
  106147. canUseWebAudio: boolean;
  106148. /**
  106149. * The master gain node defines the global audio volume of your audio engine.
  106150. */
  106151. masterGain: GainNode;
  106152. /**
  106153. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106154. * @ignoreNaming
  106155. */
  106156. WarnedWebAudioUnsupported: boolean;
  106157. /**
  106158. * Gets whether or not mp3 are supported by your browser.
  106159. */
  106160. isMP3supported: boolean;
  106161. /**
  106162. * Gets whether or not ogg are supported by your browser.
  106163. */
  106164. isOGGsupported: boolean;
  106165. /**
  106166. * Gets whether audio has been unlocked on the device.
  106167. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  106168. * a user interaction has happened.
  106169. */
  106170. unlocked: boolean;
  106171. /**
  106172. * Defines if the audio engine relies on a custom unlocked button.
  106173. * In this case, the embedded button will not be displayed.
  106174. */
  106175. useCustomUnlockedButton: boolean;
  106176. /**
  106177. * Event raised when audio has been unlocked on the browser.
  106178. */
  106179. onAudioUnlockedObservable: Observable<AudioEngine>;
  106180. /**
  106181. * Event raised when audio has been locked on the browser.
  106182. */
  106183. onAudioLockedObservable: Observable<AudioEngine>;
  106184. /**
  106185. * Gets the current AudioContext if available.
  106186. */
  106187. get audioContext(): Nullable<AudioContext>;
  106188. private _connectedAnalyser;
  106189. /**
  106190. * Instantiates a new audio engine.
  106191. *
  106192. * There should be only one per page as some browsers restrict the number
  106193. * of audio contexts you can create.
  106194. * @param hostElement defines the host element where to display the mute icon if necessary
  106195. */
  106196. constructor(hostElement?: Nullable<HTMLElement>);
  106197. /**
  106198. * Flags the audio engine in Locked state.
  106199. * This happens due to new browser policies preventing audio to autoplay.
  106200. */
  106201. lock(): void;
  106202. /**
  106203. * Unlocks the audio engine once a user action has been done on the dom.
  106204. * This is helpful to resume play once browser policies have been satisfied.
  106205. */
  106206. unlock(): void;
  106207. private _resumeAudioContext;
  106208. private _initializeAudioContext;
  106209. private _tryToRun;
  106210. private _triggerRunningState;
  106211. private _triggerSuspendedState;
  106212. private _displayMuteButton;
  106213. private _moveButtonToTopLeft;
  106214. private _onResize;
  106215. private _hideMuteButton;
  106216. /**
  106217. * Destroy and release the resources associated with the audio ccontext.
  106218. */
  106219. dispose(): void;
  106220. /**
  106221. * Gets the global volume sets on the master gain.
  106222. * @returns the global volume if set or -1 otherwise
  106223. */
  106224. getGlobalVolume(): number;
  106225. /**
  106226. * Sets the global volume of your experience (sets on the master gain).
  106227. * @param newVolume Defines the new global volume of the application
  106228. */
  106229. setGlobalVolume(newVolume: number): void;
  106230. /**
  106231. * Connect the audio engine to an audio analyser allowing some amazing
  106232. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106234. * @param analyser The analyser to connect to the engine
  106235. */
  106236. connectToAnalyser(analyser: Analyser): void;
  106237. }
  106238. }
  106239. declare module BABYLON {
  106240. /**
  106241. * Interface used to present a loading screen while loading a scene
  106242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106243. */
  106244. export interface ILoadingScreen {
  106245. /**
  106246. * Function called to display the loading screen
  106247. */
  106248. displayLoadingUI: () => void;
  106249. /**
  106250. * Function called to hide the loading screen
  106251. */
  106252. hideLoadingUI: () => void;
  106253. /**
  106254. * Gets or sets the color to use for the background
  106255. */
  106256. loadingUIBackgroundColor: string;
  106257. /**
  106258. * Gets or sets the text to display while loading
  106259. */
  106260. loadingUIText: string;
  106261. }
  106262. /**
  106263. * Class used for the default loading screen
  106264. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106265. */
  106266. export class DefaultLoadingScreen implements ILoadingScreen {
  106267. private _renderingCanvas;
  106268. private _loadingText;
  106269. private _loadingDivBackgroundColor;
  106270. private _loadingDiv;
  106271. private _loadingTextDiv;
  106272. /** Gets or sets the logo url to use for the default loading screen */
  106273. static DefaultLogoUrl: string;
  106274. /** Gets or sets the spinner url to use for the default loading screen */
  106275. static DefaultSpinnerUrl: string;
  106276. /**
  106277. * Creates a new default loading screen
  106278. * @param _renderingCanvas defines the canvas used to render the scene
  106279. * @param _loadingText defines the default text to display
  106280. * @param _loadingDivBackgroundColor defines the default background color
  106281. */
  106282. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106283. /**
  106284. * Function called to display the loading screen
  106285. */
  106286. displayLoadingUI(): void;
  106287. /**
  106288. * Function called to hide the loading screen
  106289. */
  106290. hideLoadingUI(): void;
  106291. /**
  106292. * Gets or sets the text to display while loading
  106293. */
  106294. set loadingUIText(text: string);
  106295. get loadingUIText(): string;
  106296. /**
  106297. * Gets or sets the color to use for the background
  106298. */
  106299. get loadingUIBackgroundColor(): string;
  106300. set loadingUIBackgroundColor(color: string);
  106301. private _resizeLoadingUI;
  106302. }
  106303. }
  106304. declare module BABYLON {
  106305. /**
  106306. * Interface for any object that can request an animation frame
  106307. */
  106308. export interface ICustomAnimationFrameRequester {
  106309. /**
  106310. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106311. */
  106312. renderFunction?: Function;
  106313. /**
  106314. * Called to request the next frame to render to
  106315. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106316. */
  106317. requestAnimationFrame: Function;
  106318. /**
  106319. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106320. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106321. */
  106322. requestID?: number;
  106323. }
  106324. }
  106325. declare module BABYLON {
  106326. /**
  106327. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106328. */
  106329. export class PerformanceMonitor {
  106330. private _enabled;
  106331. private _rollingFrameTime;
  106332. private _lastFrameTimeMs;
  106333. /**
  106334. * constructor
  106335. * @param frameSampleSize The number of samples required to saturate the sliding window
  106336. */
  106337. constructor(frameSampleSize?: number);
  106338. /**
  106339. * Samples current frame
  106340. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106341. */
  106342. sampleFrame(timeMs?: number): void;
  106343. /**
  106344. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106345. */
  106346. get averageFrameTime(): number;
  106347. /**
  106348. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106349. */
  106350. get averageFrameTimeVariance(): number;
  106351. /**
  106352. * Returns the frame time of the most recent frame
  106353. */
  106354. get instantaneousFrameTime(): number;
  106355. /**
  106356. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106357. */
  106358. get averageFPS(): number;
  106359. /**
  106360. * Returns the average framerate in frames per second using the most recent frame time
  106361. */
  106362. get instantaneousFPS(): number;
  106363. /**
  106364. * Returns true if enough samples have been taken to completely fill the sliding window
  106365. */
  106366. get isSaturated(): boolean;
  106367. /**
  106368. * Enables contributions to the sliding window sample set
  106369. */
  106370. enable(): void;
  106371. /**
  106372. * Disables contributions to the sliding window sample set
  106373. * Samples will not be interpolated over the disabled period
  106374. */
  106375. disable(): void;
  106376. /**
  106377. * Returns true if sampling is enabled
  106378. */
  106379. get isEnabled(): boolean;
  106380. /**
  106381. * Resets performance monitor
  106382. */
  106383. reset(): void;
  106384. }
  106385. /**
  106386. * RollingAverage
  106387. *
  106388. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106389. */
  106390. export class RollingAverage {
  106391. /**
  106392. * Current average
  106393. */
  106394. average: number;
  106395. /**
  106396. * Current variance
  106397. */
  106398. variance: number;
  106399. protected _samples: Array<number>;
  106400. protected _sampleCount: number;
  106401. protected _pos: number;
  106402. protected _m2: number;
  106403. /**
  106404. * constructor
  106405. * @param length The number of samples required to saturate the sliding window
  106406. */
  106407. constructor(length: number);
  106408. /**
  106409. * Adds a sample to the sample set
  106410. * @param v The sample value
  106411. */
  106412. add(v: number): void;
  106413. /**
  106414. * Returns previously added values or null if outside of history or outside the sliding window domain
  106415. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106416. * @return Value previously recorded with add() or null if outside of range
  106417. */
  106418. history(i: number): number;
  106419. /**
  106420. * Returns true if enough samples have been taken to completely fill the sliding window
  106421. * @return true if sample-set saturated
  106422. */
  106423. isSaturated(): boolean;
  106424. /**
  106425. * Resets the rolling average (equivalent to 0 samples taken so far)
  106426. */
  106427. reset(): void;
  106428. /**
  106429. * Wraps a value around the sample range boundaries
  106430. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106431. * @return Wrapped position in sample range
  106432. */
  106433. protected _wrapPosition(i: number): number;
  106434. }
  106435. }
  106436. declare module BABYLON {
  106437. /**
  106438. * This class is used to track a performance counter which is number based.
  106439. * The user has access to many properties which give statistics of different nature.
  106440. *
  106441. * The implementer can track two kinds of Performance Counter: time and count.
  106442. * 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.
  106443. * 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.
  106444. */
  106445. export class PerfCounter {
  106446. /**
  106447. * Gets or sets a global boolean to turn on and off all the counters
  106448. */
  106449. static Enabled: boolean;
  106450. /**
  106451. * Returns the smallest value ever
  106452. */
  106453. get min(): number;
  106454. /**
  106455. * Returns the biggest value ever
  106456. */
  106457. get max(): number;
  106458. /**
  106459. * Returns the average value since the performance counter is running
  106460. */
  106461. get average(): number;
  106462. /**
  106463. * Returns the average value of the last second the counter was monitored
  106464. */
  106465. get lastSecAverage(): number;
  106466. /**
  106467. * Returns the current value
  106468. */
  106469. get current(): number;
  106470. /**
  106471. * Gets the accumulated total
  106472. */
  106473. get total(): number;
  106474. /**
  106475. * Gets the total value count
  106476. */
  106477. get count(): number;
  106478. /**
  106479. * Creates a new counter
  106480. */
  106481. constructor();
  106482. /**
  106483. * Call this method to start monitoring a new frame.
  106484. * 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.
  106485. */
  106486. fetchNewFrame(): void;
  106487. /**
  106488. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106489. * @param newCount the count value to add to the monitored count
  106490. * @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.
  106491. */
  106492. addCount(newCount: number, fetchResult: boolean): void;
  106493. /**
  106494. * Start monitoring this performance counter
  106495. */
  106496. beginMonitoring(): void;
  106497. /**
  106498. * Compute the time lapsed since the previous beginMonitoring() call.
  106499. * @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
  106500. */
  106501. endMonitoring(newFrame?: boolean): void;
  106502. private _fetchResult;
  106503. private _startMonitoringTime;
  106504. private _min;
  106505. private _max;
  106506. private _average;
  106507. private _current;
  106508. private _totalValueCount;
  106509. private _totalAccumulated;
  106510. private _lastSecAverage;
  106511. private _lastSecAccumulated;
  106512. private _lastSecTime;
  106513. private _lastSecValueCount;
  106514. }
  106515. }
  106516. declare module BABYLON {
  106517. interface ThinEngine {
  106518. /**
  106519. * Sets alpha constants used by some alpha blending modes
  106520. * @param r defines the red component
  106521. * @param g defines the green component
  106522. * @param b defines the blue component
  106523. * @param a defines the alpha component
  106524. */
  106525. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106526. /**
  106527. * Sets the current alpha mode
  106528. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106529. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106531. */
  106532. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106533. /**
  106534. * Gets the current alpha mode
  106535. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106536. * @returns the current alpha mode
  106537. */
  106538. getAlphaMode(): number;
  106539. /**
  106540. * Sets the current alpha equation
  106541. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106542. */
  106543. setAlphaEquation(equation: number): void;
  106544. /**
  106545. * Gets the current alpha equation.
  106546. * @returns the current alpha equation
  106547. */
  106548. getAlphaEquation(): number;
  106549. }
  106550. }
  106551. declare module BABYLON {
  106552. /**
  106553. * Defines the interface used by display changed events
  106554. */
  106555. export interface IDisplayChangedEventArgs {
  106556. /** Gets the vrDisplay object (if any) */
  106557. vrDisplay: Nullable<any>;
  106558. /** Gets a boolean indicating if webVR is supported */
  106559. vrSupported: boolean;
  106560. }
  106561. /**
  106562. * Defines the interface used by objects containing a viewport (like a camera)
  106563. */
  106564. interface IViewportOwnerLike {
  106565. /**
  106566. * Gets or sets the viewport
  106567. */
  106568. viewport: IViewportLike;
  106569. }
  106570. /**
  106571. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106572. */
  106573. export class Engine extends ThinEngine {
  106574. /** Defines that alpha blending is disabled */
  106575. static readonly ALPHA_DISABLE: number;
  106576. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106577. static readonly ALPHA_ADD: number;
  106578. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106579. static readonly ALPHA_COMBINE: number;
  106580. /** Defines that alpha blending to DEST - SRC * DEST */
  106581. static readonly ALPHA_SUBTRACT: number;
  106582. /** Defines that alpha blending to SRC * DEST */
  106583. static readonly ALPHA_MULTIPLY: number;
  106584. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106585. static readonly ALPHA_MAXIMIZED: number;
  106586. /** Defines that alpha blending to SRC + DEST */
  106587. static readonly ALPHA_ONEONE: number;
  106588. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106589. static readonly ALPHA_PREMULTIPLIED: number;
  106590. /**
  106591. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106592. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106593. */
  106594. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106595. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106596. static readonly ALPHA_INTERPOLATE: number;
  106597. /**
  106598. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106599. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106600. */
  106601. static readonly ALPHA_SCREENMODE: number;
  106602. /** Defines that the ressource is not delayed*/
  106603. static readonly DELAYLOADSTATE_NONE: number;
  106604. /** Defines that the ressource was successfully delay loaded */
  106605. static readonly DELAYLOADSTATE_LOADED: number;
  106606. /** Defines that the ressource is currently delay loading */
  106607. static readonly DELAYLOADSTATE_LOADING: number;
  106608. /** Defines that the ressource is delayed and has not started loading */
  106609. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106611. static readonly NEVER: number;
  106612. /** 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 */
  106613. static readonly ALWAYS: number;
  106614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106615. static readonly LESS: number;
  106616. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106617. static readonly EQUAL: number;
  106618. /** 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 */
  106619. static readonly LEQUAL: number;
  106620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106621. static readonly GREATER: number;
  106622. /** 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 */
  106623. static readonly GEQUAL: number;
  106624. /** 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 */
  106625. static readonly NOTEQUAL: number;
  106626. /** Passed to stencilOperation to specify that stencil value must be kept */
  106627. static readonly KEEP: number;
  106628. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106629. static readonly REPLACE: number;
  106630. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106631. static readonly INCR: number;
  106632. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106633. static readonly DECR: number;
  106634. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106635. static readonly INVERT: number;
  106636. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106637. static readonly INCR_WRAP: number;
  106638. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106639. static readonly DECR_WRAP: number;
  106640. /** Texture is not repeating outside of 0..1 UVs */
  106641. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106642. /** Texture is repeating outside of 0..1 UVs */
  106643. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106644. /** Texture is repeating and mirrored */
  106645. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106646. /** ALPHA */
  106647. static readonly TEXTUREFORMAT_ALPHA: number;
  106648. /** LUMINANCE */
  106649. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106650. /** LUMINANCE_ALPHA */
  106651. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106652. /** RGB */
  106653. static readonly TEXTUREFORMAT_RGB: number;
  106654. /** RGBA */
  106655. static readonly TEXTUREFORMAT_RGBA: number;
  106656. /** RED */
  106657. static readonly TEXTUREFORMAT_RED: number;
  106658. /** RED (2nd reference) */
  106659. static readonly TEXTUREFORMAT_R: number;
  106660. /** RG */
  106661. static readonly TEXTUREFORMAT_RG: number;
  106662. /** RED_INTEGER */
  106663. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106664. /** RED_INTEGER (2nd reference) */
  106665. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106666. /** RG_INTEGER */
  106667. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106668. /** RGB_INTEGER */
  106669. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106670. /** RGBA_INTEGER */
  106671. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106672. /** UNSIGNED_BYTE */
  106673. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106674. /** UNSIGNED_BYTE (2nd reference) */
  106675. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106676. /** FLOAT */
  106677. static readonly TEXTURETYPE_FLOAT: number;
  106678. /** HALF_FLOAT */
  106679. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106680. /** BYTE */
  106681. static readonly TEXTURETYPE_BYTE: number;
  106682. /** SHORT */
  106683. static readonly TEXTURETYPE_SHORT: number;
  106684. /** UNSIGNED_SHORT */
  106685. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106686. /** INT */
  106687. static readonly TEXTURETYPE_INT: number;
  106688. /** UNSIGNED_INT */
  106689. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106690. /** UNSIGNED_SHORT_4_4_4_4 */
  106691. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106692. /** UNSIGNED_SHORT_5_5_5_1 */
  106693. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106694. /** UNSIGNED_SHORT_5_6_5 */
  106695. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106696. /** UNSIGNED_INT_2_10_10_10_REV */
  106697. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106698. /** UNSIGNED_INT_24_8 */
  106699. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106700. /** UNSIGNED_INT_10F_11F_11F_REV */
  106701. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106702. /** UNSIGNED_INT_5_9_9_9_REV */
  106703. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106704. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106705. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106706. /** nearest is mag = nearest and min = nearest and mip = linear */
  106707. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106708. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106709. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106710. /** Trilinear is mag = linear and min = linear and mip = linear */
  106711. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106712. /** nearest is mag = nearest and min = nearest and mip = linear */
  106713. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106714. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106715. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106716. /** Trilinear is mag = linear and min = linear and mip = linear */
  106717. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106718. /** mag = nearest and min = nearest and mip = nearest */
  106719. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106720. /** mag = nearest and min = linear and mip = nearest */
  106721. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106722. /** mag = nearest and min = linear and mip = linear */
  106723. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106724. /** mag = nearest and min = linear and mip = none */
  106725. static readonly TEXTURE_NEAREST_LINEAR: number;
  106726. /** mag = nearest and min = nearest and mip = none */
  106727. static readonly TEXTURE_NEAREST_NEAREST: number;
  106728. /** mag = linear and min = nearest and mip = nearest */
  106729. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106730. /** mag = linear and min = nearest and mip = linear */
  106731. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106732. /** mag = linear and min = linear and mip = none */
  106733. static readonly TEXTURE_LINEAR_LINEAR: number;
  106734. /** mag = linear and min = nearest and mip = none */
  106735. static readonly TEXTURE_LINEAR_NEAREST: number;
  106736. /** Explicit coordinates mode */
  106737. static readonly TEXTURE_EXPLICIT_MODE: number;
  106738. /** Spherical coordinates mode */
  106739. static readonly TEXTURE_SPHERICAL_MODE: number;
  106740. /** Planar coordinates mode */
  106741. static readonly TEXTURE_PLANAR_MODE: number;
  106742. /** Cubic coordinates mode */
  106743. static readonly TEXTURE_CUBIC_MODE: number;
  106744. /** Projection coordinates mode */
  106745. static readonly TEXTURE_PROJECTION_MODE: number;
  106746. /** Skybox coordinates mode */
  106747. static readonly TEXTURE_SKYBOX_MODE: number;
  106748. /** Inverse Cubic coordinates mode */
  106749. static readonly TEXTURE_INVCUBIC_MODE: number;
  106750. /** Equirectangular coordinates mode */
  106751. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106752. /** Equirectangular Fixed coordinates mode */
  106753. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106754. /** Equirectangular Fixed Mirrored coordinates mode */
  106755. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106756. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106757. static readonly SCALEMODE_FLOOR: number;
  106758. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106759. static readonly SCALEMODE_NEAREST: number;
  106760. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106761. static readonly SCALEMODE_CEILING: number;
  106762. /**
  106763. * Returns the current npm package of the sdk
  106764. */
  106765. static get NpmPackage(): string;
  106766. /**
  106767. * Returns the current version of the framework
  106768. */
  106769. static get Version(): string;
  106770. /** Gets the list of created engines */
  106771. static get Instances(): Engine[];
  106772. /**
  106773. * Gets the latest created engine
  106774. */
  106775. static get LastCreatedEngine(): Nullable<Engine>;
  106776. /**
  106777. * Gets the latest created scene
  106778. */
  106779. static get LastCreatedScene(): Nullable<Scene>;
  106780. /**
  106781. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106782. * @param flag defines which part of the materials must be marked as dirty
  106783. * @param predicate defines a predicate used to filter which materials should be affected
  106784. */
  106785. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106786. /**
  106787. * Method called to create the default loading screen.
  106788. * This can be overriden in your own app.
  106789. * @param canvas The rendering canvas element
  106790. * @returns The loading screen
  106791. */
  106792. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106793. /**
  106794. * Method called to create the default rescale post process on each engine.
  106795. */
  106796. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106797. /**
  106798. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106799. **/
  106800. enableOfflineSupport: boolean;
  106801. /**
  106802. * 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)
  106803. **/
  106804. disableManifestCheck: boolean;
  106805. /**
  106806. * Gets the list of created scenes
  106807. */
  106808. scenes: Scene[];
  106809. /**
  106810. * Event raised when a new scene is created
  106811. */
  106812. onNewSceneAddedObservable: Observable<Scene>;
  106813. /**
  106814. * Gets the list of created postprocesses
  106815. */
  106816. postProcesses: PostProcess[];
  106817. /**
  106818. * Gets a boolean indicating if the pointer is currently locked
  106819. */
  106820. isPointerLock: boolean;
  106821. /**
  106822. * Observable event triggered each time the rendering canvas is resized
  106823. */
  106824. onResizeObservable: Observable<Engine>;
  106825. /**
  106826. * Observable event triggered each time the canvas loses focus
  106827. */
  106828. onCanvasBlurObservable: Observable<Engine>;
  106829. /**
  106830. * Observable event triggered each time the canvas gains focus
  106831. */
  106832. onCanvasFocusObservable: Observable<Engine>;
  106833. /**
  106834. * Observable event triggered each time the canvas receives pointerout event
  106835. */
  106836. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106837. /**
  106838. * Observable raised when the engine begins a new frame
  106839. */
  106840. onBeginFrameObservable: Observable<Engine>;
  106841. /**
  106842. * If set, will be used to request the next animation frame for the render loop
  106843. */
  106844. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106845. /**
  106846. * Observable raised when the engine ends the current frame
  106847. */
  106848. onEndFrameObservable: Observable<Engine>;
  106849. /**
  106850. * Observable raised when the engine is about to compile a shader
  106851. */
  106852. onBeforeShaderCompilationObservable: Observable<Engine>;
  106853. /**
  106854. * Observable raised when the engine has jsut compiled a shader
  106855. */
  106856. onAfterShaderCompilationObservable: Observable<Engine>;
  106857. /**
  106858. * Gets the audio engine
  106859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106860. * @ignorenaming
  106861. */
  106862. static audioEngine: IAudioEngine;
  106863. /**
  106864. * Default AudioEngine factory responsible of creating the Audio Engine.
  106865. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106866. */
  106867. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106868. /**
  106869. * Default offline support factory responsible of creating a tool used to store data locally.
  106870. * By default, this will create a Database object if the workload has been embedded.
  106871. */
  106872. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106873. private _loadingScreen;
  106874. private _pointerLockRequested;
  106875. private _dummyFramebuffer;
  106876. private _rescalePostProcess;
  106877. private _deterministicLockstep;
  106878. private _lockstepMaxSteps;
  106879. private _timeStep;
  106880. protected get _supportsHardwareTextureRescaling(): boolean;
  106881. private _fps;
  106882. private _deltaTime;
  106883. /** @hidden */
  106884. _drawCalls: PerfCounter;
  106885. /** 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 */
  106886. canvasTabIndex: number;
  106887. /**
  106888. * Turn this value on if you want to pause FPS computation when in background
  106889. */
  106890. disablePerformanceMonitorInBackground: boolean;
  106891. private _performanceMonitor;
  106892. /**
  106893. * Gets the performance monitor attached to this engine
  106894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106895. */
  106896. get performanceMonitor(): PerformanceMonitor;
  106897. private _onFocus;
  106898. private _onBlur;
  106899. private _onCanvasPointerOut;
  106900. private _onCanvasBlur;
  106901. private _onCanvasFocus;
  106902. private _onFullscreenChange;
  106903. private _onPointerLockChange;
  106904. /**
  106905. * Gets the HTML element used to attach event listeners
  106906. * @returns a HTML element
  106907. */
  106908. getInputElement(): Nullable<HTMLElement>;
  106909. /**
  106910. * Creates a new engine
  106911. * @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
  106912. * @param antialias defines enable antialiasing (default: false)
  106913. * @param options defines further options to be sent to the getContext() function
  106914. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106915. */
  106916. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106917. /**
  106918. * Gets current aspect ratio
  106919. * @param viewportOwner defines the camera to use to get the aspect ratio
  106920. * @param useScreen defines if screen size must be used (or the current render target if any)
  106921. * @returns a number defining the aspect ratio
  106922. */
  106923. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106924. /**
  106925. * Gets current screen aspect ratio
  106926. * @returns a number defining the aspect ratio
  106927. */
  106928. getScreenAspectRatio(): number;
  106929. /**
  106930. * Gets the client rect of the HTML canvas attached with the current webGL context
  106931. * @returns a client rectanglee
  106932. */
  106933. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106934. /**
  106935. * Gets the client rect of the HTML element used for events
  106936. * @returns a client rectanglee
  106937. */
  106938. getInputElementClientRect(): Nullable<ClientRect>;
  106939. /**
  106940. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106941. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106942. * @returns true if engine is in deterministic lock step mode
  106943. */
  106944. isDeterministicLockStep(): boolean;
  106945. /**
  106946. * Gets the max steps when engine is running in deterministic lock step
  106947. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106948. * @returns the max steps
  106949. */
  106950. getLockstepMaxSteps(): number;
  106951. /**
  106952. * Returns the time in ms between steps when using deterministic lock step.
  106953. * @returns time step in (ms)
  106954. */
  106955. getTimeStep(): number;
  106956. /**
  106957. * Force the mipmap generation for the given render target texture
  106958. * @param texture defines the render target texture to use
  106959. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106960. */
  106961. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106962. /** States */
  106963. /**
  106964. * Set various states to the webGL context
  106965. * @param culling defines backface culling state
  106966. * @param zOffset defines the value to apply to zOffset (0 by default)
  106967. * @param force defines if states must be applied even if cache is up to date
  106968. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106969. */
  106970. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106971. /**
  106972. * Set the z offset to apply to current rendering
  106973. * @param value defines the offset to apply
  106974. */
  106975. setZOffset(value: number): void;
  106976. /**
  106977. * Gets the current value of the zOffset
  106978. * @returns the current zOffset state
  106979. */
  106980. getZOffset(): number;
  106981. /**
  106982. * Enable or disable depth buffering
  106983. * @param enable defines the state to set
  106984. */
  106985. setDepthBuffer(enable: boolean): void;
  106986. /**
  106987. * Gets a boolean indicating if depth writing is enabled
  106988. * @returns the current depth writing state
  106989. */
  106990. getDepthWrite(): boolean;
  106991. /**
  106992. * Enable or disable depth writing
  106993. * @param enable defines the state to set
  106994. */
  106995. setDepthWrite(enable: boolean): void;
  106996. /**
  106997. * Gets a boolean indicating if stencil buffer is enabled
  106998. * @returns the current stencil buffer state
  106999. */
  107000. getStencilBuffer(): boolean;
  107001. /**
  107002. * Enable or disable the stencil buffer
  107003. * @param enable defines if the stencil buffer must be enabled or disabled
  107004. */
  107005. setStencilBuffer(enable: boolean): void;
  107006. /**
  107007. * Gets the current stencil mask
  107008. * @returns a number defining the new stencil mask to use
  107009. */
  107010. getStencilMask(): number;
  107011. /**
  107012. * Sets the current stencil mask
  107013. * @param mask defines the new stencil mask to use
  107014. */
  107015. setStencilMask(mask: number): void;
  107016. /**
  107017. * Gets the current stencil function
  107018. * @returns a number defining the stencil function to use
  107019. */
  107020. getStencilFunction(): number;
  107021. /**
  107022. * Gets the current stencil reference value
  107023. * @returns a number defining the stencil reference value to use
  107024. */
  107025. getStencilFunctionReference(): number;
  107026. /**
  107027. * Gets the current stencil mask
  107028. * @returns a number defining the stencil mask to use
  107029. */
  107030. getStencilFunctionMask(): number;
  107031. /**
  107032. * Sets the current stencil function
  107033. * @param stencilFunc defines the new stencil function to use
  107034. */
  107035. setStencilFunction(stencilFunc: number): void;
  107036. /**
  107037. * Sets the current stencil reference
  107038. * @param reference defines the new stencil reference to use
  107039. */
  107040. setStencilFunctionReference(reference: number): void;
  107041. /**
  107042. * Sets the current stencil mask
  107043. * @param mask defines the new stencil mask to use
  107044. */
  107045. setStencilFunctionMask(mask: number): void;
  107046. /**
  107047. * Gets the current stencil operation when stencil fails
  107048. * @returns a number defining stencil operation to use when stencil fails
  107049. */
  107050. getStencilOperationFail(): number;
  107051. /**
  107052. * Gets the current stencil operation when depth fails
  107053. * @returns a number defining stencil operation to use when depth fails
  107054. */
  107055. getStencilOperationDepthFail(): number;
  107056. /**
  107057. * Gets the current stencil operation when stencil passes
  107058. * @returns a number defining stencil operation to use when stencil passes
  107059. */
  107060. getStencilOperationPass(): number;
  107061. /**
  107062. * Sets the stencil operation to use when stencil fails
  107063. * @param operation defines the stencil operation to use when stencil fails
  107064. */
  107065. setStencilOperationFail(operation: number): void;
  107066. /**
  107067. * Sets the stencil operation to use when depth fails
  107068. * @param operation defines the stencil operation to use when depth fails
  107069. */
  107070. setStencilOperationDepthFail(operation: number): void;
  107071. /**
  107072. * Sets the stencil operation to use when stencil passes
  107073. * @param operation defines the stencil operation to use when stencil passes
  107074. */
  107075. setStencilOperationPass(operation: number): void;
  107076. /**
  107077. * Sets a boolean indicating if the dithering state is enabled or disabled
  107078. * @param value defines the dithering state
  107079. */
  107080. setDitheringState(value: boolean): void;
  107081. /**
  107082. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107083. * @param value defines the rasterizer state
  107084. */
  107085. setRasterizerState(value: boolean): void;
  107086. /**
  107087. * Gets the current depth function
  107088. * @returns a number defining the depth function
  107089. */
  107090. getDepthFunction(): Nullable<number>;
  107091. /**
  107092. * Sets the current depth function
  107093. * @param depthFunc defines the function to use
  107094. */
  107095. setDepthFunction(depthFunc: number): void;
  107096. /**
  107097. * Sets the current depth function to GREATER
  107098. */
  107099. setDepthFunctionToGreater(): void;
  107100. /**
  107101. * Sets the current depth function to GEQUAL
  107102. */
  107103. setDepthFunctionToGreaterOrEqual(): void;
  107104. /**
  107105. * Sets the current depth function to LESS
  107106. */
  107107. setDepthFunctionToLess(): void;
  107108. /**
  107109. * Sets the current depth function to LEQUAL
  107110. */
  107111. setDepthFunctionToLessOrEqual(): void;
  107112. private _cachedStencilBuffer;
  107113. private _cachedStencilFunction;
  107114. private _cachedStencilMask;
  107115. private _cachedStencilOperationPass;
  107116. private _cachedStencilOperationFail;
  107117. private _cachedStencilOperationDepthFail;
  107118. private _cachedStencilReference;
  107119. /**
  107120. * Caches the the state of the stencil buffer
  107121. */
  107122. cacheStencilState(): void;
  107123. /**
  107124. * Restores the state of the stencil buffer
  107125. */
  107126. restoreStencilState(): void;
  107127. /**
  107128. * Directly set the WebGL Viewport
  107129. * @param x defines the x coordinate of the viewport (in screen space)
  107130. * @param y defines the y coordinate of the viewport (in screen space)
  107131. * @param width defines the width of the viewport (in screen space)
  107132. * @param height defines the height of the viewport (in screen space)
  107133. * @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
  107134. */
  107135. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  107136. /**
  107137. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  107138. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107139. * @param y defines the y-coordinate of the corner of the clear rectangle
  107140. * @param width defines the width of the clear rectangle
  107141. * @param height defines the height of the clear rectangle
  107142. * @param clearColor defines the clear color
  107143. */
  107144. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  107145. /**
  107146. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  107147. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107148. * @param y defines the y-coordinate of the corner of the clear rectangle
  107149. * @param width defines the width of the clear rectangle
  107150. * @param height defines the height of the clear rectangle
  107151. */
  107152. enableScissor(x: number, y: number, width: number, height: number): void;
  107153. /**
  107154. * Disable previously set scissor test rectangle
  107155. */
  107156. disableScissor(): void;
  107157. protected _reportDrawCall(): void;
  107158. /**
  107159. * Initializes a webVR display and starts listening to display change events
  107160. * The onVRDisplayChangedObservable will be notified upon these changes
  107161. * @returns The onVRDisplayChangedObservable
  107162. */
  107163. initWebVR(): Observable<IDisplayChangedEventArgs>;
  107164. /** @hidden */
  107165. _prepareVRComponent(): void;
  107166. /** @hidden */
  107167. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  107168. /** @hidden */
  107169. _submitVRFrame(): void;
  107170. /**
  107171. * Call this function to leave webVR mode
  107172. * Will do nothing if webVR is not supported or if there is no webVR device
  107173. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107174. */
  107175. disableVR(): void;
  107176. /**
  107177. * Gets a boolean indicating that the system is in VR mode and is presenting
  107178. * @returns true if VR mode is engaged
  107179. */
  107180. isVRPresenting(): boolean;
  107181. /** @hidden */
  107182. _requestVRFrame(): void;
  107183. /** @hidden */
  107184. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107185. /**
  107186. * Gets the source code of the vertex shader associated with a specific webGL program
  107187. * @param program defines the program to use
  107188. * @returns a string containing the source code of the vertex shader associated with the program
  107189. */
  107190. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107191. /**
  107192. * Gets the source code of the fragment shader associated with a specific webGL program
  107193. * @param program defines the program to use
  107194. * @returns a string containing the source code of the fragment shader associated with the program
  107195. */
  107196. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107197. /**
  107198. * Sets a depth stencil texture from a render target to the according uniform.
  107199. * @param channel The texture channel
  107200. * @param uniform The uniform to set
  107201. * @param texture The render target texture containing the depth stencil texture to apply
  107202. */
  107203. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107204. /**
  107205. * Sets a texture to the webGL context from a postprocess
  107206. * @param channel defines the channel to use
  107207. * @param postProcess defines the source postprocess
  107208. */
  107209. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107210. /**
  107211. * Binds the output of the passed in post process to the texture channel specified
  107212. * @param channel The channel the texture should be bound to
  107213. * @param postProcess The post process which's output should be bound
  107214. */
  107215. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107216. /** @hidden */
  107217. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107218. protected _rebuildBuffers(): void;
  107219. /** @hidden */
  107220. _renderFrame(): void;
  107221. _renderLoop(): void;
  107222. /** @hidden */
  107223. _renderViews(): boolean;
  107224. /**
  107225. * Toggle full screen mode
  107226. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107227. */
  107228. switchFullscreen(requestPointerLock: boolean): void;
  107229. /**
  107230. * Enters full screen mode
  107231. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107232. */
  107233. enterFullscreen(requestPointerLock: boolean): void;
  107234. /**
  107235. * Exits full screen mode
  107236. */
  107237. exitFullscreen(): void;
  107238. /**
  107239. * Enters Pointerlock mode
  107240. */
  107241. enterPointerlock(): void;
  107242. /**
  107243. * Exits Pointerlock mode
  107244. */
  107245. exitPointerlock(): void;
  107246. /**
  107247. * Begin a new frame
  107248. */
  107249. beginFrame(): void;
  107250. /**
  107251. * Enf the current frame
  107252. */
  107253. endFrame(): void;
  107254. resize(): void;
  107255. /**
  107256. * Force a specific size of the canvas
  107257. * @param width defines the new canvas' width
  107258. * @param height defines the new canvas' height
  107259. */
  107260. setSize(width: number, height: number): void;
  107261. /**
  107262. * Updates a dynamic vertex buffer.
  107263. * @param vertexBuffer the vertex buffer to update
  107264. * @param data the data used to update the vertex buffer
  107265. * @param byteOffset the byte offset of the data
  107266. * @param byteLength the byte length of the data
  107267. */
  107268. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107269. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107270. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107271. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107272. _releaseTexture(texture: InternalTexture): void;
  107273. /**
  107274. * @hidden
  107275. * Rescales a texture
  107276. * @param source input texutre
  107277. * @param destination destination texture
  107278. * @param scene scene to use to render the resize
  107279. * @param internalFormat format to use when resizing
  107280. * @param onComplete callback to be called when resize has completed
  107281. */
  107282. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107283. /**
  107284. * Gets the current framerate
  107285. * @returns a number representing the framerate
  107286. */
  107287. getFps(): number;
  107288. /**
  107289. * Gets the time spent between current and previous frame
  107290. * @returns a number representing the delta time in ms
  107291. */
  107292. getDeltaTime(): number;
  107293. private _measureFps;
  107294. /** @hidden */
  107295. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107296. /**
  107297. * Update a dynamic index buffer
  107298. * @param indexBuffer defines the target index buffer
  107299. * @param indices defines the data to update
  107300. * @param offset defines the offset in the target index buffer where update should start
  107301. */
  107302. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107303. /**
  107304. * Updates the sample count of a render target texture
  107305. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107306. * @param texture defines the texture to update
  107307. * @param samples defines the sample count to set
  107308. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107309. */
  107310. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107311. /**
  107312. * Updates a depth texture Comparison Mode and Function.
  107313. * If the comparison Function is equal to 0, the mode will be set to none.
  107314. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107315. * @param texture The texture to set the comparison function for
  107316. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107317. */
  107318. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107319. /**
  107320. * Creates a webGL buffer to use with instanciation
  107321. * @param capacity defines the size of the buffer
  107322. * @returns the webGL buffer
  107323. */
  107324. createInstancesBuffer(capacity: number): DataBuffer;
  107325. /**
  107326. * Delete a webGL buffer used with instanciation
  107327. * @param buffer defines the webGL buffer to delete
  107328. */
  107329. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107330. private _clientWaitAsync;
  107331. /** @hidden */
  107332. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107333. /** @hidden */
  107334. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107335. dispose(): void;
  107336. private _disableTouchAction;
  107337. /**
  107338. * Display the loading screen
  107339. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107340. */
  107341. displayLoadingUI(): void;
  107342. /**
  107343. * Hide the loading screen
  107344. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107345. */
  107346. hideLoadingUI(): void;
  107347. /**
  107348. * Gets the current loading screen object
  107349. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107350. */
  107351. get loadingScreen(): ILoadingScreen;
  107352. /**
  107353. * Sets the current loading screen object
  107354. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107355. */
  107356. set loadingScreen(loadingScreen: ILoadingScreen);
  107357. /**
  107358. * Sets the current loading screen text
  107359. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107360. */
  107361. set loadingUIText(text: string);
  107362. /**
  107363. * Sets the current loading screen background color
  107364. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107365. */
  107366. set loadingUIBackgroundColor(color: string);
  107367. /** Pointerlock and fullscreen */
  107368. /**
  107369. * Ask the browser to promote the current element to pointerlock mode
  107370. * @param element defines the DOM element to promote
  107371. */
  107372. static _RequestPointerlock(element: HTMLElement): void;
  107373. /**
  107374. * Asks the browser to exit pointerlock mode
  107375. */
  107376. static _ExitPointerlock(): void;
  107377. /**
  107378. * Ask the browser to promote the current element to fullscreen rendering mode
  107379. * @param element defines the DOM element to promote
  107380. */
  107381. static _RequestFullscreen(element: HTMLElement): void;
  107382. /**
  107383. * Asks the browser to exit fullscreen mode
  107384. */
  107385. static _ExitFullscreen(): void;
  107386. }
  107387. }
  107388. declare module BABYLON {
  107389. /**
  107390. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107391. * during the life time of the application.
  107392. */
  107393. export class EngineStore {
  107394. /** Gets the list of created engines */
  107395. static Instances: Engine[];
  107396. /** @hidden */
  107397. static _LastCreatedScene: Nullable<Scene>;
  107398. /**
  107399. * Gets the latest created engine
  107400. */
  107401. static get LastCreatedEngine(): Nullable<Engine>;
  107402. /**
  107403. * Gets the latest created scene
  107404. */
  107405. static get LastCreatedScene(): Nullable<Scene>;
  107406. /**
  107407. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107408. * @ignorenaming
  107409. */
  107410. static UseFallbackTexture: boolean;
  107411. /**
  107412. * Texture content used if a texture cannot loaded
  107413. * @ignorenaming
  107414. */
  107415. static FallbackTexture: string;
  107416. }
  107417. }
  107418. declare module BABYLON {
  107419. /**
  107420. * Helper class that provides a small promise polyfill
  107421. */
  107422. export class PromisePolyfill {
  107423. /**
  107424. * Static function used to check if the polyfill is required
  107425. * If this is the case then the function will inject the polyfill to window.Promise
  107426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107427. */
  107428. static Apply(force?: boolean): void;
  107429. }
  107430. }
  107431. declare module BABYLON {
  107432. /**
  107433. * Interface for screenshot methods with describe argument called `size` as object with options
  107434. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107435. */
  107436. export interface IScreenshotSize {
  107437. /**
  107438. * number in pixels for canvas height
  107439. */
  107440. height?: number;
  107441. /**
  107442. * multiplier allowing render at a higher or lower resolution
  107443. * If value is defined then height and width will be ignored and taken from camera
  107444. */
  107445. precision?: number;
  107446. /**
  107447. * number in pixels for canvas width
  107448. */
  107449. width?: number;
  107450. }
  107451. }
  107452. declare module BABYLON {
  107453. interface IColor4Like {
  107454. r: float;
  107455. g: float;
  107456. b: float;
  107457. a: float;
  107458. }
  107459. /**
  107460. * Class containing a set of static utilities functions
  107461. */
  107462. export class Tools {
  107463. /**
  107464. * Gets or sets the base URL to use to load assets
  107465. */
  107466. static get BaseUrl(): string;
  107467. static set BaseUrl(value: string);
  107468. /**
  107469. * Enable/Disable Custom HTTP Request Headers globally.
  107470. * default = false
  107471. * @see CustomRequestHeaders
  107472. */
  107473. static UseCustomRequestHeaders: boolean;
  107474. /**
  107475. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107476. * i.e. when loading files, where the server/service expects an Authorization header
  107477. */
  107478. static CustomRequestHeaders: {
  107479. [key: string]: string;
  107480. };
  107481. /**
  107482. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107483. */
  107484. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107485. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107486. /**
  107487. * Default behaviour for cors in the application.
  107488. * It can be a string if the expected behavior is identical in the entire app.
  107489. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107490. */
  107491. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107492. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107493. /**
  107494. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107495. * @ignorenaming
  107496. */
  107497. static get UseFallbackTexture(): boolean;
  107498. static set UseFallbackTexture(value: boolean);
  107499. /**
  107500. * Use this object to register external classes like custom textures or material
  107501. * to allow the laoders to instantiate them
  107502. */
  107503. static get RegisteredExternalClasses(): {
  107504. [key: string]: Object;
  107505. };
  107506. static set RegisteredExternalClasses(classes: {
  107507. [key: string]: Object;
  107508. });
  107509. /**
  107510. * Texture content used if a texture cannot loaded
  107511. * @ignorenaming
  107512. */
  107513. static get fallbackTexture(): string;
  107514. static set fallbackTexture(value: string);
  107515. /**
  107516. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107517. * @param u defines the coordinate on X axis
  107518. * @param v defines the coordinate on Y axis
  107519. * @param width defines the width of the source data
  107520. * @param height defines the height of the source data
  107521. * @param pixels defines the source byte array
  107522. * @param color defines the output color
  107523. */
  107524. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107525. /**
  107526. * Interpolates between a and b via alpha
  107527. * @param a The lower value (returned when alpha = 0)
  107528. * @param b The upper value (returned when alpha = 1)
  107529. * @param alpha The interpolation-factor
  107530. * @return The mixed value
  107531. */
  107532. static Mix(a: number, b: number, alpha: number): number;
  107533. /**
  107534. * Tries to instantiate a new object from a given class name
  107535. * @param className defines the class name to instantiate
  107536. * @returns the new object or null if the system was not able to do the instantiation
  107537. */
  107538. static Instantiate(className: string): any;
  107539. /**
  107540. * Provides a slice function that will work even on IE
  107541. * @param data defines the array to slice
  107542. * @param start defines the start of the data (optional)
  107543. * @param end defines the end of the data (optional)
  107544. * @returns the new sliced array
  107545. */
  107546. static Slice<T>(data: T, start?: number, end?: number): T;
  107547. /**
  107548. * Polyfill for setImmediate
  107549. * @param action defines the action to execute after the current execution block
  107550. */
  107551. static SetImmediate(action: () => void): void;
  107552. /**
  107553. * Function indicating if a number is an exponent of 2
  107554. * @param value defines the value to test
  107555. * @returns true if the value is an exponent of 2
  107556. */
  107557. static IsExponentOfTwo(value: number): boolean;
  107558. private static _tmpFloatArray;
  107559. /**
  107560. * Returns the nearest 32-bit single precision float representation of a Number
  107561. * @param value A Number. If the parameter is of a different type, it will get converted
  107562. * to a number or to NaN if it cannot be converted
  107563. * @returns number
  107564. */
  107565. static FloatRound(value: number): number;
  107566. /**
  107567. * Extracts the filename from a path
  107568. * @param path defines the path to use
  107569. * @returns the filename
  107570. */
  107571. static GetFilename(path: string): string;
  107572. /**
  107573. * Extracts the "folder" part of a path (everything before the filename).
  107574. * @param uri The URI to extract the info from
  107575. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107576. * @returns The "folder" part of the path
  107577. */
  107578. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107579. /**
  107580. * Extracts text content from a DOM element hierarchy
  107581. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107582. */
  107583. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107584. /**
  107585. * Convert an angle in radians to degrees
  107586. * @param angle defines the angle to convert
  107587. * @returns the angle in degrees
  107588. */
  107589. static ToDegrees(angle: number): number;
  107590. /**
  107591. * Convert an angle in degrees to radians
  107592. * @param angle defines the angle to convert
  107593. * @returns the angle in radians
  107594. */
  107595. static ToRadians(angle: number): number;
  107596. /**
  107597. * Returns an array if obj is not an array
  107598. * @param obj defines the object to evaluate as an array
  107599. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107600. * @returns either obj directly if obj is an array or a new array containing obj
  107601. */
  107602. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107603. /**
  107604. * Gets the pointer prefix to use
  107605. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107606. */
  107607. static GetPointerPrefix(): string;
  107608. /**
  107609. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107610. * @param url define the url we are trying
  107611. * @param element define the dom element where to configure the cors policy
  107612. */
  107613. static SetCorsBehavior(url: string | string[], element: {
  107614. crossOrigin: string | null;
  107615. }): void;
  107616. /**
  107617. * Removes unwanted characters from an url
  107618. * @param url defines the url to clean
  107619. * @returns the cleaned url
  107620. */
  107621. static CleanUrl(url: string): string;
  107622. /**
  107623. * Gets or sets a function used to pre-process url before using them to load assets
  107624. */
  107625. static get PreprocessUrl(): (url: string) => string;
  107626. static set PreprocessUrl(processor: (url: string) => string);
  107627. /**
  107628. * Loads an image as an HTMLImageElement.
  107629. * @param input url string, ArrayBuffer, or Blob to load
  107630. * @param onLoad callback called when the image successfully loads
  107631. * @param onError callback called when the image fails to load
  107632. * @param offlineProvider offline provider for caching
  107633. * @param mimeType optional mime type
  107634. * @returns the HTMLImageElement of the loaded image
  107635. */
  107636. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107637. /**
  107638. * Loads a file from a url
  107639. * @param url url string, ArrayBuffer, or Blob to load
  107640. * @param onSuccess callback called when the file successfully loads
  107641. * @param onProgress callback called while file is loading (if the server supports this mode)
  107642. * @param offlineProvider defines the offline provider for caching
  107643. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107644. * @param onError callback called when the file fails to load
  107645. * @returns a file request object
  107646. */
  107647. 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;
  107648. /**
  107649. * Loads a file from a url
  107650. * @param url the file url to load
  107651. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107652. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107653. */
  107654. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107655. /**
  107656. * Load a script (identified by an url). When the url returns, the
  107657. * content of this file is added into a new script element, attached to the DOM (body element)
  107658. * @param scriptUrl defines the url of the script to laod
  107659. * @param onSuccess defines the callback called when the script is loaded
  107660. * @param onError defines the callback to call if an error occurs
  107661. * @param scriptId defines the id of the script element
  107662. */
  107663. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107664. /**
  107665. * Load an asynchronous script (identified by an url). When the url returns, the
  107666. * content of this file is added into a new script element, attached to the DOM (body element)
  107667. * @param scriptUrl defines the url of the script to laod
  107668. * @param scriptId defines the id of the script element
  107669. * @returns a promise request object
  107670. */
  107671. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107672. /**
  107673. * Loads a file from a blob
  107674. * @param fileToLoad defines the blob to use
  107675. * @param callback defines the callback to call when data is loaded
  107676. * @param progressCallback defines the callback to call during loading process
  107677. * @returns a file request object
  107678. */
  107679. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107680. /**
  107681. * Reads a file from a File object
  107682. * @param file defines the file to load
  107683. * @param onSuccess defines the callback to call when data is loaded
  107684. * @param onProgress defines the callback to call during loading process
  107685. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107686. * @param onError defines the callback to call when an error occurs
  107687. * @returns a file request object
  107688. */
  107689. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107690. /**
  107691. * Creates a data url from a given string content
  107692. * @param content defines the content to convert
  107693. * @returns the new data url link
  107694. */
  107695. static FileAsURL(content: string): string;
  107696. /**
  107697. * Format the given number to a specific decimal format
  107698. * @param value defines the number to format
  107699. * @param decimals defines the number of decimals to use
  107700. * @returns the formatted string
  107701. */
  107702. static Format(value: number, decimals?: number): string;
  107703. /**
  107704. * Tries to copy an object by duplicating every property
  107705. * @param source defines the source object
  107706. * @param destination defines the target object
  107707. * @param doNotCopyList defines a list of properties to avoid
  107708. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107709. */
  107710. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107711. /**
  107712. * Gets a boolean indicating if the given object has no own property
  107713. * @param obj defines the object to test
  107714. * @returns true if object has no own property
  107715. */
  107716. static IsEmpty(obj: any): boolean;
  107717. /**
  107718. * Function used to register events at window level
  107719. * @param windowElement defines the Window object to use
  107720. * @param events defines the events to register
  107721. */
  107722. static RegisterTopRootEvents(windowElement: Window, events: {
  107723. name: string;
  107724. handler: Nullable<(e: FocusEvent) => any>;
  107725. }[]): void;
  107726. /**
  107727. * Function used to unregister events from window level
  107728. * @param windowElement defines the Window object to use
  107729. * @param events defines the events to unregister
  107730. */
  107731. static UnregisterTopRootEvents(windowElement: Window, events: {
  107732. name: string;
  107733. handler: Nullable<(e: FocusEvent) => any>;
  107734. }[]): void;
  107735. /**
  107736. * @ignore
  107737. */
  107738. static _ScreenshotCanvas: HTMLCanvasElement;
  107739. /**
  107740. * Dumps the current bound framebuffer
  107741. * @param width defines the rendering width
  107742. * @param height defines the rendering height
  107743. * @param engine defines the hosting engine
  107744. * @param successCallback defines the callback triggered once the data are available
  107745. * @param mimeType defines the mime type of the result
  107746. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107747. */
  107748. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107749. /**
  107750. * Converts the canvas data to blob.
  107751. * This acts as a polyfill for browsers not supporting the to blob function.
  107752. * @param canvas Defines the canvas to extract the data from
  107753. * @param successCallback Defines the callback triggered once the data are available
  107754. * @param mimeType Defines the mime type of the result
  107755. */
  107756. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107757. /**
  107758. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107759. * @param successCallback defines the callback triggered once the data are available
  107760. * @param mimeType defines the mime type of the result
  107761. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107762. */
  107763. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107764. /**
  107765. * Downloads a blob in the browser
  107766. * @param blob defines the blob to download
  107767. * @param fileName defines the name of the downloaded file
  107768. */
  107769. static Download(blob: Blob, fileName: string): void;
  107770. /**
  107771. * Captures a screenshot of the current rendering
  107772. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107773. * @param engine defines the rendering engine
  107774. * @param camera defines the source camera
  107775. * @param size This parameter can be set to a single number or to an object with the
  107776. * following (optional) properties: precision, width, height. If a single number is passed,
  107777. * it will be used for both width and height. If an object is passed, the screenshot size
  107778. * will be derived from the parameters. The precision property is a multiplier allowing
  107779. * rendering at a higher or lower resolution
  107780. * @param successCallback defines the callback receives a single parameter which contains the
  107781. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107782. * src parameter of an <img> to display it
  107783. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107784. * Check your browser for supported MIME types
  107785. */
  107786. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107787. /**
  107788. * Captures a screenshot of the current rendering
  107789. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107790. * @param engine defines the rendering engine
  107791. * @param camera defines the source camera
  107792. * @param size This parameter can be set to a single number or to an object with the
  107793. * following (optional) properties: precision, width, height. If a single number is passed,
  107794. * it will be used for both width and height. If an object is passed, the screenshot size
  107795. * will be derived from the parameters. The precision property is a multiplier allowing
  107796. * rendering at a higher or lower resolution
  107797. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107798. * Check your browser for supported MIME types
  107799. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107800. * to the src parameter of an <img> to display it
  107801. */
  107802. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107803. /**
  107804. * Generates an image screenshot from the specified camera.
  107805. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107806. * @param engine The engine to use for rendering
  107807. * @param camera The camera to use for rendering
  107808. * @param size This parameter can be set to a single number or to an object with the
  107809. * following (optional) properties: precision, width, height. If a single number is passed,
  107810. * it will be used for both width and height. If an object is passed, the screenshot size
  107811. * will be derived from the parameters. The precision property is a multiplier allowing
  107812. * rendering at a higher or lower resolution
  107813. * @param successCallback The callback receives a single parameter which contains the
  107814. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107815. * src parameter of an <img> to display it
  107816. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107817. * Check your browser for supported MIME types
  107818. * @param samples Texture samples (default: 1)
  107819. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107820. * @param fileName A name for for the downloaded file.
  107821. */
  107822. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107823. /**
  107824. * Generates an image screenshot from the specified camera.
  107825. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107826. * @param engine The engine to use for rendering
  107827. * @param camera The camera to use for rendering
  107828. * @param size This parameter can be set to a single number or to an object with the
  107829. * following (optional) properties: precision, width, height. If a single number is passed,
  107830. * it will be used for both width and height. If an object is passed, the screenshot size
  107831. * will be derived from the parameters. The precision property is a multiplier allowing
  107832. * rendering at a higher or lower resolution
  107833. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107834. * Check your browser for supported MIME types
  107835. * @param samples Texture samples (default: 1)
  107836. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107837. * @param fileName A name for for the downloaded file.
  107838. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107839. * to the src parameter of an <img> to display it
  107840. */
  107841. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107842. /**
  107843. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107844. * Be aware Math.random() could cause collisions, but:
  107845. * "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"
  107846. * @returns a pseudo random id
  107847. */
  107848. static RandomId(): string;
  107849. /**
  107850. * Test if the given uri is a base64 string
  107851. * @param uri The uri to test
  107852. * @return True if the uri is a base64 string or false otherwise
  107853. */
  107854. static IsBase64(uri: string): boolean;
  107855. /**
  107856. * Decode the given base64 uri.
  107857. * @param uri The uri to decode
  107858. * @return The decoded base64 data.
  107859. */
  107860. static DecodeBase64(uri: string): ArrayBuffer;
  107861. /**
  107862. * Gets the absolute url.
  107863. * @param url the input url
  107864. * @return the absolute url
  107865. */
  107866. static GetAbsoluteUrl(url: string): string;
  107867. /**
  107868. * No log
  107869. */
  107870. static readonly NoneLogLevel: number;
  107871. /**
  107872. * Only message logs
  107873. */
  107874. static readonly MessageLogLevel: number;
  107875. /**
  107876. * Only warning logs
  107877. */
  107878. static readonly WarningLogLevel: number;
  107879. /**
  107880. * Only error logs
  107881. */
  107882. static readonly ErrorLogLevel: number;
  107883. /**
  107884. * All logs
  107885. */
  107886. static readonly AllLogLevel: number;
  107887. /**
  107888. * Gets a value indicating the number of loading errors
  107889. * @ignorenaming
  107890. */
  107891. static get errorsCount(): number;
  107892. /**
  107893. * Callback called when a new log is added
  107894. */
  107895. static OnNewCacheEntry: (entry: string) => void;
  107896. /**
  107897. * Log a message to the console
  107898. * @param message defines the message to log
  107899. */
  107900. static Log(message: string): void;
  107901. /**
  107902. * Write a warning message to the console
  107903. * @param message defines the message to log
  107904. */
  107905. static Warn(message: string): void;
  107906. /**
  107907. * Write an error message to the console
  107908. * @param message defines the message to log
  107909. */
  107910. static Error(message: string): void;
  107911. /**
  107912. * Gets current log cache (list of logs)
  107913. */
  107914. static get LogCache(): string;
  107915. /**
  107916. * Clears the log cache
  107917. */
  107918. static ClearLogCache(): void;
  107919. /**
  107920. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107921. */
  107922. static set LogLevels(level: number);
  107923. /**
  107924. * Checks if the window object exists
  107925. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107926. */
  107927. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107928. /**
  107929. * No performance log
  107930. */
  107931. static readonly PerformanceNoneLogLevel: number;
  107932. /**
  107933. * Use user marks to log performance
  107934. */
  107935. static readonly PerformanceUserMarkLogLevel: number;
  107936. /**
  107937. * Log performance to the console
  107938. */
  107939. static readonly PerformanceConsoleLogLevel: number;
  107940. private static _performance;
  107941. /**
  107942. * Sets the current performance log level
  107943. */
  107944. static set PerformanceLogLevel(level: number);
  107945. private static _StartPerformanceCounterDisabled;
  107946. private static _EndPerformanceCounterDisabled;
  107947. private static _StartUserMark;
  107948. private static _EndUserMark;
  107949. private static _StartPerformanceConsole;
  107950. private static _EndPerformanceConsole;
  107951. /**
  107952. * Starts a performance counter
  107953. */
  107954. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107955. /**
  107956. * Ends a specific performance coutner
  107957. */
  107958. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107959. /**
  107960. * Gets either window.performance.now() if supported or Date.now() else
  107961. */
  107962. static get Now(): number;
  107963. /**
  107964. * This method will return the name of the class used to create the instance of the given object.
  107965. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107966. * @param object the object to get the class name from
  107967. * @param isType defines if the object is actually a type
  107968. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107969. */
  107970. static GetClassName(object: any, isType?: boolean): string;
  107971. /**
  107972. * Gets the first element of an array satisfying a given predicate
  107973. * @param array defines the array to browse
  107974. * @param predicate defines the predicate to use
  107975. * @returns null if not found or the element
  107976. */
  107977. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107978. /**
  107979. * This method will return the name of the full name of the class, including its owning module (if any).
  107980. * 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).
  107981. * @param object the object to get the class name from
  107982. * @param isType defines if the object is actually a type
  107983. * @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.
  107984. * @ignorenaming
  107985. */
  107986. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107987. /**
  107988. * Returns a promise that resolves after the given amount of time.
  107989. * @param delay Number of milliseconds to delay
  107990. * @returns Promise that resolves after the given amount of time
  107991. */
  107992. static DelayAsync(delay: number): Promise<void>;
  107993. /**
  107994. * Utility function to detect if the current user agent is Safari
  107995. * @returns whether or not the current user agent is safari
  107996. */
  107997. static IsSafari(): boolean;
  107998. }
  107999. /**
  108000. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  108001. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  108002. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  108003. * @param name The name of the class, case should be preserved
  108004. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  108005. */
  108006. export function className(name: string, module?: string): (target: Object) => void;
  108007. /**
  108008. * An implementation of a loop for asynchronous functions.
  108009. */
  108010. export class AsyncLoop {
  108011. /**
  108012. * Defines the number of iterations for the loop
  108013. */
  108014. iterations: number;
  108015. /**
  108016. * Defines the current index of the loop.
  108017. */
  108018. index: number;
  108019. private _done;
  108020. private _fn;
  108021. private _successCallback;
  108022. /**
  108023. * Constructor.
  108024. * @param iterations the number of iterations.
  108025. * @param func the function to run each iteration
  108026. * @param successCallback the callback that will be called upon succesful execution
  108027. * @param offset starting offset.
  108028. */
  108029. constructor(
  108030. /**
  108031. * Defines the number of iterations for the loop
  108032. */
  108033. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  108034. /**
  108035. * Execute the next iteration. Must be called after the last iteration was finished.
  108036. */
  108037. executeNext(): void;
  108038. /**
  108039. * Break the loop and run the success callback.
  108040. */
  108041. breakLoop(): void;
  108042. /**
  108043. * Create and run an async loop.
  108044. * @param iterations the number of iterations.
  108045. * @param fn the function to run each iteration
  108046. * @param successCallback the callback that will be called upon succesful execution
  108047. * @param offset starting offset.
  108048. * @returns the created async loop object
  108049. */
  108050. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  108051. /**
  108052. * A for-loop that will run a given number of iterations synchronous and the rest async.
  108053. * @param iterations total number of iterations
  108054. * @param syncedIterations number of synchronous iterations in each async iteration.
  108055. * @param fn the function to call each iteration.
  108056. * @param callback a success call back that will be called when iterating stops.
  108057. * @param breakFunction a break condition (optional)
  108058. * @param timeout timeout settings for the setTimeout function. default - 0.
  108059. * @returns the created async loop object
  108060. */
  108061. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  108062. }
  108063. }
  108064. declare module BABYLON {
  108065. /**
  108066. * This class implement a typical dictionary using a string as key and the generic type T as value.
  108067. * The underlying implementation relies on an associative array to ensure the best performances.
  108068. * The value can be anything including 'null' but except 'undefined'
  108069. */
  108070. export class StringDictionary<T> {
  108071. /**
  108072. * This will clear this dictionary and copy the content from the 'source' one.
  108073. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  108074. * @param source the dictionary to take the content from and copy to this dictionary
  108075. */
  108076. copyFrom(source: StringDictionary<T>): void;
  108077. /**
  108078. * Get a value based from its key
  108079. * @param key the given key to get the matching value from
  108080. * @return the value if found, otherwise undefined is returned
  108081. */
  108082. get(key: string): T | undefined;
  108083. /**
  108084. * Get a value from its key or add it if it doesn't exist.
  108085. * This method will ensure you that a given key/data will be present in the dictionary.
  108086. * @param key the given key to get the matching value from
  108087. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108088. * The factory will only be invoked if there's no data for the given key.
  108089. * @return the value corresponding to the key.
  108090. */
  108091. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108092. /**
  108093. * Get a value from its key if present in the dictionary otherwise add it
  108094. * @param key the key to get the value from
  108095. * @param val if there's no such key/value pair in the dictionary add it with this value
  108096. * @return the value corresponding to the key
  108097. */
  108098. getOrAdd(key: string, val: T): T;
  108099. /**
  108100. * Check if there's a given key in the dictionary
  108101. * @param key the key to check for
  108102. * @return true if the key is present, false otherwise
  108103. */
  108104. contains(key: string): boolean;
  108105. /**
  108106. * Add a new key and its corresponding value
  108107. * @param key the key to add
  108108. * @param value the value corresponding to the key
  108109. * @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
  108110. */
  108111. add(key: string, value: T): boolean;
  108112. /**
  108113. * Update a specific value associated to a key
  108114. * @param key defines the key to use
  108115. * @param value defines the value to store
  108116. * @returns true if the value was updated (or false if the key was not found)
  108117. */
  108118. set(key: string, value: T): boolean;
  108119. /**
  108120. * Get the element of the given key and remove it from the dictionary
  108121. * @param key defines the key to search
  108122. * @returns the value associated with the key or null if not found
  108123. */
  108124. getAndRemove(key: string): Nullable<T>;
  108125. /**
  108126. * Remove a key/value from the dictionary.
  108127. * @param key the key to remove
  108128. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  108129. */
  108130. remove(key: string): boolean;
  108131. /**
  108132. * Clear the whole content of the dictionary
  108133. */
  108134. clear(): void;
  108135. /**
  108136. * Gets the current count
  108137. */
  108138. get count(): number;
  108139. /**
  108140. * Execute a callback on each key/val of the dictionary.
  108141. * Note that you can remove any element in this dictionary in the callback implementation
  108142. * @param callback the callback to execute on a given key/value pair
  108143. */
  108144. forEach(callback: (key: string, val: T) => void): void;
  108145. /**
  108146. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  108147. * If the callback returns null or undefined the method will iterate to the next key/value pair
  108148. * Note that you can remove any element in this dictionary in the callback implementation
  108149. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  108150. * @returns the first item
  108151. */
  108152. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  108153. private _count;
  108154. private _data;
  108155. }
  108156. }
  108157. declare module BABYLON {
  108158. /** @hidden */
  108159. export interface ICollisionCoordinator {
  108160. createCollider(): Collider;
  108161. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108162. init(scene: Scene): void;
  108163. }
  108164. /** @hidden */
  108165. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108166. private _scene;
  108167. private _scaledPosition;
  108168. private _scaledVelocity;
  108169. private _finalPosition;
  108170. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108171. createCollider(): Collider;
  108172. init(scene: Scene): void;
  108173. private _collideWithWorld;
  108174. }
  108175. }
  108176. declare module BABYLON {
  108177. /**
  108178. * Class used to manage all inputs for the scene.
  108179. */
  108180. export class InputManager {
  108181. /** The distance in pixel that you have to move to prevent some events */
  108182. static DragMovementThreshold: number;
  108183. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108184. static LongPressDelay: number;
  108185. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108186. static DoubleClickDelay: number;
  108187. /** If you need to check double click without raising a single click at first click, enable this flag */
  108188. static ExclusiveDoubleClickMode: boolean;
  108189. private _wheelEventName;
  108190. private _onPointerMove;
  108191. private _onPointerDown;
  108192. private _onPointerUp;
  108193. private _initClickEvent;
  108194. private _initActionManager;
  108195. private _delayedSimpleClick;
  108196. private _delayedSimpleClickTimeout;
  108197. private _previousDelayedSimpleClickTimeout;
  108198. private _meshPickProceed;
  108199. private _previousButtonPressed;
  108200. private _currentPickResult;
  108201. private _previousPickResult;
  108202. private _totalPointersPressed;
  108203. private _doubleClickOccured;
  108204. private _pointerOverMesh;
  108205. private _pickedDownMesh;
  108206. private _pickedUpMesh;
  108207. private _pointerX;
  108208. private _pointerY;
  108209. private _unTranslatedPointerX;
  108210. private _unTranslatedPointerY;
  108211. private _startingPointerPosition;
  108212. private _previousStartingPointerPosition;
  108213. private _startingPointerTime;
  108214. private _previousStartingPointerTime;
  108215. private _pointerCaptures;
  108216. private _onKeyDown;
  108217. private _onKeyUp;
  108218. private _onCanvasFocusObserver;
  108219. private _onCanvasBlurObserver;
  108220. private _scene;
  108221. /**
  108222. * Creates a new InputManager
  108223. * @param scene defines the hosting scene
  108224. */
  108225. constructor(scene: Scene);
  108226. /**
  108227. * Gets the mesh that is currently under the pointer
  108228. */
  108229. get meshUnderPointer(): Nullable<AbstractMesh>;
  108230. /**
  108231. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108232. */
  108233. get unTranslatedPointer(): Vector2;
  108234. /**
  108235. * Gets or sets the current on-screen X position of the pointer
  108236. */
  108237. get pointerX(): number;
  108238. set pointerX(value: number);
  108239. /**
  108240. * Gets or sets the current on-screen Y position of the pointer
  108241. */
  108242. get pointerY(): number;
  108243. set pointerY(value: number);
  108244. private _updatePointerPosition;
  108245. private _processPointerMove;
  108246. private _setRayOnPointerInfo;
  108247. private _checkPrePointerObservable;
  108248. /**
  108249. * Use this method to simulate a pointer move on a mesh
  108250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108253. */
  108254. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108255. /**
  108256. * Use this method to simulate a pointer down on a mesh
  108257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108260. */
  108261. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108262. private _processPointerDown;
  108263. /** @hidden */
  108264. _isPointerSwiping(): boolean;
  108265. /**
  108266. * Use this method to simulate a pointer up on a mesh
  108267. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108268. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108269. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108270. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108271. */
  108272. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108273. private _processPointerUp;
  108274. /**
  108275. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108276. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108277. * @returns true if the pointer was captured
  108278. */
  108279. isPointerCaptured(pointerId?: number): boolean;
  108280. /**
  108281. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108282. * @param attachUp defines if you want to attach events to pointerup
  108283. * @param attachDown defines if you want to attach events to pointerdown
  108284. * @param attachMove defines if you want to attach events to pointermove
  108285. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108286. */
  108287. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108288. /**
  108289. * Detaches all event handlers
  108290. */
  108291. detachControl(): void;
  108292. /**
  108293. * Force the value of meshUnderPointer
  108294. * @param mesh defines the mesh to use
  108295. */
  108296. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108297. /**
  108298. * Gets the mesh under the pointer
  108299. * @returns a Mesh or null if no mesh is under the pointer
  108300. */
  108301. getPointerOverMesh(): Nullable<AbstractMesh>;
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /**
  108306. * Helper class used to generate session unique ID
  108307. */
  108308. export class UniqueIdGenerator {
  108309. private static _UniqueIdCounter;
  108310. /**
  108311. * Gets an unique (relatively to the current scene) Id
  108312. */
  108313. static get UniqueId(): number;
  108314. }
  108315. }
  108316. declare module BABYLON {
  108317. /**
  108318. * This class defines the direct association between an animation and a target
  108319. */
  108320. export class TargetedAnimation {
  108321. /**
  108322. * Animation to perform
  108323. */
  108324. animation: Animation;
  108325. /**
  108326. * Target to animate
  108327. */
  108328. target: any;
  108329. /**
  108330. * Serialize the object
  108331. * @returns the JSON object representing the current entity
  108332. */
  108333. serialize(): any;
  108334. }
  108335. /**
  108336. * Use this class to create coordinated animations on multiple targets
  108337. */
  108338. export class AnimationGroup implements IDisposable {
  108339. /** The name of the animation group */
  108340. name: string;
  108341. private _scene;
  108342. private _targetedAnimations;
  108343. private _animatables;
  108344. private _from;
  108345. private _to;
  108346. private _isStarted;
  108347. private _isPaused;
  108348. private _speedRatio;
  108349. private _loopAnimation;
  108350. /**
  108351. * Gets or sets the unique id of the node
  108352. */
  108353. uniqueId: number;
  108354. /**
  108355. * This observable will notify when one animation have ended
  108356. */
  108357. onAnimationEndObservable: Observable<TargetedAnimation>;
  108358. /**
  108359. * Observer raised when one animation loops
  108360. */
  108361. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108362. /**
  108363. * Observer raised when all animations have looped
  108364. */
  108365. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108366. /**
  108367. * This observable will notify when all animations have ended.
  108368. */
  108369. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108370. /**
  108371. * This observable will notify when all animations have paused.
  108372. */
  108373. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108374. /**
  108375. * This observable will notify when all animations are playing.
  108376. */
  108377. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108378. /**
  108379. * Gets the first frame
  108380. */
  108381. get from(): number;
  108382. /**
  108383. * Gets the last frame
  108384. */
  108385. get to(): number;
  108386. /**
  108387. * Define if the animations are started
  108388. */
  108389. get isStarted(): boolean;
  108390. /**
  108391. * Gets a value indicating that the current group is playing
  108392. */
  108393. get isPlaying(): boolean;
  108394. /**
  108395. * Gets or sets the speed ratio to use for all animations
  108396. */
  108397. get speedRatio(): number;
  108398. /**
  108399. * Gets or sets the speed ratio to use for all animations
  108400. */
  108401. set speedRatio(value: number);
  108402. /**
  108403. * Gets or sets if all animations should loop or not
  108404. */
  108405. get loopAnimation(): boolean;
  108406. set loopAnimation(value: boolean);
  108407. /**
  108408. * Gets the targeted animations for this animation group
  108409. */
  108410. get targetedAnimations(): Array<TargetedAnimation>;
  108411. /**
  108412. * returning the list of animatables controlled by this animation group.
  108413. */
  108414. get animatables(): Array<Animatable>;
  108415. /**
  108416. * Instantiates a new Animation Group.
  108417. * This helps managing several animations at once.
  108418. * @see http://doc.babylonjs.com/how_to/group
  108419. * @param name Defines the name of the group
  108420. * @param scene Defines the scene the group belongs to
  108421. */
  108422. constructor(
  108423. /** The name of the animation group */
  108424. name: string, scene?: Nullable<Scene>);
  108425. /**
  108426. * Add an animation (with its target) in the group
  108427. * @param animation defines the animation we want to add
  108428. * @param target defines the target of the animation
  108429. * @returns the TargetedAnimation object
  108430. */
  108431. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108432. /**
  108433. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108434. * It can add constant keys at begin or end
  108435. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108436. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108437. * @returns the animation group
  108438. */
  108439. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108440. private _animationLoopCount;
  108441. private _animationLoopFlags;
  108442. private _processLoop;
  108443. /**
  108444. * Start all animations on given targets
  108445. * @param loop defines if animations must loop
  108446. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108447. * @param from defines the from key (optional)
  108448. * @param to defines the to key (optional)
  108449. * @returns the current animation group
  108450. */
  108451. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108452. /**
  108453. * Pause all animations
  108454. * @returns the animation group
  108455. */
  108456. pause(): AnimationGroup;
  108457. /**
  108458. * Play all animations to initial state
  108459. * This function will start() the animations if they were not started or will restart() them if they were paused
  108460. * @param loop defines if animations must loop
  108461. * @returns the animation group
  108462. */
  108463. play(loop?: boolean): AnimationGroup;
  108464. /**
  108465. * Reset all animations to initial state
  108466. * @returns the animation group
  108467. */
  108468. reset(): AnimationGroup;
  108469. /**
  108470. * Restart animations from key 0
  108471. * @returns the animation group
  108472. */
  108473. restart(): AnimationGroup;
  108474. /**
  108475. * Stop all animations
  108476. * @returns the animation group
  108477. */
  108478. stop(): AnimationGroup;
  108479. /**
  108480. * Set animation weight for all animatables
  108481. * @param weight defines the weight to use
  108482. * @return the animationGroup
  108483. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108484. */
  108485. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108486. /**
  108487. * Synchronize and normalize all animatables with a source animatable
  108488. * @param root defines the root animatable to synchronize with
  108489. * @return the animationGroup
  108490. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108491. */
  108492. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108493. /**
  108494. * Goes to a specific frame in this animation group
  108495. * @param frame the frame number to go to
  108496. * @return the animationGroup
  108497. */
  108498. goToFrame(frame: number): AnimationGroup;
  108499. /**
  108500. * Dispose all associated resources
  108501. */
  108502. dispose(): void;
  108503. private _checkAnimationGroupEnded;
  108504. /**
  108505. * Clone the current animation group and returns a copy
  108506. * @param newName defines the name of the new group
  108507. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108508. * @returns the new aniamtion group
  108509. */
  108510. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108511. /**
  108512. * Serializes the animationGroup to an object
  108513. * @returns Serialized object
  108514. */
  108515. serialize(): any;
  108516. /**
  108517. * Returns a new AnimationGroup object parsed from the source provided.
  108518. * @param parsedAnimationGroup defines the source
  108519. * @param scene defines the scene that will receive the animationGroup
  108520. * @returns a new AnimationGroup
  108521. */
  108522. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108523. /**
  108524. * Returns the string "AnimationGroup"
  108525. * @returns "AnimationGroup"
  108526. */
  108527. getClassName(): string;
  108528. /**
  108529. * Creates a detailled string about the object
  108530. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108531. * @returns a string representing the object
  108532. */
  108533. toString(fullDetails?: boolean): string;
  108534. }
  108535. }
  108536. declare module BABYLON {
  108537. /**
  108538. * Define an interface for all classes that will hold resources
  108539. */
  108540. export interface IDisposable {
  108541. /**
  108542. * Releases all held resources
  108543. */
  108544. dispose(): void;
  108545. }
  108546. /** Interface defining initialization parameters for Scene class */
  108547. export interface SceneOptions {
  108548. /**
  108549. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108550. * It will improve performance when the number of geometries becomes important.
  108551. */
  108552. useGeometryUniqueIdsMap?: boolean;
  108553. /**
  108554. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108555. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108556. */
  108557. useMaterialMeshMap?: boolean;
  108558. /**
  108559. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108560. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108561. */
  108562. useClonedMeshMap?: boolean;
  108563. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108564. virtual?: boolean;
  108565. }
  108566. /**
  108567. * Represents a scene to be rendered by the engine.
  108568. * @see http://doc.babylonjs.com/features/scene
  108569. */
  108570. export class Scene extends AbstractScene implements IAnimatable {
  108571. /** The fog is deactivated */
  108572. static readonly FOGMODE_NONE: number;
  108573. /** The fog density is following an exponential function */
  108574. static readonly FOGMODE_EXP: number;
  108575. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108576. static readonly FOGMODE_EXP2: number;
  108577. /** The fog density is following a linear function. */
  108578. static readonly FOGMODE_LINEAR: number;
  108579. /**
  108580. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108582. */
  108583. static MinDeltaTime: number;
  108584. /**
  108585. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108587. */
  108588. static MaxDeltaTime: number;
  108589. /**
  108590. * Factory used to create the default material.
  108591. * @param name The name of the material to create
  108592. * @param scene The scene to create the material for
  108593. * @returns The default material
  108594. */
  108595. static DefaultMaterialFactory(scene: Scene): Material;
  108596. /**
  108597. * Factory used to create the a collision coordinator.
  108598. * @returns The collision coordinator
  108599. */
  108600. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108601. /** @hidden */
  108602. _inputManager: InputManager;
  108603. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108604. cameraToUseForPointers: Nullable<Camera>;
  108605. /** @hidden */
  108606. readonly _isScene: boolean;
  108607. /** @hidden */
  108608. _blockEntityCollection: boolean;
  108609. /**
  108610. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108611. */
  108612. autoClear: boolean;
  108613. /**
  108614. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108615. */
  108616. autoClearDepthAndStencil: boolean;
  108617. /**
  108618. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108619. */
  108620. clearColor: Color4;
  108621. /**
  108622. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108623. */
  108624. ambientColor: Color3;
  108625. /**
  108626. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108627. * It should only be one of the following (if not the default embedded one):
  108628. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108629. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108630. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108631. * The material properties need to be setup according to the type of texture in use.
  108632. */
  108633. environmentBRDFTexture: BaseTexture;
  108634. /** @hidden */
  108635. protected _environmentTexture: Nullable<BaseTexture>;
  108636. /**
  108637. * Texture used in all pbr material as the reflection texture.
  108638. * As in the majority of the scene they are the same (exception for multi room and so on),
  108639. * this is easier to reference from here than from all the materials.
  108640. */
  108641. get environmentTexture(): Nullable<BaseTexture>;
  108642. /**
  108643. * Texture used in all pbr material as the reflection texture.
  108644. * As in the majority of the scene they are the same (exception for multi room and so on),
  108645. * this is easier to set here than in all the materials.
  108646. */
  108647. set environmentTexture(value: Nullable<BaseTexture>);
  108648. /** @hidden */
  108649. protected _environmentIntensity: number;
  108650. /**
  108651. * Intensity of the environment in all pbr material.
  108652. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108653. * As in the majority of the scene they are the same (exception for multi room and so on),
  108654. * this is easier to reference from here than from all the materials.
  108655. */
  108656. get environmentIntensity(): number;
  108657. /**
  108658. * Intensity of the environment in all pbr material.
  108659. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108660. * As in the majority of the scene they are the same (exception for multi room and so on),
  108661. * this is easier to set here than in all the materials.
  108662. */
  108663. set environmentIntensity(value: number);
  108664. /** @hidden */
  108665. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108666. /**
  108667. * Default image processing configuration used either in the rendering
  108668. * Forward main pass or through the imageProcessingPostProcess if present.
  108669. * As in the majority of the scene they are the same (exception for multi camera),
  108670. * this is easier to reference from here than from all the materials and post process.
  108671. *
  108672. * No setter as we it is a shared configuration, you can set the values instead.
  108673. */
  108674. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108675. private _forceWireframe;
  108676. /**
  108677. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108678. */
  108679. set forceWireframe(value: boolean);
  108680. get forceWireframe(): boolean;
  108681. private _skipFrustumClipping;
  108682. /**
  108683. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108684. */
  108685. set skipFrustumClipping(value: boolean);
  108686. get skipFrustumClipping(): boolean;
  108687. private _forcePointsCloud;
  108688. /**
  108689. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108690. */
  108691. set forcePointsCloud(value: boolean);
  108692. get forcePointsCloud(): boolean;
  108693. /**
  108694. * Gets or sets the active clipplane 1
  108695. */
  108696. clipPlane: Nullable<Plane>;
  108697. /**
  108698. * Gets or sets the active clipplane 2
  108699. */
  108700. clipPlane2: Nullable<Plane>;
  108701. /**
  108702. * Gets or sets the active clipplane 3
  108703. */
  108704. clipPlane3: Nullable<Plane>;
  108705. /**
  108706. * Gets or sets the active clipplane 4
  108707. */
  108708. clipPlane4: Nullable<Plane>;
  108709. /**
  108710. * Gets or sets the active clipplane 5
  108711. */
  108712. clipPlane5: Nullable<Plane>;
  108713. /**
  108714. * Gets or sets the active clipplane 6
  108715. */
  108716. clipPlane6: Nullable<Plane>;
  108717. /**
  108718. * Gets or sets a boolean indicating if animations are enabled
  108719. */
  108720. animationsEnabled: boolean;
  108721. private _animationPropertiesOverride;
  108722. /**
  108723. * Gets or sets the animation properties override
  108724. */
  108725. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108726. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108727. /**
  108728. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108729. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108730. */
  108731. useConstantAnimationDeltaTime: boolean;
  108732. /**
  108733. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108734. * Please note that it requires to run a ray cast through the scene on every frame
  108735. */
  108736. constantlyUpdateMeshUnderPointer: boolean;
  108737. /**
  108738. * Defines the HTML cursor to use when hovering over interactive elements
  108739. */
  108740. hoverCursor: string;
  108741. /**
  108742. * Defines the HTML default cursor to use (empty by default)
  108743. */
  108744. defaultCursor: string;
  108745. /**
  108746. * Defines whether cursors are handled by the scene.
  108747. */
  108748. doNotHandleCursors: boolean;
  108749. /**
  108750. * This is used to call preventDefault() on pointer down
  108751. * in order to block unwanted artifacts like system double clicks
  108752. */
  108753. preventDefaultOnPointerDown: boolean;
  108754. /**
  108755. * This is used to call preventDefault() on pointer up
  108756. * in order to block unwanted artifacts like system double clicks
  108757. */
  108758. preventDefaultOnPointerUp: boolean;
  108759. /**
  108760. * Gets or sets user defined metadata
  108761. */
  108762. metadata: any;
  108763. /**
  108764. * For internal use only. Please do not use.
  108765. */
  108766. reservedDataStore: any;
  108767. /**
  108768. * Gets the name of the plugin used to load this scene (null by default)
  108769. */
  108770. loadingPluginName: string;
  108771. /**
  108772. * Use this array to add regular expressions used to disable offline support for specific urls
  108773. */
  108774. disableOfflineSupportExceptionRules: RegExp[];
  108775. /**
  108776. * An event triggered when the scene is disposed.
  108777. */
  108778. onDisposeObservable: Observable<Scene>;
  108779. private _onDisposeObserver;
  108780. /** Sets a function to be executed when this scene is disposed. */
  108781. set onDispose(callback: () => void);
  108782. /**
  108783. * An event triggered before rendering the scene (right after animations and physics)
  108784. */
  108785. onBeforeRenderObservable: Observable<Scene>;
  108786. private _onBeforeRenderObserver;
  108787. /** Sets a function to be executed before rendering this scene */
  108788. set beforeRender(callback: Nullable<() => void>);
  108789. /**
  108790. * An event triggered after rendering the scene
  108791. */
  108792. onAfterRenderObservable: Observable<Scene>;
  108793. /**
  108794. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108795. */
  108796. onAfterRenderCameraObservable: Observable<Camera>;
  108797. private _onAfterRenderObserver;
  108798. /** Sets a function to be executed after rendering this scene */
  108799. set afterRender(callback: Nullable<() => void>);
  108800. /**
  108801. * An event triggered before animating the scene
  108802. */
  108803. onBeforeAnimationsObservable: Observable<Scene>;
  108804. /**
  108805. * An event triggered after animations processing
  108806. */
  108807. onAfterAnimationsObservable: Observable<Scene>;
  108808. /**
  108809. * An event triggered before draw calls are ready to be sent
  108810. */
  108811. onBeforeDrawPhaseObservable: Observable<Scene>;
  108812. /**
  108813. * An event triggered after draw calls have been sent
  108814. */
  108815. onAfterDrawPhaseObservable: Observable<Scene>;
  108816. /**
  108817. * An event triggered when the scene is ready
  108818. */
  108819. onReadyObservable: Observable<Scene>;
  108820. /**
  108821. * An event triggered before rendering a camera
  108822. */
  108823. onBeforeCameraRenderObservable: Observable<Camera>;
  108824. private _onBeforeCameraRenderObserver;
  108825. /** Sets a function to be executed before rendering a camera*/
  108826. set beforeCameraRender(callback: () => void);
  108827. /**
  108828. * An event triggered after rendering a camera
  108829. */
  108830. onAfterCameraRenderObservable: Observable<Camera>;
  108831. private _onAfterCameraRenderObserver;
  108832. /** Sets a function to be executed after rendering a camera*/
  108833. set afterCameraRender(callback: () => void);
  108834. /**
  108835. * An event triggered when active meshes evaluation is about to start
  108836. */
  108837. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108838. /**
  108839. * An event triggered when active meshes evaluation is done
  108840. */
  108841. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108842. /**
  108843. * An event triggered when particles rendering is about to start
  108844. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108845. */
  108846. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108847. /**
  108848. * An event triggered when particles rendering is done
  108849. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108850. */
  108851. onAfterParticlesRenderingObservable: Observable<Scene>;
  108852. /**
  108853. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108854. */
  108855. onDataLoadedObservable: Observable<Scene>;
  108856. /**
  108857. * An event triggered when a camera is created
  108858. */
  108859. onNewCameraAddedObservable: Observable<Camera>;
  108860. /**
  108861. * An event triggered when a camera is removed
  108862. */
  108863. onCameraRemovedObservable: Observable<Camera>;
  108864. /**
  108865. * An event triggered when a light is created
  108866. */
  108867. onNewLightAddedObservable: Observable<Light>;
  108868. /**
  108869. * An event triggered when a light is removed
  108870. */
  108871. onLightRemovedObservable: Observable<Light>;
  108872. /**
  108873. * An event triggered when a geometry is created
  108874. */
  108875. onNewGeometryAddedObservable: Observable<Geometry>;
  108876. /**
  108877. * An event triggered when a geometry is removed
  108878. */
  108879. onGeometryRemovedObservable: Observable<Geometry>;
  108880. /**
  108881. * An event triggered when a transform node is created
  108882. */
  108883. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108884. /**
  108885. * An event triggered when a transform node is removed
  108886. */
  108887. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108888. /**
  108889. * An event triggered when a mesh is created
  108890. */
  108891. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108892. /**
  108893. * An event triggered when a mesh is removed
  108894. */
  108895. onMeshRemovedObservable: Observable<AbstractMesh>;
  108896. /**
  108897. * An event triggered when a skeleton is created
  108898. */
  108899. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108900. /**
  108901. * An event triggered when a skeleton is removed
  108902. */
  108903. onSkeletonRemovedObservable: Observable<Skeleton>;
  108904. /**
  108905. * An event triggered when a material is created
  108906. */
  108907. onNewMaterialAddedObservable: Observable<Material>;
  108908. /**
  108909. * An event triggered when a material is removed
  108910. */
  108911. onMaterialRemovedObservable: Observable<Material>;
  108912. /**
  108913. * An event triggered when a texture is created
  108914. */
  108915. onNewTextureAddedObservable: Observable<BaseTexture>;
  108916. /**
  108917. * An event triggered when a texture is removed
  108918. */
  108919. onTextureRemovedObservable: Observable<BaseTexture>;
  108920. /**
  108921. * An event triggered when render targets are about to be rendered
  108922. * Can happen multiple times per frame.
  108923. */
  108924. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108925. /**
  108926. * An event triggered when render targets were rendered.
  108927. * Can happen multiple times per frame.
  108928. */
  108929. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108930. /**
  108931. * An event triggered before calculating deterministic simulation step
  108932. */
  108933. onBeforeStepObservable: Observable<Scene>;
  108934. /**
  108935. * An event triggered after calculating deterministic simulation step
  108936. */
  108937. onAfterStepObservable: Observable<Scene>;
  108938. /**
  108939. * An event triggered when the activeCamera property is updated
  108940. */
  108941. onActiveCameraChanged: Observable<Scene>;
  108942. /**
  108943. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108944. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108945. * 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)
  108946. */
  108947. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108948. /**
  108949. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108950. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108951. * 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)
  108952. */
  108953. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108954. /**
  108955. * This Observable will when a mesh has been imported into the scene.
  108956. */
  108957. onMeshImportedObservable: Observable<AbstractMesh>;
  108958. /**
  108959. * This Observable will when an animation file has been imported into the scene.
  108960. */
  108961. onAnimationFileImportedObservable: Observable<Scene>;
  108962. /**
  108963. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108964. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108965. */
  108966. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108967. /** @hidden */
  108968. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108969. /**
  108970. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108971. */
  108972. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108973. /**
  108974. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108975. */
  108976. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108977. /**
  108978. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108979. */
  108980. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108981. /** Callback called when a pointer move is detected */
  108982. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108983. /** Callback called when a pointer down is detected */
  108984. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108985. /** Callback called when a pointer up is detected */
  108986. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108987. /** Callback called when a pointer pick is detected */
  108988. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108989. /**
  108990. * 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).
  108991. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108992. */
  108993. onPrePointerObservable: Observable<PointerInfoPre>;
  108994. /**
  108995. * Observable event triggered each time an input event is received from the rendering canvas
  108996. */
  108997. onPointerObservable: Observable<PointerInfo>;
  108998. /**
  108999. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  109000. */
  109001. get unTranslatedPointer(): Vector2;
  109002. /**
  109003. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  109004. */
  109005. static get DragMovementThreshold(): number;
  109006. static set DragMovementThreshold(value: number);
  109007. /**
  109008. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  109009. */
  109010. static get LongPressDelay(): number;
  109011. static set LongPressDelay(value: number);
  109012. /**
  109013. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  109014. */
  109015. static get DoubleClickDelay(): number;
  109016. static set DoubleClickDelay(value: number);
  109017. /** If you need to check double click without raising a single click at first click, enable this flag */
  109018. static get ExclusiveDoubleClickMode(): boolean;
  109019. static set ExclusiveDoubleClickMode(value: boolean);
  109020. /** @hidden */
  109021. _mirroredCameraPosition: Nullable<Vector3>;
  109022. /**
  109023. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  109024. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  109025. */
  109026. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  109027. /**
  109028. * Observable event triggered each time an keyboard event is received from the hosting window
  109029. */
  109030. onKeyboardObservable: Observable<KeyboardInfo>;
  109031. private _useRightHandedSystem;
  109032. /**
  109033. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  109034. */
  109035. set useRightHandedSystem(value: boolean);
  109036. get useRightHandedSystem(): boolean;
  109037. private _timeAccumulator;
  109038. private _currentStepId;
  109039. private _currentInternalStep;
  109040. /**
  109041. * Sets the step Id used by deterministic lock step
  109042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109043. * @param newStepId defines the step Id
  109044. */
  109045. setStepId(newStepId: number): void;
  109046. /**
  109047. * Gets the step Id used by deterministic lock step
  109048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109049. * @returns the step Id
  109050. */
  109051. getStepId(): number;
  109052. /**
  109053. * Gets the internal step used by deterministic lock step
  109054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109055. * @returns the internal step
  109056. */
  109057. getInternalStep(): number;
  109058. private _fogEnabled;
  109059. /**
  109060. * Gets or sets a boolean indicating if fog is enabled on this scene
  109061. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109062. * (Default is true)
  109063. */
  109064. set fogEnabled(value: boolean);
  109065. get fogEnabled(): boolean;
  109066. private _fogMode;
  109067. /**
  109068. * Gets or sets the fog mode to use
  109069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109070. * | mode | value |
  109071. * | --- | --- |
  109072. * | FOGMODE_NONE | 0 |
  109073. * | FOGMODE_EXP | 1 |
  109074. * | FOGMODE_EXP2 | 2 |
  109075. * | FOGMODE_LINEAR | 3 |
  109076. */
  109077. set fogMode(value: number);
  109078. get fogMode(): number;
  109079. /**
  109080. * Gets or sets the fog color to use
  109081. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109082. * (Default is Color3(0.2, 0.2, 0.3))
  109083. */
  109084. fogColor: Color3;
  109085. /**
  109086. * Gets or sets the fog density to use
  109087. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109088. * (Default is 0.1)
  109089. */
  109090. fogDensity: number;
  109091. /**
  109092. * Gets or sets the fog start distance to use
  109093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109094. * (Default is 0)
  109095. */
  109096. fogStart: number;
  109097. /**
  109098. * Gets or sets the fog end distance to use
  109099. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109100. * (Default is 1000)
  109101. */
  109102. fogEnd: number;
  109103. private _shadowsEnabled;
  109104. /**
  109105. * Gets or sets a boolean indicating if shadows are enabled on this scene
  109106. */
  109107. set shadowsEnabled(value: boolean);
  109108. get shadowsEnabled(): boolean;
  109109. private _lightsEnabled;
  109110. /**
  109111. * Gets or sets a boolean indicating if lights are enabled on this scene
  109112. */
  109113. set lightsEnabled(value: boolean);
  109114. get lightsEnabled(): boolean;
  109115. /** All of the active cameras added to this scene. */
  109116. activeCameras: Camera[];
  109117. /** @hidden */
  109118. _activeCamera: Nullable<Camera>;
  109119. /** Gets or sets the current active camera */
  109120. get activeCamera(): Nullable<Camera>;
  109121. set activeCamera(value: Nullable<Camera>);
  109122. private _defaultMaterial;
  109123. /** The default material used on meshes when no material is affected */
  109124. get defaultMaterial(): Material;
  109125. /** The default material used on meshes when no material is affected */
  109126. set defaultMaterial(value: Material);
  109127. private _texturesEnabled;
  109128. /**
  109129. * Gets or sets a boolean indicating if textures are enabled on this scene
  109130. */
  109131. set texturesEnabled(value: boolean);
  109132. get texturesEnabled(): boolean;
  109133. /**
  109134. * Gets or sets a boolean indicating if particles are enabled on this scene
  109135. */
  109136. particlesEnabled: boolean;
  109137. /**
  109138. * Gets or sets a boolean indicating if sprites are enabled on this scene
  109139. */
  109140. spritesEnabled: boolean;
  109141. private _skeletonsEnabled;
  109142. /**
  109143. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  109144. */
  109145. set skeletonsEnabled(value: boolean);
  109146. get skeletonsEnabled(): boolean;
  109147. /**
  109148. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  109149. */
  109150. lensFlaresEnabled: boolean;
  109151. /**
  109152. * Gets or sets a boolean indicating if collisions are enabled on this scene
  109153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109154. */
  109155. collisionsEnabled: boolean;
  109156. private _collisionCoordinator;
  109157. /** @hidden */
  109158. get collisionCoordinator(): ICollisionCoordinator;
  109159. /**
  109160. * Defines the gravity applied to this scene (used only for collisions)
  109161. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109162. */
  109163. gravity: Vector3;
  109164. /**
  109165. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109166. */
  109167. postProcessesEnabled: boolean;
  109168. /**
  109169. * The list of postprocesses added to the scene
  109170. */
  109171. postProcesses: PostProcess[];
  109172. /**
  109173. * Gets the current postprocess manager
  109174. */
  109175. postProcessManager: PostProcessManager;
  109176. /**
  109177. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109178. */
  109179. renderTargetsEnabled: boolean;
  109180. /**
  109181. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109182. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109183. */
  109184. dumpNextRenderTargets: boolean;
  109185. /**
  109186. * The list of user defined render targets added to the scene
  109187. */
  109188. customRenderTargets: RenderTargetTexture[];
  109189. /**
  109190. * Defines if texture loading must be delayed
  109191. * If true, textures will only be loaded when they need to be rendered
  109192. */
  109193. useDelayedTextureLoading: boolean;
  109194. /**
  109195. * Gets the list of meshes imported to the scene through SceneLoader
  109196. */
  109197. importedMeshesFiles: String[];
  109198. /**
  109199. * Gets or sets a boolean indicating if probes are enabled on this scene
  109200. */
  109201. probesEnabled: boolean;
  109202. /**
  109203. * Gets or sets the current offline provider to use to store scene data
  109204. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109205. */
  109206. offlineProvider: IOfflineProvider;
  109207. /**
  109208. * Gets or sets the action manager associated with the scene
  109209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109210. */
  109211. actionManager: AbstractActionManager;
  109212. private _meshesForIntersections;
  109213. /**
  109214. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109215. */
  109216. proceduralTexturesEnabled: boolean;
  109217. private _engine;
  109218. private _totalVertices;
  109219. /** @hidden */
  109220. _activeIndices: PerfCounter;
  109221. /** @hidden */
  109222. _activeParticles: PerfCounter;
  109223. /** @hidden */
  109224. _activeBones: PerfCounter;
  109225. private _animationRatio;
  109226. /** @hidden */
  109227. _animationTimeLast: number;
  109228. /** @hidden */
  109229. _animationTime: number;
  109230. /**
  109231. * Gets or sets a general scale for animation speed
  109232. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109233. */
  109234. animationTimeScale: number;
  109235. /** @hidden */
  109236. _cachedMaterial: Nullable<Material>;
  109237. /** @hidden */
  109238. _cachedEffect: Nullable<Effect>;
  109239. /** @hidden */
  109240. _cachedVisibility: Nullable<number>;
  109241. private _renderId;
  109242. private _frameId;
  109243. private _executeWhenReadyTimeoutId;
  109244. private _intermediateRendering;
  109245. private _viewUpdateFlag;
  109246. private _projectionUpdateFlag;
  109247. /** @hidden */
  109248. _toBeDisposed: Nullable<IDisposable>[];
  109249. private _activeRequests;
  109250. /** @hidden */
  109251. _pendingData: any[];
  109252. private _isDisposed;
  109253. /**
  109254. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109255. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109256. */
  109257. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109258. private _activeMeshes;
  109259. private _processedMaterials;
  109260. private _renderTargets;
  109261. /** @hidden */
  109262. _activeParticleSystems: SmartArray<IParticleSystem>;
  109263. private _activeSkeletons;
  109264. private _softwareSkinnedMeshes;
  109265. private _renderingManager;
  109266. /** @hidden */
  109267. _activeAnimatables: Animatable[];
  109268. private _transformMatrix;
  109269. private _sceneUbo;
  109270. /** @hidden */
  109271. _viewMatrix: Matrix;
  109272. private _projectionMatrix;
  109273. /** @hidden */
  109274. _forcedViewPosition: Nullable<Vector3>;
  109275. /** @hidden */
  109276. _frustumPlanes: Plane[];
  109277. /**
  109278. * Gets the list of frustum planes (built from the active camera)
  109279. */
  109280. get frustumPlanes(): Plane[];
  109281. /**
  109282. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109283. * This is useful if there are more lights that the maximum simulteanous authorized
  109284. */
  109285. requireLightSorting: boolean;
  109286. /** @hidden */
  109287. readonly useMaterialMeshMap: boolean;
  109288. /** @hidden */
  109289. readonly useClonedMeshMap: boolean;
  109290. private _externalData;
  109291. private _uid;
  109292. /**
  109293. * @hidden
  109294. * Backing store of defined scene components.
  109295. */
  109296. _components: ISceneComponent[];
  109297. /**
  109298. * @hidden
  109299. * Backing store of defined scene components.
  109300. */
  109301. _serializableComponents: ISceneSerializableComponent[];
  109302. /**
  109303. * List of components to register on the next registration step.
  109304. */
  109305. private _transientComponents;
  109306. /**
  109307. * Registers the transient components if needed.
  109308. */
  109309. private _registerTransientComponents;
  109310. /**
  109311. * @hidden
  109312. * Add a component to the scene.
  109313. * Note that the ccomponent could be registered on th next frame if this is called after
  109314. * the register component stage.
  109315. * @param component Defines the component to add to the scene
  109316. */
  109317. _addComponent(component: ISceneComponent): void;
  109318. /**
  109319. * @hidden
  109320. * Gets a component from the scene.
  109321. * @param name defines the name of the component to retrieve
  109322. * @returns the component or null if not present
  109323. */
  109324. _getComponent(name: string): Nullable<ISceneComponent>;
  109325. /**
  109326. * @hidden
  109327. * Defines the actions happening before camera updates.
  109328. */
  109329. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109330. /**
  109331. * @hidden
  109332. * Defines the actions happening before clear the canvas.
  109333. */
  109334. _beforeClearStage: Stage<SimpleStageAction>;
  109335. /**
  109336. * @hidden
  109337. * Defines the actions when collecting render targets for the frame.
  109338. */
  109339. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109340. /**
  109341. * @hidden
  109342. * Defines the actions happening for one camera in the frame.
  109343. */
  109344. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109345. /**
  109346. * @hidden
  109347. * Defines the actions happening during the per mesh ready checks.
  109348. */
  109349. _isReadyForMeshStage: Stage<MeshStageAction>;
  109350. /**
  109351. * @hidden
  109352. * Defines the actions happening before evaluate active mesh checks.
  109353. */
  109354. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109355. /**
  109356. * @hidden
  109357. * Defines the actions happening during the evaluate sub mesh checks.
  109358. */
  109359. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109360. /**
  109361. * @hidden
  109362. * Defines the actions happening during the active mesh stage.
  109363. */
  109364. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109365. /**
  109366. * @hidden
  109367. * Defines the actions happening during the per camera render target step.
  109368. */
  109369. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109370. /**
  109371. * @hidden
  109372. * Defines the actions happening just before the active camera is drawing.
  109373. */
  109374. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109375. /**
  109376. * @hidden
  109377. * Defines the actions happening just before a render target is drawing.
  109378. */
  109379. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109380. /**
  109381. * @hidden
  109382. * Defines the actions happening just before a rendering group is drawing.
  109383. */
  109384. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109385. /**
  109386. * @hidden
  109387. * Defines the actions happening just before a mesh is drawing.
  109388. */
  109389. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109390. /**
  109391. * @hidden
  109392. * Defines the actions happening just after a mesh has been drawn.
  109393. */
  109394. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109395. /**
  109396. * @hidden
  109397. * Defines the actions happening just after a rendering group has been drawn.
  109398. */
  109399. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109400. /**
  109401. * @hidden
  109402. * Defines the actions happening just after the active camera has been drawn.
  109403. */
  109404. _afterCameraDrawStage: Stage<CameraStageAction>;
  109405. /**
  109406. * @hidden
  109407. * Defines the actions happening just after a render target has been drawn.
  109408. */
  109409. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109410. /**
  109411. * @hidden
  109412. * Defines the actions happening just after rendering all cameras and computing intersections.
  109413. */
  109414. _afterRenderStage: Stage<SimpleStageAction>;
  109415. /**
  109416. * @hidden
  109417. * Defines the actions happening when a pointer move event happens.
  109418. */
  109419. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109420. /**
  109421. * @hidden
  109422. * Defines the actions happening when a pointer down event happens.
  109423. */
  109424. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109425. /**
  109426. * @hidden
  109427. * Defines the actions happening when a pointer up event happens.
  109428. */
  109429. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109430. /**
  109431. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109432. */
  109433. private geometriesByUniqueId;
  109434. /**
  109435. * Creates a new Scene
  109436. * @param engine defines the engine to use to render this scene
  109437. * @param options defines the scene options
  109438. */
  109439. constructor(engine: Engine, options?: SceneOptions);
  109440. /**
  109441. * Gets a string idenfifying the name of the class
  109442. * @returns "Scene" string
  109443. */
  109444. getClassName(): string;
  109445. private _defaultMeshCandidates;
  109446. /**
  109447. * @hidden
  109448. */
  109449. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109450. private _defaultSubMeshCandidates;
  109451. /**
  109452. * @hidden
  109453. */
  109454. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109455. /**
  109456. * Sets the default candidate providers for the scene.
  109457. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109458. * and getCollidingSubMeshCandidates to their default function
  109459. */
  109460. setDefaultCandidateProviders(): void;
  109461. /**
  109462. * Gets the mesh that is currently under the pointer
  109463. */
  109464. get meshUnderPointer(): Nullable<AbstractMesh>;
  109465. /**
  109466. * Gets or sets the current on-screen X position of the pointer
  109467. */
  109468. get pointerX(): number;
  109469. set pointerX(value: number);
  109470. /**
  109471. * Gets or sets the current on-screen Y position of the pointer
  109472. */
  109473. get pointerY(): number;
  109474. set pointerY(value: number);
  109475. /**
  109476. * Gets the cached material (ie. the latest rendered one)
  109477. * @returns the cached material
  109478. */
  109479. getCachedMaterial(): Nullable<Material>;
  109480. /**
  109481. * Gets the cached effect (ie. the latest rendered one)
  109482. * @returns the cached effect
  109483. */
  109484. getCachedEffect(): Nullable<Effect>;
  109485. /**
  109486. * Gets the cached visibility state (ie. the latest rendered one)
  109487. * @returns the cached visibility state
  109488. */
  109489. getCachedVisibility(): Nullable<number>;
  109490. /**
  109491. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109492. * @param material defines the current material
  109493. * @param effect defines the current effect
  109494. * @param visibility defines the current visibility state
  109495. * @returns true if one parameter is not cached
  109496. */
  109497. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109498. /**
  109499. * Gets the engine associated with the scene
  109500. * @returns an Engine
  109501. */
  109502. getEngine(): Engine;
  109503. /**
  109504. * Gets the total number of vertices rendered per frame
  109505. * @returns the total number of vertices rendered per frame
  109506. */
  109507. getTotalVertices(): number;
  109508. /**
  109509. * Gets the performance counter for total vertices
  109510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109511. */
  109512. get totalVerticesPerfCounter(): PerfCounter;
  109513. /**
  109514. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109515. * @returns the total number of active indices rendered per frame
  109516. */
  109517. getActiveIndices(): number;
  109518. /**
  109519. * Gets the performance counter for active indices
  109520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109521. */
  109522. get totalActiveIndicesPerfCounter(): PerfCounter;
  109523. /**
  109524. * Gets the total number of active particles rendered per frame
  109525. * @returns the total number of active particles rendered per frame
  109526. */
  109527. getActiveParticles(): number;
  109528. /**
  109529. * Gets the performance counter for active particles
  109530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109531. */
  109532. get activeParticlesPerfCounter(): PerfCounter;
  109533. /**
  109534. * Gets the total number of active bones rendered per frame
  109535. * @returns the total number of active bones rendered per frame
  109536. */
  109537. getActiveBones(): number;
  109538. /**
  109539. * Gets the performance counter for active bones
  109540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109541. */
  109542. get activeBonesPerfCounter(): PerfCounter;
  109543. /**
  109544. * Gets the array of active meshes
  109545. * @returns an array of AbstractMesh
  109546. */
  109547. getActiveMeshes(): SmartArray<AbstractMesh>;
  109548. /**
  109549. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109550. * @returns a number
  109551. */
  109552. getAnimationRatio(): number;
  109553. /**
  109554. * Gets an unique Id for the current render phase
  109555. * @returns a number
  109556. */
  109557. getRenderId(): number;
  109558. /**
  109559. * Gets an unique Id for the current frame
  109560. * @returns a number
  109561. */
  109562. getFrameId(): number;
  109563. /** Call this function if you want to manually increment the render Id*/
  109564. incrementRenderId(): void;
  109565. private _createUbo;
  109566. /**
  109567. * Use this method to simulate a pointer move on a mesh
  109568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109571. * @returns the current scene
  109572. */
  109573. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109574. /**
  109575. * Use this method to simulate a pointer down on a mesh
  109576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109579. * @returns the current scene
  109580. */
  109581. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109582. /**
  109583. * Use this method to simulate a pointer up on a mesh
  109584. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109585. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109586. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109587. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109588. * @returns the current scene
  109589. */
  109590. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109591. /**
  109592. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109593. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109594. * @returns true if the pointer was captured
  109595. */
  109596. isPointerCaptured(pointerId?: number): boolean;
  109597. /**
  109598. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109599. * @param attachUp defines if you want to attach events to pointerup
  109600. * @param attachDown defines if you want to attach events to pointerdown
  109601. * @param attachMove defines if you want to attach events to pointermove
  109602. */
  109603. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109604. /** Detaches all event handlers*/
  109605. detachControl(): void;
  109606. /**
  109607. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109608. * Delay loaded resources are not taking in account
  109609. * @return true if all required resources are ready
  109610. */
  109611. isReady(): boolean;
  109612. /** Resets all cached information relative to material (including effect and visibility) */
  109613. resetCachedMaterial(): void;
  109614. /**
  109615. * Registers a function to be called before every frame render
  109616. * @param func defines the function to register
  109617. */
  109618. registerBeforeRender(func: () => void): void;
  109619. /**
  109620. * Unregisters a function called before every frame render
  109621. * @param func defines the function to unregister
  109622. */
  109623. unregisterBeforeRender(func: () => void): void;
  109624. /**
  109625. * Registers a function to be called after every frame render
  109626. * @param func defines the function to register
  109627. */
  109628. registerAfterRender(func: () => void): void;
  109629. /**
  109630. * Unregisters a function called after every frame render
  109631. * @param func defines the function to unregister
  109632. */
  109633. unregisterAfterRender(func: () => void): void;
  109634. private _executeOnceBeforeRender;
  109635. /**
  109636. * The provided function will run before render once and will be disposed afterwards.
  109637. * A timeout delay can be provided so that the function will be executed in N ms.
  109638. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109639. * @param func The function to be executed.
  109640. * @param timeout optional delay in ms
  109641. */
  109642. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109643. /** @hidden */
  109644. _addPendingData(data: any): void;
  109645. /** @hidden */
  109646. _removePendingData(data: any): void;
  109647. /**
  109648. * Returns the number of items waiting to be loaded
  109649. * @returns the number of items waiting to be loaded
  109650. */
  109651. getWaitingItemsCount(): number;
  109652. /**
  109653. * Returns a boolean indicating if the scene is still loading data
  109654. */
  109655. get isLoading(): boolean;
  109656. /**
  109657. * Registers a function to be executed when the scene is ready
  109658. * @param {Function} func - the function to be executed
  109659. */
  109660. executeWhenReady(func: () => void): void;
  109661. /**
  109662. * Returns a promise that resolves when the scene is ready
  109663. * @returns A promise that resolves when the scene is ready
  109664. */
  109665. whenReadyAsync(): Promise<void>;
  109666. /** @hidden */
  109667. _checkIsReady(): void;
  109668. /**
  109669. * Gets all animatable attached to the scene
  109670. */
  109671. get animatables(): Animatable[];
  109672. /**
  109673. * Resets the last animation time frame.
  109674. * Useful to override when animations start running when loading a scene for the first time.
  109675. */
  109676. resetLastAnimationTimeFrame(): void;
  109677. /**
  109678. * Gets the current view matrix
  109679. * @returns a Matrix
  109680. */
  109681. getViewMatrix(): Matrix;
  109682. /**
  109683. * Gets the current projection matrix
  109684. * @returns a Matrix
  109685. */
  109686. getProjectionMatrix(): Matrix;
  109687. /**
  109688. * Gets the current transform matrix
  109689. * @returns a Matrix made of View * Projection
  109690. */
  109691. getTransformMatrix(): Matrix;
  109692. /**
  109693. * Sets the current transform matrix
  109694. * @param viewL defines the View matrix to use
  109695. * @param projectionL defines the Projection matrix to use
  109696. * @param viewR defines the right View matrix to use (if provided)
  109697. * @param projectionR defines the right Projection matrix to use (if provided)
  109698. */
  109699. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109700. /**
  109701. * Gets the uniform buffer used to store scene data
  109702. * @returns a UniformBuffer
  109703. */
  109704. getSceneUniformBuffer(): UniformBuffer;
  109705. /**
  109706. * Gets an unique (relatively to the current scene) Id
  109707. * @returns an unique number for the scene
  109708. */
  109709. getUniqueId(): number;
  109710. /**
  109711. * Add a mesh to the list of scene's meshes
  109712. * @param newMesh defines the mesh to add
  109713. * @param recursive if all child meshes should also be added to the scene
  109714. */
  109715. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109716. /**
  109717. * Remove a mesh for the list of scene's meshes
  109718. * @param toRemove defines the mesh to remove
  109719. * @param recursive if all child meshes should also be removed from the scene
  109720. * @returns the index where the mesh was in the mesh list
  109721. */
  109722. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109723. /**
  109724. * Add a transform node to the list of scene's transform nodes
  109725. * @param newTransformNode defines the transform node to add
  109726. */
  109727. addTransformNode(newTransformNode: TransformNode): void;
  109728. /**
  109729. * Remove a transform node for the list of scene's transform nodes
  109730. * @param toRemove defines the transform node to remove
  109731. * @returns the index where the transform node was in the transform node list
  109732. */
  109733. removeTransformNode(toRemove: TransformNode): number;
  109734. /**
  109735. * Remove a skeleton for the list of scene's skeletons
  109736. * @param toRemove defines the skeleton to remove
  109737. * @returns the index where the skeleton was in the skeleton list
  109738. */
  109739. removeSkeleton(toRemove: Skeleton): number;
  109740. /**
  109741. * Remove a morph target for the list of scene's morph targets
  109742. * @param toRemove defines the morph target to remove
  109743. * @returns the index where the morph target was in the morph target list
  109744. */
  109745. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109746. /**
  109747. * Remove a light for the list of scene's lights
  109748. * @param toRemove defines the light to remove
  109749. * @returns the index where the light was in the light list
  109750. */
  109751. removeLight(toRemove: Light): number;
  109752. /**
  109753. * Remove a camera for the list of scene's cameras
  109754. * @param toRemove defines the camera to remove
  109755. * @returns the index where the camera was in the camera list
  109756. */
  109757. removeCamera(toRemove: Camera): number;
  109758. /**
  109759. * Remove a particle system for the list of scene's particle systems
  109760. * @param toRemove defines the particle system to remove
  109761. * @returns the index where the particle system was in the particle system list
  109762. */
  109763. removeParticleSystem(toRemove: IParticleSystem): number;
  109764. /**
  109765. * Remove a animation for the list of scene's animations
  109766. * @param toRemove defines the animation to remove
  109767. * @returns the index where the animation was in the animation list
  109768. */
  109769. removeAnimation(toRemove: Animation): number;
  109770. /**
  109771. * Will stop the animation of the given target
  109772. * @param target - the target
  109773. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109774. * @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)
  109775. */
  109776. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109777. /**
  109778. * Removes the given animation group from this scene.
  109779. * @param toRemove The animation group to remove
  109780. * @returns The index of the removed animation group
  109781. */
  109782. removeAnimationGroup(toRemove: AnimationGroup): number;
  109783. /**
  109784. * Removes the given multi-material from this scene.
  109785. * @param toRemove The multi-material to remove
  109786. * @returns The index of the removed multi-material
  109787. */
  109788. removeMultiMaterial(toRemove: MultiMaterial): number;
  109789. /**
  109790. * Removes the given material from this scene.
  109791. * @param toRemove The material to remove
  109792. * @returns The index of the removed material
  109793. */
  109794. removeMaterial(toRemove: Material): number;
  109795. /**
  109796. * Removes the given action manager from this scene.
  109797. * @param toRemove The action manager to remove
  109798. * @returns The index of the removed action manager
  109799. */
  109800. removeActionManager(toRemove: AbstractActionManager): number;
  109801. /**
  109802. * Removes the given texture from this scene.
  109803. * @param toRemove The texture to remove
  109804. * @returns The index of the removed texture
  109805. */
  109806. removeTexture(toRemove: BaseTexture): number;
  109807. /**
  109808. * Adds the given light to this scene
  109809. * @param newLight The light to add
  109810. */
  109811. addLight(newLight: Light): void;
  109812. /**
  109813. * Sorts the list list based on light priorities
  109814. */
  109815. sortLightsByPriority(): void;
  109816. /**
  109817. * Adds the given camera to this scene
  109818. * @param newCamera The camera to add
  109819. */
  109820. addCamera(newCamera: Camera): void;
  109821. /**
  109822. * Adds the given skeleton to this scene
  109823. * @param newSkeleton The skeleton to add
  109824. */
  109825. addSkeleton(newSkeleton: Skeleton): void;
  109826. /**
  109827. * Adds the given particle system to this scene
  109828. * @param newParticleSystem The particle system to add
  109829. */
  109830. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109831. /**
  109832. * Adds the given animation to this scene
  109833. * @param newAnimation The animation to add
  109834. */
  109835. addAnimation(newAnimation: Animation): void;
  109836. /**
  109837. * Adds the given animation group to this scene.
  109838. * @param newAnimationGroup The animation group to add
  109839. */
  109840. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109841. /**
  109842. * Adds the given multi-material to this scene
  109843. * @param newMultiMaterial The multi-material to add
  109844. */
  109845. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109846. /**
  109847. * Adds the given material to this scene
  109848. * @param newMaterial The material to add
  109849. */
  109850. addMaterial(newMaterial: Material): void;
  109851. /**
  109852. * Adds the given morph target to this scene
  109853. * @param newMorphTargetManager The morph target to add
  109854. */
  109855. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109856. /**
  109857. * Adds the given geometry to this scene
  109858. * @param newGeometry The geometry to add
  109859. */
  109860. addGeometry(newGeometry: Geometry): void;
  109861. /**
  109862. * Adds the given action manager to this scene
  109863. * @param newActionManager The action manager to add
  109864. */
  109865. addActionManager(newActionManager: AbstractActionManager): void;
  109866. /**
  109867. * Adds the given texture to this scene.
  109868. * @param newTexture The texture to add
  109869. */
  109870. addTexture(newTexture: BaseTexture): void;
  109871. /**
  109872. * Switch active camera
  109873. * @param newCamera defines the new active camera
  109874. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109875. */
  109876. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109877. /**
  109878. * sets the active camera of the scene using its ID
  109879. * @param id defines the camera's ID
  109880. * @return the new active camera or null if none found.
  109881. */
  109882. setActiveCameraByID(id: string): Nullable<Camera>;
  109883. /**
  109884. * sets the active camera of the scene using its name
  109885. * @param name defines the camera's name
  109886. * @returns the new active camera or null if none found.
  109887. */
  109888. setActiveCameraByName(name: string): Nullable<Camera>;
  109889. /**
  109890. * get an animation group using its name
  109891. * @param name defines the material's name
  109892. * @return the animation group or null if none found.
  109893. */
  109894. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109895. /**
  109896. * Get a material using its unique id
  109897. * @param uniqueId defines the material's unique id
  109898. * @return the material or null if none found.
  109899. */
  109900. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109901. /**
  109902. * get a material using its id
  109903. * @param id defines the material's ID
  109904. * @return the material or null if none found.
  109905. */
  109906. getMaterialByID(id: string): Nullable<Material>;
  109907. /**
  109908. * Gets a the last added material using a given id
  109909. * @param id defines the material's ID
  109910. * @return the last material with the given id or null if none found.
  109911. */
  109912. getLastMaterialByID(id: string): Nullable<Material>;
  109913. /**
  109914. * Gets a material using its name
  109915. * @param name defines the material's name
  109916. * @return the material or null if none found.
  109917. */
  109918. getMaterialByName(name: string): Nullable<Material>;
  109919. /**
  109920. * Get a texture using its unique id
  109921. * @param uniqueId defines the texture's unique id
  109922. * @return the texture or null if none found.
  109923. */
  109924. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109925. /**
  109926. * Gets a camera using its id
  109927. * @param id defines the id to look for
  109928. * @returns the camera or null if not found
  109929. */
  109930. getCameraByID(id: string): Nullable<Camera>;
  109931. /**
  109932. * Gets a camera using its unique id
  109933. * @param uniqueId defines the unique id to look for
  109934. * @returns the camera or null if not found
  109935. */
  109936. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109937. /**
  109938. * Gets a camera using its name
  109939. * @param name defines the camera's name
  109940. * @return the camera or null if none found.
  109941. */
  109942. getCameraByName(name: string): Nullable<Camera>;
  109943. /**
  109944. * Gets a bone using its id
  109945. * @param id defines the bone's id
  109946. * @return the bone or null if not found
  109947. */
  109948. getBoneByID(id: string): Nullable<Bone>;
  109949. /**
  109950. * Gets a bone using its id
  109951. * @param name defines the bone's name
  109952. * @return the bone or null if not found
  109953. */
  109954. getBoneByName(name: string): Nullable<Bone>;
  109955. /**
  109956. * Gets a light node using its name
  109957. * @param name defines the the light's name
  109958. * @return the light or null if none found.
  109959. */
  109960. getLightByName(name: string): Nullable<Light>;
  109961. /**
  109962. * Gets a light node using its id
  109963. * @param id defines the light's id
  109964. * @return the light or null if none found.
  109965. */
  109966. getLightByID(id: string): Nullable<Light>;
  109967. /**
  109968. * Gets a light node using its scene-generated unique ID
  109969. * @param uniqueId defines the light's unique id
  109970. * @return the light or null if none found.
  109971. */
  109972. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109973. /**
  109974. * Gets a particle system by id
  109975. * @param id defines the particle system id
  109976. * @return the corresponding system or null if none found
  109977. */
  109978. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109979. /**
  109980. * Gets a geometry using its ID
  109981. * @param id defines the geometry's id
  109982. * @return the geometry or null if none found.
  109983. */
  109984. getGeometryByID(id: string): Nullable<Geometry>;
  109985. private _getGeometryByUniqueID;
  109986. /**
  109987. * Add a new geometry to this scene
  109988. * @param geometry defines the geometry to be added to the scene.
  109989. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109990. * @return a boolean defining if the geometry was added or not
  109991. */
  109992. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109993. /**
  109994. * Removes an existing geometry
  109995. * @param geometry defines the geometry to be removed from the scene
  109996. * @return a boolean defining if the geometry was removed or not
  109997. */
  109998. removeGeometry(geometry: Geometry): boolean;
  109999. /**
  110000. * Gets the list of geometries attached to the scene
  110001. * @returns an array of Geometry
  110002. */
  110003. getGeometries(): Geometry[];
  110004. /**
  110005. * Gets the first added mesh found of a given ID
  110006. * @param id defines the id to search for
  110007. * @return the mesh found or null if not found at all
  110008. */
  110009. getMeshByID(id: string): Nullable<AbstractMesh>;
  110010. /**
  110011. * Gets a list of meshes using their id
  110012. * @param id defines the id to search for
  110013. * @returns a list of meshes
  110014. */
  110015. getMeshesByID(id: string): Array<AbstractMesh>;
  110016. /**
  110017. * Gets the first added transform node found of a given ID
  110018. * @param id defines the id to search for
  110019. * @return the found transform node or null if not found at all.
  110020. */
  110021. getTransformNodeByID(id: string): Nullable<TransformNode>;
  110022. /**
  110023. * Gets a transform node with its auto-generated unique id
  110024. * @param uniqueId efines the unique id to search for
  110025. * @return the found transform node or null if not found at all.
  110026. */
  110027. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  110028. /**
  110029. * Gets a list of transform nodes using their id
  110030. * @param id defines the id to search for
  110031. * @returns a list of transform nodes
  110032. */
  110033. getTransformNodesByID(id: string): Array<TransformNode>;
  110034. /**
  110035. * Gets a mesh with its auto-generated unique id
  110036. * @param uniqueId defines the unique id to search for
  110037. * @return the found mesh or null if not found at all.
  110038. */
  110039. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  110040. /**
  110041. * Gets a the last added mesh using a given id
  110042. * @param id defines the id to search for
  110043. * @return the found mesh or null if not found at all.
  110044. */
  110045. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  110046. /**
  110047. * Gets a the last added node (Mesh, Camera, Light) using a given id
  110048. * @param id defines the id to search for
  110049. * @return the found node or null if not found at all
  110050. */
  110051. getLastEntryByID(id: string): Nullable<Node>;
  110052. /**
  110053. * Gets a node (Mesh, Camera, Light) using a given id
  110054. * @param id defines the id to search for
  110055. * @return the found node or null if not found at all
  110056. */
  110057. getNodeByID(id: string): Nullable<Node>;
  110058. /**
  110059. * Gets a node (Mesh, Camera, Light) using a given name
  110060. * @param name defines the name to search for
  110061. * @return the found node or null if not found at all.
  110062. */
  110063. getNodeByName(name: string): Nullable<Node>;
  110064. /**
  110065. * Gets a mesh using a given name
  110066. * @param name defines the name to search for
  110067. * @return the found mesh or null if not found at all.
  110068. */
  110069. getMeshByName(name: string): Nullable<AbstractMesh>;
  110070. /**
  110071. * Gets a transform node using a given name
  110072. * @param name defines the name to search for
  110073. * @return the found transform node or null if not found at all.
  110074. */
  110075. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110076. /**
  110077. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110078. * @param id defines the id to search for
  110079. * @return the found skeleton or null if not found at all.
  110080. */
  110081. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  110082. /**
  110083. * Gets a skeleton using a given auto generated unique id
  110084. * @param uniqueId defines the unique id to search for
  110085. * @return the found skeleton or null if not found at all.
  110086. */
  110087. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  110088. /**
  110089. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  110090. * @param id defines the id to search for
  110091. * @return the found skeleton or null if not found at all.
  110092. */
  110093. getSkeletonById(id: string): Nullable<Skeleton>;
  110094. /**
  110095. * Gets a skeleton using a given name
  110096. * @param name defines the name to search for
  110097. * @return the found skeleton or null if not found at all.
  110098. */
  110099. getSkeletonByName(name: string): Nullable<Skeleton>;
  110100. /**
  110101. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  110102. * @param id defines the id to search for
  110103. * @return the found morph target manager or null if not found at all.
  110104. */
  110105. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  110106. /**
  110107. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  110108. * @param id defines the id to search for
  110109. * @return the found morph target or null if not found at all.
  110110. */
  110111. getMorphTargetById(id: string): Nullable<MorphTarget>;
  110112. /**
  110113. * Gets a boolean indicating if the given mesh is active
  110114. * @param mesh defines the mesh to look for
  110115. * @returns true if the mesh is in the active list
  110116. */
  110117. isActiveMesh(mesh: AbstractMesh): boolean;
  110118. /**
  110119. * Return a unique id as a string which can serve as an identifier for the scene
  110120. */
  110121. get uid(): string;
  110122. /**
  110123. * Add an externaly attached data from its key.
  110124. * This method call will fail and return false, if such key already exists.
  110125. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  110126. * @param key the unique key that identifies the data
  110127. * @param data the data object to associate to the key for this Engine instance
  110128. * @return true if no such key were already present and the data was added successfully, false otherwise
  110129. */
  110130. addExternalData<T>(key: string, data: T): boolean;
  110131. /**
  110132. * Get an externaly attached data from its key
  110133. * @param key the unique key that identifies the data
  110134. * @return the associated data, if present (can be null), or undefined if not present
  110135. */
  110136. getExternalData<T>(key: string): Nullable<T>;
  110137. /**
  110138. * Get an externaly attached data from its key, create it using a factory if it's not already present
  110139. * @param key the unique key that identifies the data
  110140. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  110141. * @return the associated data, can be null if the factory returned null.
  110142. */
  110143. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  110144. /**
  110145. * Remove an externaly attached data from the Engine instance
  110146. * @param key the unique key that identifies the data
  110147. * @return true if the data was successfully removed, false if it doesn't exist
  110148. */
  110149. removeExternalData(key: string): boolean;
  110150. private _evaluateSubMesh;
  110151. /**
  110152. * Clear the processed materials smart array preventing retention point in material dispose.
  110153. */
  110154. freeProcessedMaterials(): void;
  110155. private _preventFreeActiveMeshesAndRenderingGroups;
  110156. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  110157. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  110158. * when disposing several meshes in a row or a hierarchy of meshes.
  110159. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  110160. */
  110161. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  110162. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110163. /**
  110164. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110165. */
  110166. freeActiveMeshes(): void;
  110167. /**
  110168. * Clear the info related to rendering groups preventing retention points during dispose.
  110169. */
  110170. freeRenderingGroups(): void;
  110171. /** @hidden */
  110172. _isInIntermediateRendering(): boolean;
  110173. /**
  110174. * Lambda returning the list of potentially active meshes.
  110175. */
  110176. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110177. /**
  110178. * Lambda returning the list of potentially active sub meshes.
  110179. */
  110180. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110181. /**
  110182. * Lambda returning the list of potentially intersecting sub meshes.
  110183. */
  110184. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110185. /**
  110186. * Lambda returning the list of potentially colliding sub meshes.
  110187. */
  110188. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110189. private _activeMeshesFrozen;
  110190. private _skipEvaluateActiveMeshesCompletely;
  110191. /**
  110192. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110193. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110194. * @returns the current scene
  110195. */
  110196. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110197. /**
  110198. * Use this function to restart evaluating active meshes on every frame
  110199. * @returns the current scene
  110200. */
  110201. unfreezeActiveMeshes(): Scene;
  110202. private _evaluateActiveMeshes;
  110203. private _activeMesh;
  110204. /**
  110205. * Update the transform matrix to update from the current active camera
  110206. * @param force defines a boolean used to force the update even if cache is up to date
  110207. */
  110208. updateTransformMatrix(force?: boolean): void;
  110209. private _bindFrameBuffer;
  110210. /** @hidden */
  110211. _allowPostProcessClearColor: boolean;
  110212. /** @hidden */
  110213. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110214. private _processSubCameras;
  110215. private _checkIntersections;
  110216. /** @hidden */
  110217. _advancePhysicsEngineStep(step: number): void;
  110218. /**
  110219. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110220. */
  110221. getDeterministicFrameTime: () => number;
  110222. /** @hidden */
  110223. _animate(): void;
  110224. /** Execute all animations (for a frame) */
  110225. animate(): void;
  110226. /**
  110227. * Render the scene
  110228. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110229. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110230. */
  110231. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110232. /**
  110233. * Freeze all materials
  110234. * A frozen material will not be updatable but should be faster to render
  110235. */
  110236. freezeMaterials(): void;
  110237. /**
  110238. * Unfreeze all materials
  110239. * A frozen material will not be updatable but should be faster to render
  110240. */
  110241. unfreezeMaterials(): void;
  110242. /**
  110243. * Releases all held ressources
  110244. */
  110245. dispose(): void;
  110246. /**
  110247. * Gets if the scene is already disposed
  110248. */
  110249. get isDisposed(): boolean;
  110250. /**
  110251. * Call this function to reduce memory footprint of the scene.
  110252. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110253. */
  110254. clearCachedVertexData(): void;
  110255. /**
  110256. * This function will remove the local cached buffer data from texture.
  110257. * It will save memory but will prevent the texture from being rebuilt
  110258. */
  110259. cleanCachedTextureBuffer(): void;
  110260. /**
  110261. * Get the world extend vectors with an optional filter
  110262. *
  110263. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110264. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110265. */
  110266. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110267. min: Vector3;
  110268. max: Vector3;
  110269. };
  110270. /**
  110271. * Creates a ray that can be used to pick in the scene
  110272. * @param x defines the x coordinate of the origin (on-screen)
  110273. * @param y defines the y coordinate of the origin (on-screen)
  110274. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110275. * @param camera defines the camera to use for the picking
  110276. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110277. * @returns a Ray
  110278. */
  110279. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110280. /**
  110281. * Creates a ray that can be used to pick in the scene
  110282. * @param x defines the x coordinate of the origin (on-screen)
  110283. * @param y defines the y coordinate of the origin (on-screen)
  110284. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110285. * @param result defines the ray where to store the picking ray
  110286. * @param camera defines the camera to use for the picking
  110287. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110288. * @returns the current scene
  110289. */
  110290. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110291. /**
  110292. * Creates a ray that can be used to pick in the scene
  110293. * @param x defines the x coordinate of the origin (on-screen)
  110294. * @param y defines the y coordinate of the origin (on-screen)
  110295. * @param camera defines the camera to use for the picking
  110296. * @returns a Ray
  110297. */
  110298. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110299. /**
  110300. * Creates a ray that can be used to pick in the scene
  110301. * @param x defines the x coordinate of the origin (on-screen)
  110302. * @param y defines the y coordinate of the origin (on-screen)
  110303. * @param result defines the ray where to store the picking ray
  110304. * @param camera defines the camera to use for the picking
  110305. * @returns the current scene
  110306. */
  110307. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110308. /** Launch a ray to try to pick a mesh in the scene
  110309. * @param x position on screen
  110310. * @param y position on screen
  110311. * @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
  110312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110313. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110314. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110315. * @returns a PickingInfo
  110316. */
  110317. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110318. /** Use the given ray to pick a mesh in the scene
  110319. * @param ray The ray to use to pick meshes
  110320. * @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
  110321. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110322. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110323. * @returns a PickingInfo
  110324. */
  110325. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110326. /**
  110327. * Launch a ray to try to pick a mesh in the scene
  110328. * @param x X position on screen
  110329. * @param y Y position on screen
  110330. * @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
  110331. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110332. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110333. * @returns an array of PickingInfo
  110334. */
  110335. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110336. /**
  110337. * Launch a ray to try to pick a mesh in the scene
  110338. * @param ray Ray to use
  110339. * @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
  110340. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110341. * @returns an array of PickingInfo
  110342. */
  110343. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110344. /**
  110345. * Force the value of meshUnderPointer
  110346. * @param mesh defines the mesh to use
  110347. */
  110348. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110349. /**
  110350. * Gets the mesh under the pointer
  110351. * @returns a Mesh or null if no mesh is under the pointer
  110352. */
  110353. getPointerOverMesh(): Nullable<AbstractMesh>;
  110354. /** @hidden */
  110355. _rebuildGeometries(): void;
  110356. /** @hidden */
  110357. _rebuildTextures(): void;
  110358. private _getByTags;
  110359. /**
  110360. * Get a list of meshes by tags
  110361. * @param tagsQuery defines the tags query to use
  110362. * @param forEach defines a predicate used to filter results
  110363. * @returns an array of Mesh
  110364. */
  110365. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110366. /**
  110367. * Get a list of cameras by tags
  110368. * @param tagsQuery defines the tags query to use
  110369. * @param forEach defines a predicate used to filter results
  110370. * @returns an array of Camera
  110371. */
  110372. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110373. /**
  110374. * Get a list of lights by tags
  110375. * @param tagsQuery defines the tags query to use
  110376. * @param forEach defines a predicate used to filter results
  110377. * @returns an array of Light
  110378. */
  110379. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110380. /**
  110381. * Get a list of materials by tags
  110382. * @param tagsQuery defines the tags query to use
  110383. * @param forEach defines a predicate used to filter results
  110384. * @returns an array of Material
  110385. */
  110386. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110387. /**
  110388. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110389. * This allowed control for front to back rendering or reversly depending of the special needs.
  110390. *
  110391. * @param renderingGroupId The rendering group id corresponding to its index
  110392. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110393. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110394. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110395. */
  110396. 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;
  110397. /**
  110398. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110399. *
  110400. * @param renderingGroupId The rendering group id corresponding to its index
  110401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110402. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110403. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110404. */
  110405. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110406. /**
  110407. * Gets the current auto clear configuration for one rendering group of the rendering
  110408. * manager.
  110409. * @param index the rendering group index to get the information for
  110410. * @returns The auto clear setup for the requested rendering group
  110411. */
  110412. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110413. private _blockMaterialDirtyMechanism;
  110414. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110415. get blockMaterialDirtyMechanism(): boolean;
  110416. set blockMaterialDirtyMechanism(value: boolean);
  110417. /**
  110418. * Will flag all materials as dirty to trigger new shader compilation
  110419. * @param flag defines the flag used to specify which material part must be marked as dirty
  110420. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110421. */
  110422. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110423. /** @hidden */
  110424. _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;
  110425. /** @hidden */
  110426. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110427. /** @hidden */
  110428. _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;
  110429. /** @hidden */
  110430. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110431. /** @hidden */
  110432. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110433. /** @hidden */
  110434. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110435. }
  110436. }
  110437. declare module BABYLON {
  110438. /**
  110439. * Set of assets to keep when moving a scene into an asset container.
  110440. */
  110441. export class KeepAssets extends AbstractScene {
  110442. }
  110443. /**
  110444. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110445. */
  110446. export class InstantiatedEntries {
  110447. /**
  110448. * List of new root nodes (eg. nodes with no parent)
  110449. */
  110450. rootNodes: TransformNode[];
  110451. /**
  110452. * List of new skeletons
  110453. */
  110454. skeletons: Skeleton[];
  110455. /**
  110456. * List of new animation groups
  110457. */
  110458. animationGroups: AnimationGroup[];
  110459. }
  110460. /**
  110461. * Container with a set of assets that can be added or removed from a scene.
  110462. */
  110463. export class AssetContainer extends AbstractScene {
  110464. private _wasAddedToScene;
  110465. /**
  110466. * The scene the AssetContainer belongs to.
  110467. */
  110468. scene: Scene;
  110469. /**
  110470. * Instantiates an AssetContainer.
  110471. * @param scene The scene the AssetContainer belongs to.
  110472. */
  110473. constructor(scene: Scene);
  110474. /**
  110475. * Instantiate or clone all meshes and add the new ones to the scene.
  110476. * Skeletons and animation groups will all be cloned
  110477. * @param nameFunction defines an optional function used to get new names for clones
  110478. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110479. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110480. */
  110481. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110482. /**
  110483. * Adds all the assets from the container to the scene.
  110484. */
  110485. addAllToScene(): void;
  110486. /**
  110487. * Removes all the assets in the container from the scene
  110488. */
  110489. removeAllFromScene(): void;
  110490. /**
  110491. * Disposes all the assets in the container
  110492. */
  110493. dispose(): void;
  110494. private _moveAssets;
  110495. /**
  110496. * Removes all the assets contained in the scene and adds them to the container.
  110497. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110498. */
  110499. moveAllFromScene(keepAssets?: KeepAssets): void;
  110500. /**
  110501. * 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.
  110502. * @returns the root mesh
  110503. */
  110504. createRootMesh(): Mesh;
  110505. /**
  110506. * Merge animations from this asset container into a scene
  110507. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110508. * @param animatables set of animatables to retarget to a node from the scene
  110509. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110510. */
  110511. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110512. }
  110513. }
  110514. declare module BABYLON {
  110515. /**
  110516. * Defines how the parser contract is defined.
  110517. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110518. */
  110519. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110520. /**
  110521. * Defines how the individual parser contract is defined.
  110522. * These parser can parse an individual asset
  110523. */
  110524. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110525. /**
  110526. * Base class of the scene acting as a container for the different elements composing a scene.
  110527. * This class is dynamically extended by the different components of the scene increasing
  110528. * flexibility and reducing coupling
  110529. */
  110530. export abstract class AbstractScene {
  110531. /**
  110532. * Stores the list of available parsers in the application.
  110533. */
  110534. private static _BabylonFileParsers;
  110535. /**
  110536. * Stores the list of available individual parsers in the application.
  110537. */
  110538. private static _IndividualBabylonFileParsers;
  110539. /**
  110540. * Adds a parser in the list of available ones
  110541. * @param name Defines the name of the parser
  110542. * @param parser Defines the parser to add
  110543. */
  110544. static AddParser(name: string, parser: BabylonFileParser): void;
  110545. /**
  110546. * Gets a general parser from the list of avaialble ones
  110547. * @param name Defines the name of the parser
  110548. * @returns the requested parser or null
  110549. */
  110550. static GetParser(name: string): Nullable<BabylonFileParser>;
  110551. /**
  110552. * Adds n individual parser in the list of available ones
  110553. * @param name Defines the name of the parser
  110554. * @param parser Defines the parser to add
  110555. */
  110556. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110557. /**
  110558. * Gets an individual parser from the list of avaialble ones
  110559. * @param name Defines the name of the parser
  110560. * @returns the requested parser or null
  110561. */
  110562. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110563. /**
  110564. * Parser json data and populate both a scene and its associated container object
  110565. * @param jsonData Defines the data to parse
  110566. * @param scene Defines the scene to parse the data for
  110567. * @param container Defines the container attached to the parsing sequence
  110568. * @param rootUrl Defines the root url of the data
  110569. */
  110570. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110571. /**
  110572. * Gets the list of root nodes (ie. nodes with no parent)
  110573. */
  110574. rootNodes: Node[];
  110575. /** All of the cameras added to this scene
  110576. * @see http://doc.babylonjs.com/babylon101/cameras
  110577. */
  110578. cameras: Camera[];
  110579. /**
  110580. * All of the lights added to this scene
  110581. * @see http://doc.babylonjs.com/babylon101/lights
  110582. */
  110583. lights: Light[];
  110584. /**
  110585. * All of the (abstract) meshes added to this scene
  110586. */
  110587. meshes: AbstractMesh[];
  110588. /**
  110589. * The list of skeletons added to the scene
  110590. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110591. */
  110592. skeletons: Skeleton[];
  110593. /**
  110594. * All of the particle systems added to this scene
  110595. * @see http://doc.babylonjs.com/babylon101/particles
  110596. */
  110597. particleSystems: IParticleSystem[];
  110598. /**
  110599. * Gets a list of Animations associated with the scene
  110600. */
  110601. animations: Animation[];
  110602. /**
  110603. * All of the animation groups added to this scene
  110604. * @see http://doc.babylonjs.com/how_to/group
  110605. */
  110606. animationGroups: AnimationGroup[];
  110607. /**
  110608. * All of the multi-materials added to this scene
  110609. * @see http://doc.babylonjs.com/how_to/multi_materials
  110610. */
  110611. multiMaterials: MultiMaterial[];
  110612. /**
  110613. * All of the materials added to this scene
  110614. * In the context of a Scene, it is not supposed to be modified manually.
  110615. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110616. * Note also that the order of the Material within the array is not significant and might change.
  110617. * @see http://doc.babylonjs.com/babylon101/materials
  110618. */
  110619. materials: Material[];
  110620. /**
  110621. * The list of morph target managers added to the scene
  110622. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110623. */
  110624. morphTargetManagers: MorphTargetManager[];
  110625. /**
  110626. * The list of geometries used in the scene.
  110627. */
  110628. geometries: Geometry[];
  110629. /**
  110630. * All of the tranform nodes added to this scene
  110631. * In the context of a Scene, it is not supposed to be modified manually.
  110632. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110633. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110634. * @see http://doc.babylonjs.com/how_to/transformnode
  110635. */
  110636. transformNodes: TransformNode[];
  110637. /**
  110638. * ActionManagers available on the scene.
  110639. */
  110640. actionManagers: AbstractActionManager[];
  110641. /**
  110642. * Textures to keep.
  110643. */
  110644. textures: BaseTexture[];
  110645. /**
  110646. * Environment texture for the scene
  110647. */
  110648. environmentTexture: Nullable<BaseTexture>;
  110649. /**
  110650. * @returns all meshes, lights, cameras, transformNodes and bones
  110651. */
  110652. getNodes(): Array<Node>;
  110653. }
  110654. }
  110655. declare module BABYLON {
  110656. /**
  110657. * Interface used to define options for Sound class
  110658. */
  110659. export interface ISoundOptions {
  110660. /**
  110661. * Does the sound autoplay once loaded.
  110662. */
  110663. autoplay?: boolean;
  110664. /**
  110665. * Does the sound loop after it finishes playing once.
  110666. */
  110667. loop?: boolean;
  110668. /**
  110669. * Sound's volume
  110670. */
  110671. volume?: number;
  110672. /**
  110673. * Is it a spatial sound?
  110674. */
  110675. spatialSound?: boolean;
  110676. /**
  110677. * Maximum distance to hear that sound
  110678. */
  110679. maxDistance?: number;
  110680. /**
  110681. * Uses user defined attenuation function
  110682. */
  110683. useCustomAttenuation?: boolean;
  110684. /**
  110685. * Define the roll off factor of spatial sounds.
  110686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110687. */
  110688. rolloffFactor?: number;
  110689. /**
  110690. * Define the reference distance the sound should be heard perfectly.
  110691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110692. */
  110693. refDistance?: number;
  110694. /**
  110695. * Define the distance attenuation model the sound will follow.
  110696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110697. */
  110698. distanceModel?: string;
  110699. /**
  110700. * Defines the playback speed (1 by default)
  110701. */
  110702. playbackRate?: number;
  110703. /**
  110704. * Defines if the sound is from a streaming source
  110705. */
  110706. streaming?: boolean;
  110707. /**
  110708. * Defines an optional length (in seconds) inside the sound file
  110709. */
  110710. length?: number;
  110711. /**
  110712. * Defines an optional offset (in seconds) inside the sound file
  110713. */
  110714. offset?: number;
  110715. /**
  110716. * If true, URLs will not be required to state the audio file codec to use.
  110717. */
  110718. skipCodecCheck?: boolean;
  110719. }
  110720. /**
  110721. * Defines a sound that can be played in the application.
  110722. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110724. */
  110725. export class Sound {
  110726. /**
  110727. * The name of the sound in the scene.
  110728. */
  110729. name: string;
  110730. /**
  110731. * Does the sound autoplay once loaded.
  110732. */
  110733. autoplay: boolean;
  110734. /**
  110735. * Does the sound loop after it finishes playing once.
  110736. */
  110737. loop: boolean;
  110738. /**
  110739. * Does the sound use a custom attenuation curve to simulate the falloff
  110740. * happening when the source gets further away from the camera.
  110741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110742. */
  110743. useCustomAttenuation: boolean;
  110744. /**
  110745. * The sound track id this sound belongs to.
  110746. */
  110747. soundTrackId: number;
  110748. /**
  110749. * Is this sound currently played.
  110750. */
  110751. isPlaying: boolean;
  110752. /**
  110753. * Is this sound currently paused.
  110754. */
  110755. isPaused: boolean;
  110756. /**
  110757. * Does this sound enables spatial sound.
  110758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110759. */
  110760. spatialSound: boolean;
  110761. /**
  110762. * Define the reference distance the sound should be heard perfectly.
  110763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110764. */
  110765. refDistance: number;
  110766. /**
  110767. * Define the roll off factor of spatial sounds.
  110768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110769. */
  110770. rolloffFactor: number;
  110771. /**
  110772. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110774. */
  110775. maxDistance: number;
  110776. /**
  110777. * Define the distance attenuation model the sound will follow.
  110778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110779. */
  110780. distanceModel: string;
  110781. /**
  110782. * @hidden
  110783. * Back Compat
  110784. **/
  110785. onended: () => any;
  110786. /**
  110787. * Observable event when the current playing sound finishes.
  110788. */
  110789. onEndedObservable: Observable<Sound>;
  110790. private _panningModel;
  110791. private _playbackRate;
  110792. private _streaming;
  110793. private _startTime;
  110794. private _startOffset;
  110795. private _position;
  110796. /** @hidden */
  110797. _positionInEmitterSpace: boolean;
  110798. private _localDirection;
  110799. private _volume;
  110800. private _isReadyToPlay;
  110801. private _isDirectional;
  110802. private _readyToPlayCallback;
  110803. private _audioBuffer;
  110804. private _soundSource;
  110805. private _streamingSource;
  110806. private _soundPanner;
  110807. private _soundGain;
  110808. private _inputAudioNode;
  110809. private _outputAudioNode;
  110810. private _coneInnerAngle;
  110811. private _coneOuterAngle;
  110812. private _coneOuterGain;
  110813. private _scene;
  110814. private _connectedTransformNode;
  110815. private _customAttenuationFunction;
  110816. private _registerFunc;
  110817. private _isOutputConnected;
  110818. private _htmlAudioElement;
  110819. private _urlType;
  110820. private _length?;
  110821. private _offset?;
  110822. /** @hidden */
  110823. static _SceneComponentInitialization: (scene: Scene) => void;
  110824. /**
  110825. * Create a sound and attach it to a scene
  110826. * @param name Name of your sound
  110827. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110828. * @param scene defines the scene the sound belongs to
  110829. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110830. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110831. */
  110832. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110833. /**
  110834. * Release the sound and its associated resources
  110835. */
  110836. dispose(): void;
  110837. /**
  110838. * Gets if the sounds is ready to be played or not.
  110839. * @returns true if ready, otherwise false
  110840. */
  110841. isReady(): boolean;
  110842. private _soundLoaded;
  110843. /**
  110844. * Sets the data of the sound from an audiobuffer
  110845. * @param audioBuffer The audioBuffer containing the data
  110846. */
  110847. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110848. /**
  110849. * Updates the current sounds options such as maxdistance, loop...
  110850. * @param options A JSON object containing values named as the object properties
  110851. */
  110852. updateOptions(options: ISoundOptions): void;
  110853. private _createSpatialParameters;
  110854. private _updateSpatialParameters;
  110855. /**
  110856. * Switch the panning model to HRTF:
  110857. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110859. */
  110860. switchPanningModelToHRTF(): void;
  110861. /**
  110862. * Switch the panning model to Equal Power:
  110863. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110865. */
  110866. switchPanningModelToEqualPower(): void;
  110867. private _switchPanningModel;
  110868. /**
  110869. * Connect this sound to a sound track audio node like gain...
  110870. * @param soundTrackAudioNode the sound track audio node to connect to
  110871. */
  110872. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110873. /**
  110874. * Transform this sound into a directional source
  110875. * @param coneInnerAngle Size of the inner cone in degree
  110876. * @param coneOuterAngle Size of the outer cone in degree
  110877. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110878. */
  110879. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110880. /**
  110881. * Gets or sets the inner angle for the directional cone.
  110882. */
  110883. get directionalConeInnerAngle(): number;
  110884. /**
  110885. * Gets or sets the inner angle for the directional cone.
  110886. */
  110887. set directionalConeInnerAngle(value: number);
  110888. /**
  110889. * Gets or sets the outer angle for the directional cone.
  110890. */
  110891. get directionalConeOuterAngle(): number;
  110892. /**
  110893. * Gets or sets the outer angle for the directional cone.
  110894. */
  110895. set directionalConeOuterAngle(value: number);
  110896. /**
  110897. * Sets the position of the emitter if spatial sound is enabled
  110898. * @param newPosition Defines the new posisiton
  110899. */
  110900. setPosition(newPosition: Vector3): void;
  110901. /**
  110902. * Sets the local direction of the emitter if spatial sound is enabled
  110903. * @param newLocalDirection Defines the new local direction
  110904. */
  110905. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110906. private _updateDirection;
  110907. /** @hidden */
  110908. updateDistanceFromListener(): void;
  110909. /**
  110910. * Sets a new custom attenuation function for the sound.
  110911. * @param callback Defines the function used for the attenuation
  110912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110913. */
  110914. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110915. /**
  110916. * Play the sound
  110917. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110918. * @param offset (optional) Start the sound at a specific time in seconds
  110919. * @param length (optional) Sound duration (in seconds)
  110920. */
  110921. play(time?: number, offset?: number, length?: number): void;
  110922. private _onended;
  110923. /**
  110924. * Stop the sound
  110925. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110926. */
  110927. stop(time?: number): void;
  110928. /**
  110929. * Put the sound in pause
  110930. */
  110931. pause(): void;
  110932. /**
  110933. * Sets a dedicated volume for this sounds
  110934. * @param newVolume Define the new volume of the sound
  110935. * @param time Define time for gradual change to new volume
  110936. */
  110937. setVolume(newVolume: number, time?: number): void;
  110938. /**
  110939. * Set the sound play back rate
  110940. * @param newPlaybackRate Define the playback rate the sound should be played at
  110941. */
  110942. setPlaybackRate(newPlaybackRate: number): void;
  110943. /**
  110944. * Gets the volume of the sound.
  110945. * @returns the volume of the sound
  110946. */
  110947. getVolume(): number;
  110948. /**
  110949. * Attach the sound to a dedicated mesh
  110950. * @param transformNode The transform node to connect the sound with
  110951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110952. */
  110953. attachToMesh(transformNode: TransformNode): void;
  110954. /**
  110955. * Detach the sound from the previously attached mesh
  110956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110957. */
  110958. detachFromMesh(): void;
  110959. private _onRegisterAfterWorldMatrixUpdate;
  110960. /**
  110961. * Clone the current sound in the scene.
  110962. * @returns the new sound clone
  110963. */
  110964. clone(): Nullable<Sound>;
  110965. /**
  110966. * Gets the current underlying audio buffer containing the data
  110967. * @returns the audio buffer
  110968. */
  110969. getAudioBuffer(): Nullable<AudioBuffer>;
  110970. /**
  110971. * Serializes the Sound in a JSON representation
  110972. * @returns the JSON representation of the sound
  110973. */
  110974. serialize(): any;
  110975. /**
  110976. * Parse a JSON representation of a sound to innstantiate in a given scene
  110977. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110978. * @param scene Define the scene the new parsed sound should be created in
  110979. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110980. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110981. * @returns the newly parsed sound
  110982. */
  110983. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110984. }
  110985. }
  110986. declare module BABYLON {
  110987. /**
  110988. * This defines an action helpful to play a defined sound on a triggered action.
  110989. */
  110990. export class PlaySoundAction extends Action {
  110991. private _sound;
  110992. /**
  110993. * Instantiate the action
  110994. * @param triggerOptions defines the trigger options
  110995. * @param sound defines the sound to play
  110996. * @param condition defines the trigger related conditions
  110997. */
  110998. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110999. /** @hidden */
  111000. _prepare(): void;
  111001. /**
  111002. * Execute the action and play the sound.
  111003. */
  111004. execute(): void;
  111005. /**
  111006. * Serializes the actions and its related information.
  111007. * @param parent defines the object to serialize in
  111008. * @returns the serialized object
  111009. */
  111010. serialize(parent: any): any;
  111011. }
  111012. /**
  111013. * This defines an action helpful to stop a defined sound on a triggered action.
  111014. */
  111015. export class StopSoundAction extends Action {
  111016. private _sound;
  111017. /**
  111018. * Instantiate the action
  111019. * @param triggerOptions defines the trigger options
  111020. * @param sound defines the sound to stop
  111021. * @param condition defines the trigger related conditions
  111022. */
  111023. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111024. /** @hidden */
  111025. _prepare(): void;
  111026. /**
  111027. * Execute the action and stop the sound.
  111028. */
  111029. execute(): void;
  111030. /**
  111031. * Serializes the actions and its related information.
  111032. * @param parent defines the object to serialize in
  111033. * @returns the serialized object
  111034. */
  111035. serialize(parent: any): any;
  111036. }
  111037. }
  111038. declare module BABYLON {
  111039. /**
  111040. * This defines an action responsible to change the value of a property
  111041. * by interpolating between its current value and the newly set one once triggered.
  111042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  111043. */
  111044. export class InterpolateValueAction extends Action {
  111045. /**
  111046. * Defines the path of the property where the value should be interpolated
  111047. */
  111048. propertyPath: string;
  111049. /**
  111050. * Defines the target value at the end of the interpolation.
  111051. */
  111052. value: any;
  111053. /**
  111054. * Defines the time it will take for the property to interpolate to the value.
  111055. */
  111056. duration: number;
  111057. /**
  111058. * Defines if the other scene animations should be stopped when the action has been triggered
  111059. */
  111060. stopOtherAnimations?: boolean;
  111061. /**
  111062. * Defines a callback raised once the interpolation animation has been done.
  111063. */
  111064. onInterpolationDone?: () => void;
  111065. /**
  111066. * Observable triggered once the interpolation animation has been done.
  111067. */
  111068. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  111069. private _target;
  111070. private _effectiveTarget;
  111071. private _property;
  111072. /**
  111073. * Instantiate the action
  111074. * @param triggerOptions defines the trigger options
  111075. * @param target defines the object containing the value to interpolate
  111076. * @param propertyPath defines the path to the property in the target object
  111077. * @param value defines the target value at the end of the interpolation
  111078. * @param duration deines the time it will take for the property to interpolate to the value.
  111079. * @param condition defines the trigger related conditions
  111080. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  111081. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  111082. */
  111083. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  111084. /** @hidden */
  111085. _prepare(): void;
  111086. /**
  111087. * Execute the action starts the value interpolation.
  111088. */
  111089. execute(): void;
  111090. /**
  111091. * Serializes the actions and its related information.
  111092. * @param parent defines the object to serialize in
  111093. * @returns the serialized object
  111094. */
  111095. serialize(parent: any): any;
  111096. }
  111097. }
  111098. declare module BABYLON {
  111099. /**
  111100. * Options allowed during the creation of a sound track.
  111101. */
  111102. export interface ISoundTrackOptions {
  111103. /**
  111104. * The volume the sound track should take during creation
  111105. */
  111106. volume?: number;
  111107. /**
  111108. * Define if the sound track is the main sound track of the scene
  111109. */
  111110. mainTrack?: boolean;
  111111. }
  111112. /**
  111113. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  111114. * It will be also used in a future release to apply effects on a specific track.
  111115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111116. */
  111117. export class SoundTrack {
  111118. /**
  111119. * The unique identifier of the sound track in the scene.
  111120. */
  111121. id: number;
  111122. /**
  111123. * The list of sounds included in the sound track.
  111124. */
  111125. soundCollection: Array<Sound>;
  111126. private _outputAudioNode;
  111127. private _scene;
  111128. private _connectedAnalyser;
  111129. private _options;
  111130. private _isInitialized;
  111131. /**
  111132. * Creates a new sound track.
  111133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111134. * @param scene Define the scene the sound track belongs to
  111135. * @param options
  111136. */
  111137. constructor(scene: Scene, options?: ISoundTrackOptions);
  111138. private _initializeSoundTrackAudioGraph;
  111139. /**
  111140. * Release the sound track and its associated resources
  111141. */
  111142. dispose(): void;
  111143. /**
  111144. * Adds a sound to this sound track
  111145. * @param sound define the cound to add
  111146. * @ignoreNaming
  111147. */
  111148. AddSound(sound: Sound): void;
  111149. /**
  111150. * Removes a sound to this sound track
  111151. * @param sound define the cound to remove
  111152. * @ignoreNaming
  111153. */
  111154. RemoveSound(sound: Sound): void;
  111155. /**
  111156. * Set a global volume for the full sound track.
  111157. * @param newVolume Define the new volume of the sound track
  111158. */
  111159. setVolume(newVolume: number): void;
  111160. /**
  111161. * Switch the panning model to HRTF:
  111162. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111164. */
  111165. switchPanningModelToHRTF(): void;
  111166. /**
  111167. * Switch the panning model to Equal Power:
  111168. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111170. */
  111171. switchPanningModelToEqualPower(): void;
  111172. /**
  111173. * Connect the sound track to an audio analyser allowing some amazing
  111174. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111176. * @param analyser The analyser to connect to the engine
  111177. */
  111178. connectToAnalyser(analyser: Analyser): void;
  111179. }
  111180. }
  111181. declare module BABYLON {
  111182. interface AbstractScene {
  111183. /**
  111184. * The list of sounds used in the scene.
  111185. */
  111186. sounds: Nullable<Array<Sound>>;
  111187. }
  111188. interface Scene {
  111189. /**
  111190. * @hidden
  111191. * Backing field
  111192. */
  111193. _mainSoundTrack: SoundTrack;
  111194. /**
  111195. * The main sound track played by the scene.
  111196. * It cotains your primary collection of sounds.
  111197. */
  111198. mainSoundTrack: SoundTrack;
  111199. /**
  111200. * The list of sound tracks added to the scene
  111201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111202. */
  111203. soundTracks: Nullable<Array<SoundTrack>>;
  111204. /**
  111205. * Gets a sound using a given name
  111206. * @param name defines the name to search for
  111207. * @return the found sound or null if not found at all.
  111208. */
  111209. getSoundByName(name: string): Nullable<Sound>;
  111210. /**
  111211. * Gets or sets if audio support is enabled
  111212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111213. */
  111214. audioEnabled: boolean;
  111215. /**
  111216. * Gets or sets if audio will be output to headphones
  111217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111218. */
  111219. headphone: boolean;
  111220. /**
  111221. * Gets or sets custom audio listener position provider
  111222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111223. */
  111224. audioListenerPositionProvider: Nullable<() => Vector3>;
  111225. /**
  111226. * Gets or sets a refresh rate when using 3D audio positioning
  111227. */
  111228. audioPositioningRefreshRate: number;
  111229. }
  111230. /**
  111231. * Defines the sound scene component responsible to manage any sounds
  111232. * in a given scene.
  111233. */
  111234. export class AudioSceneComponent implements ISceneSerializableComponent {
  111235. /**
  111236. * The component name helpfull to identify the component in the list of scene components.
  111237. */
  111238. readonly name: string;
  111239. /**
  111240. * The scene the component belongs to.
  111241. */
  111242. scene: Scene;
  111243. private _audioEnabled;
  111244. /**
  111245. * Gets whether audio is enabled or not.
  111246. * Please use related enable/disable method to switch state.
  111247. */
  111248. get audioEnabled(): boolean;
  111249. private _headphone;
  111250. /**
  111251. * Gets whether audio is outputing to headphone or not.
  111252. * Please use the according Switch methods to change output.
  111253. */
  111254. get headphone(): boolean;
  111255. /**
  111256. * Gets or sets a refresh rate when using 3D audio positioning
  111257. */
  111258. audioPositioningRefreshRate: number;
  111259. private _audioListenerPositionProvider;
  111260. /**
  111261. * Gets the current audio listener position provider
  111262. */
  111263. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111264. /**
  111265. * Sets a custom listener position for all sounds in the scene
  111266. * By default, this is the position of the first active camera
  111267. */
  111268. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111269. /**
  111270. * Creates a new instance of the component for the given scene
  111271. * @param scene Defines the scene to register the component in
  111272. */
  111273. constructor(scene: Scene);
  111274. /**
  111275. * Registers the component in a given scene
  111276. */
  111277. register(): void;
  111278. /**
  111279. * Rebuilds the elements related to this component in case of
  111280. * context lost for instance.
  111281. */
  111282. rebuild(): void;
  111283. /**
  111284. * Serializes the component data to the specified json object
  111285. * @param serializationObject The object to serialize to
  111286. */
  111287. serialize(serializationObject: any): void;
  111288. /**
  111289. * Adds all the elements from the container to the scene
  111290. * @param container the container holding the elements
  111291. */
  111292. addFromContainer(container: AbstractScene): void;
  111293. /**
  111294. * Removes all the elements in the container from the scene
  111295. * @param container contains the elements to remove
  111296. * @param dispose if the removed element should be disposed (default: false)
  111297. */
  111298. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111299. /**
  111300. * Disposes the component and the associated ressources.
  111301. */
  111302. dispose(): void;
  111303. /**
  111304. * Disables audio in the associated scene.
  111305. */
  111306. disableAudio(): void;
  111307. /**
  111308. * Enables audio in the associated scene.
  111309. */
  111310. enableAudio(): void;
  111311. /**
  111312. * Switch audio to headphone output.
  111313. */
  111314. switchAudioModeForHeadphones(): void;
  111315. /**
  111316. * Switch audio to normal speakers.
  111317. */
  111318. switchAudioModeForNormalSpeakers(): void;
  111319. private _cachedCameraDirection;
  111320. private _cachedCameraPosition;
  111321. private _lastCheck;
  111322. private _afterRender;
  111323. }
  111324. }
  111325. declare module BABYLON {
  111326. /**
  111327. * Wraps one or more Sound objects and selects one with random weight for playback.
  111328. */
  111329. export class WeightedSound {
  111330. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111331. loop: boolean;
  111332. private _coneInnerAngle;
  111333. private _coneOuterAngle;
  111334. private _volume;
  111335. /** A Sound is currently playing. */
  111336. isPlaying: boolean;
  111337. /** A Sound is currently paused. */
  111338. isPaused: boolean;
  111339. private _sounds;
  111340. private _weights;
  111341. private _currentIndex?;
  111342. /**
  111343. * Creates a new WeightedSound from the list of sounds given.
  111344. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111345. * @param sounds Array of Sounds that will be selected from.
  111346. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111347. */
  111348. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111349. /**
  111350. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111351. */
  111352. get directionalConeInnerAngle(): number;
  111353. /**
  111354. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111355. */
  111356. set directionalConeInnerAngle(value: number);
  111357. /**
  111358. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111359. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111360. */
  111361. get directionalConeOuterAngle(): number;
  111362. /**
  111363. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111364. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111365. */
  111366. set directionalConeOuterAngle(value: number);
  111367. /**
  111368. * Playback volume.
  111369. */
  111370. get volume(): number;
  111371. /**
  111372. * Playback volume.
  111373. */
  111374. set volume(value: number);
  111375. private _onended;
  111376. /**
  111377. * Suspend playback
  111378. */
  111379. pause(): void;
  111380. /**
  111381. * Stop playback
  111382. */
  111383. stop(): void;
  111384. /**
  111385. * Start playback.
  111386. * @param startOffset Position the clip head at a specific time in seconds.
  111387. */
  111388. play(startOffset?: number): void;
  111389. }
  111390. }
  111391. declare module BABYLON {
  111392. /**
  111393. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111394. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111395. */
  111396. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111397. /**
  111398. * Gets the name of the behavior.
  111399. */
  111400. get name(): string;
  111401. /**
  111402. * The easing function used by animations
  111403. */
  111404. static EasingFunction: BackEase;
  111405. /**
  111406. * The easing mode used by animations
  111407. */
  111408. static EasingMode: number;
  111409. /**
  111410. * The duration of the animation, in milliseconds
  111411. */
  111412. transitionDuration: number;
  111413. /**
  111414. * Length of the distance animated by the transition when lower radius is reached
  111415. */
  111416. lowerRadiusTransitionRange: number;
  111417. /**
  111418. * Length of the distance animated by the transition when upper radius is reached
  111419. */
  111420. upperRadiusTransitionRange: number;
  111421. private _autoTransitionRange;
  111422. /**
  111423. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111424. */
  111425. get autoTransitionRange(): boolean;
  111426. /**
  111427. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111428. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111429. */
  111430. set autoTransitionRange(value: boolean);
  111431. private _attachedCamera;
  111432. private _onAfterCheckInputsObserver;
  111433. private _onMeshTargetChangedObserver;
  111434. /**
  111435. * Initializes the behavior.
  111436. */
  111437. init(): void;
  111438. /**
  111439. * Attaches the behavior to its arc rotate camera.
  111440. * @param camera Defines the camera to attach the behavior to
  111441. */
  111442. attach(camera: ArcRotateCamera): void;
  111443. /**
  111444. * Detaches the behavior from its current arc rotate camera.
  111445. */
  111446. detach(): void;
  111447. private _radiusIsAnimating;
  111448. private _radiusBounceTransition;
  111449. private _animatables;
  111450. private _cachedWheelPrecision;
  111451. /**
  111452. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111453. * @param radiusLimit The limit to check against.
  111454. * @return Bool to indicate if at limit.
  111455. */
  111456. private _isRadiusAtLimit;
  111457. /**
  111458. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111459. * @param radiusDelta The delta by which to animate to. Can be negative.
  111460. */
  111461. private _applyBoundRadiusAnimation;
  111462. /**
  111463. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111464. */
  111465. protected _clearAnimationLocks(): void;
  111466. /**
  111467. * Stops and removes all animations that have been applied to the camera
  111468. */
  111469. stopAllAnimations(): void;
  111470. }
  111471. }
  111472. declare module BABYLON {
  111473. /**
  111474. * 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.
  111475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111476. */
  111477. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111478. /**
  111479. * Gets the name of the behavior.
  111480. */
  111481. get name(): string;
  111482. private _mode;
  111483. private _radiusScale;
  111484. private _positionScale;
  111485. private _defaultElevation;
  111486. private _elevationReturnTime;
  111487. private _elevationReturnWaitTime;
  111488. private _zoomStopsAnimation;
  111489. private _framingTime;
  111490. /**
  111491. * The easing function used by animations
  111492. */
  111493. static EasingFunction: ExponentialEase;
  111494. /**
  111495. * The easing mode used by animations
  111496. */
  111497. static EasingMode: number;
  111498. /**
  111499. * Sets the current mode used by the behavior
  111500. */
  111501. set mode(mode: number);
  111502. /**
  111503. * Gets current mode used by the behavior.
  111504. */
  111505. get mode(): number;
  111506. /**
  111507. * Sets the scale applied to the radius (1 by default)
  111508. */
  111509. set radiusScale(radius: number);
  111510. /**
  111511. * Gets the scale applied to the radius
  111512. */
  111513. get radiusScale(): number;
  111514. /**
  111515. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111516. */
  111517. set positionScale(scale: number);
  111518. /**
  111519. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111520. */
  111521. get positionScale(): number;
  111522. /**
  111523. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111524. * behaviour is triggered, in radians.
  111525. */
  111526. set defaultElevation(elevation: number);
  111527. /**
  111528. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111529. * behaviour is triggered, in radians.
  111530. */
  111531. get defaultElevation(): number;
  111532. /**
  111533. * Sets the time (in milliseconds) taken to return to the default beta position.
  111534. * Negative value indicates camera should not return to default.
  111535. */
  111536. set elevationReturnTime(speed: number);
  111537. /**
  111538. * Gets the time (in milliseconds) taken to return to the default beta position.
  111539. * Negative value indicates camera should not return to default.
  111540. */
  111541. get elevationReturnTime(): number;
  111542. /**
  111543. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111544. */
  111545. set elevationReturnWaitTime(time: number);
  111546. /**
  111547. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111548. */
  111549. get elevationReturnWaitTime(): number;
  111550. /**
  111551. * Sets the flag that indicates if user zooming should stop animation.
  111552. */
  111553. set zoomStopsAnimation(flag: boolean);
  111554. /**
  111555. * Gets the flag that indicates if user zooming should stop animation.
  111556. */
  111557. get zoomStopsAnimation(): boolean;
  111558. /**
  111559. * Sets the transition time when framing the mesh, in milliseconds
  111560. */
  111561. set framingTime(time: number);
  111562. /**
  111563. * Gets the transition time when framing the mesh, in milliseconds
  111564. */
  111565. get framingTime(): number;
  111566. /**
  111567. * Define if the behavior should automatically change the configured
  111568. * camera limits and sensibilities.
  111569. */
  111570. autoCorrectCameraLimitsAndSensibility: boolean;
  111571. private _onPrePointerObservableObserver;
  111572. private _onAfterCheckInputsObserver;
  111573. private _onMeshTargetChangedObserver;
  111574. private _attachedCamera;
  111575. private _isPointerDown;
  111576. private _lastInteractionTime;
  111577. /**
  111578. * Initializes the behavior.
  111579. */
  111580. init(): void;
  111581. /**
  111582. * Attaches the behavior to its arc rotate camera.
  111583. * @param camera Defines the camera to attach the behavior to
  111584. */
  111585. attach(camera: ArcRotateCamera): void;
  111586. /**
  111587. * Detaches the behavior from its current arc rotate camera.
  111588. */
  111589. detach(): void;
  111590. private _animatables;
  111591. private _betaIsAnimating;
  111592. private _betaTransition;
  111593. private _radiusTransition;
  111594. private _vectorTransition;
  111595. /**
  111596. * Targets the given mesh and updates zoom level accordingly.
  111597. * @param mesh The mesh to target.
  111598. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111599. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111600. */
  111601. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111602. /**
  111603. * Targets the given mesh with its children and updates zoom level accordingly.
  111604. * @param mesh The mesh to target.
  111605. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111606. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111607. */
  111608. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111609. /**
  111610. * Targets the given meshes with their children and updates zoom level accordingly.
  111611. * @param meshes The mesh to target.
  111612. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111613. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111614. */
  111615. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111616. /**
  111617. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111618. * @param minimumWorld Determines the smaller position of the bounding box extend
  111619. * @param maximumWorld Determines the bigger position of the bounding box extend
  111620. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111621. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111622. */
  111623. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111624. /**
  111625. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111626. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111627. * frustum width.
  111628. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111629. * to fully enclose the mesh in the viewing frustum.
  111630. */
  111631. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111632. /**
  111633. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111634. * is automatically returned to its default position (expected to be above ground plane).
  111635. */
  111636. private _maintainCameraAboveGround;
  111637. /**
  111638. * Returns the frustum slope based on the canvas ratio and camera FOV
  111639. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111640. */
  111641. private _getFrustumSlope;
  111642. /**
  111643. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111644. */
  111645. private _clearAnimationLocks;
  111646. /**
  111647. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111648. */
  111649. private _applyUserInteraction;
  111650. /**
  111651. * Stops and removes all animations that have been applied to the camera
  111652. */
  111653. stopAllAnimations(): void;
  111654. /**
  111655. * Gets a value indicating if the user is moving the camera
  111656. */
  111657. get isUserIsMoving(): boolean;
  111658. /**
  111659. * The camera can move all the way towards the mesh.
  111660. */
  111661. static IgnoreBoundsSizeMode: number;
  111662. /**
  111663. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111664. */
  111665. static FitFrustumSidesMode: number;
  111666. }
  111667. }
  111668. declare module BABYLON {
  111669. /**
  111670. * Base class for Camera Pointer Inputs.
  111671. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111672. * for example usage.
  111673. */
  111674. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111675. /**
  111676. * Defines the camera the input is attached to.
  111677. */
  111678. abstract camera: Camera;
  111679. /**
  111680. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111681. */
  111682. protected _altKey: boolean;
  111683. protected _ctrlKey: boolean;
  111684. protected _metaKey: boolean;
  111685. protected _shiftKey: boolean;
  111686. /**
  111687. * Which mouse buttons were pressed at time of last mouse event.
  111688. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111689. */
  111690. protected _buttonsPressed: number;
  111691. /**
  111692. * Defines the buttons associated with the input to handle camera move.
  111693. */
  111694. buttons: number[];
  111695. /**
  111696. * Attach the input controls to a specific dom element to get the input from.
  111697. * @param element Defines the element the controls should be listened from
  111698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111699. */
  111700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111701. /**
  111702. * Detach the current controls from the specified dom element.
  111703. * @param element Defines the element to stop listening the inputs from
  111704. */
  111705. detachControl(element: Nullable<HTMLElement>): void;
  111706. /**
  111707. * Gets the class name of the current input.
  111708. * @returns the class name
  111709. */
  111710. getClassName(): string;
  111711. /**
  111712. * Get the friendly name associated with the input class.
  111713. * @returns the input friendly name
  111714. */
  111715. getSimpleName(): string;
  111716. /**
  111717. * Called on pointer POINTERDOUBLETAP event.
  111718. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111719. */
  111720. protected onDoubleTap(type: string): void;
  111721. /**
  111722. * Called on pointer POINTERMOVE event if only a single touch is active.
  111723. * Override this method to provide functionality.
  111724. */
  111725. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111726. /**
  111727. * Called on pointer POINTERMOVE event if multiple touches are active.
  111728. * Override this method to provide functionality.
  111729. */
  111730. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111731. /**
  111732. * Called on JS contextmenu event.
  111733. * Override this method to provide functionality.
  111734. */
  111735. protected onContextMenu(evt: PointerEvent): void;
  111736. /**
  111737. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111738. * press.
  111739. * Override this method to provide functionality.
  111740. */
  111741. protected onButtonDown(evt: PointerEvent): void;
  111742. /**
  111743. * Called each time a new POINTERUP event occurs. Ie, for each button
  111744. * release.
  111745. * Override this method to provide functionality.
  111746. */
  111747. protected onButtonUp(evt: PointerEvent): void;
  111748. /**
  111749. * Called when window becomes inactive.
  111750. * Override this method to provide functionality.
  111751. */
  111752. protected onLostFocus(): void;
  111753. private _pointerInput;
  111754. private _observer;
  111755. private _onLostFocus;
  111756. private pointA;
  111757. private pointB;
  111758. }
  111759. }
  111760. declare module BABYLON {
  111761. /**
  111762. * Manage the pointers inputs to control an arc rotate camera.
  111763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111764. */
  111765. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111766. /**
  111767. * Defines the camera the input is attached to.
  111768. */
  111769. camera: ArcRotateCamera;
  111770. /**
  111771. * Gets the class name of the current input.
  111772. * @returns the class name
  111773. */
  111774. getClassName(): string;
  111775. /**
  111776. * Defines the buttons associated with the input to handle camera move.
  111777. */
  111778. buttons: number[];
  111779. /**
  111780. * Defines the pointer angular sensibility along the X axis or how fast is
  111781. * the camera rotating.
  111782. */
  111783. angularSensibilityX: number;
  111784. /**
  111785. * Defines the pointer angular sensibility along the Y axis or how fast is
  111786. * the camera rotating.
  111787. */
  111788. angularSensibilityY: number;
  111789. /**
  111790. * Defines the pointer pinch precision or how fast is the camera zooming.
  111791. */
  111792. pinchPrecision: number;
  111793. /**
  111794. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111795. * from 0.
  111796. * It defines the percentage of current camera.radius to use as delta when
  111797. * pinch zoom is used.
  111798. */
  111799. pinchDeltaPercentage: number;
  111800. /**
  111801. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111802. * that any object in the plane at the camera's target point will scale
  111803. * perfectly with finger motion.
  111804. * Overrides pinchDeltaPercentage and pinchPrecision.
  111805. */
  111806. useNaturalPinchZoom: boolean;
  111807. /**
  111808. * Defines the pointer panning sensibility or how fast is the camera moving.
  111809. */
  111810. panningSensibility: number;
  111811. /**
  111812. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111813. */
  111814. multiTouchPanning: boolean;
  111815. /**
  111816. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111817. * zoom (pinch) through multitouch.
  111818. */
  111819. multiTouchPanAndZoom: boolean;
  111820. /**
  111821. * Revers pinch action direction.
  111822. */
  111823. pinchInwards: boolean;
  111824. private _isPanClick;
  111825. private _twoFingerActivityCount;
  111826. private _isPinching;
  111827. /**
  111828. * Called on pointer POINTERMOVE event if only a single touch is active.
  111829. */
  111830. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111831. /**
  111832. * Called on pointer POINTERDOUBLETAP event.
  111833. */
  111834. protected onDoubleTap(type: string): void;
  111835. /**
  111836. * Called on pointer POINTERMOVE event if multiple touches are active.
  111837. */
  111838. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111839. /**
  111840. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111841. * press.
  111842. */
  111843. protected onButtonDown(evt: PointerEvent): void;
  111844. /**
  111845. * Called each time a new POINTERUP event occurs. Ie, for each button
  111846. * release.
  111847. */
  111848. protected onButtonUp(evt: PointerEvent): void;
  111849. /**
  111850. * Called when window becomes inactive.
  111851. */
  111852. protected onLostFocus(): void;
  111853. }
  111854. }
  111855. declare module BABYLON {
  111856. /**
  111857. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111859. */
  111860. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111861. /**
  111862. * Defines the camera the input is attached to.
  111863. */
  111864. camera: ArcRotateCamera;
  111865. /**
  111866. * Defines the list of key codes associated with the up action (increase alpha)
  111867. */
  111868. keysUp: number[];
  111869. /**
  111870. * Defines the list of key codes associated with the down action (decrease alpha)
  111871. */
  111872. keysDown: number[];
  111873. /**
  111874. * Defines the list of key codes associated with the left action (increase beta)
  111875. */
  111876. keysLeft: number[];
  111877. /**
  111878. * Defines the list of key codes associated with the right action (decrease beta)
  111879. */
  111880. keysRight: number[];
  111881. /**
  111882. * Defines the list of key codes associated with the reset action.
  111883. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111884. */
  111885. keysReset: number[];
  111886. /**
  111887. * Defines the panning sensibility of the inputs.
  111888. * (How fast is the camera panning)
  111889. */
  111890. panningSensibility: number;
  111891. /**
  111892. * Defines the zooming sensibility of the inputs.
  111893. * (How fast is the camera zooming)
  111894. */
  111895. zoomingSensibility: number;
  111896. /**
  111897. * Defines whether maintaining the alt key down switch the movement mode from
  111898. * orientation to zoom.
  111899. */
  111900. useAltToZoom: boolean;
  111901. /**
  111902. * Rotation speed of the camera
  111903. */
  111904. angularSpeed: number;
  111905. private _keys;
  111906. private _ctrlPressed;
  111907. private _altPressed;
  111908. private _onCanvasBlurObserver;
  111909. private _onKeyboardObserver;
  111910. private _engine;
  111911. private _scene;
  111912. /**
  111913. * Attach the input controls to a specific dom element to get the input from.
  111914. * @param element Defines the element the controls should be listened from
  111915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111916. */
  111917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111918. /**
  111919. * Detach the current controls from the specified dom element.
  111920. * @param element Defines the element to stop listening the inputs from
  111921. */
  111922. detachControl(element: Nullable<HTMLElement>): void;
  111923. /**
  111924. * Update the current camera state depending on the inputs that have been used this frame.
  111925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111926. */
  111927. checkInputs(): void;
  111928. /**
  111929. * Gets the class name of the current intput.
  111930. * @returns the class name
  111931. */
  111932. getClassName(): string;
  111933. /**
  111934. * Get the friendly name associated with the input class.
  111935. * @returns the input friendly name
  111936. */
  111937. getSimpleName(): string;
  111938. }
  111939. }
  111940. declare module BABYLON {
  111941. /**
  111942. * Manage the mouse wheel inputs to control an arc rotate camera.
  111943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111944. */
  111945. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111946. /**
  111947. * Defines the camera the input is attached to.
  111948. */
  111949. camera: ArcRotateCamera;
  111950. /**
  111951. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111952. */
  111953. wheelPrecision: number;
  111954. /**
  111955. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111956. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111957. */
  111958. wheelDeltaPercentage: number;
  111959. private _wheel;
  111960. private _observer;
  111961. private computeDeltaFromMouseWheelLegacyEvent;
  111962. /**
  111963. * Attach the input controls to a specific dom element to get the input from.
  111964. * @param element Defines the element the controls should be listened from
  111965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111966. */
  111967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111968. /**
  111969. * Detach the current controls from the specified dom element.
  111970. * @param element Defines the element to stop listening the inputs from
  111971. */
  111972. detachControl(element: Nullable<HTMLElement>): void;
  111973. /**
  111974. * Gets the class name of the current intput.
  111975. * @returns the class name
  111976. */
  111977. getClassName(): string;
  111978. /**
  111979. * Get the friendly name associated with the input class.
  111980. * @returns the input friendly name
  111981. */
  111982. getSimpleName(): string;
  111983. }
  111984. }
  111985. declare module BABYLON {
  111986. /**
  111987. * Default Inputs manager for the ArcRotateCamera.
  111988. * It groups all the default supported inputs for ease of use.
  111989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111990. */
  111991. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111992. /**
  111993. * Instantiates a new ArcRotateCameraInputsManager.
  111994. * @param camera Defines the camera the inputs belong to
  111995. */
  111996. constructor(camera: ArcRotateCamera);
  111997. /**
  111998. * Add mouse wheel input support to the input manager.
  111999. * @returns the current input manager
  112000. */
  112001. addMouseWheel(): ArcRotateCameraInputsManager;
  112002. /**
  112003. * Add pointers input support to the input manager.
  112004. * @returns the current input manager
  112005. */
  112006. addPointers(): ArcRotateCameraInputsManager;
  112007. /**
  112008. * Add keyboard input support to the input manager.
  112009. * @returns the current input manager
  112010. */
  112011. addKeyboard(): ArcRotateCameraInputsManager;
  112012. }
  112013. }
  112014. declare module BABYLON {
  112015. /**
  112016. * This represents an orbital type of camera.
  112017. *
  112018. * 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.
  112019. * 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.
  112020. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  112021. */
  112022. export class ArcRotateCamera extends TargetCamera {
  112023. /**
  112024. * Defines the rotation angle of the camera along the longitudinal axis.
  112025. */
  112026. alpha: number;
  112027. /**
  112028. * Defines the rotation angle of the camera along the latitudinal axis.
  112029. */
  112030. beta: number;
  112031. /**
  112032. * Defines the radius of the camera from it s target point.
  112033. */
  112034. radius: number;
  112035. protected _target: Vector3;
  112036. protected _targetHost: Nullable<AbstractMesh>;
  112037. /**
  112038. * Defines the target point of the camera.
  112039. * The camera looks towards it form the radius distance.
  112040. */
  112041. get target(): Vector3;
  112042. set target(value: Vector3);
  112043. /**
  112044. * Define the current local position of the camera in the scene
  112045. */
  112046. get position(): Vector3;
  112047. set position(newPosition: Vector3);
  112048. protected _upVector: Vector3;
  112049. protected _upToYMatrix: Matrix;
  112050. protected _YToUpMatrix: Matrix;
  112051. /**
  112052. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  112053. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  112054. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  112055. */
  112056. set upVector(vec: Vector3);
  112057. get upVector(): Vector3;
  112058. /**
  112059. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  112060. */
  112061. setMatUp(): void;
  112062. /**
  112063. * Current inertia value on the longitudinal axis.
  112064. * The bigger this number the longer it will take for the camera to stop.
  112065. */
  112066. inertialAlphaOffset: number;
  112067. /**
  112068. * Current inertia value on the latitudinal axis.
  112069. * The bigger this number the longer it will take for the camera to stop.
  112070. */
  112071. inertialBetaOffset: number;
  112072. /**
  112073. * Current inertia value on the radius axis.
  112074. * The bigger this number the longer it will take for the camera to stop.
  112075. */
  112076. inertialRadiusOffset: number;
  112077. /**
  112078. * Minimum allowed angle on the longitudinal axis.
  112079. * This can help limiting how the Camera is able to move in the scene.
  112080. */
  112081. lowerAlphaLimit: Nullable<number>;
  112082. /**
  112083. * Maximum allowed angle on the longitudinal axis.
  112084. * This can help limiting how the Camera is able to move in the scene.
  112085. */
  112086. upperAlphaLimit: Nullable<number>;
  112087. /**
  112088. * Minimum allowed angle on the latitudinal axis.
  112089. * This can help limiting how the Camera is able to move in the scene.
  112090. */
  112091. lowerBetaLimit: number;
  112092. /**
  112093. * Maximum allowed angle on the latitudinal axis.
  112094. * This can help limiting how the Camera is able to move in the scene.
  112095. */
  112096. upperBetaLimit: number;
  112097. /**
  112098. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  112099. * This can help limiting how the Camera is able to move in the scene.
  112100. */
  112101. lowerRadiusLimit: Nullable<number>;
  112102. /**
  112103. * Maximum allowed distance of the camera to the target (The camera can not get further).
  112104. * This can help limiting how the Camera is able to move in the scene.
  112105. */
  112106. upperRadiusLimit: Nullable<number>;
  112107. /**
  112108. * Defines the current inertia value used during panning of the camera along the X axis.
  112109. */
  112110. inertialPanningX: number;
  112111. /**
  112112. * Defines the current inertia value used during panning of the camera along the Y axis.
  112113. */
  112114. inertialPanningY: number;
  112115. /**
  112116. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  112117. * Basically if your fingers moves away from more than this distance you will be considered
  112118. * in pinch mode.
  112119. */
  112120. pinchToPanMaxDistance: number;
  112121. /**
  112122. * Defines the maximum distance the camera can pan.
  112123. * This could help keeping the cammera always in your scene.
  112124. */
  112125. panningDistanceLimit: Nullable<number>;
  112126. /**
  112127. * Defines the target of the camera before paning.
  112128. */
  112129. panningOriginTarget: Vector3;
  112130. /**
  112131. * Defines the value of the inertia used during panning.
  112132. * 0 would mean stop inertia and one would mean no decelleration at all.
  112133. */
  112134. panningInertia: number;
  112135. /**
  112136. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  112137. */
  112138. get angularSensibilityX(): number;
  112139. set angularSensibilityX(value: number);
  112140. /**
  112141. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  112142. */
  112143. get angularSensibilityY(): number;
  112144. set angularSensibilityY(value: number);
  112145. /**
  112146. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  112147. */
  112148. get pinchPrecision(): number;
  112149. set pinchPrecision(value: number);
  112150. /**
  112151. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  112152. * It will be used instead of pinchDeltaPrecision if different from 0.
  112153. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112154. */
  112155. get pinchDeltaPercentage(): number;
  112156. set pinchDeltaPercentage(value: number);
  112157. /**
  112158. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  112159. * and pinch delta percentage.
  112160. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112161. * that any object in the plane at the camera's target point will scale
  112162. * perfectly with finger motion.
  112163. */
  112164. get useNaturalPinchZoom(): boolean;
  112165. set useNaturalPinchZoom(value: boolean);
  112166. /**
  112167. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112168. */
  112169. get panningSensibility(): number;
  112170. set panningSensibility(value: number);
  112171. /**
  112172. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112173. */
  112174. get keysUp(): number[];
  112175. set keysUp(value: number[]);
  112176. /**
  112177. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112178. */
  112179. get keysDown(): number[];
  112180. set keysDown(value: number[]);
  112181. /**
  112182. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112183. */
  112184. get keysLeft(): number[];
  112185. set keysLeft(value: number[]);
  112186. /**
  112187. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112188. */
  112189. get keysRight(): number[];
  112190. set keysRight(value: number[]);
  112191. /**
  112192. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112193. */
  112194. get wheelPrecision(): number;
  112195. set wheelPrecision(value: number);
  112196. /**
  112197. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112198. * It will be used instead of pinchDeltaPrecision if different from 0.
  112199. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112200. */
  112201. get wheelDeltaPercentage(): number;
  112202. set wheelDeltaPercentage(value: number);
  112203. /**
  112204. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112205. */
  112206. zoomOnFactor: number;
  112207. /**
  112208. * Defines a screen offset for the camera position.
  112209. */
  112210. targetScreenOffset: Vector2;
  112211. /**
  112212. * Allows the camera to be completely reversed.
  112213. * If false the camera can not arrive upside down.
  112214. */
  112215. allowUpsideDown: boolean;
  112216. /**
  112217. * Define if double tap/click is used to restore the previously saved state of the camera.
  112218. */
  112219. useInputToRestoreState: boolean;
  112220. /** @hidden */
  112221. _viewMatrix: Matrix;
  112222. /** @hidden */
  112223. _useCtrlForPanning: boolean;
  112224. /** @hidden */
  112225. _panningMouseButton: number;
  112226. /**
  112227. * Defines the input associated to the camera.
  112228. */
  112229. inputs: ArcRotateCameraInputsManager;
  112230. /** @hidden */
  112231. _reset: () => void;
  112232. /**
  112233. * Defines the allowed panning axis.
  112234. */
  112235. panningAxis: Vector3;
  112236. protected _localDirection: Vector3;
  112237. protected _transformedDirection: Vector3;
  112238. private _bouncingBehavior;
  112239. /**
  112240. * Gets the bouncing behavior of the camera if it has been enabled.
  112241. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112242. */
  112243. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112244. /**
  112245. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112247. */
  112248. get useBouncingBehavior(): boolean;
  112249. set useBouncingBehavior(value: boolean);
  112250. private _framingBehavior;
  112251. /**
  112252. * Gets the framing behavior of the camera if it has been enabled.
  112253. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112254. */
  112255. get framingBehavior(): Nullable<FramingBehavior>;
  112256. /**
  112257. * Defines if the framing behavior of the camera is enabled on the camera.
  112258. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112259. */
  112260. get useFramingBehavior(): boolean;
  112261. set useFramingBehavior(value: boolean);
  112262. private _autoRotationBehavior;
  112263. /**
  112264. * Gets the auto rotation behavior of the camera if it has been enabled.
  112265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112266. */
  112267. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112268. /**
  112269. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112270. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112271. */
  112272. get useAutoRotationBehavior(): boolean;
  112273. set useAutoRotationBehavior(value: boolean);
  112274. /**
  112275. * Observable triggered when the mesh target has been changed on the camera.
  112276. */
  112277. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112278. /**
  112279. * Event raised when the camera is colliding with a mesh.
  112280. */
  112281. onCollide: (collidedMesh: AbstractMesh) => void;
  112282. /**
  112283. * Defines whether the camera should check collision with the objects oh the scene.
  112284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112285. */
  112286. checkCollisions: boolean;
  112287. /**
  112288. * Defines the collision radius of the camera.
  112289. * This simulates a sphere around the camera.
  112290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112291. */
  112292. collisionRadius: Vector3;
  112293. protected _collider: Collider;
  112294. protected _previousPosition: Vector3;
  112295. protected _collisionVelocity: Vector3;
  112296. protected _newPosition: Vector3;
  112297. protected _previousAlpha: number;
  112298. protected _previousBeta: number;
  112299. protected _previousRadius: number;
  112300. protected _collisionTriggered: boolean;
  112301. protected _targetBoundingCenter: Nullable<Vector3>;
  112302. private _computationVector;
  112303. /**
  112304. * Instantiates a new ArcRotateCamera in a given scene
  112305. * @param name Defines the name of the camera
  112306. * @param alpha Defines the camera rotation along the logitudinal axis
  112307. * @param beta Defines the camera rotation along the latitudinal axis
  112308. * @param radius Defines the camera distance from its target
  112309. * @param target Defines the camera target
  112310. * @param scene Defines the scene the camera belongs to
  112311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112312. */
  112313. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112314. /** @hidden */
  112315. _initCache(): void;
  112316. /** @hidden */
  112317. _updateCache(ignoreParentClass?: boolean): void;
  112318. protected _getTargetPosition(): Vector3;
  112319. private _storedAlpha;
  112320. private _storedBeta;
  112321. private _storedRadius;
  112322. private _storedTarget;
  112323. private _storedTargetScreenOffset;
  112324. /**
  112325. * Stores the current state of the camera (alpha, beta, radius and target)
  112326. * @returns the camera itself
  112327. */
  112328. storeState(): Camera;
  112329. /**
  112330. * @hidden
  112331. * Restored camera state. You must call storeState() first
  112332. */
  112333. _restoreStateValues(): boolean;
  112334. /** @hidden */
  112335. _isSynchronizedViewMatrix(): boolean;
  112336. /**
  112337. * Attached controls to the current camera.
  112338. * @param element Defines the element the controls should be listened from
  112339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112340. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112341. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112342. */
  112343. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112344. /**
  112345. * Detach the current controls from the camera.
  112346. * The camera will stop reacting to inputs.
  112347. * @param element Defines the element to stop listening the inputs from
  112348. */
  112349. detachControl(element: HTMLElement): void;
  112350. /** @hidden */
  112351. _checkInputs(): void;
  112352. protected _checkLimits(): void;
  112353. /**
  112354. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112355. */
  112356. rebuildAnglesAndRadius(): void;
  112357. /**
  112358. * Use a position to define the current camera related information like alpha, beta and radius
  112359. * @param position Defines the position to set the camera at
  112360. */
  112361. setPosition(position: Vector3): void;
  112362. /**
  112363. * Defines the target the camera should look at.
  112364. * This will automatically adapt alpha beta and radius to fit within the new target.
  112365. * @param target Defines the new target as a Vector or a mesh
  112366. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112367. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112368. */
  112369. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112370. /** @hidden */
  112371. _getViewMatrix(): Matrix;
  112372. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112373. /**
  112374. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112375. * @param meshes Defines the mesh to zoom on
  112376. * @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)
  112377. */
  112378. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112379. /**
  112380. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112381. * The target will be changed but the radius
  112382. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112383. * @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)
  112384. */
  112385. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112386. min: Vector3;
  112387. max: Vector3;
  112388. distance: number;
  112389. }, doNotUpdateMaxZ?: boolean): void;
  112390. /**
  112391. * @override
  112392. * Override Camera.createRigCamera
  112393. */
  112394. createRigCamera(name: string, cameraIndex: number): Camera;
  112395. /**
  112396. * @hidden
  112397. * @override
  112398. * Override Camera._updateRigCameras
  112399. */
  112400. _updateRigCameras(): void;
  112401. /**
  112402. * Destroy the camera and release the current resources hold by it.
  112403. */
  112404. dispose(): void;
  112405. /**
  112406. * Gets the current object class name.
  112407. * @return the class name
  112408. */
  112409. getClassName(): string;
  112410. }
  112411. }
  112412. declare module BABYLON {
  112413. /**
  112414. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112415. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112416. */
  112417. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112418. /**
  112419. * Gets the name of the behavior.
  112420. */
  112421. get name(): string;
  112422. private _zoomStopsAnimation;
  112423. private _idleRotationSpeed;
  112424. private _idleRotationWaitTime;
  112425. private _idleRotationSpinupTime;
  112426. /**
  112427. * Sets the flag that indicates if user zooming should stop animation.
  112428. */
  112429. set zoomStopsAnimation(flag: boolean);
  112430. /**
  112431. * Gets the flag that indicates if user zooming should stop animation.
  112432. */
  112433. get zoomStopsAnimation(): boolean;
  112434. /**
  112435. * Sets the default speed at which the camera rotates around the model.
  112436. */
  112437. set idleRotationSpeed(speed: number);
  112438. /**
  112439. * Gets the default speed at which the camera rotates around the model.
  112440. */
  112441. get idleRotationSpeed(): number;
  112442. /**
  112443. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112444. */
  112445. set idleRotationWaitTime(time: number);
  112446. /**
  112447. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112448. */
  112449. get idleRotationWaitTime(): number;
  112450. /**
  112451. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112452. */
  112453. set idleRotationSpinupTime(time: number);
  112454. /**
  112455. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112456. */
  112457. get idleRotationSpinupTime(): number;
  112458. /**
  112459. * Gets a value indicating if the camera is currently rotating because of this behavior
  112460. */
  112461. get rotationInProgress(): boolean;
  112462. private _onPrePointerObservableObserver;
  112463. private _onAfterCheckInputsObserver;
  112464. private _attachedCamera;
  112465. private _isPointerDown;
  112466. private _lastFrameTime;
  112467. private _lastInteractionTime;
  112468. private _cameraRotationSpeed;
  112469. /**
  112470. * Initializes the behavior.
  112471. */
  112472. init(): void;
  112473. /**
  112474. * Attaches the behavior to its arc rotate camera.
  112475. * @param camera Defines the camera to attach the behavior to
  112476. */
  112477. attach(camera: ArcRotateCamera): void;
  112478. /**
  112479. * Detaches the behavior from its current arc rotate camera.
  112480. */
  112481. detach(): void;
  112482. /**
  112483. * Returns true if user is scrolling.
  112484. * @return true if user is scrolling.
  112485. */
  112486. private _userIsZooming;
  112487. private _lastFrameRadius;
  112488. private _shouldAnimationStopForInteraction;
  112489. /**
  112490. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112491. */
  112492. private _applyUserInteraction;
  112493. private _userIsMoving;
  112494. }
  112495. }
  112496. declare module BABYLON {
  112497. /**
  112498. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112499. */
  112500. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112501. private ui;
  112502. /**
  112503. * The name of the behavior
  112504. */
  112505. name: string;
  112506. /**
  112507. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112508. */
  112509. distanceAwayFromFace: number;
  112510. /**
  112511. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112512. */
  112513. distanceAwayFromBottomOfFace: number;
  112514. private _faceVectors;
  112515. private _target;
  112516. private _scene;
  112517. private _onRenderObserver;
  112518. private _tmpMatrix;
  112519. private _tmpVector;
  112520. /**
  112521. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112522. * @param ui The transform node that should be attched to the mesh
  112523. */
  112524. constructor(ui: TransformNode);
  112525. /**
  112526. * Initializes the behavior
  112527. */
  112528. init(): void;
  112529. private _closestFace;
  112530. private _zeroVector;
  112531. private _lookAtTmpMatrix;
  112532. private _lookAtToRef;
  112533. /**
  112534. * Attaches the AttachToBoxBehavior to the passed in mesh
  112535. * @param target The mesh that the specified node will be attached to
  112536. */
  112537. attach(target: Mesh): void;
  112538. /**
  112539. * Detaches the behavior from the mesh
  112540. */
  112541. detach(): void;
  112542. }
  112543. }
  112544. declare module BABYLON {
  112545. /**
  112546. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112547. */
  112548. export class FadeInOutBehavior implements Behavior<Mesh> {
  112549. /**
  112550. * Time in milliseconds to delay before fading in (Default: 0)
  112551. */
  112552. delay: number;
  112553. /**
  112554. * Time in milliseconds for the mesh to fade in (Default: 300)
  112555. */
  112556. fadeInTime: number;
  112557. private _millisecondsPerFrame;
  112558. private _hovered;
  112559. private _hoverValue;
  112560. private _ownerNode;
  112561. /**
  112562. * Instatiates the FadeInOutBehavior
  112563. */
  112564. constructor();
  112565. /**
  112566. * The name of the behavior
  112567. */
  112568. get name(): string;
  112569. /**
  112570. * Initializes the behavior
  112571. */
  112572. init(): void;
  112573. /**
  112574. * Attaches the fade behavior on the passed in mesh
  112575. * @param ownerNode The mesh that will be faded in/out once attached
  112576. */
  112577. attach(ownerNode: Mesh): void;
  112578. /**
  112579. * Detaches the behavior from the mesh
  112580. */
  112581. detach(): void;
  112582. /**
  112583. * Triggers the mesh to begin fading in or out
  112584. * @param value if the object should fade in or out (true to fade in)
  112585. */
  112586. fadeIn(value: boolean): void;
  112587. private _update;
  112588. private _setAllVisibility;
  112589. }
  112590. }
  112591. declare module BABYLON {
  112592. /**
  112593. * Class containing a set of static utilities functions for managing Pivots
  112594. * @hidden
  112595. */
  112596. export class PivotTools {
  112597. private static _PivotCached;
  112598. private static _OldPivotPoint;
  112599. private static _PivotTranslation;
  112600. private static _PivotTmpVector;
  112601. /** @hidden */
  112602. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112603. /** @hidden */
  112604. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112605. }
  112606. }
  112607. declare module BABYLON {
  112608. /**
  112609. * Class containing static functions to help procedurally build meshes
  112610. */
  112611. export class PlaneBuilder {
  112612. /**
  112613. * Creates a plane mesh
  112614. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112615. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112616. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112620. * @param name defines the name of the mesh
  112621. * @param options defines the options used to create the mesh
  112622. * @param scene defines the hosting scene
  112623. * @returns the plane mesh
  112624. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112625. */
  112626. static CreatePlane(name: string, options: {
  112627. size?: number;
  112628. width?: number;
  112629. height?: number;
  112630. sideOrientation?: number;
  112631. frontUVs?: Vector4;
  112632. backUVs?: Vector4;
  112633. updatable?: boolean;
  112634. sourcePlane?: Plane;
  112635. }, scene?: Nullable<Scene>): Mesh;
  112636. }
  112637. }
  112638. declare module BABYLON {
  112639. /**
  112640. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112641. */
  112642. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112643. private static _AnyMouseID;
  112644. /**
  112645. * Abstract mesh the behavior is set on
  112646. */
  112647. attachedNode: AbstractMesh;
  112648. private _dragPlane;
  112649. private _scene;
  112650. private _pointerObserver;
  112651. private _beforeRenderObserver;
  112652. private static _planeScene;
  112653. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112654. /**
  112655. * 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)
  112656. */
  112657. maxDragAngle: number;
  112658. /**
  112659. * @hidden
  112660. */
  112661. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112662. /**
  112663. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112664. */
  112665. currentDraggingPointerID: number;
  112666. /**
  112667. * The last position where the pointer hit the drag plane in world space
  112668. */
  112669. lastDragPosition: Vector3;
  112670. /**
  112671. * If the behavior is currently in a dragging state
  112672. */
  112673. dragging: boolean;
  112674. /**
  112675. * 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)
  112676. */
  112677. dragDeltaRatio: number;
  112678. /**
  112679. * If the drag plane orientation should be updated during the dragging (Default: true)
  112680. */
  112681. updateDragPlane: boolean;
  112682. private _debugMode;
  112683. private _moving;
  112684. /**
  112685. * Fires each time the attached mesh is dragged with the pointer
  112686. * * delta between last drag position and current drag position in world space
  112687. * * dragDistance along the drag axis
  112688. * * dragPlaneNormal normal of the current drag plane used during the drag
  112689. * * dragPlanePoint in world space where the drag intersects the drag plane
  112690. */
  112691. onDragObservable: Observable<{
  112692. delta: Vector3;
  112693. dragPlanePoint: Vector3;
  112694. dragPlaneNormal: Vector3;
  112695. dragDistance: number;
  112696. pointerId: number;
  112697. }>;
  112698. /**
  112699. * Fires each time a drag begins (eg. mouse down on mesh)
  112700. */
  112701. onDragStartObservable: Observable<{
  112702. dragPlanePoint: Vector3;
  112703. pointerId: number;
  112704. }>;
  112705. /**
  112706. * Fires each time a drag ends (eg. mouse release after drag)
  112707. */
  112708. onDragEndObservable: Observable<{
  112709. dragPlanePoint: Vector3;
  112710. pointerId: number;
  112711. }>;
  112712. /**
  112713. * If the attached mesh should be moved when dragged
  112714. */
  112715. moveAttached: boolean;
  112716. /**
  112717. * If the drag behavior will react to drag events (Default: true)
  112718. */
  112719. enabled: boolean;
  112720. /**
  112721. * If pointer events should start and release the drag (Default: true)
  112722. */
  112723. startAndReleaseDragOnPointerEvents: boolean;
  112724. /**
  112725. * If camera controls should be detached during the drag
  112726. */
  112727. detachCameraControls: boolean;
  112728. /**
  112729. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112730. */
  112731. useObjectOrientationForDragging: boolean;
  112732. private _options;
  112733. /**
  112734. * Gets the options used by the behavior
  112735. */
  112736. get options(): {
  112737. dragAxis?: Vector3;
  112738. dragPlaneNormal?: Vector3;
  112739. };
  112740. /**
  112741. * Sets the options used by the behavior
  112742. */
  112743. set options(options: {
  112744. dragAxis?: Vector3;
  112745. dragPlaneNormal?: Vector3;
  112746. });
  112747. /**
  112748. * Creates a pointer drag behavior that can be attached to a mesh
  112749. * @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)
  112750. */
  112751. constructor(options?: {
  112752. dragAxis?: Vector3;
  112753. dragPlaneNormal?: Vector3;
  112754. });
  112755. /**
  112756. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112757. */
  112758. validateDrag: (targetPosition: Vector3) => boolean;
  112759. /**
  112760. * The name of the behavior
  112761. */
  112762. get name(): string;
  112763. /**
  112764. * Initializes the behavior
  112765. */
  112766. init(): void;
  112767. private _tmpVector;
  112768. private _alternatePickedPoint;
  112769. private _worldDragAxis;
  112770. private _targetPosition;
  112771. private _attachedElement;
  112772. /**
  112773. * Attaches the drag behavior the passed in mesh
  112774. * @param ownerNode The mesh that will be dragged around once attached
  112775. * @param predicate Predicate to use for pick filtering
  112776. */
  112777. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112778. /**
  112779. * Force relase the drag action by code.
  112780. */
  112781. releaseDrag(): void;
  112782. private _startDragRay;
  112783. private _lastPointerRay;
  112784. /**
  112785. * Simulates the start of a pointer drag event on the behavior
  112786. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112787. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112788. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112789. */
  112790. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112791. private _startDrag;
  112792. private _dragDelta;
  112793. private _moveDrag;
  112794. private _pickWithRayOnDragPlane;
  112795. private _pointA;
  112796. private _pointB;
  112797. private _pointC;
  112798. private _lineA;
  112799. private _lineB;
  112800. private _localAxis;
  112801. private _lookAt;
  112802. private _updateDragPlanePosition;
  112803. /**
  112804. * Detaches the behavior from the mesh
  112805. */
  112806. detach(): void;
  112807. }
  112808. }
  112809. declare module BABYLON {
  112810. /**
  112811. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112812. */
  112813. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112814. private _dragBehaviorA;
  112815. private _dragBehaviorB;
  112816. private _startDistance;
  112817. private _initialScale;
  112818. private _targetScale;
  112819. private _ownerNode;
  112820. private _sceneRenderObserver;
  112821. /**
  112822. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112823. */
  112824. constructor();
  112825. /**
  112826. * The name of the behavior
  112827. */
  112828. get name(): string;
  112829. /**
  112830. * Initializes the behavior
  112831. */
  112832. init(): void;
  112833. private _getCurrentDistance;
  112834. /**
  112835. * Attaches the scale behavior the passed in mesh
  112836. * @param ownerNode The mesh that will be scaled around once attached
  112837. */
  112838. attach(ownerNode: Mesh): void;
  112839. /**
  112840. * Detaches the behavior from the mesh
  112841. */
  112842. detach(): void;
  112843. }
  112844. }
  112845. declare module BABYLON {
  112846. /**
  112847. * 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
  112848. */
  112849. export class SixDofDragBehavior implements Behavior<Mesh> {
  112850. private static _virtualScene;
  112851. private _ownerNode;
  112852. private _sceneRenderObserver;
  112853. private _scene;
  112854. private _targetPosition;
  112855. private _virtualOriginMesh;
  112856. private _virtualDragMesh;
  112857. private _pointerObserver;
  112858. private _moving;
  112859. private _startingOrientation;
  112860. /**
  112861. * 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)
  112862. */
  112863. private zDragFactor;
  112864. /**
  112865. * If the object should rotate to face the drag origin
  112866. */
  112867. rotateDraggedObject: boolean;
  112868. /**
  112869. * If the behavior is currently in a dragging state
  112870. */
  112871. dragging: boolean;
  112872. /**
  112873. * 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)
  112874. */
  112875. dragDeltaRatio: number;
  112876. /**
  112877. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112878. */
  112879. currentDraggingPointerID: number;
  112880. /**
  112881. * If camera controls should be detached during the drag
  112882. */
  112883. detachCameraControls: boolean;
  112884. /**
  112885. * Fires each time a drag starts
  112886. */
  112887. onDragStartObservable: Observable<{}>;
  112888. /**
  112889. * Fires each time a drag ends (eg. mouse release after drag)
  112890. */
  112891. onDragEndObservable: Observable<{}>;
  112892. /**
  112893. * 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
  112894. */
  112895. constructor();
  112896. /**
  112897. * The name of the behavior
  112898. */
  112899. get name(): string;
  112900. /**
  112901. * Initializes the behavior
  112902. */
  112903. init(): void;
  112904. /**
  112905. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112906. */
  112907. private get _pointerCamera();
  112908. /**
  112909. * Attaches the scale behavior the passed in mesh
  112910. * @param ownerNode The mesh that will be scaled around once attached
  112911. */
  112912. attach(ownerNode: Mesh): void;
  112913. /**
  112914. * Detaches the behavior from the mesh
  112915. */
  112916. detach(): void;
  112917. }
  112918. }
  112919. declare module BABYLON {
  112920. /**
  112921. * Class used to apply inverse kinematics to bones
  112922. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112923. */
  112924. export class BoneIKController {
  112925. private static _tmpVecs;
  112926. private static _tmpQuat;
  112927. private static _tmpMats;
  112928. /**
  112929. * Gets or sets the target mesh
  112930. */
  112931. targetMesh: AbstractMesh;
  112932. /** Gets or sets the mesh used as pole */
  112933. poleTargetMesh: AbstractMesh;
  112934. /**
  112935. * Gets or sets the bone used as pole
  112936. */
  112937. poleTargetBone: Nullable<Bone>;
  112938. /**
  112939. * Gets or sets the target position
  112940. */
  112941. targetPosition: Vector3;
  112942. /**
  112943. * Gets or sets the pole target position
  112944. */
  112945. poleTargetPosition: Vector3;
  112946. /**
  112947. * Gets or sets the pole target local offset
  112948. */
  112949. poleTargetLocalOffset: Vector3;
  112950. /**
  112951. * Gets or sets the pole angle
  112952. */
  112953. poleAngle: number;
  112954. /**
  112955. * Gets or sets the mesh associated with the controller
  112956. */
  112957. mesh: AbstractMesh;
  112958. /**
  112959. * 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)
  112960. */
  112961. slerpAmount: number;
  112962. private _bone1Quat;
  112963. private _bone1Mat;
  112964. private _bone2Ang;
  112965. private _bone1;
  112966. private _bone2;
  112967. private _bone1Length;
  112968. private _bone2Length;
  112969. private _maxAngle;
  112970. private _maxReach;
  112971. private _rightHandedSystem;
  112972. private _bendAxis;
  112973. private _slerping;
  112974. private _adjustRoll;
  112975. /**
  112976. * Gets or sets maximum allowed angle
  112977. */
  112978. get maxAngle(): number;
  112979. set maxAngle(value: number);
  112980. /**
  112981. * Creates a new BoneIKController
  112982. * @param mesh defines the mesh to control
  112983. * @param bone defines the bone to control
  112984. * @param options defines options to set up the controller
  112985. */
  112986. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112987. targetMesh?: AbstractMesh;
  112988. poleTargetMesh?: AbstractMesh;
  112989. poleTargetBone?: Bone;
  112990. poleTargetLocalOffset?: Vector3;
  112991. poleAngle?: number;
  112992. bendAxis?: Vector3;
  112993. maxAngle?: number;
  112994. slerpAmount?: number;
  112995. });
  112996. private _setMaxAngle;
  112997. /**
  112998. * Force the controller to update the bones
  112999. */
  113000. update(): void;
  113001. }
  113002. }
  113003. declare module BABYLON {
  113004. /**
  113005. * Class used to make a bone look toward a point in space
  113006. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  113007. */
  113008. export class BoneLookController {
  113009. private static _tmpVecs;
  113010. private static _tmpQuat;
  113011. private static _tmpMats;
  113012. /**
  113013. * The target Vector3 that the bone will look at
  113014. */
  113015. target: Vector3;
  113016. /**
  113017. * The mesh that the bone is attached to
  113018. */
  113019. mesh: AbstractMesh;
  113020. /**
  113021. * The bone that will be looking to the target
  113022. */
  113023. bone: Bone;
  113024. /**
  113025. * The up axis of the coordinate system that is used when the bone is rotated
  113026. */
  113027. upAxis: Vector3;
  113028. /**
  113029. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  113030. */
  113031. upAxisSpace: Space;
  113032. /**
  113033. * Used to make an adjustment to the yaw of the bone
  113034. */
  113035. adjustYaw: number;
  113036. /**
  113037. * Used to make an adjustment to the pitch of the bone
  113038. */
  113039. adjustPitch: number;
  113040. /**
  113041. * Used to make an adjustment to the roll of the bone
  113042. */
  113043. adjustRoll: number;
  113044. /**
  113045. * 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)
  113046. */
  113047. slerpAmount: number;
  113048. private _minYaw;
  113049. private _maxYaw;
  113050. private _minPitch;
  113051. private _maxPitch;
  113052. private _minYawSin;
  113053. private _minYawCos;
  113054. private _maxYawSin;
  113055. private _maxYawCos;
  113056. private _midYawConstraint;
  113057. private _minPitchTan;
  113058. private _maxPitchTan;
  113059. private _boneQuat;
  113060. private _slerping;
  113061. private _transformYawPitch;
  113062. private _transformYawPitchInv;
  113063. private _firstFrameSkipped;
  113064. private _yawRange;
  113065. private _fowardAxis;
  113066. /**
  113067. * Gets or sets the minimum yaw angle that the bone can look to
  113068. */
  113069. get minYaw(): number;
  113070. set minYaw(value: number);
  113071. /**
  113072. * Gets or sets the maximum yaw angle that the bone can look to
  113073. */
  113074. get maxYaw(): number;
  113075. set maxYaw(value: number);
  113076. /**
  113077. * Gets or sets the minimum pitch angle that the bone can look to
  113078. */
  113079. get minPitch(): number;
  113080. set minPitch(value: number);
  113081. /**
  113082. * Gets or sets the maximum pitch angle that the bone can look to
  113083. */
  113084. get maxPitch(): number;
  113085. set maxPitch(value: number);
  113086. /**
  113087. * Create a BoneLookController
  113088. * @param mesh the mesh that the bone belongs to
  113089. * @param bone the bone that will be looking to the target
  113090. * @param target the target Vector3 to look at
  113091. * @param options optional settings:
  113092. * * maxYaw: the maximum angle the bone will yaw to
  113093. * * minYaw: the minimum angle the bone will yaw to
  113094. * * maxPitch: the maximum angle the bone will pitch to
  113095. * * minPitch: the minimum angle the bone will yaw to
  113096. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  113097. * * upAxis: the up axis of the coordinate system
  113098. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  113099. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  113100. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  113101. * * adjustYaw: used to make an adjustment to the yaw of the bone
  113102. * * adjustPitch: used to make an adjustment to the pitch of the bone
  113103. * * adjustRoll: used to make an adjustment to the roll of the bone
  113104. **/
  113105. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  113106. maxYaw?: number;
  113107. minYaw?: number;
  113108. maxPitch?: number;
  113109. minPitch?: number;
  113110. slerpAmount?: number;
  113111. upAxis?: Vector3;
  113112. upAxisSpace?: Space;
  113113. yawAxis?: Vector3;
  113114. pitchAxis?: Vector3;
  113115. adjustYaw?: number;
  113116. adjustPitch?: number;
  113117. adjustRoll?: number;
  113118. });
  113119. /**
  113120. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  113121. */
  113122. update(): void;
  113123. private _getAngleDiff;
  113124. private _getAngleBetween;
  113125. private _isAngleBetween;
  113126. }
  113127. }
  113128. declare module BABYLON {
  113129. /**
  113130. * Manage the gamepad inputs to control an arc rotate camera.
  113131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113132. */
  113133. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  113134. /**
  113135. * Defines the camera the input is attached to.
  113136. */
  113137. camera: ArcRotateCamera;
  113138. /**
  113139. * Defines the gamepad the input is gathering event from.
  113140. */
  113141. gamepad: Nullable<Gamepad>;
  113142. /**
  113143. * Defines the gamepad rotation sensiblity.
  113144. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113145. */
  113146. gamepadRotationSensibility: number;
  113147. /**
  113148. * Defines the gamepad move sensiblity.
  113149. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113150. */
  113151. gamepadMoveSensibility: number;
  113152. private _yAxisScale;
  113153. /**
  113154. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113155. */
  113156. get invertYAxis(): boolean;
  113157. set invertYAxis(value: boolean);
  113158. private _onGamepadConnectedObserver;
  113159. private _onGamepadDisconnectedObserver;
  113160. /**
  113161. * Attach the input controls to a specific dom element to get the input from.
  113162. * @param element Defines the element the controls should be listened from
  113163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113164. */
  113165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113166. /**
  113167. * Detach the current controls from the specified dom element.
  113168. * @param element Defines the element to stop listening the inputs from
  113169. */
  113170. detachControl(element: Nullable<HTMLElement>): void;
  113171. /**
  113172. * Update the current camera state depending on the inputs that have been used this frame.
  113173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113174. */
  113175. checkInputs(): void;
  113176. /**
  113177. * Gets the class name of the current intput.
  113178. * @returns the class name
  113179. */
  113180. getClassName(): string;
  113181. /**
  113182. * Get the friendly name associated with the input class.
  113183. * @returns the input friendly name
  113184. */
  113185. getSimpleName(): string;
  113186. }
  113187. }
  113188. declare module BABYLON {
  113189. interface ArcRotateCameraInputsManager {
  113190. /**
  113191. * Add orientation input support to the input manager.
  113192. * @returns the current input manager
  113193. */
  113194. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113195. }
  113196. /**
  113197. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113199. */
  113200. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113201. /**
  113202. * Defines the camera the input is attached to.
  113203. */
  113204. camera: ArcRotateCamera;
  113205. /**
  113206. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113207. */
  113208. alphaCorrection: number;
  113209. /**
  113210. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113211. */
  113212. gammaCorrection: number;
  113213. private _alpha;
  113214. private _gamma;
  113215. private _dirty;
  113216. private _deviceOrientationHandler;
  113217. /**
  113218. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113219. */
  113220. constructor();
  113221. /**
  113222. * Attach the input controls to a specific dom element to get the input from.
  113223. * @param element Defines the element the controls should be listened from
  113224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113225. */
  113226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113227. /** @hidden */
  113228. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113229. /**
  113230. * Update the current camera state depending on the inputs that have been used this frame.
  113231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113232. */
  113233. checkInputs(): void;
  113234. /**
  113235. * Detach the current controls from the specified dom element.
  113236. * @param element Defines the element to stop listening the inputs from
  113237. */
  113238. detachControl(element: Nullable<HTMLElement>): void;
  113239. /**
  113240. * Gets the class name of the current intput.
  113241. * @returns the class name
  113242. */
  113243. getClassName(): string;
  113244. /**
  113245. * Get the friendly name associated with the input class.
  113246. * @returns the input friendly name
  113247. */
  113248. getSimpleName(): string;
  113249. }
  113250. }
  113251. declare module BABYLON {
  113252. /**
  113253. * Listen to mouse events to control the camera.
  113254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113255. */
  113256. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113257. /**
  113258. * Defines the camera the input is attached to.
  113259. */
  113260. camera: FlyCamera;
  113261. /**
  113262. * Defines if touch is enabled. (Default is true.)
  113263. */
  113264. touchEnabled: boolean;
  113265. /**
  113266. * Defines the buttons associated with the input to handle camera rotation.
  113267. */
  113268. buttons: number[];
  113269. /**
  113270. * Assign buttons for Yaw control.
  113271. */
  113272. buttonsYaw: number[];
  113273. /**
  113274. * Assign buttons for Pitch control.
  113275. */
  113276. buttonsPitch: number[];
  113277. /**
  113278. * Assign buttons for Roll control.
  113279. */
  113280. buttonsRoll: number[];
  113281. /**
  113282. * Detect if any button is being pressed while mouse is moved.
  113283. * -1 = Mouse locked.
  113284. * 0 = Left button.
  113285. * 1 = Middle Button.
  113286. * 2 = Right Button.
  113287. */
  113288. activeButton: number;
  113289. /**
  113290. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113291. * Higher values reduce its sensitivity.
  113292. */
  113293. angularSensibility: number;
  113294. private _mousemoveCallback;
  113295. private _observer;
  113296. private _rollObserver;
  113297. private previousPosition;
  113298. private noPreventDefault;
  113299. private element;
  113300. /**
  113301. * Listen to mouse events to control the camera.
  113302. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113304. */
  113305. constructor(touchEnabled?: boolean);
  113306. /**
  113307. * Attach the mouse control to the HTML DOM element.
  113308. * @param element Defines the element that listens to the input events.
  113309. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113310. */
  113311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113312. /**
  113313. * Detach the current controls from the specified dom element.
  113314. * @param element Defines the element to stop listening the inputs from
  113315. */
  113316. detachControl(element: Nullable<HTMLElement>): void;
  113317. /**
  113318. * Gets the class name of the current input.
  113319. * @returns the class name.
  113320. */
  113321. getClassName(): string;
  113322. /**
  113323. * Get the friendly name associated with the input class.
  113324. * @returns the input's friendly name.
  113325. */
  113326. getSimpleName(): string;
  113327. private _pointerInput;
  113328. private _onMouseMove;
  113329. /**
  113330. * Rotate camera by mouse offset.
  113331. */
  113332. private rotateCamera;
  113333. }
  113334. }
  113335. declare module BABYLON {
  113336. /**
  113337. * Default Inputs manager for the FlyCamera.
  113338. * It groups all the default supported inputs for ease of use.
  113339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113340. */
  113341. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113342. /**
  113343. * Instantiates a new FlyCameraInputsManager.
  113344. * @param camera Defines the camera the inputs belong to.
  113345. */
  113346. constructor(camera: FlyCamera);
  113347. /**
  113348. * Add keyboard input support to the input manager.
  113349. * @returns the new FlyCameraKeyboardMoveInput().
  113350. */
  113351. addKeyboard(): FlyCameraInputsManager;
  113352. /**
  113353. * Add mouse input support to the input manager.
  113354. * @param touchEnabled Enable touch screen support.
  113355. * @returns the new FlyCameraMouseInput().
  113356. */
  113357. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113358. }
  113359. }
  113360. declare module BABYLON {
  113361. /**
  113362. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113363. * such as in a 3D Space Shooter or a Flight Simulator.
  113364. */
  113365. export class FlyCamera extends TargetCamera {
  113366. /**
  113367. * Define the collision ellipsoid of the camera.
  113368. * This is helpful for simulating a camera body, like a player's body.
  113369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113370. */
  113371. ellipsoid: Vector3;
  113372. /**
  113373. * Define an offset for the position of the ellipsoid around the camera.
  113374. * This can be helpful if the camera is attached away from the player's body center,
  113375. * such as at its head.
  113376. */
  113377. ellipsoidOffset: Vector3;
  113378. /**
  113379. * Enable or disable collisions of the camera with the rest of the scene objects.
  113380. */
  113381. checkCollisions: boolean;
  113382. /**
  113383. * Enable or disable gravity on the camera.
  113384. */
  113385. applyGravity: boolean;
  113386. /**
  113387. * Define the current direction the camera is moving to.
  113388. */
  113389. cameraDirection: Vector3;
  113390. /**
  113391. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113392. * This overrides and empties cameraRotation.
  113393. */
  113394. rotationQuaternion: Quaternion;
  113395. /**
  113396. * Track Roll to maintain the wanted Rolling when looking around.
  113397. */
  113398. _trackRoll: number;
  113399. /**
  113400. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113401. */
  113402. rollCorrect: number;
  113403. /**
  113404. * Mimic a banked turn, Rolling the camera when Yawing.
  113405. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113406. */
  113407. bankedTurn: boolean;
  113408. /**
  113409. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113410. */
  113411. bankedTurnLimit: number;
  113412. /**
  113413. * Value of 0 disables the banked Roll.
  113414. * Value of 1 is equal to the Yaw angle in radians.
  113415. */
  113416. bankedTurnMultiplier: number;
  113417. /**
  113418. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113419. */
  113420. inputs: FlyCameraInputsManager;
  113421. /**
  113422. * Gets the input sensibility for mouse input.
  113423. * Higher values reduce sensitivity.
  113424. */
  113425. get angularSensibility(): number;
  113426. /**
  113427. * Sets the input sensibility for a mouse input.
  113428. * Higher values reduce sensitivity.
  113429. */
  113430. set angularSensibility(value: number);
  113431. /**
  113432. * Get the keys for camera movement forward.
  113433. */
  113434. get keysForward(): number[];
  113435. /**
  113436. * Set the keys for camera movement forward.
  113437. */
  113438. set keysForward(value: number[]);
  113439. /**
  113440. * Get the keys for camera movement backward.
  113441. */
  113442. get keysBackward(): number[];
  113443. set keysBackward(value: number[]);
  113444. /**
  113445. * Get the keys for camera movement up.
  113446. */
  113447. get keysUp(): number[];
  113448. /**
  113449. * Set the keys for camera movement up.
  113450. */
  113451. set keysUp(value: number[]);
  113452. /**
  113453. * Get the keys for camera movement down.
  113454. */
  113455. get keysDown(): number[];
  113456. /**
  113457. * Set the keys for camera movement down.
  113458. */
  113459. set keysDown(value: number[]);
  113460. /**
  113461. * Get the keys for camera movement left.
  113462. */
  113463. get keysLeft(): number[];
  113464. /**
  113465. * Set the keys for camera movement left.
  113466. */
  113467. set keysLeft(value: number[]);
  113468. /**
  113469. * Set the keys for camera movement right.
  113470. */
  113471. get keysRight(): number[];
  113472. /**
  113473. * Set the keys for camera movement right.
  113474. */
  113475. set keysRight(value: number[]);
  113476. /**
  113477. * Event raised when the camera collides with a mesh in the scene.
  113478. */
  113479. onCollide: (collidedMesh: AbstractMesh) => void;
  113480. private _collider;
  113481. private _needMoveForGravity;
  113482. private _oldPosition;
  113483. private _diffPosition;
  113484. private _newPosition;
  113485. /** @hidden */
  113486. _localDirection: Vector3;
  113487. /** @hidden */
  113488. _transformedDirection: Vector3;
  113489. /**
  113490. * Instantiates a FlyCamera.
  113491. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113492. * such as in a 3D Space Shooter or a Flight Simulator.
  113493. * @param name Define the name of the camera in the scene.
  113494. * @param position Define the starting position of the camera in the scene.
  113495. * @param scene Define the scene the camera belongs to.
  113496. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113497. */
  113498. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113499. /**
  113500. * Attach a control to the HTML DOM element.
  113501. * @param element Defines the element that listens to the input events.
  113502. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113503. */
  113504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113505. /**
  113506. * Detach a control from the HTML DOM element.
  113507. * The camera will stop reacting to that input.
  113508. * @param element Defines the element that listens to the input events.
  113509. */
  113510. detachControl(element: HTMLElement): void;
  113511. private _collisionMask;
  113512. /**
  113513. * Get the mask that the camera ignores in collision events.
  113514. */
  113515. get collisionMask(): number;
  113516. /**
  113517. * Set the mask that the camera ignores in collision events.
  113518. */
  113519. set collisionMask(mask: number);
  113520. /** @hidden */
  113521. _collideWithWorld(displacement: Vector3): void;
  113522. /** @hidden */
  113523. private _onCollisionPositionChange;
  113524. /** @hidden */
  113525. _checkInputs(): void;
  113526. /** @hidden */
  113527. _decideIfNeedsToMove(): boolean;
  113528. /** @hidden */
  113529. _updatePosition(): void;
  113530. /**
  113531. * Restore the Roll to its target value at the rate specified.
  113532. * @param rate - Higher means slower restoring.
  113533. * @hidden
  113534. */
  113535. restoreRoll(rate: number): void;
  113536. /**
  113537. * Destroy the camera and release the current resources held by it.
  113538. */
  113539. dispose(): void;
  113540. /**
  113541. * Get the current object class name.
  113542. * @returns the class name.
  113543. */
  113544. getClassName(): string;
  113545. }
  113546. }
  113547. declare module BABYLON {
  113548. /**
  113549. * Listen to keyboard events to control the camera.
  113550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113551. */
  113552. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113553. /**
  113554. * Defines the camera the input is attached to.
  113555. */
  113556. camera: FlyCamera;
  113557. /**
  113558. * The list of keyboard keys used to control the forward move of the camera.
  113559. */
  113560. keysForward: number[];
  113561. /**
  113562. * The list of keyboard keys used to control the backward move of the camera.
  113563. */
  113564. keysBackward: number[];
  113565. /**
  113566. * The list of keyboard keys used to control the forward move of the camera.
  113567. */
  113568. keysUp: number[];
  113569. /**
  113570. * The list of keyboard keys used to control the backward move of the camera.
  113571. */
  113572. keysDown: number[];
  113573. /**
  113574. * The list of keyboard keys used to control the right strafe move of the camera.
  113575. */
  113576. keysRight: number[];
  113577. /**
  113578. * The list of keyboard keys used to control the left strafe move of the camera.
  113579. */
  113580. keysLeft: number[];
  113581. private _keys;
  113582. private _onCanvasBlurObserver;
  113583. private _onKeyboardObserver;
  113584. private _engine;
  113585. private _scene;
  113586. /**
  113587. * Attach the input controls to a specific dom element to get the input from.
  113588. * @param element Defines the element the controls should be listened from
  113589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113590. */
  113591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113592. /**
  113593. * Detach the current controls from the specified dom element.
  113594. * @param element Defines the element to stop listening the inputs from
  113595. */
  113596. detachControl(element: Nullable<HTMLElement>): void;
  113597. /**
  113598. * Gets the class name of the current intput.
  113599. * @returns the class name
  113600. */
  113601. getClassName(): string;
  113602. /** @hidden */
  113603. _onLostFocus(e: FocusEvent): void;
  113604. /**
  113605. * Get the friendly name associated with the input class.
  113606. * @returns the input friendly name
  113607. */
  113608. getSimpleName(): string;
  113609. /**
  113610. * Update the current camera state depending on the inputs that have been used this frame.
  113611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113612. */
  113613. checkInputs(): void;
  113614. }
  113615. }
  113616. declare module BABYLON {
  113617. /**
  113618. * Manage the mouse wheel inputs to control a follow camera.
  113619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113620. */
  113621. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113622. /**
  113623. * Defines the camera the input is attached to.
  113624. */
  113625. camera: FollowCamera;
  113626. /**
  113627. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113628. */
  113629. axisControlRadius: boolean;
  113630. /**
  113631. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113632. */
  113633. axisControlHeight: boolean;
  113634. /**
  113635. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113636. */
  113637. axisControlRotation: boolean;
  113638. /**
  113639. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113640. * relation to mouseWheel events.
  113641. */
  113642. wheelPrecision: number;
  113643. /**
  113644. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113645. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113646. */
  113647. wheelDeltaPercentage: number;
  113648. private _wheel;
  113649. private _observer;
  113650. /**
  113651. * Attach the input controls to a specific dom element to get the input from.
  113652. * @param element Defines the element the controls should be listened from
  113653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113654. */
  113655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113656. /**
  113657. * Detach the current controls from the specified dom element.
  113658. * @param element Defines the element to stop listening the inputs from
  113659. */
  113660. detachControl(element: Nullable<HTMLElement>): void;
  113661. /**
  113662. * Gets the class name of the current intput.
  113663. * @returns the class name
  113664. */
  113665. getClassName(): string;
  113666. /**
  113667. * Get the friendly name associated with the input class.
  113668. * @returns the input friendly name
  113669. */
  113670. getSimpleName(): string;
  113671. }
  113672. }
  113673. declare module BABYLON {
  113674. /**
  113675. * Manage the pointers inputs to control an follow camera.
  113676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113677. */
  113678. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113679. /**
  113680. * Defines the camera the input is attached to.
  113681. */
  113682. camera: FollowCamera;
  113683. /**
  113684. * Gets the class name of the current input.
  113685. * @returns the class name
  113686. */
  113687. getClassName(): string;
  113688. /**
  113689. * Defines the pointer angular sensibility along the X axis or how fast is
  113690. * the camera rotating.
  113691. * A negative number will reverse the axis direction.
  113692. */
  113693. angularSensibilityX: number;
  113694. /**
  113695. * Defines the pointer angular sensibility along the Y axis or how fast is
  113696. * the camera rotating.
  113697. * A negative number will reverse the axis direction.
  113698. */
  113699. angularSensibilityY: number;
  113700. /**
  113701. * Defines the pointer pinch precision or how fast is the camera zooming.
  113702. * A negative number will reverse the axis direction.
  113703. */
  113704. pinchPrecision: number;
  113705. /**
  113706. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113707. * from 0.
  113708. * It defines the percentage of current camera.radius to use as delta when
  113709. * pinch zoom is used.
  113710. */
  113711. pinchDeltaPercentage: number;
  113712. /**
  113713. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113714. */
  113715. axisXControlRadius: boolean;
  113716. /**
  113717. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113718. */
  113719. axisXControlHeight: boolean;
  113720. /**
  113721. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113722. */
  113723. axisXControlRotation: boolean;
  113724. /**
  113725. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113726. */
  113727. axisYControlRadius: boolean;
  113728. /**
  113729. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113730. */
  113731. axisYControlHeight: boolean;
  113732. /**
  113733. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113734. */
  113735. axisYControlRotation: boolean;
  113736. /**
  113737. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113738. */
  113739. axisPinchControlRadius: boolean;
  113740. /**
  113741. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113742. */
  113743. axisPinchControlHeight: boolean;
  113744. /**
  113745. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113746. */
  113747. axisPinchControlRotation: boolean;
  113748. /**
  113749. * Log error messages if basic misconfiguration has occurred.
  113750. */
  113751. warningEnable: boolean;
  113752. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113753. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113754. private _warningCounter;
  113755. private _warning;
  113756. }
  113757. }
  113758. declare module BABYLON {
  113759. /**
  113760. * Default Inputs manager for the FollowCamera.
  113761. * It groups all the default supported inputs for ease of use.
  113762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113763. */
  113764. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113765. /**
  113766. * Instantiates a new FollowCameraInputsManager.
  113767. * @param camera Defines the camera the inputs belong to
  113768. */
  113769. constructor(camera: FollowCamera);
  113770. /**
  113771. * Add keyboard input support to the input manager.
  113772. * @returns the current input manager
  113773. */
  113774. addKeyboard(): FollowCameraInputsManager;
  113775. /**
  113776. * Add mouse wheel input support to the input manager.
  113777. * @returns the current input manager
  113778. */
  113779. addMouseWheel(): FollowCameraInputsManager;
  113780. /**
  113781. * Add pointers input support to the input manager.
  113782. * @returns the current input manager
  113783. */
  113784. addPointers(): FollowCameraInputsManager;
  113785. /**
  113786. * Add orientation input support to the input manager.
  113787. * @returns the current input manager
  113788. */
  113789. addVRDeviceOrientation(): FollowCameraInputsManager;
  113790. }
  113791. }
  113792. declare module BABYLON {
  113793. /**
  113794. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113795. * an arc rotate version arcFollowCamera are available.
  113796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113797. */
  113798. export class FollowCamera extends TargetCamera {
  113799. /**
  113800. * Distance the follow camera should follow an object at
  113801. */
  113802. radius: number;
  113803. /**
  113804. * Minimum allowed distance of the camera to the axis of rotation
  113805. * (The camera can not get closer).
  113806. * This can help limiting how the Camera is able to move in the scene.
  113807. */
  113808. lowerRadiusLimit: Nullable<number>;
  113809. /**
  113810. * Maximum allowed distance of the camera to the axis of rotation
  113811. * (The camera can not get further).
  113812. * This can help limiting how the Camera is able to move in the scene.
  113813. */
  113814. upperRadiusLimit: Nullable<number>;
  113815. /**
  113816. * Define a rotation offset between the camera and the object it follows
  113817. */
  113818. rotationOffset: number;
  113819. /**
  113820. * Minimum allowed angle to camera position relative to target object.
  113821. * This can help limiting how the Camera is able to move in the scene.
  113822. */
  113823. lowerRotationOffsetLimit: Nullable<number>;
  113824. /**
  113825. * Maximum allowed angle to camera position relative to target object.
  113826. * This can help limiting how the Camera is able to move in the scene.
  113827. */
  113828. upperRotationOffsetLimit: Nullable<number>;
  113829. /**
  113830. * Define a height offset between the camera and the object it follows.
  113831. * It can help following an object from the top (like a car chaing a plane)
  113832. */
  113833. heightOffset: number;
  113834. /**
  113835. * Minimum allowed height of camera position relative to target object.
  113836. * This can help limiting how the Camera is able to move in the scene.
  113837. */
  113838. lowerHeightOffsetLimit: Nullable<number>;
  113839. /**
  113840. * Maximum allowed height of camera position relative to target object.
  113841. * This can help limiting how the Camera is able to move in the scene.
  113842. */
  113843. upperHeightOffsetLimit: Nullable<number>;
  113844. /**
  113845. * Define how fast the camera can accelerate to follow it s target.
  113846. */
  113847. cameraAcceleration: number;
  113848. /**
  113849. * Define the speed limit of the camera following an object.
  113850. */
  113851. maxCameraSpeed: number;
  113852. /**
  113853. * Define the target of the camera.
  113854. */
  113855. lockedTarget: Nullable<AbstractMesh>;
  113856. /**
  113857. * Defines the input associated with the camera.
  113858. */
  113859. inputs: FollowCameraInputsManager;
  113860. /**
  113861. * Instantiates the follow camera.
  113862. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113863. * @param name Define the name of the camera in the scene
  113864. * @param position Define the position of the camera
  113865. * @param scene Define the scene the camera belong to
  113866. * @param lockedTarget Define the target of the camera
  113867. */
  113868. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113869. private _follow;
  113870. /**
  113871. * Attached controls to the current camera.
  113872. * @param element Defines the element the controls should be listened from
  113873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113874. */
  113875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113876. /**
  113877. * Detach the current controls from the camera.
  113878. * The camera will stop reacting to inputs.
  113879. * @param element Defines the element to stop listening the inputs from
  113880. */
  113881. detachControl(element: HTMLElement): void;
  113882. /** @hidden */
  113883. _checkInputs(): void;
  113884. private _checkLimits;
  113885. /**
  113886. * Gets the camera class name.
  113887. * @returns the class name
  113888. */
  113889. getClassName(): string;
  113890. }
  113891. /**
  113892. * Arc Rotate version of the follow camera.
  113893. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113894. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113895. */
  113896. export class ArcFollowCamera extends TargetCamera {
  113897. /** The longitudinal angle of the camera */
  113898. alpha: number;
  113899. /** The latitudinal angle of the camera */
  113900. beta: number;
  113901. /** The radius of the camera from its target */
  113902. radius: number;
  113903. /** Define the camera target (the messh it should follow) */
  113904. target: Nullable<AbstractMesh>;
  113905. private _cartesianCoordinates;
  113906. /**
  113907. * Instantiates a new ArcFollowCamera
  113908. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113909. * @param name Define the name of the camera
  113910. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113911. * @param beta Define the rotation angle of the camera around the elevation axis
  113912. * @param radius Define the radius of the camera from its target point
  113913. * @param target Define the target of the camera
  113914. * @param scene Define the scene the camera belongs to
  113915. */
  113916. constructor(name: string,
  113917. /** The longitudinal angle of the camera */
  113918. alpha: number,
  113919. /** The latitudinal angle of the camera */
  113920. beta: number,
  113921. /** The radius of the camera from its target */
  113922. radius: number,
  113923. /** Define the camera target (the messh it should follow) */
  113924. target: Nullable<AbstractMesh>, scene: Scene);
  113925. private _follow;
  113926. /** @hidden */
  113927. _checkInputs(): void;
  113928. /**
  113929. * Returns the class name of the object.
  113930. * It is mostly used internally for serialization purposes.
  113931. */
  113932. getClassName(): string;
  113933. }
  113934. }
  113935. declare module BABYLON {
  113936. /**
  113937. * Manage the keyboard inputs to control the movement of a follow camera.
  113938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113939. */
  113940. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113941. /**
  113942. * Defines the camera the input is attached to.
  113943. */
  113944. camera: FollowCamera;
  113945. /**
  113946. * Defines the list of key codes associated with the up action (increase heightOffset)
  113947. */
  113948. keysHeightOffsetIncr: number[];
  113949. /**
  113950. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113951. */
  113952. keysHeightOffsetDecr: number[];
  113953. /**
  113954. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113955. */
  113956. keysHeightOffsetModifierAlt: boolean;
  113957. /**
  113958. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113959. */
  113960. keysHeightOffsetModifierCtrl: boolean;
  113961. /**
  113962. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113963. */
  113964. keysHeightOffsetModifierShift: boolean;
  113965. /**
  113966. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113967. */
  113968. keysRotationOffsetIncr: number[];
  113969. /**
  113970. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113971. */
  113972. keysRotationOffsetDecr: number[];
  113973. /**
  113974. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113975. */
  113976. keysRotationOffsetModifierAlt: boolean;
  113977. /**
  113978. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113979. */
  113980. keysRotationOffsetModifierCtrl: boolean;
  113981. /**
  113982. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113983. */
  113984. keysRotationOffsetModifierShift: boolean;
  113985. /**
  113986. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113987. */
  113988. keysRadiusIncr: number[];
  113989. /**
  113990. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113991. */
  113992. keysRadiusDecr: number[];
  113993. /**
  113994. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113995. */
  113996. keysRadiusModifierAlt: boolean;
  113997. /**
  113998. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113999. */
  114000. keysRadiusModifierCtrl: boolean;
  114001. /**
  114002. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  114003. */
  114004. keysRadiusModifierShift: boolean;
  114005. /**
  114006. * Defines the rate of change of heightOffset.
  114007. */
  114008. heightSensibility: number;
  114009. /**
  114010. * Defines the rate of change of rotationOffset.
  114011. */
  114012. rotationSensibility: number;
  114013. /**
  114014. * Defines the rate of change of radius.
  114015. */
  114016. radiusSensibility: number;
  114017. private _keys;
  114018. private _ctrlPressed;
  114019. private _altPressed;
  114020. private _shiftPressed;
  114021. private _onCanvasBlurObserver;
  114022. private _onKeyboardObserver;
  114023. private _engine;
  114024. private _scene;
  114025. /**
  114026. * Attach the input controls to a specific dom element to get the input from.
  114027. * @param element Defines the element the controls should be listened from
  114028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114029. */
  114030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114031. /**
  114032. * Detach the current controls from the specified dom element.
  114033. * @param element Defines the element to stop listening the inputs from
  114034. */
  114035. detachControl(element: Nullable<HTMLElement>): void;
  114036. /**
  114037. * Update the current camera state depending on the inputs that have been used this frame.
  114038. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114039. */
  114040. checkInputs(): void;
  114041. /**
  114042. * Gets the class name of the current input.
  114043. * @returns the class name
  114044. */
  114045. getClassName(): string;
  114046. /**
  114047. * Get the friendly name associated with the input class.
  114048. * @returns the input friendly name
  114049. */
  114050. getSimpleName(): string;
  114051. /**
  114052. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114053. * allow modification of the heightOffset value.
  114054. */
  114055. private _modifierHeightOffset;
  114056. /**
  114057. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114058. * allow modification of the rotationOffset value.
  114059. */
  114060. private _modifierRotationOffset;
  114061. /**
  114062. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114063. * allow modification of the radius value.
  114064. */
  114065. private _modifierRadius;
  114066. }
  114067. }
  114068. declare module BABYLON {
  114069. interface FreeCameraInputsManager {
  114070. /**
  114071. * @hidden
  114072. */
  114073. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  114074. /**
  114075. * Add orientation input support to the input manager.
  114076. * @returns the current input manager
  114077. */
  114078. addDeviceOrientation(): FreeCameraInputsManager;
  114079. }
  114080. /**
  114081. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  114082. * Screen rotation is taken into account.
  114083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114084. */
  114085. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  114086. private _camera;
  114087. private _screenOrientationAngle;
  114088. private _constantTranform;
  114089. private _screenQuaternion;
  114090. private _alpha;
  114091. private _beta;
  114092. private _gamma;
  114093. /**
  114094. * Can be used to detect if a device orientation sensor is available on a device
  114095. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  114096. * @returns a promise that will resolve on orientation change
  114097. */
  114098. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  114099. /**
  114100. * @hidden
  114101. */
  114102. _onDeviceOrientationChangedObservable: Observable<void>;
  114103. /**
  114104. * Instantiates a new input
  114105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114106. */
  114107. constructor();
  114108. /**
  114109. * Define the camera controlled by the input.
  114110. */
  114111. get camera(): FreeCamera;
  114112. set camera(camera: FreeCamera);
  114113. /**
  114114. * Attach the input controls to a specific dom element to get the input from.
  114115. * @param element Defines the element the controls should be listened from
  114116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114117. */
  114118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114119. private _orientationChanged;
  114120. private _deviceOrientation;
  114121. /**
  114122. * Detach the current controls from the specified dom element.
  114123. * @param element Defines the element to stop listening the inputs from
  114124. */
  114125. detachControl(element: Nullable<HTMLElement>): void;
  114126. /**
  114127. * Update the current camera state depending on the inputs that have been used this frame.
  114128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114129. */
  114130. checkInputs(): void;
  114131. /**
  114132. * Gets the class name of the current intput.
  114133. * @returns the class name
  114134. */
  114135. getClassName(): string;
  114136. /**
  114137. * Get the friendly name associated with the input class.
  114138. * @returns the input friendly name
  114139. */
  114140. getSimpleName(): string;
  114141. }
  114142. }
  114143. declare module BABYLON {
  114144. /**
  114145. * Manage the gamepad inputs to control a free camera.
  114146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114147. */
  114148. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  114149. /**
  114150. * Define the camera the input is attached to.
  114151. */
  114152. camera: FreeCamera;
  114153. /**
  114154. * Define the Gamepad controlling the input
  114155. */
  114156. gamepad: Nullable<Gamepad>;
  114157. /**
  114158. * Defines the gamepad rotation sensiblity.
  114159. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114160. */
  114161. gamepadAngularSensibility: number;
  114162. /**
  114163. * Defines the gamepad move sensiblity.
  114164. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114165. */
  114166. gamepadMoveSensibility: number;
  114167. private _yAxisScale;
  114168. /**
  114169. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114170. */
  114171. get invertYAxis(): boolean;
  114172. set invertYAxis(value: boolean);
  114173. private _onGamepadConnectedObserver;
  114174. private _onGamepadDisconnectedObserver;
  114175. private _cameraTransform;
  114176. private _deltaTransform;
  114177. private _vector3;
  114178. private _vector2;
  114179. /**
  114180. * Attach the input controls to a specific dom element to get the input from.
  114181. * @param element Defines the element the controls should be listened from
  114182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114183. */
  114184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114185. /**
  114186. * Detach the current controls from the specified dom element.
  114187. * @param element Defines the element to stop listening the inputs from
  114188. */
  114189. detachControl(element: Nullable<HTMLElement>): void;
  114190. /**
  114191. * Update the current camera state depending on the inputs that have been used this frame.
  114192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114193. */
  114194. checkInputs(): void;
  114195. /**
  114196. * Gets the class name of the current intput.
  114197. * @returns the class name
  114198. */
  114199. getClassName(): string;
  114200. /**
  114201. * Get the friendly name associated with the input class.
  114202. * @returns the input friendly name
  114203. */
  114204. getSimpleName(): string;
  114205. }
  114206. }
  114207. declare module BABYLON {
  114208. /**
  114209. * Defines the potential axis of a Joystick
  114210. */
  114211. export enum JoystickAxis {
  114212. /** X axis */
  114213. X = 0,
  114214. /** Y axis */
  114215. Y = 1,
  114216. /** Z axis */
  114217. Z = 2
  114218. }
  114219. /**
  114220. * Class used to define virtual joystick (used in touch mode)
  114221. */
  114222. export class VirtualJoystick {
  114223. /**
  114224. * Gets or sets a boolean indicating that left and right values must be inverted
  114225. */
  114226. reverseLeftRight: boolean;
  114227. /**
  114228. * Gets or sets a boolean indicating that up and down values must be inverted
  114229. */
  114230. reverseUpDown: boolean;
  114231. /**
  114232. * Gets the offset value for the position (ie. the change of the position value)
  114233. */
  114234. deltaPosition: Vector3;
  114235. /**
  114236. * Gets a boolean indicating if the virtual joystick was pressed
  114237. */
  114238. pressed: boolean;
  114239. /**
  114240. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114241. */
  114242. static Canvas: Nullable<HTMLCanvasElement>;
  114243. private static _globalJoystickIndex;
  114244. private static vjCanvasContext;
  114245. private static vjCanvasWidth;
  114246. private static vjCanvasHeight;
  114247. private static halfWidth;
  114248. private _action;
  114249. private _axisTargetedByLeftAndRight;
  114250. private _axisTargetedByUpAndDown;
  114251. private _joystickSensibility;
  114252. private _inversedSensibility;
  114253. private _joystickPointerID;
  114254. private _joystickColor;
  114255. private _joystickPointerPos;
  114256. private _joystickPreviousPointerPos;
  114257. private _joystickPointerStartPos;
  114258. private _deltaJoystickVector;
  114259. private _leftJoystick;
  114260. private _touches;
  114261. private _onPointerDownHandlerRef;
  114262. private _onPointerMoveHandlerRef;
  114263. private _onPointerUpHandlerRef;
  114264. private _onResize;
  114265. /**
  114266. * Creates a new virtual joystick
  114267. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114268. */
  114269. constructor(leftJoystick?: boolean);
  114270. /**
  114271. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114272. * @param newJoystickSensibility defines the new sensibility
  114273. */
  114274. setJoystickSensibility(newJoystickSensibility: number): void;
  114275. private _onPointerDown;
  114276. private _onPointerMove;
  114277. private _onPointerUp;
  114278. /**
  114279. * Change the color of the virtual joystick
  114280. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114281. */
  114282. setJoystickColor(newColor: string): void;
  114283. /**
  114284. * Defines a callback to call when the joystick is touched
  114285. * @param action defines the callback
  114286. */
  114287. setActionOnTouch(action: () => any): void;
  114288. /**
  114289. * Defines which axis you'd like to control for left & right
  114290. * @param axis defines the axis to use
  114291. */
  114292. setAxisForLeftRight(axis: JoystickAxis): void;
  114293. /**
  114294. * Defines which axis you'd like to control for up & down
  114295. * @param axis defines the axis to use
  114296. */
  114297. setAxisForUpDown(axis: JoystickAxis): void;
  114298. private _drawVirtualJoystick;
  114299. /**
  114300. * Release internal HTML canvas
  114301. */
  114302. releaseCanvas(): void;
  114303. }
  114304. }
  114305. declare module BABYLON {
  114306. interface FreeCameraInputsManager {
  114307. /**
  114308. * Add virtual joystick input support to the input manager.
  114309. * @returns the current input manager
  114310. */
  114311. addVirtualJoystick(): FreeCameraInputsManager;
  114312. }
  114313. /**
  114314. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114316. */
  114317. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114318. /**
  114319. * Defines the camera the input is attached to.
  114320. */
  114321. camera: FreeCamera;
  114322. private _leftjoystick;
  114323. private _rightjoystick;
  114324. /**
  114325. * Gets the left stick of the virtual joystick.
  114326. * @returns The virtual Joystick
  114327. */
  114328. getLeftJoystick(): VirtualJoystick;
  114329. /**
  114330. * Gets the right stick of the virtual joystick.
  114331. * @returns The virtual Joystick
  114332. */
  114333. getRightJoystick(): VirtualJoystick;
  114334. /**
  114335. * Update the current camera state depending on the inputs that have been used this frame.
  114336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114337. */
  114338. checkInputs(): void;
  114339. /**
  114340. * Attach the input controls to a specific dom element to get the input from.
  114341. * @param element Defines the element the controls should be listened from
  114342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114343. */
  114344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114345. /**
  114346. * Detach the current controls from the specified dom element.
  114347. * @param element Defines the element to stop listening the inputs from
  114348. */
  114349. detachControl(element: Nullable<HTMLElement>): void;
  114350. /**
  114351. * Gets the class name of the current intput.
  114352. * @returns the class name
  114353. */
  114354. getClassName(): string;
  114355. /**
  114356. * Get the friendly name associated with the input class.
  114357. * @returns the input friendly name
  114358. */
  114359. getSimpleName(): string;
  114360. }
  114361. }
  114362. declare module BABYLON {
  114363. /**
  114364. * This represents a FPS type of camera controlled by touch.
  114365. * This is like a universal camera minus the Gamepad controls.
  114366. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114367. */
  114368. export class TouchCamera extends FreeCamera {
  114369. /**
  114370. * Defines the touch sensibility for rotation.
  114371. * The higher the faster.
  114372. */
  114373. get touchAngularSensibility(): number;
  114374. set touchAngularSensibility(value: number);
  114375. /**
  114376. * Defines the touch sensibility for move.
  114377. * The higher the faster.
  114378. */
  114379. get touchMoveSensibility(): number;
  114380. set touchMoveSensibility(value: number);
  114381. /**
  114382. * Instantiates a new touch camera.
  114383. * This represents a FPS type of camera controlled by touch.
  114384. * This is like a universal camera minus the Gamepad controls.
  114385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114386. * @param name Define the name of the camera in the scene
  114387. * @param position Define the start position of the camera in the scene
  114388. * @param scene Define the scene the camera belongs to
  114389. */
  114390. constructor(name: string, position: Vector3, scene: Scene);
  114391. /**
  114392. * Gets the current object class name.
  114393. * @return the class name
  114394. */
  114395. getClassName(): string;
  114396. /** @hidden */
  114397. _setupInputs(): void;
  114398. }
  114399. }
  114400. declare module BABYLON {
  114401. /**
  114402. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114403. * being tilted forward or back and left or right.
  114404. */
  114405. export class DeviceOrientationCamera extends FreeCamera {
  114406. private _initialQuaternion;
  114407. private _quaternionCache;
  114408. private _tmpDragQuaternion;
  114409. private _disablePointerInputWhenUsingDeviceOrientation;
  114410. /**
  114411. * Creates a new device orientation camera
  114412. * @param name The name of the camera
  114413. * @param position The start position camera
  114414. * @param scene The scene the camera belongs to
  114415. */
  114416. constructor(name: string, position: Vector3, scene: Scene);
  114417. /**
  114418. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114419. */
  114420. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114421. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114422. private _dragFactor;
  114423. /**
  114424. * Enabled turning on the y axis when the orientation sensor is active
  114425. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114426. */
  114427. enableHorizontalDragging(dragFactor?: number): void;
  114428. /**
  114429. * Gets the current instance class name ("DeviceOrientationCamera").
  114430. * This helps avoiding instanceof at run time.
  114431. * @returns the class name
  114432. */
  114433. getClassName(): string;
  114434. /**
  114435. * @hidden
  114436. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114437. */
  114438. _checkInputs(): void;
  114439. /**
  114440. * Reset the camera to its default orientation on the specified axis only.
  114441. * @param axis The axis to reset
  114442. */
  114443. resetToCurrentRotation(axis?: Axis): void;
  114444. }
  114445. }
  114446. declare module BABYLON {
  114447. /**
  114448. * Defines supported buttons for XBox360 compatible gamepads
  114449. */
  114450. export enum Xbox360Button {
  114451. /** A */
  114452. A = 0,
  114453. /** B */
  114454. B = 1,
  114455. /** X */
  114456. X = 2,
  114457. /** Y */
  114458. Y = 3,
  114459. /** Left button */
  114460. LB = 4,
  114461. /** Right button */
  114462. RB = 5,
  114463. /** Back */
  114464. Back = 8,
  114465. /** Start */
  114466. Start = 9,
  114467. /** Left stick */
  114468. LeftStick = 10,
  114469. /** Right stick */
  114470. RightStick = 11
  114471. }
  114472. /** Defines values for XBox360 DPad */
  114473. export enum Xbox360Dpad {
  114474. /** Up */
  114475. Up = 12,
  114476. /** Down */
  114477. Down = 13,
  114478. /** Left */
  114479. Left = 14,
  114480. /** Right */
  114481. Right = 15
  114482. }
  114483. /**
  114484. * Defines a XBox360 gamepad
  114485. */
  114486. export class Xbox360Pad extends Gamepad {
  114487. private _leftTrigger;
  114488. private _rightTrigger;
  114489. private _onlefttriggerchanged;
  114490. private _onrighttriggerchanged;
  114491. private _onbuttondown;
  114492. private _onbuttonup;
  114493. private _ondpaddown;
  114494. private _ondpadup;
  114495. /** Observable raised when a button is pressed */
  114496. onButtonDownObservable: Observable<Xbox360Button>;
  114497. /** Observable raised when a button is released */
  114498. onButtonUpObservable: Observable<Xbox360Button>;
  114499. /** Observable raised when a pad is pressed */
  114500. onPadDownObservable: Observable<Xbox360Dpad>;
  114501. /** Observable raised when a pad is released */
  114502. onPadUpObservable: Observable<Xbox360Dpad>;
  114503. private _buttonA;
  114504. private _buttonB;
  114505. private _buttonX;
  114506. private _buttonY;
  114507. private _buttonBack;
  114508. private _buttonStart;
  114509. private _buttonLB;
  114510. private _buttonRB;
  114511. private _buttonLeftStick;
  114512. private _buttonRightStick;
  114513. private _dPadUp;
  114514. private _dPadDown;
  114515. private _dPadLeft;
  114516. private _dPadRight;
  114517. private _isXboxOnePad;
  114518. /**
  114519. * Creates a new XBox360 gamepad object
  114520. * @param id defines the id of this gamepad
  114521. * @param index defines its index
  114522. * @param gamepad defines the internal HTML gamepad object
  114523. * @param xboxOne defines if it is a XBox One gamepad
  114524. */
  114525. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114526. /**
  114527. * Defines the callback to call when left trigger is pressed
  114528. * @param callback defines the callback to use
  114529. */
  114530. onlefttriggerchanged(callback: (value: number) => void): void;
  114531. /**
  114532. * Defines the callback to call when right trigger is pressed
  114533. * @param callback defines the callback to use
  114534. */
  114535. onrighttriggerchanged(callback: (value: number) => void): void;
  114536. /**
  114537. * Gets the left trigger value
  114538. */
  114539. get leftTrigger(): number;
  114540. /**
  114541. * Sets the left trigger value
  114542. */
  114543. set leftTrigger(newValue: number);
  114544. /**
  114545. * Gets the right trigger value
  114546. */
  114547. get rightTrigger(): number;
  114548. /**
  114549. * Sets the right trigger value
  114550. */
  114551. set rightTrigger(newValue: number);
  114552. /**
  114553. * Defines the callback to call when a button is pressed
  114554. * @param callback defines the callback to use
  114555. */
  114556. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114557. /**
  114558. * Defines the callback to call when a button is released
  114559. * @param callback defines the callback to use
  114560. */
  114561. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114562. /**
  114563. * Defines the callback to call when a pad is pressed
  114564. * @param callback defines the callback to use
  114565. */
  114566. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114567. /**
  114568. * Defines the callback to call when a pad is released
  114569. * @param callback defines the callback to use
  114570. */
  114571. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114572. private _setButtonValue;
  114573. private _setDPadValue;
  114574. /**
  114575. * Gets the value of the `A` button
  114576. */
  114577. get buttonA(): number;
  114578. /**
  114579. * Sets the value of the `A` button
  114580. */
  114581. set buttonA(value: number);
  114582. /**
  114583. * Gets the value of the `B` button
  114584. */
  114585. get buttonB(): number;
  114586. /**
  114587. * Sets the value of the `B` button
  114588. */
  114589. set buttonB(value: number);
  114590. /**
  114591. * Gets the value of the `X` button
  114592. */
  114593. get buttonX(): number;
  114594. /**
  114595. * Sets the value of the `X` button
  114596. */
  114597. set buttonX(value: number);
  114598. /**
  114599. * Gets the value of the `Y` button
  114600. */
  114601. get buttonY(): number;
  114602. /**
  114603. * Sets the value of the `Y` button
  114604. */
  114605. set buttonY(value: number);
  114606. /**
  114607. * Gets the value of the `Start` button
  114608. */
  114609. get buttonStart(): number;
  114610. /**
  114611. * Sets the value of the `Start` button
  114612. */
  114613. set buttonStart(value: number);
  114614. /**
  114615. * Gets the value of the `Back` button
  114616. */
  114617. get buttonBack(): number;
  114618. /**
  114619. * Sets the value of the `Back` button
  114620. */
  114621. set buttonBack(value: number);
  114622. /**
  114623. * Gets the value of the `Left` button
  114624. */
  114625. get buttonLB(): number;
  114626. /**
  114627. * Sets the value of the `Left` button
  114628. */
  114629. set buttonLB(value: number);
  114630. /**
  114631. * Gets the value of the `Right` button
  114632. */
  114633. get buttonRB(): number;
  114634. /**
  114635. * Sets the value of the `Right` button
  114636. */
  114637. set buttonRB(value: number);
  114638. /**
  114639. * Gets the value of the Left joystick
  114640. */
  114641. get buttonLeftStick(): number;
  114642. /**
  114643. * Sets the value of the Left joystick
  114644. */
  114645. set buttonLeftStick(value: number);
  114646. /**
  114647. * Gets the value of the Right joystick
  114648. */
  114649. get buttonRightStick(): number;
  114650. /**
  114651. * Sets the value of the Right joystick
  114652. */
  114653. set buttonRightStick(value: number);
  114654. /**
  114655. * Gets the value of D-pad up
  114656. */
  114657. get dPadUp(): number;
  114658. /**
  114659. * Sets the value of D-pad up
  114660. */
  114661. set dPadUp(value: number);
  114662. /**
  114663. * Gets the value of D-pad down
  114664. */
  114665. get dPadDown(): number;
  114666. /**
  114667. * Sets the value of D-pad down
  114668. */
  114669. set dPadDown(value: number);
  114670. /**
  114671. * Gets the value of D-pad left
  114672. */
  114673. get dPadLeft(): number;
  114674. /**
  114675. * Sets the value of D-pad left
  114676. */
  114677. set dPadLeft(value: number);
  114678. /**
  114679. * Gets the value of D-pad right
  114680. */
  114681. get dPadRight(): number;
  114682. /**
  114683. * Sets the value of D-pad right
  114684. */
  114685. set dPadRight(value: number);
  114686. /**
  114687. * Force the gamepad to synchronize with device values
  114688. */
  114689. update(): void;
  114690. /**
  114691. * Disposes the gamepad
  114692. */
  114693. dispose(): void;
  114694. }
  114695. }
  114696. declare module BABYLON {
  114697. /**
  114698. * Defines supported buttons for DualShock compatible gamepads
  114699. */
  114700. export enum DualShockButton {
  114701. /** Cross */
  114702. Cross = 0,
  114703. /** Circle */
  114704. Circle = 1,
  114705. /** Square */
  114706. Square = 2,
  114707. /** Triangle */
  114708. Triangle = 3,
  114709. /** L1 */
  114710. L1 = 4,
  114711. /** R1 */
  114712. R1 = 5,
  114713. /** Share */
  114714. Share = 8,
  114715. /** Options */
  114716. Options = 9,
  114717. /** Left stick */
  114718. LeftStick = 10,
  114719. /** Right stick */
  114720. RightStick = 11
  114721. }
  114722. /** Defines values for DualShock DPad */
  114723. export enum DualShockDpad {
  114724. /** Up */
  114725. Up = 12,
  114726. /** Down */
  114727. Down = 13,
  114728. /** Left */
  114729. Left = 14,
  114730. /** Right */
  114731. Right = 15
  114732. }
  114733. /**
  114734. * Defines a DualShock gamepad
  114735. */
  114736. export class DualShockPad extends Gamepad {
  114737. private _leftTrigger;
  114738. private _rightTrigger;
  114739. private _onlefttriggerchanged;
  114740. private _onrighttriggerchanged;
  114741. private _onbuttondown;
  114742. private _onbuttonup;
  114743. private _ondpaddown;
  114744. private _ondpadup;
  114745. /** Observable raised when a button is pressed */
  114746. onButtonDownObservable: Observable<DualShockButton>;
  114747. /** Observable raised when a button is released */
  114748. onButtonUpObservable: Observable<DualShockButton>;
  114749. /** Observable raised when a pad is pressed */
  114750. onPadDownObservable: Observable<DualShockDpad>;
  114751. /** Observable raised when a pad is released */
  114752. onPadUpObservable: Observable<DualShockDpad>;
  114753. private _buttonCross;
  114754. private _buttonCircle;
  114755. private _buttonSquare;
  114756. private _buttonTriangle;
  114757. private _buttonShare;
  114758. private _buttonOptions;
  114759. private _buttonL1;
  114760. private _buttonR1;
  114761. private _buttonLeftStick;
  114762. private _buttonRightStick;
  114763. private _dPadUp;
  114764. private _dPadDown;
  114765. private _dPadLeft;
  114766. private _dPadRight;
  114767. /**
  114768. * Creates a new DualShock gamepad object
  114769. * @param id defines the id of this gamepad
  114770. * @param index defines its index
  114771. * @param gamepad defines the internal HTML gamepad object
  114772. */
  114773. constructor(id: string, index: number, gamepad: any);
  114774. /**
  114775. * Defines the callback to call when left trigger is pressed
  114776. * @param callback defines the callback to use
  114777. */
  114778. onlefttriggerchanged(callback: (value: number) => void): void;
  114779. /**
  114780. * Defines the callback to call when right trigger is pressed
  114781. * @param callback defines the callback to use
  114782. */
  114783. onrighttriggerchanged(callback: (value: number) => void): void;
  114784. /**
  114785. * Gets the left trigger value
  114786. */
  114787. get leftTrigger(): number;
  114788. /**
  114789. * Sets the left trigger value
  114790. */
  114791. set leftTrigger(newValue: number);
  114792. /**
  114793. * Gets the right trigger value
  114794. */
  114795. get rightTrigger(): number;
  114796. /**
  114797. * Sets the right trigger value
  114798. */
  114799. set rightTrigger(newValue: number);
  114800. /**
  114801. * Defines the callback to call when a button is pressed
  114802. * @param callback defines the callback to use
  114803. */
  114804. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114805. /**
  114806. * Defines the callback to call when a button is released
  114807. * @param callback defines the callback to use
  114808. */
  114809. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114810. /**
  114811. * Defines the callback to call when a pad is pressed
  114812. * @param callback defines the callback to use
  114813. */
  114814. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114815. /**
  114816. * Defines the callback to call when a pad is released
  114817. * @param callback defines the callback to use
  114818. */
  114819. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114820. private _setButtonValue;
  114821. private _setDPadValue;
  114822. /**
  114823. * Gets the value of the `Cross` button
  114824. */
  114825. get buttonCross(): number;
  114826. /**
  114827. * Sets the value of the `Cross` button
  114828. */
  114829. set buttonCross(value: number);
  114830. /**
  114831. * Gets the value of the `Circle` button
  114832. */
  114833. get buttonCircle(): number;
  114834. /**
  114835. * Sets the value of the `Circle` button
  114836. */
  114837. set buttonCircle(value: number);
  114838. /**
  114839. * Gets the value of the `Square` button
  114840. */
  114841. get buttonSquare(): number;
  114842. /**
  114843. * Sets the value of the `Square` button
  114844. */
  114845. set buttonSquare(value: number);
  114846. /**
  114847. * Gets the value of the `Triangle` button
  114848. */
  114849. get buttonTriangle(): number;
  114850. /**
  114851. * Sets the value of the `Triangle` button
  114852. */
  114853. set buttonTriangle(value: number);
  114854. /**
  114855. * Gets the value of the `Options` button
  114856. */
  114857. get buttonOptions(): number;
  114858. /**
  114859. * Sets the value of the `Options` button
  114860. */
  114861. set buttonOptions(value: number);
  114862. /**
  114863. * Gets the value of the `Share` button
  114864. */
  114865. get buttonShare(): number;
  114866. /**
  114867. * Sets the value of the `Share` button
  114868. */
  114869. set buttonShare(value: number);
  114870. /**
  114871. * Gets the value of the `L1` button
  114872. */
  114873. get buttonL1(): number;
  114874. /**
  114875. * Sets the value of the `L1` button
  114876. */
  114877. set buttonL1(value: number);
  114878. /**
  114879. * Gets the value of the `R1` button
  114880. */
  114881. get buttonR1(): number;
  114882. /**
  114883. * Sets the value of the `R1` button
  114884. */
  114885. set buttonR1(value: number);
  114886. /**
  114887. * Gets the value of the Left joystick
  114888. */
  114889. get buttonLeftStick(): number;
  114890. /**
  114891. * Sets the value of the Left joystick
  114892. */
  114893. set buttonLeftStick(value: number);
  114894. /**
  114895. * Gets the value of the Right joystick
  114896. */
  114897. get buttonRightStick(): number;
  114898. /**
  114899. * Sets the value of the Right joystick
  114900. */
  114901. set buttonRightStick(value: number);
  114902. /**
  114903. * Gets the value of D-pad up
  114904. */
  114905. get dPadUp(): number;
  114906. /**
  114907. * Sets the value of D-pad up
  114908. */
  114909. set dPadUp(value: number);
  114910. /**
  114911. * Gets the value of D-pad down
  114912. */
  114913. get dPadDown(): number;
  114914. /**
  114915. * Sets the value of D-pad down
  114916. */
  114917. set dPadDown(value: number);
  114918. /**
  114919. * Gets the value of D-pad left
  114920. */
  114921. get dPadLeft(): number;
  114922. /**
  114923. * Sets the value of D-pad left
  114924. */
  114925. set dPadLeft(value: number);
  114926. /**
  114927. * Gets the value of D-pad right
  114928. */
  114929. get dPadRight(): number;
  114930. /**
  114931. * Sets the value of D-pad right
  114932. */
  114933. set dPadRight(value: number);
  114934. /**
  114935. * Force the gamepad to synchronize with device values
  114936. */
  114937. update(): void;
  114938. /**
  114939. * Disposes the gamepad
  114940. */
  114941. dispose(): void;
  114942. }
  114943. }
  114944. declare module BABYLON {
  114945. /**
  114946. * Manager for handling gamepads
  114947. */
  114948. export class GamepadManager {
  114949. private _scene?;
  114950. private _babylonGamepads;
  114951. private _oneGamepadConnected;
  114952. /** @hidden */
  114953. _isMonitoring: boolean;
  114954. private _gamepadEventSupported;
  114955. private _gamepadSupport?;
  114956. /**
  114957. * observable to be triggered when the gamepad controller has been connected
  114958. */
  114959. onGamepadConnectedObservable: Observable<Gamepad>;
  114960. /**
  114961. * observable to be triggered when the gamepad controller has been disconnected
  114962. */
  114963. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114964. private _onGamepadConnectedEvent;
  114965. private _onGamepadDisconnectedEvent;
  114966. /**
  114967. * Initializes the gamepad manager
  114968. * @param _scene BabylonJS scene
  114969. */
  114970. constructor(_scene?: Scene | undefined);
  114971. /**
  114972. * The gamepads in the game pad manager
  114973. */
  114974. get gamepads(): Gamepad[];
  114975. /**
  114976. * Get the gamepad controllers based on type
  114977. * @param type The type of gamepad controller
  114978. * @returns Nullable gamepad
  114979. */
  114980. getGamepadByType(type?: number): Nullable<Gamepad>;
  114981. /**
  114982. * Disposes the gamepad manager
  114983. */
  114984. dispose(): void;
  114985. private _addNewGamepad;
  114986. private _startMonitoringGamepads;
  114987. private _stopMonitoringGamepads;
  114988. /** @hidden */
  114989. _checkGamepadsStatus(): void;
  114990. private _updateGamepadObjects;
  114991. }
  114992. }
  114993. declare module BABYLON {
  114994. interface Scene {
  114995. /** @hidden */
  114996. _gamepadManager: Nullable<GamepadManager>;
  114997. /**
  114998. * Gets the gamepad manager associated with the scene
  114999. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  115000. */
  115001. gamepadManager: GamepadManager;
  115002. }
  115003. /**
  115004. * Interface representing a free camera inputs manager
  115005. */
  115006. interface FreeCameraInputsManager {
  115007. /**
  115008. * Adds gamepad input support to the FreeCameraInputsManager.
  115009. * @returns the FreeCameraInputsManager
  115010. */
  115011. addGamepad(): FreeCameraInputsManager;
  115012. }
  115013. /**
  115014. * Interface representing an arc rotate camera inputs manager
  115015. */
  115016. interface ArcRotateCameraInputsManager {
  115017. /**
  115018. * Adds gamepad input support to the ArcRotateCamera InputManager.
  115019. * @returns the camera inputs manager
  115020. */
  115021. addGamepad(): ArcRotateCameraInputsManager;
  115022. }
  115023. /**
  115024. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  115025. */
  115026. export class GamepadSystemSceneComponent implements ISceneComponent {
  115027. /**
  115028. * The component name helpfull to identify the component in the list of scene components.
  115029. */
  115030. readonly name: string;
  115031. /**
  115032. * The scene the component belongs to.
  115033. */
  115034. scene: Scene;
  115035. /**
  115036. * Creates a new instance of the component for the given scene
  115037. * @param scene Defines the scene to register the component in
  115038. */
  115039. constructor(scene: Scene);
  115040. /**
  115041. * Registers the component in a given scene
  115042. */
  115043. register(): void;
  115044. /**
  115045. * Rebuilds the elements related to this component in case of
  115046. * context lost for instance.
  115047. */
  115048. rebuild(): void;
  115049. /**
  115050. * Disposes the component and the associated ressources
  115051. */
  115052. dispose(): void;
  115053. private _beforeCameraUpdate;
  115054. }
  115055. }
  115056. declare module BABYLON {
  115057. /**
  115058. * 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,
  115059. * which still works and will still be found in many Playgrounds.
  115060. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115061. */
  115062. export class UniversalCamera extends TouchCamera {
  115063. /**
  115064. * Defines the gamepad rotation sensiblity.
  115065. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115066. */
  115067. get gamepadAngularSensibility(): number;
  115068. set gamepadAngularSensibility(value: number);
  115069. /**
  115070. * Defines the gamepad move sensiblity.
  115071. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115072. */
  115073. get gamepadMoveSensibility(): number;
  115074. set gamepadMoveSensibility(value: number);
  115075. /**
  115076. * 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,
  115077. * which still works and will still be found in many Playgrounds.
  115078. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115079. * @param name Define the name of the camera in the scene
  115080. * @param position Define the start position of the camera in the scene
  115081. * @param scene Define the scene the camera belongs to
  115082. */
  115083. constructor(name: string, position: Vector3, scene: Scene);
  115084. /**
  115085. * Gets the current object class name.
  115086. * @return the class name
  115087. */
  115088. getClassName(): string;
  115089. }
  115090. }
  115091. declare module BABYLON {
  115092. /**
  115093. * This represents a FPS type of camera. This is only here for back compat purpose.
  115094. * Please use the UniversalCamera instead as both are identical.
  115095. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115096. */
  115097. export class GamepadCamera extends UniversalCamera {
  115098. /**
  115099. * Instantiates a new Gamepad Camera
  115100. * This represents a FPS type of camera. This is only here for back compat purpose.
  115101. * Please use the UniversalCamera instead as both are identical.
  115102. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115103. * @param name Define the name of the camera in the scene
  115104. * @param position Define the start position of the camera in the scene
  115105. * @param scene Define the scene the camera belongs to
  115106. */
  115107. constructor(name: string, position: Vector3, scene: Scene);
  115108. /**
  115109. * Gets the current object class name.
  115110. * @return the class name
  115111. */
  115112. getClassName(): string;
  115113. }
  115114. }
  115115. declare module BABYLON {
  115116. /** @hidden */
  115117. export var passPixelShader: {
  115118. name: string;
  115119. shader: string;
  115120. };
  115121. }
  115122. declare module BABYLON {
  115123. /** @hidden */
  115124. export var passCubePixelShader: {
  115125. name: string;
  115126. shader: string;
  115127. };
  115128. }
  115129. declare module BABYLON {
  115130. /**
  115131. * PassPostProcess which produces an output the same as it's input
  115132. */
  115133. export class PassPostProcess extends PostProcess {
  115134. /**
  115135. * Creates the PassPostProcess
  115136. * @param name The name of the effect.
  115137. * @param options The required width/height ratio to downsize to before computing the render pass.
  115138. * @param camera The camera to apply the render pass to.
  115139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115140. * @param engine The engine which the post process will be applied. (default: current engine)
  115141. * @param reusable If the post process can be reused on the same frame. (default: false)
  115142. * @param textureType The type of texture to be used when performing the post processing.
  115143. * @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)
  115144. */
  115145. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115146. }
  115147. /**
  115148. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  115149. */
  115150. export class PassCubePostProcess extends PostProcess {
  115151. private _face;
  115152. /**
  115153. * Gets or sets the cube face to display.
  115154. * * 0 is +X
  115155. * * 1 is -X
  115156. * * 2 is +Y
  115157. * * 3 is -Y
  115158. * * 4 is +Z
  115159. * * 5 is -Z
  115160. */
  115161. get face(): number;
  115162. set face(value: number);
  115163. /**
  115164. * Creates the PassCubePostProcess
  115165. * @param name The name of the effect.
  115166. * @param options The required width/height ratio to downsize to before computing the render pass.
  115167. * @param camera The camera to apply the render pass to.
  115168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115169. * @param engine The engine which the post process will be applied. (default: current engine)
  115170. * @param reusable If the post process can be reused on the same frame. (default: false)
  115171. * @param textureType The type of texture to be used when performing the post processing.
  115172. * @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)
  115173. */
  115174. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115175. }
  115176. }
  115177. declare module BABYLON {
  115178. /** @hidden */
  115179. export var anaglyphPixelShader: {
  115180. name: string;
  115181. shader: string;
  115182. };
  115183. }
  115184. declare module BABYLON {
  115185. /**
  115186. * Postprocess used to generate anaglyphic rendering
  115187. */
  115188. export class AnaglyphPostProcess extends PostProcess {
  115189. private _passedProcess;
  115190. /**
  115191. * Creates a new AnaglyphPostProcess
  115192. * @param name defines postprocess name
  115193. * @param options defines creation options or target ratio scale
  115194. * @param rigCameras defines cameras using this postprocess
  115195. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115196. * @param engine defines hosting engine
  115197. * @param reusable defines if the postprocess will be reused multiple times per frame
  115198. */
  115199. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115200. }
  115201. }
  115202. declare module BABYLON {
  115203. /**
  115204. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115205. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115206. */
  115207. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115208. /**
  115209. * Creates a new AnaglyphArcRotateCamera
  115210. * @param name defines camera name
  115211. * @param alpha defines alpha angle (in radians)
  115212. * @param beta defines beta angle (in radians)
  115213. * @param radius defines radius
  115214. * @param target defines camera target
  115215. * @param interaxialDistance defines distance between each color axis
  115216. * @param scene defines the hosting scene
  115217. */
  115218. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115219. /**
  115220. * Gets camera class name
  115221. * @returns AnaglyphArcRotateCamera
  115222. */
  115223. getClassName(): string;
  115224. }
  115225. }
  115226. declare module BABYLON {
  115227. /**
  115228. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115229. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115230. */
  115231. export class AnaglyphFreeCamera extends FreeCamera {
  115232. /**
  115233. * Creates a new AnaglyphFreeCamera
  115234. * @param name defines camera name
  115235. * @param position defines initial position
  115236. * @param interaxialDistance defines distance between each color axis
  115237. * @param scene defines the hosting scene
  115238. */
  115239. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115240. /**
  115241. * Gets camera class name
  115242. * @returns AnaglyphFreeCamera
  115243. */
  115244. getClassName(): string;
  115245. }
  115246. }
  115247. declare module BABYLON {
  115248. /**
  115249. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115250. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115251. */
  115252. export class AnaglyphGamepadCamera extends GamepadCamera {
  115253. /**
  115254. * Creates a new AnaglyphGamepadCamera
  115255. * @param name defines camera name
  115256. * @param position defines initial position
  115257. * @param interaxialDistance defines distance between each color axis
  115258. * @param scene defines the hosting scene
  115259. */
  115260. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115261. /**
  115262. * Gets camera class name
  115263. * @returns AnaglyphGamepadCamera
  115264. */
  115265. getClassName(): string;
  115266. }
  115267. }
  115268. declare module BABYLON {
  115269. /**
  115270. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115271. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115272. */
  115273. export class AnaglyphUniversalCamera extends UniversalCamera {
  115274. /**
  115275. * Creates a new AnaglyphUniversalCamera
  115276. * @param name defines camera name
  115277. * @param position defines initial position
  115278. * @param interaxialDistance defines distance between each color axis
  115279. * @param scene defines the hosting scene
  115280. */
  115281. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115282. /**
  115283. * Gets camera class name
  115284. * @returns AnaglyphUniversalCamera
  115285. */
  115286. getClassName(): string;
  115287. }
  115288. }
  115289. declare module BABYLON {
  115290. /** @hidden */
  115291. export var stereoscopicInterlacePixelShader: {
  115292. name: string;
  115293. shader: string;
  115294. };
  115295. }
  115296. declare module BABYLON {
  115297. /**
  115298. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115299. */
  115300. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115301. private _stepSize;
  115302. private _passedProcess;
  115303. /**
  115304. * Initializes a StereoscopicInterlacePostProcessI
  115305. * @param name The name of the effect.
  115306. * @param rigCameras The rig cameras to be appled to the post process
  115307. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115308. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115310. * @param engine The engine which the post process will be applied. (default: current engine)
  115311. * @param reusable If the post process can be reused on the same frame. (default: false)
  115312. */
  115313. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115314. }
  115315. /**
  115316. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115317. */
  115318. export class StereoscopicInterlacePostProcess extends PostProcess {
  115319. private _stepSize;
  115320. private _passedProcess;
  115321. /**
  115322. * Initializes a StereoscopicInterlacePostProcess
  115323. * @param name The name of the effect.
  115324. * @param rigCameras The rig cameras to be appled to the post process
  115325. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115327. * @param engine The engine which the post process will be applied. (default: current engine)
  115328. * @param reusable If the post process can be reused on the same frame. (default: false)
  115329. */
  115330. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115331. }
  115332. }
  115333. declare module BABYLON {
  115334. /**
  115335. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115336. * @see http://doc.babylonjs.com/features/cameras
  115337. */
  115338. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115339. /**
  115340. * Creates a new StereoscopicArcRotateCamera
  115341. * @param name defines camera name
  115342. * @param alpha defines alpha angle (in radians)
  115343. * @param beta defines beta angle (in radians)
  115344. * @param radius defines radius
  115345. * @param target defines camera target
  115346. * @param interaxialDistance defines distance between each color axis
  115347. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115348. * @param scene defines the hosting scene
  115349. */
  115350. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115351. /**
  115352. * Gets camera class name
  115353. * @returns StereoscopicArcRotateCamera
  115354. */
  115355. getClassName(): string;
  115356. }
  115357. }
  115358. declare module BABYLON {
  115359. /**
  115360. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115361. * @see http://doc.babylonjs.com/features/cameras
  115362. */
  115363. export class StereoscopicFreeCamera extends FreeCamera {
  115364. /**
  115365. * Creates a new StereoscopicFreeCamera
  115366. * @param name defines camera name
  115367. * @param position defines initial position
  115368. * @param interaxialDistance defines distance between each color axis
  115369. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115370. * @param scene defines the hosting scene
  115371. */
  115372. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115373. /**
  115374. * Gets camera class name
  115375. * @returns StereoscopicFreeCamera
  115376. */
  115377. getClassName(): string;
  115378. }
  115379. }
  115380. declare module BABYLON {
  115381. /**
  115382. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115383. * @see http://doc.babylonjs.com/features/cameras
  115384. */
  115385. export class StereoscopicGamepadCamera extends GamepadCamera {
  115386. /**
  115387. * Creates a new StereoscopicGamepadCamera
  115388. * @param name defines camera name
  115389. * @param position defines initial position
  115390. * @param interaxialDistance defines distance between each color axis
  115391. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115392. * @param scene defines the hosting scene
  115393. */
  115394. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115395. /**
  115396. * Gets camera class name
  115397. * @returns StereoscopicGamepadCamera
  115398. */
  115399. getClassName(): string;
  115400. }
  115401. }
  115402. declare module BABYLON {
  115403. /**
  115404. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115405. * @see http://doc.babylonjs.com/features/cameras
  115406. */
  115407. export class StereoscopicUniversalCamera extends UniversalCamera {
  115408. /**
  115409. * Creates a new StereoscopicUniversalCamera
  115410. * @param name defines camera name
  115411. * @param position defines initial position
  115412. * @param interaxialDistance defines distance between each color axis
  115413. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115414. * @param scene defines the hosting scene
  115415. */
  115416. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115417. /**
  115418. * Gets camera class name
  115419. * @returns StereoscopicUniversalCamera
  115420. */
  115421. getClassName(): string;
  115422. }
  115423. }
  115424. declare module BABYLON {
  115425. /**
  115426. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115427. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115428. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115429. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115430. */
  115431. export class VirtualJoysticksCamera extends FreeCamera {
  115432. /**
  115433. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115434. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115435. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115436. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115437. * @param name Define the name of the camera in the scene
  115438. * @param position Define the start position of the camera in the scene
  115439. * @param scene Define the scene the camera belongs to
  115440. */
  115441. constructor(name: string, position: Vector3, scene: Scene);
  115442. /**
  115443. * Gets the current object class name.
  115444. * @return the class name
  115445. */
  115446. getClassName(): string;
  115447. }
  115448. }
  115449. declare module BABYLON {
  115450. /**
  115451. * This represents all the required metrics to create a VR camera.
  115452. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115453. */
  115454. export class VRCameraMetrics {
  115455. /**
  115456. * Define the horizontal resolution off the screen.
  115457. */
  115458. hResolution: number;
  115459. /**
  115460. * Define the vertical resolution off the screen.
  115461. */
  115462. vResolution: number;
  115463. /**
  115464. * Define the horizontal screen size.
  115465. */
  115466. hScreenSize: number;
  115467. /**
  115468. * Define the vertical screen size.
  115469. */
  115470. vScreenSize: number;
  115471. /**
  115472. * Define the vertical screen center position.
  115473. */
  115474. vScreenCenter: number;
  115475. /**
  115476. * Define the distance of the eyes to the screen.
  115477. */
  115478. eyeToScreenDistance: number;
  115479. /**
  115480. * Define the distance between both lenses
  115481. */
  115482. lensSeparationDistance: number;
  115483. /**
  115484. * Define the distance between both viewer's eyes.
  115485. */
  115486. interpupillaryDistance: number;
  115487. /**
  115488. * Define the distortion factor of the VR postprocess.
  115489. * Please, touch with care.
  115490. */
  115491. distortionK: number[];
  115492. /**
  115493. * Define the chromatic aberration correction factors for the VR post process.
  115494. */
  115495. chromaAbCorrection: number[];
  115496. /**
  115497. * Define the scale factor of the post process.
  115498. * The smaller the better but the slower.
  115499. */
  115500. postProcessScaleFactor: number;
  115501. /**
  115502. * Define an offset for the lens center.
  115503. */
  115504. lensCenterOffset: number;
  115505. /**
  115506. * Define if the current vr camera should compensate the distortion of the lense or not.
  115507. */
  115508. compensateDistortion: boolean;
  115509. /**
  115510. * Defines if multiview should be enabled when rendering (Default: false)
  115511. */
  115512. multiviewEnabled: boolean;
  115513. /**
  115514. * Gets the rendering aspect ratio based on the provided resolutions.
  115515. */
  115516. get aspectRatio(): number;
  115517. /**
  115518. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115519. */
  115520. get aspectRatioFov(): number;
  115521. /**
  115522. * @hidden
  115523. */
  115524. get leftHMatrix(): Matrix;
  115525. /**
  115526. * @hidden
  115527. */
  115528. get rightHMatrix(): Matrix;
  115529. /**
  115530. * @hidden
  115531. */
  115532. get leftPreViewMatrix(): Matrix;
  115533. /**
  115534. * @hidden
  115535. */
  115536. get rightPreViewMatrix(): Matrix;
  115537. /**
  115538. * Get the default VRMetrics based on the most generic setup.
  115539. * @returns the default vr metrics
  115540. */
  115541. static GetDefault(): VRCameraMetrics;
  115542. }
  115543. }
  115544. declare module BABYLON {
  115545. /** @hidden */
  115546. export var vrDistortionCorrectionPixelShader: {
  115547. name: string;
  115548. shader: string;
  115549. };
  115550. }
  115551. declare module BABYLON {
  115552. /**
  115553. * VRDistortionCorrectionPostProcess used for mobile VR
  115554. */
  115555. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115556. private _isRightEye;
  115557. private _distortionFactors;
  115558. private _postProcessScaleFactor;
  115559. private _lensCenterOffset;
  115560. private _scaleIn;
  115561. private _scaleFactor;
  115562. private _lensCenter;
  115563. /**
  115564. * Initializes the VRDistortionCorrectionPostProcess
  115565. * @param name The name of the effect.
  115566. * @param camera The camera to apply the render pass to.
  115567. * @param isRightEye If this is for the right eye distortion
  115568. * @param vrMetrics All the required metrics for the VR camera
  115569. */
  115570. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115571. }
  115572. }
  115573. declare module BABYLON {
  115574. /**
  115575. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115576. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115577. */
  115578. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115579. /**
  115580. * Creates a new VRDeviceOrientationArcRotateCamera
  115581. * @param name defines camera name
  115582. * @param alpha defines the camera rotation along the logitudinal axis
  115583. * @param beta defines the camera rotation along the latitudinal axis
  115584. * @param radius defines the camera distance from its target
  115585. * @param target defines the camera target
  115586. * @param scene defines the scene the camera belongs to
  115587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115589. */
  115590. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115591. /**
  115592. * Gets camera class name
  115593. * @returns VRDeviceOrientationArcRotateCamera
  115594. */
  115595. getClassName(): string;
  115596. }
  115597. }
  115598. declare module BABYLON {
  115599. /**
  115600. * Camera used to simulate VR rendering (based on FreeCamera)
  115601. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115602. */
  115603. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115604. /**
  115605. * Creates a new VRDeviceOrientationFreeCamera
  115606. * @param name defines camera name
  115607. * @param position defines the start position of the camera
  115608. * @param scene defines the scene the camera belongs to
  115609. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115610. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115611. */
  115612. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115613. /**
  115614. * Gets camera class name
  115615. * @returns VRDeviceOrientationFreeCamera
  115616. */
  115617. getClassName(): string;
  115618. }
  115619. }
  115620. declare module BABYLON {
  115621. /**
  115622. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115623. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115624. */
  115625. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115626. /**
  115627. * Creates a new VRDeviceOrientationGamepadCamera
  115628. * @param name defines camera name
  115629. * @param position defines the start position of the camera
  115630. * @param scene defines the scene the camera belongs to
  115631. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115632. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115633. */
  115634. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115635. /**
  115636. * Gets camera class name
  115637. * @returns VRDeviceOrientationGamepadCamera
  115638. */
  115639. getClassName(): string;
  115640. }
  115641. }
  115642. declare module BABYLON {
  115643. /** @hidden */
  115644. export var imageProcessingPixelShader: {
  115645. name: string;
  115646. shader: string;
  115647. };
  115648. }
  115649. declare module BABYLON {
  115650. /**
  115651. * ImageProcessingPostProcess
  115652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115653. */
  115654. export class ImageProcessingPostProcess extends PostProcess {
  115655. /**
  115656. * Default configuration related to image processing available in the PBR Material.
  115657. */
  115658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115659. /**
  115660. * Gets the image processing configuration used either in this material.
  115661. */
  115662. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115663. /**
  115664. * Sets the Default image processing configuration used either in the this material.
  115665. *
  115666. * If sets to null, the scene one is in use.
  115667. */
  115668. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115669. /**
  115670. * Keep track of the image processing observer to allow dispose and replace.
  115671. */
  115672. private _imageProcessingObserver;
  115673. /**
  115674. * Attaches a new image processing configuration to the PBR Material.
  115675. * @param configuration
  115676. */
  115677. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115678. /**
  115679. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115680. */
  115681. get colorCurves(): Nullable<ColorCurves>;
  115682. /**
  115683. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115684. */
  115685. set colorCurves(value: Nullable<ColorCurves>);
  115686. /**
  115687. * Gets wether the color curves effect is enabled.
  115688. */
  115689. get colorCurvesEnabled(): boolean;
  115690. /**
  115691. * Sets wether the color curves effect is enabled.
  115692. */
  115693. set colorCurvesEnabled(value: boolean);
  115694. /**
  115695. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115696. */
  115697. get colorGradingTexture(): Nullable<BaseTexture>;
  115698. /**
  115699. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115700. */
  115701. set colorGradingTexture(value: Nullable<BaseTexture>);
  115702. /**
  115703. * Gets wether the color grading effect is enabled.
  115704. */
  115705. get colorGradingEnabled(): boolean;
  115706. /**
  115707. * Gets wether the color grading effect is enabled.
  115708. */
  115709. set colorGradingEnabled(value: boolean);
  115710. /**
  115711. * Gets exposure used in the effect.
  115712. */
  115713. get exposure(): number;
  115714. /**
  115715. * Sets exposure used in the effect.
  115716. */
  115717. set exposure(value: number);
  115718. /**
  115719. * Gets wether tonemapping is enabled or not.
  115720. */
  115721. get toneMappingEnabled(): boolean;
  115722. /**
  115723. * Sets wether tonemapping is enabled or not
  115724. */
  115725. set toneMappingEnabled(value: boolean);
  115726. /**
  115727. * Gets the type of tone mapping effect.
  115728. */
  115729. get toneMappingType(): number;
  115730. /**
  115731. * Sets the type of tone mapping effect.
  115732. */
  115733. set toneMappingType(value: number);
  115734. /**
  115735. * Gets contrast used in the effect.
  115736. */
  115737. get contrast(): number;
  115738. /**
  115739. * Sets contrast used in the effect.
  115740. */
  115741. set contrast(value: number);
  115742. /**
  115743. * Gets Vignette stretch size.
  115744. */
  115745. get vignetteStretch(): number;
  115746. /**
  115747. * Sets Vignette stretch size.
  115748. */
  115749. set vignetteStretch(value: number);
  115750. /**
  115751. * Gets Vignette centre X Offset.
  115752. */
  115753. get vignetteCentreX(): number;
  115754. /**
  115755. * Sets Vignette centre X Offset.
  115756. */
  115757. set vignetteCentreX(value: number);
  115758. /**
  115759. * Gets Vignette centre Y Offset.
  115760. */
  115761. get vignetteCentreY(): number;
  115762. /**
  115763. * Sets Vignette centre Y Offset.
  115764. */
  115765. set vignetteCentreY(value: number);
  115766. /**
  115767. * Gets Vignette weight or intensity of the vignette effect.
  115768. */
  115769. get vignetteWeight(): number;
  115770. /**
  115771. * Sets Vignette weight or intensity of the vignette effect.
  115772. */
  115773. set vignetteWeight(value: number);
  115774. /**
  115775. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115776. * if vignetteEnabled is set to true.
  115777. */
  115778. get vignetteColor(): Color4;
  115779. /**
  115780. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115781. * if vignetteEnabled is set to true.
  115782. */
  115783. set vignetteColor(value: Color4);
  115784. /**
  115785. * Gets Camera field of view used by the Vignette effect.
  115786. */
  115787. get vignetteCameraFov(): number;
  115788. /**
  115789. * Sets Camera field of view used by the Vignette effect.
  115790. */
  115791. set vignetteCameraFov(value: number);
  115792. /**
  115793. * Gets the vignette blend mode allowing different kind of effect.
  115794. */
  115795. get vignetteBlendMode(): number;
  115796. /**
  115797. * Sets the vignette blend mode allowing different kind of effect.
  115798. */
  115799. set vignetteBlendMode(value: number);
  115800. /**
  115801. * Gets wether the vignette effect is enabled.
  115802. */
  115803. get vignetteEnabled(): boolean;
  115804. /**
  115805. * Sets wether the vignette effect is enabled.
  115806. */
  115807. set vignetteEnabled(value: boolean);
  115808. private _fromLinearSpace;
  115809. /**
  115810. * Gets wether the input of the processing is in Gamma or Linear Space.
  115811. */
  115812. get fromLinearSpace(): boolean;
  115813. /**
  115814. * Sets wether the input of the processing is in Gamma or Linear Space.
  115815. */
  115816. set fromLinearSpace(value: boolean);
  115817. /**
  115818. * Defines cache preventing GC.
  115819. */
  115820. private _defines;
  115821. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115822. /**
  115823. * "ImageProcessingPostProcess"
  115824. * @returns "ImageProcessingPostProcess"
  115825. */
  115826. getClassName(): string;
  115827. protected _updateParameters(): void;
  115828. dispose(camera?: Camera): void;
  115829. }
  115830. }
  115831. declare module BABYLON {
  115832. /**
  115833. * Class containing static functions to help procedurally build meshes
  115834. */
  115835. export class GroundBuilder {
  115836. /**
  115837. * Creates a ground mesh
  115838. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115839. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115841. * @param name defines the name of the mesh
  115842. * @param options defines the options used to create the mesh
  115843. * @param scene defines the hosting scene
  115844. * @returns the ground mesh
  115845. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115846. */
  115847. static CreateGround(name: string, options: {
  115848. width?: number;
  115849. height?: number;
  115850. subdivisions?: number;
  115851. subdivisionsX?: number;
  115852. subdivisionsY?: number;
  115853. updatable?: boolean;
  115854. }, scene: any): Mesh;
  115855. /**
  115856. * Creates a tiled ground mesh
  115857. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115858. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115859. * * 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
  115860. * * 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
  115861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115862. * @param name defines the name of the mesh
  115863. * @param options defines the options used to create the mesh
  115864. * @param scene defines the hosting scene
  115865. * @returns the tiled ground mesh
  115866. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115867. */
  115868. static CreateTiledGround(name: string, options: {
  115869. xmin: number;
  115870. zmin: number;
  115871. xmax: number;
  115872. zmax: number;
  115873. subdivisions?: {
  115874. w: number;
  115875. h: number;
  115876. };
  115877. precision?: {
  115878. w: number;
  115879. h: number;
  115880. };
  115881. updatable?: boolean;
  115882. }, scene?: Nullable<Scene>): Mesh;
  115883. /**
  115884. * Creates a ground mesh from a height map
  115885. * * The parameter `url` sets the URL of the height map image resource.
  115886. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115887. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115888. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115889. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115890. * * 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.
  115891. * * 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).
  115892. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115894. * @param name defines the name of the mesh
  115895. * @param url defines the url to the height map
  115896. * @param options defines the options used to create the mesh
  115897. * @param scene defines the hosting scene
  115898. * @returns the ground mesh
  115899. * @see https://doc.babylonjs.com/babylon101/height_map
  115900. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115901. */
  115902. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115903. width?: number;
  115904. height?: number;
  115905. subdivisions?: number;
  115906. minHeight?: number;
  115907. maxHeight?: number;
  115908. colorFilter?: Color3;
  115909. alphaFilter?: number;
  115910. updatable?: boolean;
  115911. onReady?: (mesh: GroundMesh) => void;
  115912. }, scene?: Nullable<Scene>): GroundMesh;
  115913. }
  115914. }
  115915. declare module BABYLON {
  115916. /**
  115917. * Class containing static functions to help procedurally build meshes
  115918. */
  115919. export class TorusBuilder {
  115920. /**
  115921. * Creates a torus mesh
  115922. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115923. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115924. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115928. * @param name defines the name of the mesh
  115929. * @param options defines the options used to create the mesh
  115930. * @param scene defines the hosting scene
  115931. * @returns the torus mesh
  115932. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115933. */
  115934. static CreateTorus(name: string, options: {
  115935. diameter?: number;
  115936. thickness?: number;
  115937. tessellation?: number;
  115938. updatable?: boolean;
  115939. sideOrientation?: number;
  115940. frontUVs?: Vector4;
  115941. backUVs?: Vector4;
  115942. }, scene: any): Mesh;
  115943. }
  115944. }
  115945. declare module BABYLON {
  115946. /**
  115947. * Class containing static functions to help procedurally build meshes
  115948. */
  115949. export class CylinderBuilder {
  115950. /**
  115951. * Creates a cylinder or a cone mesh
  115952. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115953. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115954. * * 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.
  115955. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115956. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115957. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115958. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115959. * * 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).
  115960. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115961. * * 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).
  115962. * * 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
  115963. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115964. * * 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
  115965. * * 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.
  115966. * * If `enclose` is false, a ring surface is one element.
  115967. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115968. * * 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
  115969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115972. * @param name defines the name of the mesh
  115973. * @param options defines the options used to create the mesh
  115974. * @param scene defines the hosting scene
  115975. * @returns the cylinder mesh
  115976. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115977. */
  115978. static CreateCylinder(name: string, options: {
  115979. height?: number;
  115980. diameterTop?: number;
  115981. diameterBottom?: number;
  115982. diameter?: number;
  115983. tessellation?: number;
  115984. subdivisions?: number;
  115985. arc?: number;
  115986. faceColors?: Color4[];
  115987. faceUV?: Vector4[];
  115988. updatable?: boolean;
  115989. hasRings?: boolean;
  115990. enclose?: boolean;
  115991. cap?: number;
  115992. sideOrientation?: number;
  115993. frontUVs?: Vector4;
  115994. backUVs?: Vector4;
  115995. }, scene: any): Mesh;
  115996. }
  115997. }
  115998. declare module BABYLON {
  115999. /**
  116000. * States of the webXR experience
  116001. */
  116002. export enum WebXRState {
  116003. /**
  116004. * Transitioning to being in XR mode
  116005. */
  116006. ENTERING_XR = 0,
  116007. /**
  116008. * Transitioning to non XR mode
  116009. */
  116010. EXITING_XR = 1,
  116011. /**
  116012. * In XR mode and presenting
  116013. */
  116014. IN_XR = 2,
  116015. /**
  116016. * Not entered XR mode
  116017. */
  116018. NOT_IN_XR = 3
  116019. }
  116020. /**
  116021. * Abstraction of the XR render target
  116022. */
  116023. export interface WebXRRenderTarget extends IDisposable {
  116024. /**
  116025. * xrpresent context of the canvas which can be used to display/mirror xr content
  116026. */
  116027. canvasContext: WebGLRenderingContext;
  116028. /**
  116029. * xr layer for the canvas
  116030. */
  116031. xrLayer: Nullable<XRWebGLLayer>;
  116032. /**
  116033. * Initializes the xr layer for the session
  116034. * @param xrSession xr session
  116035. * @returns a promise that will resolve once the XR Layer has been created
  116036. */
  116037. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116038. }
  116039. }
  116040. declare module BABYLON {
  116041. /**
  116042. * COnfiguration object for WebXR output canvas
  116043. */
  116044. export class WebXRManagedOutputCanvasOptions {
  116045. /**
  116046. * An optional canvas in case you wish to create it yourself and provide it here.
  116047. * If not provided, a new canvas will be created
  116048. */
  116049. canvasElement?: HTMLCanvasElement;
  116050. /**
  116051. * Options for this XR Layer output
  116052. */
  116053. canvasOptions?: XRWebGLLayerOptions;
  116054. /**
  116055. * CSS styling for a newly created canvas (if not provided)
  116056. */
  116057. newCanvasCssStyle?: string;
  116058. /**
  116059. * Get the default values of the configuration object
  116060. * @returns default values of this configuration object
  116061. */
  116062. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  116063. }
  116064. /**
  116065. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  116066. */
  116067. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  116068. private _options;
  116069. private _canvas;
  116070. private _engine;
  116071. /**
  116072. * Rendering context of the canvas which can be used to display/mirror xr content
  116073. */
  116074. canvasContext: WebGLRenderingContext;
  116075. /**
  116076. * xr layer for the canvas
  116077. */
  116078. xrLayer: Nullable<XRWebGLLayer>;
  116079. /**
  116080. * Initializes the canvas to be added/removed upon entering/exiting xr
  116081. * @param _xrSessionManager The XR Session manager
  116082. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  116083. */
  116084. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  116085. /**
  116086. * Disposes of the object
  116087. */
  116088. dispose(): void;
  116089. /**
  116090. * Initializes the xr layer for the session
  116091. * @param xrSession xr session
  116092. * @returns a promise that will resolve once the XR Layer has been created
  116093. */
  116094. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116095. private _addCanvas;
  116096. private _removeCanvas;
  116097. private _setManagedOutputCanvas;
  116098. }
  116099. }
  116100. declare module BABYLON {
  116101. /**
  116102. * Manages an XRSession to work with Babylon's engine
  116103. * @see https://doc.babylonjs.com/how_to/webxr
  116104. */
  116105. export class WebXRSessionManager implements IDisposable {
  116106. /** The scene which the session should be created for */
  116107. scene: Scene;
  116108. private _referenceSpace;
  116109. private _rttProvider;
  116110. private _sessionEnded;
  116111. private _xrNavigator;
  116112. private baseLayer;
  116113. /**
  116114. * The base reference space from which the session started. good if you want to reset your
  116115. * reference space
  116116. */
  116117. baseReferenceSpace: XRReferenceSpace;
  116118. /**
  116119. * Current XR frame
  116120. */
  116121. currentFrame: Nullable<XRFrame>;
  116122. /** WebXR timestamp updated every frame */
  116123. currentTimestamp: number;
  116124. /**
  116125. * Used just in case of a failure to initialize an immersive session.
  116126. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  116127. */
  116128. defaultHeightCompensation: number;
  116129. /**
  116130. * Fires every time a new xrFrame arrives which can be used to update the camera
  116131. */
  116132. onXRFrameObservable: Observable<XRFrame>;
  116133. /**
  116134. * Fires when the reference space changed
  116135. */
  116136. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  116137. /**
  116138. * Fires when the xr session is ended either by the device or manually done
  116139. */
  116140. onXRSessionEnded: Observable<any>;
  116141. /**
  116142. * Fires when the xr session is ended either by the device or manually done
  116143. */
  116144. onXRSessionInit: Observable<XRSession>;
  116145. /**
  116146. * Underlying xr session
  116147. */
  116148. session: XRSession;
  116149. /**
  116150. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  116151. * or get the offset the player is currently at.
  116152. */
  116153. viewerReferenceSpace: XRReferenceSpace;
  116154. /**
  116155. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116156. * @param scene The scene which the session should be created for
  116157. */
  116158. constructor(
  116159. /** The scene which the session should be created for */
  116160. scene: Scene);
  116161. /**
  116162. * The current reference space used in this session. This reference space can constantly change!
  116163. * It is mainly used to offset the camera's position.
  116164. */
  116165. get referenceSpace(): XRReferenceSpace;
  116166. /**
  116167. * Set a new reference space and triggers the observable
  116168. */
  116169. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  116170. /**
  116171. * Disposes of the session manager
  116172. */
  116173. dispose(): void;
  116174. /**
  116175. * Stops the xrSession and restores the render loop
  116176. * @returns Promise which resolves after it exits XR
  116177. */
  116178. exitXRAsync(): Promise<void>;
  116179. /**
  116180. * Gets the correct render target texture to be rendered this frame for this eye
  116181. * @param eye the eye for which to get the render target
  116182. * @returns the render target for the specified eye
  116183. */
  116184. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116185. /**
  116186. * Creates a WebXRRenderTarget object for the XR session
  116187. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116188. * @param options optional options to provide when creating a new render target
  116189. * @returns a WebXR render target to which the session can render
  116190. */
  116191. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116192. /**
  116193. * Initializes the manager
  116194. * After initialization enterXR can be called to start an XR session
  116195. * @returns Promise which resolves after it is initialized
  116196. */
  116197. initializeAsync(): Promise<void>;
  116198. /**
  116199. * Initializes an xr session
  116200. * @param xrSessionMode mode to initialize
  116201. * @param xrSessionInit defines optional and required values to pass to the session builder
  116202. * @returns a promise which will resolve once the session has been initialized
  116203. */
  116204. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116205. /**
  116206. * Checks if a session would be supported for the creation options specified
  116207. * @param sessionMode session mode to check if supported eg. immersive-vr
  116208. * @returns A Promise that resolves to true if supported and false if not
  116209. */
  116210. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116211. /**
  116212. * Resets the reference space to the one started the session
  116213. */
  116214. resetReferenceSpace(): void;
  116215. /**
  116216. * Starts rendering to the xr layer
  116217. */
  116218. runXRRenderLoop(): void;
  116219. /**
  116220. * Sets the reference space on the xr session
  116221. * @param referenceSpaceType space to set
  116222. * @returns a promise that will resolve once the reference space has been set
  116223. */
  116224. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116225. /**
  116226. * Updates the render state of the session
  116227. * @param state state to set
  116228. * @returns a promise that resolves once the render state has been updated
  116229. */
  116230. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116231. /**
  116232. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116233. * @param sessionMode defines the session to test
  116234. * @returns a promise with boolean as final value
  116235. */
  116236. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116237. private _createRenderTargetTexture;
  116238. }
  116239. }
  116240. declare module BABYLON {
  116241. /**
  116242. * WebXR Camera which holds the views for the xrSession
  116243. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116244. */
  116245. export class WebXRCamera extends FreeCamera {
  116246. private _xrSessionManager;
  116247. private _firstFrame;
  116248. private _referenceQuaternion;
  116249. private _referencedPosition;
  116250. private _xrInvPositionCache;
  116251. private _xrInvQuaternionCache;
  116252. /**
  116253. * Should position compensation execute on first frame.
  116254. * This is used when copying the position from a native (non XR) camera
  116255. */
  116256. compensateOnFirstFrame: boolean;
  116257. /**
  116258. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116259. * @param name the name of the camera
  116260. * @param scene the scene to add the camera to
  116261. * @param _xrSessionManager a constructed xr session manager
  116262. */
  116263. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116264. /**
  116265. * Return the user's height, unrelated to the current ground.
  116266. * This will be the y position of this camera, when ground level is 0.
  116267. */
  116268. get realWorldHeight(): number;
  116269. /** @hidden */
  116270. _updateForDualEyeDebugging(): void;
  116271. /**
  116272. * Sets this camera's transformation based on a non-vr camera
  116273. * @param otherCamera the non-vr camera to copy the transformation from
  116274. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116275. */
  116276. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116277. /**
  116278. * Gets the current instance class name ("WebXRCamera").
  116279. * @returns the class name
  116280. */
  116281. getClassName(): string;
  116282. private _updateFromXRSession;
  116283. private _updateNumberOfRigCameras;
  116284. private _updateReferenceSpace;
  116285. private _updateReferenceSpaceOffset;
  116286. }
  116287. }
  116288. declare module BABYLON {
  116289. /**
  116290. * Defining the interface required for a (webxr) feature
  116291. */
  116292. export interface IWebXRFeature extends IDisposable {
  116293. /**
  116294. * Is this feature attached
  116295. */
  116296. attached: boolean;
  116297. /**
  116298. * Should auto-attach be disabled?
  116299. */
  116300. disableAutoAttach: boolean;
  116301. /**
  116302. * Attach the feature to the session
  116303. * Will usually be called by the features manager
  116304. *
  116305. * @param force should attachment be forced (even when already attached)
  116306. * @returns true if successful.
  116307. */
  116308. attach(force?: boolean): boolean;
  116309. /**
  116310. * Detach the feature from the session
  116311. * Will usually be called by the features manager
  116312. *
  116313. * @returns true if successful.
  116314. */
  116315. detach(): boolean;
  116316. }
  116317. /**
  116318. * A list of the currently available features without referencing them
  116319. */
  116320. export class WebXRFeatureName {
  116321. /**
  116322. * The name of the anchor system feature
  116323. */
  116324. static ANCHOR_SYSTEM: string;
  116325. /**
  116326. * The name of the background remover feature
  116327. */
  116328. static BACKGROUND_REMOVER: string;
  116329. /**
  116330. * The name of the hit test feature
  116331. */
  116332. static HIT_TEST: string;
  116333. /**
  116334. * physics impostors for xr controllers feature
  116335. */
  116336. static PHYSICS_CONTROLLERS: string;
  116337. /**
  116338. * The name of the plane detection feature
  116339. */
  116340. static PLANE_DETECTION: string;
  116341. /**
  116342. * The name of the pointer selection feature
  116343. */
  116344. static POINTER_SELECTION: string;
  116345. /**
  116346. * The name of the teleportation feature
  116347. */
  116348. static TELEPORTATION: string;
  116349. }
  116350. /**
  116351. * Defining the constructor of a feature. Used to register the modules.
  116352. */
  116353. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116354. /**
  116355. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116356. * It is mainly used in AR sessions.
  116357. *
  116358. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116359. */
  116360. export class WebXRFeaturesManager implements IDisposable {
  116361. private _xrSessionManager;
  116362. private static readonly _AvailableFeatures;
  116363. private _features;
  116364. /**
  116365. * constructs a new features manages.
  116366. *
  116367. * @param _xrSessionManager an instance of WebXRSessionManager
  116368. */
  116369. constructor(_xrSessionManager: WebXRSessionManager);
  116370. /**
  116371. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116372. * Mainly used internally.
  116373. *
  116374. * @param featureName the name of the feature to register
  116375. * @param constructorFunction the function used to construct the module
  116376. * @param version the (babylon) version of the module
  116377. * @param stable is that a stable version of this module
  116378. */
  116379. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116380. /**
  116381. * Returns a constructor of a specific feature.
  116382. *
  116383. * @param featureName the name of the feature to construct
  116384. * @param version the version of the feature to load
  116385. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116386. * @param options optional options provided to the module.
  116387. * @returns a function that, when called, will return a new instance of this feature
  116388. */
  116389. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116390. /**
  116391. * Can be used to return the list of features currently registered
  116392. *
  116393. * @returns an Array of available features
  116394. */
  116395. static GetAvailableFeatures(): string[];
  116396. /**
  116397. * Gets the versions available for a specific feature
  116398. * @param featureName the name of the feature
  116399. * @returns an array with the available versions
  116400. */
  116401. static GetAvailableVersions(featureName: string): string[];
  116402. /**
  116403. * Return the latest unstable version of this feature
  116404. * @param featureName the name of the feature to search
  116405. * @returns the version number. if not found will return -1
  116406. */
  116407. static GetLatestVersionOfFeature(featureName: string): number;
  116408. /**
  116409. * Return the latest stable version of this feature
  116410. * @param featureName the name of the feature to search
  116411. * @returns the version number. if not found will return -1
  116412. */
  116413. static GetStableVersionOfFeature(featureName: string): number;
  116414. /**
  116415. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116416. * Can be used during a session to start a feature
  116417. * @param featureName the name of feature to attach
  116418. */
  116419. attachFeature(featureName: string): void;
  116420. /**
  116421. * Can be used inside a session or when the session ends to detach a specific feature
  116422. * @param featureName the name of the feature to detach
  116423. */
  116424. detachFeature(featureName: string): void;
  116425. /**
  116426. * Used to disable an already-enabled feature
  116427. * The feature will be disposed and will be recreated once enabled.
  116428. * @param featureName the feature to disable
  116429. * @returns true if disable was successful
  116430. */
  116431. disableFeature(featureName: string | {
  116432. Name: string;
  116433. }): boolean;
  116434. /**
  116435. * dispose this features manager
  116436. */
  116437. dispose(): void;
  116438. /**
  116439. * 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.
  116440. * 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.
  116441. *
  116442. * @param featureName the name of the feature to load or the class of the feature
  116443. * @param version optional version to load. if not provided the latest version will be enabled
  116444. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116445. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116446. * @returns a new constructed feature or throws an error if feature not found.
  116447. */
  116448. enableFeature(featureName: string | {
  116449. Name: string;
  116450. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116451. /**
  116452. * get the implementation of an enabled feature.
  116453. * @param featureName the name of the feature to load
  116454. * @returns the feature class, if found
  116455. */
  116456. getEnabledFeature(featureName: string): IWebXRFeature;
  116457. /**
  116458. * Get the list of enabled features
  116459. * @returns an array of enabled features
  116460. */
  116461. getEnabledFeatures(): string[];
  116462. }
  116463. }
  116464. declare module BABYLON {
  116465. /**
  116466. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116467. * @see https://doc.babylonjs.com/how_to/webxr
  116468. */
  116469. export class WebXRExperienceHelper implements IDisposable {
  116470. private scene;
  116471. private _nonVRCamera;
  116472. private _originalSceneAutoClear;
  116473. private _supported;
  116474. /**
  116475. * Camera used to render xr content
  116476. */
  116477. camera: WebXRCamera;
  116478. /** A features manager for this xr session */
  116479. featuresManager: WebXRFeaturesManager;
  116480. /**
  116481. * Observers registered here will be triggered after the camera's initial transformation is set
  116482. * This can be used to set a different ground level or an extra rotation.
  116483. *
  116484. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116485. * to the position set after this observable is done executing.
  116486. */
  116487. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116488. /**
  116489. * Fires when the state of the experience helper has changed
  116490. */
  116491. onStateChangedObservable: Observable<WebXRState>;
  116492. /** Session manager used to keep track of xr session */
  116493. sessionManager: WebXRSessionManager;
  116494. /**
  116495. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116496. */
  116497. state: WebXRState;
  116498. /**
  116499. * Creates a WebXRExperienceHelper
  116500. * @param scene The scene the helper should be created in
  116501. */
  116502. private constructor();
  116503. /**
  116504. * Creates the experience helper
  116505. * @param scene the scene to attach the experience helper to
  116506. * @returns a promise for the experience helper
  116507. */
  116508. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116509. /**
  116510. * Disposes of the experience helper
  116511. */
  116512. dispose(): void;
  116513. /**
  116514. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116515. * @param sessionMode options for the XR session
  116516. * @param referenceSpaceType frame of reference of the XR session
  116517. * @param renderTarget the output canvas that will be used to enter XR mode
  116518. * @returns promise that resolves after xr mode has entered
  116519. */
  116520. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116521. /**
  116522. * Exits XR mode and returns the scene to its original state
  116523. * @returns promise that resolves after xr mode has exited
  116524. */
  116525. exitXRAsync(): Promise<void>;
  116526. private _nonXRToXRCamera;
  116527. private _setState;
  116528. }
  116529. }
  116530. declare module BABYLON {
  116531. /**
  116532. * X-Y values for axes in WebXR
  116533. */
  116534. export interface IWebXRMotionControllerAxesValue {
  116535. /**
  116536. * The value of the x axis
  116537. */
  116538. x: number;
  116539. /**
  116540. * The value of the y-axis
  116541. */
  116542. y: number;
  116543. }
  116544. /**
  116545. * changed / previous values for the values of this component
  116546. */
  116547. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116548. /**
  116549. * current (this frame) value
  116550. */
  116551. current: T;
  116552. /**
  116553. * previous (last change) value
  116554. */
  116555. previous: T;
  116556. }
  116557. /**
  116558. * Represents changes in the component between current frame and last values recorded
  116559. */
  116560. export interface IWebXRMotionControllerComponentChanges {
  116561. /**
  116562. * will be populated with previous and current values if axes changed
  116563. */
  116564. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116565. /**
  116566. * will be populated with previous and current values if pressed changed
  116567. */
  116568. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116569. /**
  116570. * will be populated with previous and current values if touched changed
  116571. */
  116572. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116573. /**
  116574. * will be populated with previous and current values if value changed
  116575. */
  116576. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116577. }
  116578. /**
  116579. * This class represents a single component (for example button or thumbstick) of a motion controller
  116580. */
  116581. export class WebXRControllerComponent implements IDisposable {
  116582. /**
  116583. * the id of this component
  116584. */
  116585. id: string;
  116586. /**
  116587. * the type of the component
  116588. */
  116589. type: MotionControllerComponentType;
  116590. private _buttonIndex;
  116591. private _axesIndices;
  116592. private _axes;
  116593. private _changes;
  116594. private _currentValue;
  116595. private _hasChanges;
  116596. private _pressed;
  116597. private _touched;
  116598. /**
  116599. * button component type
  116600. */
  116601. static BUTTON_TYPE: MotionControllerComponentType;
  116602. /**
  116603. * squeeze component type
  116604. */
  116605. static SQUEEZE_TYPE: MotionControllerComponentType;
  116606. /**
  116607. * Thumbstick component type
  116608. */
  116609. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116610. /**
  116611. * Touchpad component type
  116612. */
  116613. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116614. /**
  116615. * trigger component type
  116616. */
  116617. static TRIGGER_TYPE: MotionControllerComponentType;
  116618. /**
  116619. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116620. * the axes data changes
  116621. */
  116622. onAxisValueChangedObservable: Observable<{
  116623. x: number;
  116624. y: number;
  116625. }>;
  116626. /**
  116627. * Observers registered here will be triggered when the state of a button changes
  116628. * State change is either pressed / touched / value
  116629. */
  116630. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116631. /**
  116632. * Creates a new component for a motion controller.
  116633. * It is created by the motion controller itself
  116634. *
  116635. * @param id the id of this component
  116636. * @param type the type of the component
  116637. * @param _buttonIndex index in the buttons array of the gamepad
  116638. * @param _axesIndices indices of the values in the axes array of the gamepad
  116639. */
  116640. constructor(
  116641. /**
  116642. * the id of this component
  116643. */
  116644. id: string,
  116645. /**
  116646. * the type of the component
  116647. */
  116648. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116649. /**
  116650. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116651. */
  116652. get axes(): IWebXRMotionControllerAxesValue;
  116653. /**
  116654. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116655. */
  116656. get changes(): IWebXRMotionControllerComponentChanges;
  116657. /**
  116658. * Return whether or not the component changed the last frame
  116659. */
  116660. get hasChanges(): boolean;
  116661. /**
  116662. * is the button currently pressed
  116663. */
  116664. get pressed(): boolean;
  116665. /**
  116666. * is the button currently touched
  116667. */
  116668. get touched(): boolean;
  116669. /**
  116670. * Get the current value of this component
  116671. */
  116672. get value(): number;
  116673. /**
  116674. * Dispose this component
  116675. */
  116676. dispose(): void;
  116677. /**
  116678. * Are there axes correlating to this component
  116679. * @return true is axes data is available
  116680. */
  116681. isAxes(): boolean;
  116682. /**
  116683. * Is this component a button (hence - pressable)
  116684. * @returns true if can be pressed
  116685. */
  116686. isButton(): boolean;
  116687. /**
  116688. * update this component using the gamepad object it is in. Called on every frame
  116689. * @param nativeController the native gamepad controller object
  116690. */
  116691. update(nativeController: IMinimalMotionControllerObject): void;
  116692. }
  116693. }
  116694. declare module BABYLON {
  116695. /**
  116696. * Class used to represent data loading progression
  116697. */
  116698. export class SceneLoaderProgressEvent {
  116699. /** defines if data length to load can be evaluated */
  116700. readonly lengthComputable: boolean;
  116701. /** defines the loaded data length */
  116702. readonly loaded: number;
  116703. /** defines the data length to load */
  116704. readonly total: number;
  116705. /**
  116706. * Create a new progress event
  116707. * @param lengthComputable defines if data length to load can be evaluated
  116708. * @param loaded defines the loaded data length
  116709. * @param total defines the data length to load
  116710. */
  116711. constructor(
  116712. /** defines if data length to load can be evaluated */
  116713. lengthComputable: boolean,
  116714. /** defines the loaded data length */
  116715. loaded: number,
  116716. /** defines the data length to load */
  116717. total: number);
  116718. /**
  116719. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116720. * @param event defines the source event
  116721. * @returns a new SceneLoaderProgressEvent
  116722. */
  116723. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116724. }
  116725. /**
  116726. * Interface used by SceneLoader plugins to define supported file extensions
  116727. */
  116728. export interface ISceneLoaderPluginExtensions {
  116729. /**
  116730. * Defines the list of supported extensions
  116731. */
  116732. [extension: string]: {
  116733. isBinary: boolean;
  116734. };
  116735. }
  116736. /**
  116737. * Interface used by SceneLoader plugin factory
  116738. */
  116739. export interface ISceneLoaderPluginFactory {
  116740. /**
  116741. * Defines the name of the factory
  116742. */
  116743. name: string;
  116744. /**
  116745. * Function called to create a new plugin
  116746. * @return the new plugin
  116747. */
  116748. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116749. /**
  116750. * The callback that returns true if the data can be directly loaded.
  116751. * @param data string containing the file data
  116752. * @returns if the data can be loaded directly
  116753. */
  116754. canDirectLoad?(data: string): boolean;
  116755. }
  116756. /**
  116757. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116758. */
  116759. export interface ISceneLoaderPluginBase {
  116760. /**
  116761. * The friendly name of this plugin.
  116762. */
  116763. name: string;
  116764. /**
  116765. * The file extensions supported by this plugin.
  116766. */
  116767. extensions: string | ISceneLoaderPluginExtensions;
  116768. /**
  116769. * The callback called when loading from a url.
  116770. * @param scene scene loading this url
  116771. * @param url url to load
  116772. * @param onSuccess callback called when the file successfully loads
  116773. * @param onProgress callback called while file is loading (if the server supports this mode)
  116774. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116775. * @param onError callback called when the file fails to load
  116776. * @returns a file request object
  116777. */
  116778. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116779. /**
  116780. * The callback called when loading from a file object.
  116781. * @param scene scene loading this file
  116782. * @param file defines the file to load
  116783. * @param onSuccess defines the callback to call when data is loaded
  116784. * @param onProgress defines the callback to call during loading process
  116785. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116786. * @param onError defines the callback to call when an error occurs
  116787. * @returns a file request object
  116788. */
  116789. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116790. /**
  116791. * The callback that returns true if the data can be directly loaded.
  116792. * @param data string containing the file data
  116793. * @returns if the data can be loaded directly
  116794. */
  116795. canDirectLoad?(data: string): boolean;
  116796. /**
  116797. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116798. * @param scene scene loading this data
  116799. * @param data string containing the data
  116800. * @returns data to pass to the plugin
  116801. */
  116802. directLoad?(scene: Scene, data: string): any;
  116803. /**
  116804. * The callback that allows custom handling of the root url based on the response url.
  116805. * @param rootUrl the original root url
  116806. * @param responseURL the response url if available
  116807. * @returns the new root url
  116808. */
  116809. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116810. }
  116811. /**
  116812. * Interface used to define a SceneLoader plugin
  116813. */
  116814. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116815. /**
  116816. * Import meshes into a scene.
  116817. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116818. * @param scene The scene to import into
  116819. * @param data The data to import
  116820. * @param rootUrl The root url for scene and resources
  116821. * @param meshes The meshes array to import into
  116822. * @param particleSystems The particle systems array to import into
  116823. * @param skeletons The skeletons array to import into
  116824. * @param onError The callback when import fails
  116825. * @returns True if successful or false otherwise
  116826. */
  116827. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116828. /**
  116829. * Load into a scene.
  116830. * @param scene The scene to load into
  116831. * @param data The data to import
  116832. * @param rootUrl The root url for scene and resources
  116833. * @param onError The callback when import fails
  116834. * @returns True if successful or false otherwise
  116835. */
  116836. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116837. /**
  116838. * Load into an asset container.
  116839. * @param scene The scene to load into
  116840. * @param data The data to import
  116841. * @param rootUrl The root url for scene and resources
  116842. * @param onError The callback when import fails
  116843. * @returns The loaded asset container
  116844. */
  116845. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116846. }
  116847. /**
  116848. * Interface used to define an async SceneLoader plugin
  116849. */
  116850. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116851. /**
  116852. * Import meshes into a scene.
  116853. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116854. * @param scene The scene to import into
  116855. * @param data The data to import
  116856. * @param rootUrl The root url for scene and resources
  116857. * @param onProgress The callback when the load progresses
  116858. * @param fileName Defines the name of the file to load
  116859. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116860. */
  116861. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116862. meshes: AbstractMesh[];
  116863. particleSystems: IParticleSystem[];
  116864. skeletons: Skeleton[];
  116865. animationGroups: AnimationGroup[];
  116866. }>;
  116867. /**
  116868. * Load into a scene.
  116869. * @param scene The scene to load into
  116870. * @param data The data to import
  116871. * @param rootUrl The root url for scene and resources
  116872. * @param onProgress The callback when the load progresses
  116873. * @param fileName Defines the name of the file to load
  116874. * @returns Nothing
  116875. */
  116876. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116877. /**
  116878. * Load into an asset container.
  116879. * @param scene The scene to load into
  116880. * @param data The data to import
  116881. * @param rootUrl The root url for scene and resources
  116882. * @param onProgress The callback when the load progresses
  116883. * @param fileName Defines the name of the file to load
  116884. * @returns The loaded asset container
  116885. */
  116886. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116887. }
  116888. /**
  116889. * Mode that determines how to handle old animation groups before loading new ones.
  116890. */
  116891. export enum SceneLoaderAnimationGroupLoadingMode {
  116892. /**
  116893. * Reset all old animations to initial state then dispose them.
  116894. */
  116895. Clean = 0,
  116896. /**
  116897. * Stop all old animations.
  116898. */
  116899. Stop = 1,
  116900. /**
  116901. * Restart old animations from first frame.
  116902. */
  116903. Sync = 2,
  116904. /**
  116905. * Old animations remains untouched.
  116906. */
  116907. NoSync = 3
  116908. }
  116909. /**
  116910. * Class used to load scene from various file formats using registered plugins
  116911. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116912. */
  116913. export class SceneLoader {
  116914. /**
  116915. * No logging while loading
  116916. */
  116917. static readonly NO_LOGGING: number;
  116918. /**
  116919. * Minimal logging while loading
  116920. */
  116921. static readonly MINIMAL_LOGGING: number;
  116922. /**
  116923. * Summary logging while loading
  116924. */
  116925. static readonly SUMMARY_LOGGING: number;
  116926. /**
  116927. * Detailled logging while loading
  116928. */
  116929. static readonly DETAILED_LOGGING: number;
  116930. /**
  116931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116932. */
  116933. static get ForceFullSceneLoadingForIncremental(): boolean;
  116934. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116935. /**
  116936. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116937. */
  116938. static get ShowLoadingScreen(): boolean;
  116939. static set ShowLoadingScreen(value: boolean);
  116940. /**
  116941. * Defines the current logging level (while loading the scene)
  116942. * @ignorenaming
  116943. */
  116944. static get loggingLevel(): number;
  116945. static set loggingLevel(value: number);
  116946. /**
  116947. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116948. */
  116949. static get CleanBoneMatrixWeights(): boolean;
  116950. static set CleanBoneMatrixWeights(value: boolean);
  116951. /**
  116952. * Event raised when a plugin is used to load a scene
  116953. */
  116954. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116955. private static _registeredPlugins;
  116956. private static _getDefaultPlugin;
  116957. private static _getPluginForExtension;
  116958. private static _getPluginForDirectLoad;
  116959. private static _getPluginForFilename;
  116960. private static _getDirectLoad;
  116961. private static _loadData;
  116962. private static _getFileInfo;
  116963. /**
  116964. * Gets a plugin that can load the given extension
  116965. * @param extension defines the extension to load
  116966. * @returns a plugin or null if none works
  116967. */
  116968. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116969. /**
  116970. * Gets a boolean indicating that the given extension can be loaded
  116971. * @param extension defines the extension to load
  116972. * @returns true if the extension is supported
  116973. */
  116974. static IsPluginForExtensionAvailable(extension: string): boolean;
  116975. /**
  116976. * Adds a new plugin to the list of registered plugins
  116977. * @param plugin defines the plugin to add
  116978. */
  116979. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116980. /**
  116981. * Import meshes into a scene
  116982. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116983. * @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)
  116984. * @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)
  116985. * @param scene the instance of BABYLON.Scene to append to
  116986. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116987. * @param onProgress a callback with a progress event for each file being loaded
  116988. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116989. * @param pluginExtension the extension used to determine the plugin
  116990. * @returns The loaded plugin
  116991. */
  116992. 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>;
  116993. /**
  116994. * Import meshes into a scene
  116995. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116996. * @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)
  116997. * @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)
  116998. * @param scene the instance of BABYLON.Scene to append to
  116999. * @param onProgress a callback with a progress event for each file being loaded
  117000. * @param pluginExtension the extension used to determine the plugin
  117001. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  117002. */
  117003. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  117004. meshes: AbstractMesh[];
  117005. particleSystems: IParticleSystem[];
  117006. skeletons: Skeleton[];
  117007. animationGroups: AnimationGroup[];
  117008. }>;
  117009. /**
  117010. * Load a scene
  117011. * @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)
  117012. * @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)
  117013. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117014. * @param onSuccess a callback with the scene when import succeeds
  117015. * @param onProgress a callback with a progress event for each file being loaded
  117016. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117017. * @param pluginExtension the extension used to determine the plugin
  117018. * @returns The loaded plugin
  117019. */
  117020. 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>;
  117021. /**
  117022. * Load a scene
  117023. * @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)
  117024. * @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)
  117025. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117026. * @param onProgress a callback with a progress event for each file being loaded
  117027. * @param pluginExtension the extension used to determine the plugin
  117028. * @returns The loaded scene
  117029. */
  117030. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117031. /**
  117032. * Append a scene
  117033. * @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)
  117034. * @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)
  117035. * @param scene is the instance of BABYLON.Scene to append to
  117036. * @param onSuccess a callback with the scene when import succeeds
  117037. * @param onProgress a callback with a progress event for each file being loaded
  117038. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117039. * @param pluginExtension the extension used to determine the plugin
  117040. * @returns The loaded plugin
  117041. */
  117042. 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>;
  117043. /**
  117044. * Append a scene
  117045. * @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)
  117046. * @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)
  117047. * @param scene is the instance of BABYLON.Scene to append to
  117048. * @param onProgress a callback with a progress event for each file being loaded
  117049. * @param pluginExtension the extension used to determine the plugin
  117050. * @returns The given scene
  117051. */
  117052. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117053. /**
  117054. * Load a scene into an asset container
  117055. * @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)
  117056. * @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)
  117057. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117058. * @param onSuccess a callback with the scene when import succeeds
  117059. * @param onProgress a callback with a progress event for each file being loaded
  117060. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117061. * @param pluginExtension the extension used to determine the plugin
  117062. * @returns The loaded plugin
  117063. */
  117064. 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>;
  117065. /**
  117066. * Load a scene into an asset container
  117067. * @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)
  117068. * @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)
  117069. * @param scene is the instance of Scene to append to
  117070. * @param onProgress a callback with a progress event for each file being loaded
  117071. * @param pluginExtension the extension used to determine the plugin
  117072. * @returns The loaded asset container
  117073. */
  117074. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  117075. /**
  117076. * Import animations from a file into a scene
  117077. * @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)
  117078. * @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)
  117079. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117080. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117081. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117082. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117083. * @param onSuccess a callback with the scene when import succeeds
  117084. * @param onProgress a callback with a progress event for each file being loaded
  117085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117086. */
  117087. 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;
  117088. /**
  117089. * Import animations from a file into a scene
  117090. * @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)
  117091. * @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)
  117092. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117093. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117094. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117095. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117096. * @param onSuccess a callback with the scene when import succeeds
  117097. * @param onProgress a callback with a progress event for each file being loaded
  117098. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117099. * @returns the updated scene with imported animations
  117100. */
  117101. 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>;
  117102. }
  117103. }
  117104. declare module BABYLON {
  117105. /**
  117106. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  117107. */
  117108. export type MotionControllerHandness = "none" | "left" | "right";
  117109. /**
  117110. * The type of components available in motion controllers.
  117111. * This is not the name of the component.
  117112. */
  117113. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  117114. /**
  117115. * The state of a controller component
  117116. */
  117117. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  117118. /**
  117119. * The schema of motion controller layout.
  117120. * No object will be initialized using this interface
  117121. * This is used just to define the profile.
  117122. */
  117123. export interface IMotionControllerLayout {
  117124. /**
  117125. * Path to load the assets. Usually relative to the base path
  117126. */
  117127. assetPath: string;
  117128. /**
  117129. * Available components (unsorted)
  117130. */
  117131. components: {
  117132. /**
  117133. * A map of component Ids
  117134. */
  117135. [componentId: string]: {
  117136. /**
  117137. * The type of input the component outputs
  117138. */
  117139. type: MotionControllerComponentType;
  117140. /**
  117141. * The indices of this component in the gamepad object
  117142. */
  117143. gamepadIndices: {
  117144. /**
  117145. * Index of button
  117146. */
  117147. button?: number;
  117148. /**
  117149. * If available, index of x-axis
  117150. */
  117151. xAxis?: number;
  117152. /**
  117153. * If available, index of y-axis
  117154. */
  117155. yAxis?: number;
  117156. };
  117157. /**
  117158. * The mesh's root node name
  117159. */
  117160. rootNodeName: string;
  117161. /**
  117162. * Animation definitions for this model
  117163. */
  117164. visualResponses: {
  117165. [stateKey: string]: {
  117166. /**
  117167. * What property will be animated
  117168. */
  117169. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117170. /**
  117171. * What states influence this visual response
  117172. */
  117173. states: MotionControllerComponentStateType[];
  117174. /**
  117175. * Type of animation - movement or visibility
  117176. */
  117177. valueNodeProperty: "transform" | "visibility";
  117178. /**
  117179. * Base node name to move. Its position will be calculated according to the min and max nodes
  117180. */
  117181. valueNodeName?: string;
  117182. /**
  117183. * Minimum movement node
  117184. */
  117185. minNodeName?: string;
  117186. /**
  117187. * Max movement node
  117188. */
  117189. maxNodeName?: string;
  117190. };
  117191. };
  117192. /**
  117193. * If touch enabled, what is the name of node to display user feedback
  117194. */
  117195. touchPointNodeName?: string;
  117196. };
  117197. };
  117198. /**
  117199. * Is it xr standard mapping or not
  117200. */
  117201. gamepadMapping: "" | "xr-standard";
  117202. /**
  117203. * Base root node of this entire model
  117204. */
  117205. rootNodeName: string;
  117206. /**
  117207. * Defines the main button component id
  117208. */
  117209. selectComponentId: string;
  117210. }
  117211. /**
  117212. * A definition for the layout map in the input profile
  117213. */
  117214. export interface IMotionControllerLayoutMap {
  117215. /**
  117216. * Layouts with handness type as a key
  117217. */
  117218. [handness: string]: IMotionControllerLayout;
  117219. }
  117220. /**
  117221. * The XR Input profile schema
  117222. * Profiles can be found here:
  117223. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117224. */
  117225. export interface IMotionControllerProfile {
  117226. /**
  117227. * fallback profiles for this profileId
  117228. */
  117229. fallbackProfileIds: string[];
  117230. /**
  117231. * The layout map, with handness as key
  117232. */
  117233. layouts: IMotionControllerLayoutMap;
  117234. /**
  117235. * The id of this profile
  117236. * correlates to the profile(s) in the xrInput.profiles array
  117237. */
  117238. profileId: string;
  117239. }
  117240. /**
  117241. * A helper-interface for the 3 meshes needed for controller button animation
  117242. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117243. */
  117244. export interface IMotionControllerButtonMeshMap {
  117245. /**
  117246. * the mesh that defines the pressed value mesh position.
  117247. * This is used to find the max-position of this button
  117248. */
  117249. pressedMesh: AbstractMesh;
  117250. /**
  117251. * the mesh that defines the unpressed value mesh position.
  117252. * This is used to find the min (or initial) position of this button
  117253. */
  117254. unpressedMesh: AbstractMesh;
  117255. /**
  117256. * The mesh that will be changed when value changes
  117257. */
  117258. valueMesh: AbstractMesh;
  117259. }
  117260. /**
  117261. * A helper-interface for the 3 meshes needed for controller axis animation.
  117262. * This will be expanded when touchpad animations are fully supported
  117263. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117264. */
  117265. export interface IMotionControllerMeshMap {
  117266. /**
  117267. * the mesh that defines the maximum value mesh position.
  117268. */
  117269. maxMesh?: AbstractMesh;
  117270. /**
  117271. * the mesh that defines the minimum value mesh position.
  117272. */
  117273. minMesh?: AbstractMesh;
  117274. /**
  117275. * The mesh that will be changed when axis value changes
  117276. */
  117277. valueMesh: AbstractMesh;
  117278. }
  117279. /**
  117280. * The elements needed for change-detection of the gamepad objects in motion controllers
  117281. */
  117282. export interface IMinimalMotionControllerObject {
  117283. /**
  117284. * Available axes of this controller
  117285. */
  117286. axes: number[];
  117287. /**
  117288. * An array of available buttons
  117289. */
  117290. buttons: Array<{
  117291. /**
  117292. * Value of the button/trigger
  117293. */
  117294. value: number;
  117295. /**
  117296. * If the button/trigger is currently touched
  117297. */
  117298. touched: boolean;
  117299. /**
  117300. * If the button/trigger is currently pressed
  117301. */
  117302. pressed: boolean;
  117303. }>;
  117304. }
  117305. /**
  117306. * An Abstract Motion controller
  117307. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117308. * Each component has an observable to check for changes in value and state
  117309. */
  117310. export abstract class WebXRAbstractMotionController implements IDisposable {
  117311. protected scene: Scene;
  117312. protected layout: IMotionControllerLayout;
  117313. /**
  117314. * The gamepad object correlating to this controller
  117315. */
  117316. gamepadObject: IMinimalMotionControllerObject;
  117317. /**
  117318. * handness (left/right/none) of this controller
  117319. */
  117320. handness: MotionControllerHandness;
  117321. private _initComponent;
  117322. private _modelReady;
  117323. /**
  117324. * A map of components (WebXRControllerComponent) in this motion controller
  117325. * Components have a ComponentType and can also have both button and axis definitions
  117326. */
  117327. readonly components: {
  117328. [id: string]: WebXRControllerComponent;
  117329. };
  117330. /**
  117331. * Disable the model's animation. Can be set at any time.
  117332. */
  117333. disableAnimation: boolean;
  117334. /**
  117335. * Observers registered here will be triggered when the model of this controller is done loading
  117336. */
  117337. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117338. /**
  117339. * The profile id of this motion controller
  117340. */
  117341. abstract profileId: string;
  117342. /**
  117343. * The root mesh of the model. It is null if the model was not yet initialized
  117344. */
  117345. rootMesh: Nullable<AbstractMesh>;
  117346. /**
  117347. * constructs a new abstract motion controller
  117348. * @param scene the scene to which the model of the controller will be added
  117349. * @param layout The profile layout to load
  117350. * @param gamepadObject The gamepad object correlating to this controller
  117351. * @param handness handness (left/right/none) of this controller
  117352. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117353. */
  117354. constructor(scene: Scene, layout: IMotionControllerLayout,
  117355. /**
  117356. * The gamepad object correlating to this controller
  117357. */
  117358. gamepadObject: IMinimalMotionControllerObject,
  117359. /**
  117360. * handness (left/right/none) of this controller
  117361. */
  117362. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117363. /**
  117364. * Dispose this controller, the model mesh and all its components
  117365. */
  117366. dispose(): void;
  117367. /**
  117368. * Returns all components of specific type
  117369. * @param type the type to search for
  117370. * @return an array of components with this type
  117371. */
  117372. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117373. /**
  117374. * get a component based an its component id as defined in layout.components
  117375. * @param id the id of the component
  117376. * @returns the component correlates to the id or undefined if not found
  117377. */
  117378. getComponent(id: string): WebXRControllerComponent;
  117379. /**
  117380. * Get the list of components available in this motion controller
  117381. * @returns an array of strings correlating to available components
  117382. */
  117383. getComponentIds(): string[];
  117384. /**
  117385. * Get the first component of specific type
  117386. * @param type type of component to find
  117387. * @return a controller component or null if not found
  117388. */
  117389. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117390. /**
  117391. * Get the main (Select) component of this controller as defined in the layout
  117392. * @returns the main component of this controller
  117393. */
  117394. getMainComponent(): WebXRControllerComponent;
  117395. /**
  117396. * Loads the model correlating to this controller
  117397. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117398. * @returns A promise fulfilled with the result of the model loading
  117399. */
  117400. loadModel(): Promise<boolean>;
  117401. /**
  117402. * Update this model using the current XRFrame
  117403. * @param xrFrame the current xr frame to use and update the model
  117404. */
  117405. updateFromXRFrame(xrFrame: XRFrame): void;
  117406. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117407. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117408. /**
  117409. * Moves the axis on the controller mesh based on its current state
  117410. * @param axis the index of the axis
  117411. * @param axisValue the value of the axis which determines the meshes new position
  117412. * @hidden
  117413. */
  117414. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117415. /**
  117416. * Update the model itself with the current frame data
  117417. * @param xrFrame the frame to use for updating the model mesh
  117418. */
  117419. protected updateModel(xrFrame: XRFrame): void;
  117420. /**
  117421. * Get the filename and path for this controller's model
  117422. * @returns a map of filename and path
  117423. */
  117424. protected abstract _getFilenameAndPath(): {
  117425. filename: string;
  117426. path: string;
  117427. };
  117428. /**
  117429. * This function is called before the mesh is loaded. It checks for loading constraints.
  117430. * For example, this function can check if the GLB loader is available
  117431. * If this function returns false, the generic controller will be loaded instead
  117432. * @returns Is the client ready to load the mesh
  117433. */
  117434. protected abstract _getModelLoadingConstraints(): boolean;
  117435. /**
  117436. * This function will be called after the model was successfully loaded and can be used
  117437. * for mesh transformations before it is available for the user
  117438. * @param meshes the loaded meshes
  117439. */
  117440. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117441. /**
  117442. * Set the root mesh for this controller. Important for the WebXR controller class
  117443. * @param meshes the loaded meshes
  117444. */
  117445. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117446. /**
  117447. * A function executed each frame that updates the mesh (if needed)
  117448. * @param xrFrame the current xrFrame
  117449. */
  117450. protected abstract _updateModel(xrFrame: XRFrame): void;
  117451. private _getGenericFilenameAndPath;
  117452. private _getGenericParentMesh;
  117453. }
  117454. }
  117455. declare module BABYLON {
  117456. /**
  117457. * A generic trigger-only motion controller for WebXR
  117458. */
  117459. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117460. /**
  117461. * Static version of the profile id of this controller
  117462. */
  117463. static ProfileId: string;
  117464. profileId: string;
  117465. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117466. protected _getFilenameAndPath(): {
  117467. filename: string;
  117468. path: string;
  117469. };
  117470. protected _getModelLoadingConstraints(): boolean;
  117471. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117472. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117473. protected _updateModel(): void;
  117474. }
  117475. }
  117476. declare module BABYLON {
  117477. /**
  117478. * Class containing static functions to help procedurally build meshes
  117479. */
  117480. export class SphereBuilder {
  117481. /**
  117482. * Creates a sphere mesh
  117483. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117484. * * 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`)
  117485. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117486. * * 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
  117487. * * 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)
  117488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117491. * @param name defines the name of the mesh
  117492. * @param options defines the options used to create the mesh
  117493. * @param scene defines the hosting scene
  117494. * @returns the sphere mesh
  117495. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117496. */
  117497. static CreateSphere(name: string, options: {
  117498. segments?: number;
  117499. diameter?: number;
  117500. diameterX?: number;
  117501. diameterY?: number;
  117502. diameterZ?: number;
  117503. arc?: number;
  117504. slice?: number;
  117505. sideOrientation?: number;
  117506. frontUVs?: Vector4;
  117507. backUVs?: Vector4;
  117508. updatable?: boolean;
  117509. }, scene?: Nullable<Scene>): Mesh;
  117510. }
  117511. }
  117512. declare module BABYLON {
  117513. /**
  117514. * A profiled motion controller has its profile loaded from an online repository.
  117515. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117516. */
  117517. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117518. private _repositoryUrl;
  117519. private _buttonMeshMapping;
  117520. private _touchDots;
  117521. /**
  117522. * The profile ID of this controller. Will be populated when the controller initializes.
  117523. */
  117524. profileId: string;
  117525. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117526. dispose(): void;
  117527. protected _getFilenameAndPath(): {
  117528. filename: string;
  117529. path: string;
  117530. };
  117531. protected _getModelLoadingConstraints(): boolean;
  117532. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117533. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117534. protected _updateModel(_xrFrame: XRFrame): void;
  117535. }
  117536. }
  117537. declare module BABYLON {
  117538. /**
  117539. * A construction function type to create a new controller based on an xrInput object
  117540. */
  117541. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117542. /**
  117543. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117544. *
  117545. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117546. * it should be replaced with auto-loaded controllers.
  117547. *
  117548. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117549. */
  117550. export class WebXRMotionControllerManager {
  117551. private static _AvailableControllers;
  117552. private static _Fallbacks;
  117553. private static _ProfileLoadingPromises;
  117554. private static _ProfilesList;
  117555. /**
  117556. * The base URL of the online controller repository. Can be changed at any time.
  117557. */
  117558. static BaseRepositoryUrl: string;
  117559. /**
  117560. * Which repository gets priority - local or online
  117561. */
  117562. static PrioritizeOnlineRepository: boolean;
  117563. /**
  117564. * Use the online repository, or use only locally-defined controllers
  117565. */
  117566. static UseOnlineRepository: boolean;
  117567. /**
  117568. * Clear the cache used for profile loading and reload when requested again
  117569. */
  117570. static ClearProfilesCache(): void;
  117571. /**
  117572. * Register the default fallbacks.
  117573. * This function is called automatically when this file is imported.
  117574. */
  117575. static DefaultFallbacks(): void;
  117576. /**
  117577. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117578. * @param profileId the profile to which a fallback needs to be found
  117579. * @return an array with corresponding fallback profiles
  117580. */
  117581. static FindFallbackWithProfileId(profileId: string): string[];
  117582. /**
  117583. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117584. * The order of search:
  117585. *
  117586. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117587. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117588. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117589. * 4) return the generic trigger controller if none were found
  117590. *
  117591. * @param xrInput the xrInput to which a new controller is initialized
  117592. * @param scene the scene to which the model will be added
  117593. * @param forceProfile force a certain profile for this controller
  117594. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117595. */
  117596. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117597. /**
  117598. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117599. *
  117600. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117601. *
  117602. * @param type the profile type to register
  117603. * @param constructFunction the function to be called when loading this profile
  117604. */
  117605. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117606. /**
  117607. * Register a fallback to a specific profile.
  117608. * @param profileId the profileId that will receive the fallbacks
  117609. * @param fallbacks A list of fallback profiles
  117610. */
  117611. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117612. /**
  117613. * Will update the list of profiles available in the repository
  117614. * @return a promise that resolves to a map of profiles available online
  117615. */
  117616. static UpdateProfilesList(): Promise<{
  117617. [profile: string]: string;
  117618. }>;
  117619. private static _LoadProfileFromRepository;
  117620. private static _LoadProfilesFromAvailableControllers;
  117621. }
  117622. }
  117623. declare module BABYLON {
  117624. /**
  117625. * Configuration options for the WebXR controller creation
  117626. */
  117627. export interface IWebXRControllerOptions {
  117628. /**
  117629. * Should the controller mesh be animated when a user interacts with it
  117630. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117631. */
  117632. disableMotionControllerAnimation?: boolean;
  117633. /**
  117634. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117635. */
  117636. doNotLoadControllerMesh?: boolean;
  117637. /**
  117638. * Force a specific controller type for this controller.
  117639. * This can be used when creating your own profile or when testing different controllers
  117640. */
  117641. forceControllerProfile?: string;
  117642. }
  117643. /**
  117644. * Represents an XR controller
  117645. */
  117646. export class WebXRInputSource {
  117647. private _scene;
  117648. /** The underlying input source for the controller */
  117649. inputSource: XRInputSource;
  117650. private _options;
  117651. private _tmpQuaternion;
  117652. private _tmpVector;
  117653. private _uniqueId;
  117654. /**
  117655. * 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
  117656. */
  117657. grip?: AbstractMesh;
  117658. /**
  117659. * If available, this is the gamepad object related to this controller.
  117660. * Using this object it is possible to get click events and trackpad changes of the
  117661. * webxr controller that is currently being used.
  117662. */
  117663. motionController?: WebXRAbstractMotionController;
  117664. /**
  117665. * Event that fires when the controller is removed/disposed.
  117666. * The object provided as event data is this controller, after associated assets were disposed.
  117667. * uniqueId is still available.
  117668. */
  117669. onDisposeObservable: Observable<WebXRInputSource>;
  117670. /**
  117671. * Will be triggered when the mesh associated with the motion controller is done loading.
  117672. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117673. * A shortened version of controller -> motion controller -> on mesh loaded.
  117674. */
  117675. onMeshLoadedObservable: Observable<AbstractMesh>;
  117676. /**
  117677. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117678. */
  117679. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117680. /**
  117681. * Pointer which can be used to select objects or attach a visible laser to
  117682. */
  117683. pointer: AbstractMesh;
  117684. /**
  117685. * Creates the controller
  117686. * @see https://doc.babylonjs.com/how_to/webxr
  117687. * @param _scene the scene which the controller should be associated to
  117688. * @param inputSource the underlying input source for the controller
  117689. * @param _options options for this controller creation
  117690. */
  117691. constructor(_scene: Scene,
  117692. /** The underlying input source for the controller */
  117693. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117694. /**
  117695. * Get this controllers unique id
  117696. */
  117697. get uniqueId(): string;
  117698. /**
  117699. * Disposes of the object
  117700. */
  117701. dispose(): void;
  117702. /**
  117703. * Gets a world space ray coming from the pointer or grip
  117704. * @param result the resulting ray
  117705. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117706. */
  117707. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117708. /**
  117709. * Updates the controller pose based on the given XRFrame
  117710. * @param xrFrame xr frame to update the pose with
  117711. * @param referenceSpace reference space to use
  117712. */
  117713. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117714. }
  117715. }
  117716. declare module BABYLON {
  117717. /**
  117718. * The schema for initialization options of the XR Input class
  117719. */
  117720. export interface IWebXRInputOptions {
  117721. /**
  117722. * If set to true no model will be automatically loaded
  117723. */
  117724. doNotLoadControllerMeshes?: boolean;
  117725. /**
  117726. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117727. * If not found, the xr input profile data will be used.
  117728. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117729. */
  117730. forceInputProfile?: string;
  117731. /**
  117732. * Do not send a request to the controller repository to load the profile.
  117733. *
  117734. * Instead, use the controllers available in babylon itself.
  117735. */
  117736. disableOnlineControllerRepository?: boolean;
  117737. /**
  117738. * A custom URL for the controllers repository
  117739. */
  117740. customControllersRepositoryURL?: string;
  117741. /**
  117742. * Should the controller model's components not move according to the user input
  117743. */
  117744. disableControllerAnimation?: boolean;
  117745. }
  117746. /**
  117747. * XR input used to track XR inputs such as controllers/rays
  117748. */
  117749. export class WebXRInput implements IDisposable {
  117750. /**
  117751. * the xr session manager for this session
  117752. */
  117753. xrSessionManager: WebXRSessionManager;
  117754. /**
  117755. * the WebXR camera for this session. Mainly used for teleportation
  117756. */
  117757. xrCamera: WebXRCamera;
  117758. private readonly options;
  117759. /**
  117760. * XR controllers being tracked
  117761. */
  117762. controllers: Array<WebXRInputSource>;
  117763. private _frameObserver;
  117764. private _sessionEndedObserver;
  117765. private _sessionInitObserver;
  117766. /**
  117767. * Event when a controller has been connected/added
  117768. */
  117769. onControllerAddedObservable: Observable<WebXRInputSource>;
  117770. /**
  117771. * Event when a controller has been removed/disconnected
  117772. */
  117773. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117774. /**
  117775. * Initializes the WebXRInput
  117776. * @param xrSessionManager the xr session manager for this session
  117777. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117778. * @param options = initialization options for this xr input
  117779. */
  117780. constructor(
  117781. /**
  117782. * the xr session manager for this session
  117783. */
  117784. xrSessionManager: WebXRSessionManager,
  117785. /**
  117786. * the WebXR camera for this session. Mainly used for teleportation
  117787. */
  117788. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117789. private _onInputSourcesChange;
  117790. private _addAndRemoveControllers;
  117791. /**
  117792. * Disposes of the object
  117793. */
  117794. dispose(): void;
  117795. }
  117796. }
  117797. declare module BABYLON {
  117798. /**
  117799. * This is the base class for all WebXR features.
  117800. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117801. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117802. */
  117803. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117804. protected _xrSessionManager: WebXRSessionManager;
  117805. private _attached;
  117806. private _removeOnDetach;
  117807. /**
  117808. * Should auto-attach be disabled?
  117809. */
  117810. disableAutoAttach: boolean;
  117811. /**
  117812. * Construct a new (abstract) WebXR feature
  117813. * @param _xrSessionManager the xr session manager for this feature
  117814. */
  117815. constructor(_xrSessionManager: WebXRSessionManager);
  117816. /**
  117817. * Is this feature attached
  117818. */
  117819. get attached(): boolean;
  117820. /**
  117821. * attach this feature
  117822. *
  117823. * @param force should attachment be forced (even when already attached)
  117824. * @returns true if successful, false is failed or already attached
  117825. */
  117826. attach(force?: boolean): boolean;
  117827. /**
  117828. * detach this feature.
  117829. *
  117830. * @returns true if successful, false if failed or already detached
  117831. */
  117832. detach(): boolean;
  117833. /**
  117834. * Dispose this feature and all of the resources attached
  117835. */
  117836. dispose(): void;
  117837. /**
  117838. * This is used to register callbacks that will automatically be removed when detach is called.
  117839. * @param observable the observable to which the observer will be attached
  117840. * @param callback the callback to register
  117841. */
  117842. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117843. /**
  117844. * Code in this function will be executed on each xrFrame received from the browser.
  117845. * This function will not execute after the feature is detached.
  117846. * @param _xrFrame the current frame
  117847. */
  117848. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117849. }
  117850. }
  117851. declare module BABYLON {
  117852. /**
  117853. * Renders a layer on top of an existing scene
  117854. */
  117855. export class UtilityLayerRenderer implements IDisposable {
  117856. /** the original scene that will be rendered on top of */
  117857. originalScene: Scene;
  117858. private _pointerCaptures;
  117859. private _lastPointerEvents;
  117860. private static _DefaultUtilityLayer;
  117861. private static _DefaultKeepDepthUtilityLayer;
  117862. private _sharedGizmoLight;
  117863. private _renderCamera;
  117864. /**
  117865. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117866. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  117867. * @returns the camera that is used when rendering the utility layer
  117868. */
  117869. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  117870. /**
  117871. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117872. * @param cam the camera that should be used when rendering the utility layer
  117873. */
  117874. setRenderCamera(cam: Nullable<Camera>): void;
  117875. /**
  117876. * @hidden
  117877. * Light which used by gizmos to get light shading
  117878. */
  117879. _getSharedGizmoLight(): HemisphericLight;
  117880. /**
  117881. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117882. */
  117883. pickUtilitySceneFirst: boolean;
  117884. /**
  117885. * 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)
  117886. */
  117887. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117888. /**
  117889. * 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)
  117890. */
  117891. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117892. /**
  117893. * The scene that is rendered on top of the original scene
  117894. */
  117895. utilityLayerScene: Scene;
  117896. /**
  117897. * If the utility layer should automatically be rendered on top of existing scene
  117898. */
  117899. shouldRender: boolean;
  117900. /**
  117901. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117902. */
  117903. onlyCheckPointerDownEvents: boolean;
  117904. /**
  117905. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117906. */
  117907. processAllEvents: boolean;
  117908. /**
  117909. * Observable raised when the pointer move from the utility layer scene to the main scene
  117910. */
  117911. onPointerOutObservable: Observable<number>;
  117912. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117913. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117914. private _afterRenderObserver;
  117915. private _sceneDisposeObserver;
  117916. private _originalPointerObserver;
  117917. /**
  117918. * Instantiates a UtilityLayerRenderer
  117919. * @param originalScene the original scene that will be rendered on top of
  117920. * @param handleEvents boolean indicating if the utility layer should handle events
  117921. */
  117922. constructor(
  117923. /** the original scene that will be rendered on top of */
  117924. originalScene: Scene, handleEvents?: boolean);
  117925. private _notifyObservers;
  117926. /**
  117927. * Renders the utility layers scene on top of the original scene
  117928. */
  117929. render(): void;
  117930. /**
  117931. * Disposes of the renderer
  117932. */
  117933. dispose(): void;
  117934. private _updateCamera;
  117935. }
  117936. }
  117937. declare module BABYLON {
  117938. /**
  117939. * Options interface for the pointer selection module
  117940. */
  117941. export interface IWebXRControllerPointerSelectionOptions {
  117942. /**
  117943. * if provided, this scene will be used to render meshes.
  117944. */
  117945. customUtilityLayerScene?: Scene;
  117946. /**
  117947. * 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)
  117948. * If not disabled, the last picked point will be used to execute a pointer up event
  117949. * If disabled, pointer up event will be triggered right after the pointer down event.
  117950. * Used in screen and gaze target ray mode only
  117951. */
  117952. disablePointerUpOnTouchOut: boolean;
  117953. /**
  117954. * For gaze mode (time to select instead of press)
  117955. */
  117956. forceGazeMode: boolean;
  117957. /**
  117958. * 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
  117959. * to start a new countdown to the pointer down event.
  117960. * Defaults to 1.
  117961. */
  117962. gazeModePointerMovedFactor?: number;
  117963. /**
  117964. * Different button type to use instead of the main component
  117965. */
  117966. overrideButtonId?: string;
  117967. /**
  117968. * use this rendering group id for the meshes (optional)
  117969. */
  117970. renderingGroupId?: number;
  117971. /**
  117972. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117973. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117974. * 3000 means 3 seconds between pointing at something and selecting it
  117975. */
  117976. timeToSelect?: number;
  117977. /**
  117978. * Should meshes created here be added to a utility layer or the main scene
  117979. */
  117980. useUtilityLayer?: boolean;
  117981. /**
  117982. * the xr input to use with this pointer selection
  117983. */
  117984. xrInput: WebXRInput;
  117985. }
  117986. /**
  117987. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117988. */
  117989. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117990. private readonly _options;
  117991. private static _idCounter;
  117992. private _attachController;
  117993. private _controllers;
  117994. private _scene;
  117995. private _tmpVectorForPickCompare;
  117996. /**
  117997. * The module's name
  117998. */
  117999. static readonly Name: string;
  118000. /**
  118001. * The (Babylon) version of this module.
  118002. * This is an integer representing the implementation version.
  118003. * This number does not correspond to the WebXR specs version
  118004. */
  118005. static readonly Version: number;
  118006. /**
  118007. * Disable lighting on the laser pointer (so it will always be visible)
  118008. */
  118009. disablePointerLighting: boolean;
  118010. /**
  118011. * Disable lighting on the selection mesh (so it will always be visible)
  118012. */
  118013. disableSelectionMeshLighting: boolean;
  118014. /**
  118015. * Should the laser pointer be displayed
  118016. */
  118017. displayLaserPointer: boolean;
  118018. /**
  118019. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  118020. */
  118021. displaySelectionMesh: boolean;
  118022. /**
  118023. * This color will be set to the laser pointer when selection is triggered
  118024. */
  118025. laserPointerPickedColor: Color3;
  118026. /**
  118027. * Default color of the laser pointer
  118028. */
  118029. lasterPointerDefaultColor: Color3;
  118030. /**
  118031. * default color of the selection ring
  118032. */
  118033. selectionMeshDefaultColor: Color3;
  118034. /**
  118035. * This color will be applied to the selection ring when selection is triggered
  118036. */
  118037. selectionMeshPickedColor: Color3;
  118038. /**
  118039. * constructs a new background remover module
  118040. * @param _xrSessionManager the session manager for this module
  118041. * @param _options read-only options to be used in this module
  118042. */
  118043. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  118044. /**
  118045. * attach this feature
  118046. * Will usually be called by the features manager
  118047. *
  118048. * @returns true if successful.
  118049. */
  118050. attach(): boolean;
  118051. /**
  118052. * detach this feature.
  118053. * Will usually be called by the features manager
  118054. *
  118055. * @returns true if successful.
  118056. */
  118057. detach(): boolean;
  118058. /**
  118059. * Will get the mesh under a specific pointer.
  118060. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  118061. * @param controllerId the controllerId to check
  118062. * @returns The mesh under pointer or null if no mesh is under the pointer
  118063. */
  118064. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  118065. /**
  118066. * Get the xr controller that correlates to the pointer id in the pointer event
  118067. *
  118068. * @param id the pointer id to search for
  118069. * @returns the controller that correlates to this id or null if not found
  118070. */
  118071. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  118072. protected _onXRFrame(_xrFrame: XRFrame): void;
  118073. private _attachGazeMode;
  118074. private _attachScreenRayMode;
  118075. private _attachTrackedPointerRayMode;
  118076. private _convertNormalToDirectionOfRay;
  118077. private _detachController;
  118078. private _generateNewMeshPair;
  118079. private _pickingMoved;
  118080. private _updatePointerDistance;
  118081. }
  118082. }
  118083. declare module BABYLON {
  118084. /**
  118085. * Button which can be used to enter a different mode of XR
  118086. */
  118087. export class WebXREnterExitUIButton {
  118088. /** button element */
  118089. element: HTMLElement;
  118090. /** XR initialization options for the button */
  118091. sessionMode: XRSessionMode;
  118092. /** Reference space type */
  118093. referenceSpaceType: XRReferenceSpaceType;
  118094. /**
  118095. * Creates a WebXREnterExitUIButton
  118096. * @param element button element
  118097. * @param sessionMode XR initialization session mode
  118098. * @param referenceSpaceType the type of reference space to be used
  118099. */
  118100. constructor(
  118101. /** button element */
  118102. element: HTMLElement,
  118103. /** XR initialization options for the button */
  118104. sessionMode: XRSessionMode,
  118105. /** Reference space type */
  118106. referenceSpaceType: XRReferenceSpaceType);
  118107. /**
  118108. * Extendable function which can be used to update the button's visuals when the state changes
  118109. * @param activeButton the current active button in the UI
  118110. */
  118111. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  118112. }
  118113. /**
  118114. * Options to create the webXR UI
  118115. */
  118116. export class WebXREnterExitUIOptions {
  118117. /**
  118118. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  118119. */
  118120. customButtons?: Array<WebXREnterExitUIButton>;
  118121. /**
  118122. * A reference space type to use when creating the default button.
  118123. * Default is local-floor
  118124. */
  118125. referenceSpaceType?: XRReferenceSpaceType;
  118126. /**
  118127. * Context to enter xr with
  118128. */
  118129. renderTarget?: Nullable<WebXRRenderTarget>;
  118130. /**
  118131. * A session mode to use when creating the default button.
  118132. * Default is immersive-vr
  118133. */
  118134. sessionMode?: XRSessionMode;
  118135. }
  118136. /**
  118137. * UI to allow the user to enter/exit XR mode
  118138. */
  118139. export class WebXREnterExitUI implements IDisposable {
  118140. private scene;
  118141. /** version of the options passed to this UI */
  118142. options: WebXREnterExitUIOptions;
  118143. private _activeButton;
  118144. private _buttons;
  118145. private _overlay;
  118146. /**
  118147. * Fired every time the active button is changed.
  118148. *
  118149. * When xr is entered via a button that launches xr that button will be the callback parameter
  118150. *
  118151. * When exiting xr the callback parameter will be null)
  118152. */
  118153. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  118154. /**
  118155. *
  118156. * @param scene babylon scene object to use
  118157. * @param options (read-only) version of the options passed to this UI
  118158. */
  118159. private constructor();
  118160. /**
  118161. * Creates UI to allow the user to enter/exit XR mode
  118162. * @param scene the scene to add the ui to
  118163. * @param helper the xr experience helper to enter/exit xr with
  118164. * @param options options to configure the UI
  118165. * @returns the created ui
  118166. */
  118167. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118168. /**
  118169. * Disposes of the XR UI component
  118170. */
  118171. dispose(): void;
  118172. private _updateButtons;
  118173. }
  118174. }
  118175. declare module BABYLON {
  118176. /**
  118177. * Class containing static functions to help procedurally build meshes
  118178. */
  118179. export class LinesBuilder {
  118180. /**
  118181. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118182. * * 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
  118183. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118184. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118185. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118186. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118187. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118188. * * 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
  118189. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118192. * @param name defines the name of the new line system
  118193. * @param options defines the options used to create the line system
  118194. * @param scene defines the hosting scene
  118195. * @returns a new line system mesh
  118196. */
  118197. static CreateLineSystem(name: string, options: {
  118198. lines: Vector3[][];
  118199. updatable?: boolean;
  118200. instance?: Nullable<LinesMesh>;
  118201. colors?: Nullable<Color4[][]>;
  118202. useVertexAlpha?: boolean;
  118203. }, scene: Nullable<Scene>): LinesMesh;
  118204. /**
  118205. * Creates a line mesh
  118206. * 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
  118207. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118208. * * The parameter `points` is an array successive Vector3
  118209. * * 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
  118210. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118211. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118212. * * When updating an instance, remember that only point positions can change, not the number of points
  118213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118215. * @param name defines the name of the new line system
  118216. * @param options defines the options used to create the line system
  118217. * @param scene defines the hosting scene
  118218. * @returns a new line mesh
  118219. */
  118220. static CreateLines(name: string, options: {
  118221. points: Vector3[];
  118222. updatable?: boolean;
  118223. instance?: Nullable<LinesMesh>;
  118224. colors?: Color4[];
  118225. useVertexAlpha?: boolean;
  118226. }, scene?: Nullable<Scene>): LinesMesh;
  118227. /**
  118228. * Creates a dashed line mesh
  118229. * * 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
  118230. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118231. * * The parameter `points` is an array successive Vector3
  118232. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118233. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118234. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118235. * * 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
  118236. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118237. * * When updating an instance, remember that only point positions can change, not the number of points
  118238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118239. * @param name defines the name of the mesh
  118240. * @param options defines the options used to create the mesh
  118241. * @param scene defines the hosting scene
  118242. * @returns the dashed line mesh
  118243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118244. */
  118245. static CreateDashedLines(name: string, options: {
  118246. points: Vector3[];
  118247. dashSize?: number;
  118248. gapSize?: number;
  118249. dashNb?: number;
  118250. updatable?: boolean;
  118251. instance?: LinesMesh;
  118252. useVertexAlpha?: boolean;
  118253. }, scene?: Nullable<Scene>): LinesMesh;
  118254. }
  118255. }
  118256. declare module BABYLON {
  118257. /**
  118258. * The options container for the teleportation module
  118259. */
  118260. export interface IWebXRTeleportationOptions {
  118261. /**
  118262. * if provided, this scene will be used to render meshes.
  118263. */
  118264. customUtilityLayerScene?: Scene;
  118265. /**
  118266. * Values to configure the default target mesh
  118267. */
  118268. defaultTargetMeshOptions?: {
  118269. /**
  118270. * Fill color of the teleportation area
  118271. */
  118272. teleportationFillColor?: string;
  118273. /**
  118274. * Border color for the teleportation area
  118275. */
  118276. teleportationBorderColor?: string;
  118277. /**
  118278. * Disable the mesh's animation sequence
  118279. */
  118280. disableAnimation?: boolean;
  118281. /**
  118282. * Disable lighting on the material or the ring and arrow
  118283. */
  118284. disableLighting?: boolean;
  118285. /**
  118286. * Override the default material of the torus and arrow
  118287. */
  118288. torusArrowMaterial?: Material;
  118289. };
  118290. /**
  118291. * A list of meshes to use as floor meshes.
  118292. * Meshes can be added and removed after initializing the feature using the
  118293. * addFloorMesh and removeFloorMesh functions
  118294. * If empty, rotation will still work
  118295. */
  118296. floorMeshes?: AbstractMesh[];
  118297. /**
  118298. * use this rendering group id for the meshes (optional)
  118299. */
  118300. renderingGroupId?: number;
  118301. /**
  118302. * Should teleportation move only to snap points
  118303. */
  118304. snapPointsOnly?: boolean;
  118305. /**
  118306. * An array of points to which the teleportation will snap to.
  118307. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118308. */
  118309. snapPositions?: Vector3[];
  118310. /**
  118311. * How close should the teleportation ray be in order to snap to position.
  118312. * Default to 0.8 units (meters)
  118313. */
  118314. snapToPositionRadius?: number;
  118315. /**
  118316. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118317. * If you want to support rotation, make sure your mesh has a direction indicator.
  118318. *
  118319. * When left untouched, the default mesh will be initialized.
  118320. */
  118321. teleportationTargetMesh?: AbstractMesh;
  118322. /**
  118323. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118324. */
  118325. timeToTeleport?: number;
  118326. /**
  118327. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118328. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118329. */
  118330. useMainComponentOnly?: boolean;
  118331. /**
  118332. * Should meshes created here be added to a utility layer or the main scene
  118333. */
  118334. useUtilityLayer?: boolean;
  118335. /**
  118336. * Babylon XR Input class for controller
  118337. */
  118338. xrInput: WebXRInput;
  118339. }
  118340. /**
  118341. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118342. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118343. * the input of the attached controllers.
  118344. */
  118345. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118346. private _options;
  118347. private _controllers;
  118348. private _currentTeleportationControllerId;
  118349. private _floorMeshes;
  118350. private _quadraticBezierCurve;
  118351. private _selectionFeature;
  118352. private _snapToPositions;
  118353. private _snappedToPoint;
  118354. private _teleportationRingMaterial?;
  118355. private _tmpRay;
  118356. private _tmpVector;
  118357. /**
  118358. * The module's name
  118359. */
  118360. static readonly Name: string;
  118361. /**
  118362. * The (Babylon) version of this module.
  118363. * This is an integer representing the implementation version.
  118364. * This number does not correspond to the webxr specs version
  118365. */
  118366. static readonly Version: number;
  118367. /**
  118368. * Is movement backwards enabled
  118369. */
  118370. backwardsMovementEnabled: boolean;
  118371. /**
  118372. * Distance to travel when moving backwards
  118373. */
  118374. backwardsTeleportationDistance: number;
  118375. /**
  118376. * The distance from the user to the inspection point in the direction of the controller
  118377. * A higher number will allow the user to move further
  118378. * defaults to 5 (meters, in xr units)
  118379. */
  118380. parabolicCheckRadius: number;
  118381. /**
  118382. * Should the module support parabolic ray on top of direct ray
  118383. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118384. * Very helpful when moving between floors / different heights
  118385. */
  118386. parabolicRayEnabled: boolean;
  118387. /**
  118388. * How much rotation should be applied when rotating right and left
  118389. */
  118390. rotationAngle: number;
  118391. /**
  118392. * Is rotation enabled when moving forward?
  118393. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118394. */
  118395. rotationEnabled: boolean;
  118396. /**
  118397. * constructs a new anchor system
  118398. * @param _xrSessionManager an instance of WebXRSessionManager
  118399. * @param _options configuration object for this feature
  118400. */
  118401. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118402. /**
  118403. * Get the snapPointsOnly flag
  118404. */
  118405. get snapPointsOnly(): boolean;
  118406. /**
  118407. * Sets the snapPointsOnly flag
  118408. * @param snapToPoints should teleportation be exclusively to snap points
  118409. */
  118410. set snapPointsOnly(snapToPoints: boolean);
  118411. /**
  118412. * Add a new mesh to the floor meshes array
  118413. * @param mesh the mesh to use as floor mesh
  118414. */
  118415. addFloorMesh(mesh: AbstractMesh): void;
  118416. /**
  118417. * Add a new snap-to point to fix teleportation to this position
  118418. * @param newSnapPoint The new Snap-To point
  118419. */
  118420. addSnapPoint(newSnapPoint: Vector3): void;
  118421. attach(): boolean;
  118422. detach(): boolean;
  118423. dispose(): void;
  118424. /**
  118425. * Remove a mesh from the floor meshes array
  118426. * @param mesh the mesh to remove
  118427. */
  118428. removeFloorMesh(mesh: AbstractMesh): void;
  118429. /**
  118430. * Remove a mesh from the floor meshes array using its name
  118431. * @param name the mesh name to remove
  118432. */
  118433. removeFloorMeshByName(name: string): void;
  118434. /**
  118435. * 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
  118436. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118437. * @returns was the point found and removed or not
  118438. */
  118439. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118440. /**
  118441. * This function sets a selection feature that will be disabled when
  118442. * the forward ray is shown and will be reattached when hidden.
  118443. * This is used to remove the selection rays when moving.
  118444. * @param selectionFeature the feature to disable when forward movement is enabled
  118445. */
  118446. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118447. protected _onXRFrame(_xrFrame: XRFrame): void;
  118448. private _attachController;
  118449. private _createDefaultTargetMesh;
  118450. private _detachController;
  118451. private _findClosestSnapPointWithRadius;
  118452. private _setTargetMeshPosition;
  118453. private _setTargetMeshVisibility;
  118454. private _showParabolicPath;
  118455. private _teleportForward;
  118456. }
  118457. }
  118458. declare module BABYLON {
  118459. /**
  118460. * Options for the default xr helper
  118461. */
  118462. export class WebXRDefaultExperienceOptions {
  118463. /**
  118464. * Enable or disable default UI to enter XR
  118465. */
  118466. disableDefaultUI?: boolean;
  118467. /**
  118468. * Should teleportation not initialize. defaults to false.
  118469. */
  118470. disableTeleportation?: boolean;
  118471. /**
  118472. * Floor meshes that will be used for teleport
  118473. */
  118474. floorMeshes?: Array<AbstractMesh>;
  118475. /**
  118476. * If set to true, the first frame will not be used to reset position
  118477. * The first frame is mainly used when copying transformation from the old camera
  118478. * Mainly used in AR
  118479. */
  118480. ignoreNativeCameraTransformation?: boolean;
  118481. /**
  118482. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118483. */
  118484. inputOptions?: IWebXRInputOptions;
  118485. /**
  118486. * optional configuration for the output canvas
  118487. */
  118488. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118489. /**
  118490. * optional UI options. This can be used among other to change session mode and reference space type
  118491. */
  118492. uiOptions?: WebXREnterExitUIOptions;
  118493. /**
  118494. * When loading teleportation and pointer select, use stable versions instead of latest.
  118495. */
  118496. useStablePlugins?: boolean;
  118497. }
  118498. /**
  118499. * Default experience which provides a similar setup to the previous webVRExperience
  118500. */
  118501. export class WebXRDefaultExperience {
  118502. /**
  118503. * Base experience
  118504. */
  118505. baseExperience: WebXRExperienceHelper;
  118506. /**
  118507. * Enables ui for entering/exiting xr
  118508. */
  118509. enterExitUI: WebXREnterExitUI;
  118510. /**
  118511. * Input experience extension
  118512. */
  118513. input: WebXRInput;
  118514. /**
  118515. * Enables laser pointer and selection
  118516. */
  118517. pointerSelection: WebXRControllerPointerSelection;
  118518. /**
  118519. * Default target xr should render to
  118520. */
  118521. renderTarget: WebXRRenderTarget;
  118522. /**
  118523. * Enables teleportation
  118524. */
  118525. teleportation: WebXRMotionControllerTeleportation;
  118526. private constructor();
  118527. /**
  118528. * Creates the default xr experience
  118529. * @param scene scene
  118530. * @param options options for basic configuration
  118531. * @returns resulting WebXRDefaultExperience
  118532. */
  118533. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118534. /**
  118535. * DIsposes of the experience helper
  118536. */
  118537. dispose(): void;
  118538. }
  118539. }
  118540. declare module BABYLON {
  118541. /**
  118542. * Options to modify the vr teleportation behavior.
  118543. */
  118544. export interface VRTeleportationOptions {
  118545. /**
  118546. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118547. */
  118548. floorMeshName?: string;
  118549. /**
  118550. * A list of meshes to be used as the teleportation floor. (default: empty)
  118551. */
  118552. floorMeshes?: Mesh[];
  118553. /**
  118554. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118555. */
  118556. teleportationMode?: number;
  118557. /**
  118558. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118559. */
  118560. teleportationTime?: number;
  118561. /**
  118562. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118563. */
  118564. teleportationSpeed?: number;
  118565. /**
  118566. * The easing function used in the animation or null for Linear. (default CircleEase)
  118567. */
  118568. easingFunction?: EasingFunction;
  118569. }
  118570. /**
  118571. * Options to modify the vr experience helper's behavior.
  118572. */
  118573. export interface VRExperienceHelperOptions extends WebVROptions {
  118574. /**
  118575. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118576. */
  118577. createDeviceOrientationCamera?: boolean;
  118578. /**
  118579. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118580. */
  118581. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118582. /**
  118583. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118584. */
  118585. laserToggle?: boolean;
  118586. /**
  118587. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118588. */
  118589. floorMeshes?: Mesh[];
  118590. /**
  118591. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118592. */
  118593. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118594. /**
  118595. * Defines if WebXR should be used instead of WebVR (if available)
  118596. */
  118597. useXR?: boolean;
  118598. }
  118599. /**
  118600. * Event containing information after VR has been entered
  118601. */
  118602. export class OnAfterEnteringVRObservableEvent {
  118603. /**
  118604. * If entering vr was successful
  118605. */
  118606. success: boolean;
  118607. }
  118608. /**
  118609. * Helps to quickly add VR support to an existing scene.
  118610. * See http://doc.babylonjs.com/how_to/webvr_helper
  118611. */
  118612. export class VRExperienceHelper {
  118613. /** Options to modify the vr experience helper's behavior. */
  118614. webVROptions: VRExperienceHelperOptions;
  118615. private _scene;
  118616. private _position;
  118617. private _btnVR;
  118618. private _btnVRDisplayed;
  118619. private _webVRsupported;
  118620. private _webVRready;
  118621. private _webVRrequesting;
  118622. private _webVRpresenting;
  118623. private _hasEnteredVR;
  118624. private _fullscreenVRpresenting;
  118625. private _inputElement;
  118626. private _webVRCamera;
  118627. private _vrDeviceOrientationCamera;
  118628. private _deviceOrientationCamera;
  118629. private _existingCamera;
  118630. private _onKeyDown;
  118631. private _onVrDisplayPresentChange;
  118632. private _onVRDisplayChanged;
  118633. private _onVRRequestPresentStart;
  118634. private _onVRRequestPresentComplete;
  118635. /**
  118636. * 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)
  118637. */
  118638. enableGazeEvenWhenNoPointerLock: boolean;
  118639. /**
  118640. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118641. */
  118642. exitVROnDoubleTap: boolean;
  118643. /**
  118644. * Observable raised right before entering VR.
  118645. */
  118646. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118647. /**
  118648. * Observable raised when entering VR has completed.
  118649. */
  118650. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118651. /**
  118652. * Observable raised when exiting VR.
  118653. */
  118654. onExitingVRObservable: Observable<VRExperienceHelper>;
  118655. /**
  118656. * Observable raised when controller mesh is loaded.
  118657. */
  118658. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118659. /** Return this.onEnteringVRObservable
  118660. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118661. */
  118662. get onEnteringVR(): Observable<VRExperienceHelper>;
  118663. /** Return this.onExitingVRObservable
  118664. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118665. */
  118666. get onExitingVR(): Observable<VRExperienceHelper>;
  118667. /** Return this.onControllerMeshLoadedObservable
  118668. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118669. */
  118670. get onControllerMeshLoaded(): Observable<WebVRController>;
  118671. private _rayLength;
  118672. private _useCustomVRButton;
  118673. private _teleportationRequested;
  118674. private _teleportActive;
  118675. private _floorMeshName;
  118676. private _floorMeshesCollection;
  118677. private _teleportationMode;
  118678. private _teleportationTime;
  118679. private _teleportationSpeed;
  118680. private _teleportationEasing;
  118681. private _rotationAllowed;
  118682. private _teleportBackwardsVector;
  118683. private _teleportationTarget;
  118684. private _isDefaultTeleportationTarget;
  118685. private _postProcessMove;
  118686. private _teleportationFillColor;
  118687. private _teleportationBorderColor;
  118688. private _rotationAngle;
  118689. private _haloCenter;
  118690. private _cameraGazer;
  118691. private _padSensibilityUp;
  118692. private _padSensibilityDown;
  118693. private _leftController;
  118694. private _rightController;
  118695. private _gazeColor;
  118696. private _laserColor;
  118697. private _pickedLaserColor;
  118698. private _pickedGazeColor;
  118699. /**
  118700. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118701. */
  118702. onNewMeshSelected: Observable<AbstractMesh>;
  118703. /**
  118704. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118705. * This observable will provide the mesh and the controller used to select the mesh
  118706. */
  118707. onMeshSelectedWithController: Observable<{
  118708. mesh: AbstractMesh;
  118709. controller: WebVRController;
  118710. }>;
  118711. /**
  118712. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118713. */
  118714. onNewMeshPicked: Observable<PickingInfo>;
  118715. private _circleEase;
  118716. /**
  118717. * Observable raised before camera teleportation
  118718. */
  118719. onBeforeCameraTeleport: Observable<Vector3>;
  118720. /**
  118721. * Observable raised after camera teleportation
  118722. */
  118723. onAfterCameraTeleport: Observable<Vector3>;
  118724. /**
  118725. * Observable raised when current selected mesh gets unselected
  118726. */
  118727. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118728. private _raySelectionPredicate;
  118729. /**
  118730. * To be optionaly changed by user to define custom ray selection
  118731. */
  118732. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118733. /**
  118734. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118735. */
  118736. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118737. /**
  118738. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118739. */
  118740. teleportationEnabled: boolean;
  118741. private _defaultHeight;
  118742. private _teleportationInitialized;
  118743. private _interactionsEnabled;
  118744. private _interactionsRequested;
  118745. private _displayGaze;
  118746. private _displayLaserPointer;
  118747. /**
  118748. * The mesh used to display where the user is going to teleport.
  118749. */
  118750. get teleportationTarget(): Mesh;
  118751. /**
  118752. * Sets the mesh to be used to display where the user is going to teleport.
  118753. */
  118754. set teleportationTarget(value: Mesh);
  118755. /**
  118756. * 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
  118757. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118758. * See http://doc.babylonjs.com/resources/baking_transformations
  118759. */
  118760. get gazeTrackerMesh(): Mesh;
  118761. set gazeTrackerMesh(value: Mesh);
  118762. /**
  118763. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118764. */
  118765. updateGazeTrackerScale: boolean;
  118766. /**
  118767. * If the gaze trackers color should be updated when selecting meshes
  118768. */
  118769. updateGazeTrackerColor: boolean;
  118770. /**
  118771. * If the controller laser color should be updated when selecting meshes
  118772. */
  118773. updateControllerLaserColor: boolean;
  118774. /**
  118775. * The gaze tracking mesh corresponding to the left controller
  118776. */
  118777. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118778. /**
  118779. * The gaze tracking mesh corresponding to the right controller
  118780. */
  118781. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118782. /**
  118783. * If the ray of the gaze should be displayed.
  118784. */
  118785. get displayGaze(): boolean;
  118786. /**
  118787. * Sets if the ray of the gaze should be displayed.
  118788. */
  118789. set displayGaze(value: boolean);
  118790. /**
  118791. * If the ray of the LaserPointer should be displayed.
  118792. */
  118793. get displayLaserPointer(): boolean;
  118794. /**
  118795. * Sets if the ray of the LaserPointer should be displayed.
  118796. */
  118797. set displayLaserPointer(value: boolean);
  118798. /**
  118799. * The deviceOrientationCamera used as the camera when not in VR.
  118800. */
  118801. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118802. /**
  118803. * Based on the current WebVR support, returns the current VR camera used.
  118804. */
  118805. get currentVRCamera(): Nullable<Camera>;
  118806. /**
  118807. * The webVRCamera which is used when in VR.
  118808. */
  118809. get webVRCamera(): WebVRFreeCamera;
  118810. /**
  118811. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118812. */
  118813. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118814. /**
  118815. * The html button that is used to trigger entering into VR.
  118816. */
  118817. get vrButton(): Nullable<HTMLButtonElement>;
  118818. private get _teleportationRequestInitiated();
  118819. /**
  118820. * Defines whether or not Pointer lock should be requested when switching to
  118821. * full screen.
  118822. */
  118823. requestPointerLockOnFullScreen: boolean;
  118824. /**
  118825. * If asking to force XR, this will be populated with the default xr experience
  118826. */
  118827. xr: WebXRDefaultExperience;
  118828. /**
  118829. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118830. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118831. */
  118832. xrTestDone: boolean;
  118833. /**
  118834. * Instantiates a VRExperienceHelper.
  118835. * Helps to quickly add VR support to an existing scene.
  118836. * @param scene The scene the VRExperienceHelper belongs to.
  118837. * @param webVROptions Options to modify the vr experience helper's behavior.
  118838. */
  118839. constructor(scene: Scene,
  118840. /** Options to modify the vr experience helper's behavior. */
  118841. webVROptions?: VRExperienceHelperOptions);
  118842. private completeVRInit;
  118843. private _onDefaultMeshLoaded;
  118844. private _onResize;
  118845. private _onFullscreenChange;
  118846. /**
  118847. * Gets a value indicating if we are currently in VR mode.
  118848. */
  118849. get isInVRMode(): boolean;
  118850. private onVrDisplayPresentChange;
  118851. private onVRDisplayChanged;
  118852. private moveButtonToBottomRight;
  118853. private displayVRButton;
  118854. private updateButtonVisibility;
  118855. private _cachedAngularSensibility;
  118856. /**
  118857. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118858. * Otherwise, will use the fullscreen API.
  118859. */
  118860. enterVR(): void;
  118861. /**
  118862. * Attempt to exit VR, or fullscreen.
  118863. */
  118864. exitVR(): void;
  118865. /**
  118866. * The position of the vr experience helper.
  118867. */
  118868. get position(): Vector3;
  118869. /**
  118870. * Sets the position of the vr experience helper.
  118871. */
  118872. set position(value: Vector3);
  118873. /**
  118874. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118875. */
  118876. enableInteractions(): void;
  118877. private get _noControllerIsActive();
  118878. private beforeRender;
  118879. private _isTeleportationFloor;
  118880. /**
  118881. * Adds a floor mesh to be used for teleportation.
  118882. * @param floorMesh the mesh to be used for teleportation.
  118883. */
  118884. addFloorMesh(floorMesh: Mesh): void;
  118885. /**
  118886. * Removes a floor mesh from being used for teleportation.
  118887. * @param floorMesh the mesh to be removed.
  118888. */
  118889. removeFloorMesh(floorMesh: Mesh): void;
  118890. /**
  118891. * Enables interactions and teleportation using the VR controllers and gaze.
  118892. * @param vrTeleportationOptions options to modify teleportation behavior.
  118893. */
  118894. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118895. private _onNewGamepadConnected;
  118896. private _tryEnableInteractionOnController;
  118897. private _onNewGamepadDisconnected;
  118898. private _enableInteractionOnController;
  118899. private _checkTeleportWithRay;
  118900. private _checkRotate;
  118901. private _checkTeleportBackwards;
  118902. private _enableTeleportationOnController;
  118903. private _createTeleportationCircles;
  118904. private _displayTeleportationTarget;
  118905. private _hideTeleportationTarget;
  118906. private _rotateCamera;
  118907. private _moveTeleportationSelectorTo;
  118908. private _workingVector;
  118909. private _workingQuaternion;
  118910. private _workingMatrix;
  118911. /**
  118912. * Time Constant Teleportation Mode
  118913. */
  118914. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118915. /**
  118916. * Speed Constant Teleportation Mode
  118917. */
  118918. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118919. /**
  118920. * Teleports the users feet to the desired location
  118921. * @param location The location where the user's feet should be placed
  118922. */
  118923. teleportCamera(location: Vector3): void;
  118924. private _convertNormalToDirectionOfRay;
  118925. private _castRayAndSelectObject;
  118926. private _notifySelectedMeshUnselected;
  118927. /**
  118928. * Permanently set new colors for the laser pointer
  118929. * @param color the new laser color
  118930. * @param pickedColor the new laser color when picked mesh detected
  118931. */
  118932. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118933. /**
  118934. * Set lighting enabled / disabled on the laser pointer of both controllers
  118935. * @param enabled should the lighting be enabled on the laser pointer
  118936. */
  118937. setLaserLightingState(enabled?: boolean): void;
  118938. /**
  118939. * Permanently set new colors for the gaze pointer
  118940. * @param color the new gaze color
  118941. * @param pickedColor the new gaze color when picked mesh detected
  118942. */
  118943. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118944. /**
  118945. * Sets the color of the laser ray from the vr controllers.
  118946. * @param color new color for the ray.
  118947. */
  118948. changeLaserColor(color: Color3): void;
  118949. /**
  118950. * Sets the color of the ray from the vr headsets gaze.
  118951. * @param color new color for the ray.
  118952. */
  118953. changeGazeColor(color: Color3): void;
  118954. /**
  118955. * Exits VR and disposes of the vr experience helper
  118956. */
  118957. dispose(): void;
  118958. /**
  118959. * Gets the name of the VRExperienceHelper class
  118960. * @returns "VRExperienceHelper"
  118961. */
  118962. getClassName(): string;
  118963. }
  118964. }
  118965. declare module BABYLON {
  118966. /**
  118967. * Contains an array of blocks representing the octree
  118968. */
  118969. export interface IOctreeContainer<T> {
  118970. /**
  118971. * Blocks within the octree
  118972. */
  118973. blocks: Array<OctreeBlock<T>>;
  118974. }
  118975. /**
  118976. * Class used to store a cell in an octree
  118977. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118978. */
  118979. export class OctreeBlock<T> {
  118980. /**
  118981. * Gets the content of the current block
  118982. */
  118983. entries: T[];
  118984. /**
  118985. * Gets the list of block children
  118986. */
  118987. blocks: Array<OctreeBlock<T>>;
  118988. private _depth;
  118989. private _maxDepth;
  118990. private _capacity;
  118991. private _minPoint;
  118992. private _maxPoint;
  118993. private _boundingVectors;
  118994. private _creationFunc;
  118995. /**
  118996. * Creates a new block
  118997. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118998. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118999. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119000. * @param depth defines the current depth of this block in the octree
  119001. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  119002. * @param creationFunc defines a callback to call when an element is added to the block
  119003. */
  119004. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  119005. /**
  119006. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119007. */
  119008. get capacity(): number;
  119009. /**
  119010. * Gets the minimum vector (in world space) of the block's bounding box
  119011. */
  119012. get minPoint(): Vector3;
  119013. /**
  119014. * Gets the maximum vector (in world space) of the block's bounding box
  119015. */
  119016. get maxPoint(): Vector3;
  119017. /**
  119018. * Add a new element to this block
  119019. * @param entry defines the element to add
  119020. */
  119021. addEntry(entry: T): void;
  119022. /**
  119023. * Remove an element from this block
  119024. * @param entry defines the element to remove
  119025. */
  119026. removeEntry(entry: T): void;
  119027. /**
  119028. * Add an array of elements to this block
  119029. * @param entries defines the array of elements to add
  119030. */
  119031. addEntries(entries: T[]): void;
  119032. /**
  119033. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  119034. * @param frustumPlanes defines the frustum planes to test
  119035. * @param selection defines the array to store current content if selection is positive
  119036. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119037. */
  119038. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119039. /**
  119040. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  119041. * @param sphereCenter defines the bounding sphere center
  119042. * @param sphereRadius defines the bounding sphere radius
  119043. * @param selection defines the array to store current content if selection is positive
  119044. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119045. */
  119046. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119047. /**
  119048. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  119049. * @param ray defines the ray to test with
  119050. * @param selection defines the array to store current content if selection is positive
  119051. */
  119052. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  119053. /**
  119054. * Subdivide the content into child blocks (this block will then be empty)
  119055. */
  119056. createInnerBlocks(): void;
  119057. /**
  119058. * @hidden
  119059. */
  119060. 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;
  119061. }
  119062. }
  119063. declare module BABYLON {
  119064. /**
  119065. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  119066. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119067. */
  119068. export class Octree<T> {
  119069. /** 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.) */
  119070. maxDepth: number;
  119071. /**
  119072. * Blocks within the octree containing objects
  119073. */
  119074. blocks: Array<OctreeBlock<T>>;
  119075. /**
  119076. * Content stored in the octree
  119077. */
  119078. dynamicContent: T[];
  119079. private _maxBlockCapacity;
  119080. private _selectionContent;
  119081. private _creationFunc;
  119082. /**
  119083. * Creates a octree
  119084. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119085. * @param creationFunc function to be used to instatiate the octree
  119086. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  119087. * @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.)
  119088. */
  119089. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  119090. /** 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.) */
  119091. maxDepth?: number);
  119092. /**
  119093. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  119094. * @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);
  119095. * @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);
  119096. * @param entries meshes to be added to the octree blocks
  119097. */
  119098. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  119099. /**
  119100. * Adds a mesh to the octree
  119101. * @param entry Mesh to add to the octree
  119102. */
  119103. addMesh(entry: T): void;
  119104. /**
  119105. * Remove an element from the octree
  119106. * @param entry defines the element to remove
  119107. */
  119108. removeMesh(entry: T): void;
  119109. /**
  119110. * Selects an array of meshes within the frustum
  119111. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  119112. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  119113. * @returns array of meshes within the frustum
  119114. */
  119115. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  119116. /**
  119117. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  119118. * @param sphereCenter defines the bounding sphere center
  119119. * @param sphereRadius defines the bounding sphere radius
  119120. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119121. * @returns an array of objects that intersect the sphere
  119122. */
  119123. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  119124. /**
  119125. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  119126. * @param ray defines the ray to test with
  119127. * @returns array of intersected objects
  119128. */
  119129. intersectsRay(ray: Ray): SmartArray<T>;
  119130. /**
  119131. * Adds a mesh into the octree block if it intersects the block
  119132. */
  119133. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  119134. /**
  119135. * Adds a submesh into the octree block if it intersects the block
  119136. */
  119137. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  119138. }
  119139. }
  119140. declare module BABYLON {
  119141. interface Scene {
  119142. /**
  119143. * @hidden
  119144. * Backing Filed
  119145. */
  119146. _selectionOctree: Octree<AbstractMesh>;
  119147. /**
  119148. * Gets the octree used to boost mesh selection (picking)
  119149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119150. */
  119151. selectionOctree: Octree<AbstractMesh>;
  119152. /**
  119153. * Creates or updates the octree used to boost selection (picking)
  119154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119155. * @param maxCapacity defines the maximum capacity per leaf
  119156. * @param maxDepth defines the maximum depth of the octree
  119157. * @returns an octree of AbstractMesh
  119158. */
  119159. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  119160. }
  119161. interface AbstractMesh {
  119162. /**
  119163. * @hidden
  119164. * Backing Field
  119165. */
  119166. _submeshesOctree: Octree<SubMesh>;
  119167. /**
  119168. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119169. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119170. * @param maxCapacity defines the maximum size of each block (64 by default)
  119171. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119172. * @returns the new octree
  119173. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119175. */
  119176. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119177. }
  119178. /**
  119179. * Defines the octree scene component responsible to manage any octrees
  119180. * in a given scene.
  119181. */
  119182. export class OctreeSceneComponent {
  119183. /**
  119184. * The component name help to identify the component in the list of scene components.
  119185. */
  119186. readonly name: string;
  119187. /**
  119188. * The scene the component belongs to.
  119189. */
  119190. scene: Scene;
  119191. /**
  119192. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119193. */
  119194. readonly checksIsEnabled: boolean;
  119195. /**
  119196. * Creates a new instance of the component for the given scene
  119197. * @param scene Defines the scene to register the component in
  119198. */
  119199. constructor(scene: Scene);
  119200. /**
  119201. * Registers the component in a given scene
  119202. */
  119203. register(): void;
  119204. /**
  119205. * Return the list of active meshes
  119206. * @returns the list of active meshes
  119207. */
  119208. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119209. /**
  119210. * Return the list of active sub meshes
  119211. * @param mesh The mesh to get the candidates sub meshes from
  119212. * @returns the list of active sub meshes
  119213. */
  119214. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119215. private _tempRay;
  119216. /**
  119217. * Return the list of sub meshes intersecting with a given local ray
  119218. * @param mesh defines the mesh to find the submesh for
  119219. * @param localRay defines the ray in local space
  119220. * @returns the list of intersecting sub meshes
  119221. */
  119222. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119223. /**
  119224. * Return the list of sub meshes colliding with a collider
  119225. * @param mesh defines the mesh to find the submesh for
  119226. * @param collider defines the collider to evaluate the collision against
  119227. * @returns the list of colliding sub meshes
  119228. */
  119229. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119230. /**
  119231. * Rebuilds the elements related to this component in case of
  119232. * context lost for instance.
  119233. */
  119234. rebuild(): void;
  119235. /**
  119236. * Disposes the component and the associated ressources.
  119237. */
  119238. dispose(): void;
  119239. }
  119240. }
  119241. declare module BABYLON {
  119242. /**
  119243. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119244. */
  119245. export class Gizmo implements IDisposable {
  119246. /** The utility layer the gizmo will be added to */
  119247. gizmoLayer: UtilityLayerRenderer;
  119248. /**
  119249. * The root mesh of the gizmo
  119250. */
  119251. _rootMesh: Mesh;
  119252. private _attachedMesh;
  119253. /**
  119254. * Ratio for the scale of the gizmo (Default: 1)
  119255. */
  119256. scaleRatio: number;
  119257. /**
  119258. * If a custom mesh has been set (Default: false)
  119259. */
  119260. protected _customMeshSet: boolean;
  119261. /**
  119262. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119263. * * When set, interactions will be enabled
  119264. */
  119265. get attachedMesh(): Nullable<AbstractMesh>;
  119266. set attachedMesh(value: Nullable<AbstractMesh>);
  119267. /**
  119268. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119269. * @param mesh The mesh to replace the default mesh of the gizmo
  119270. */
  119271. setCustomMesh(mesh: Mesh): void;
  119272. /**
  119273. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119274. */
  119275. updateGizmoRotationToMatchAttachedMesh: boolean;
  119276. /**
  119277. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119278. */
  119279. updateGizmoPositionToMatchAttachedMesh: boolean;
  119280. /**
  119281. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119282. */
  119283. updateScale: boolean;
  119284. protected _interactionsEnabled: boolean;
  119285. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119286. private _beforeRenderObserver;
  119287. private _tempVector;
  119288. /**
  119289. * Creates a gizmo
  119290. * @param gizmoLayer The utility layer the gizmo will be added to
  119291. */
  119292. constructor(
  119293. /** The utility layer the gizmo will be added to */
  119294. gizmoLayer?: UtilityLayerRenderer);
  119295. /**
  119296. * Updates the gizmo to match the attached mesh's position/rotation
  119297. */
  119298. protected _update(): void;
  119299. /**
  119300. * Disposes of the gizmo
  119301. */
  119302. dispose(): void;
  119303. }
  119304. }
  119305. declare module BABYLON {
  119306. /**
  119307. * Single plane drag gizmo
  119308. */
  119309. export class PlaneDragGizmo extends Gizmo {
  119310. /**
  119311. * Drag behavior responsible for the gizmos dragging interactions
  119312. */
  119313. dragBehavior: PointerDragBehavior;
  119314. private _pointerObserver;
  119315. /**
  119316. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119317. */
  119318. snapDistance: number;
  119319. /**
  119320. * Event that fires each time the gizmo snaps to a new location.
  119321. * * snapDistance is the the change in distance
  119322. */
  119323. onSnapObservable: Observable<{
  119324. snapDistance: number;
  119325. }>;
  119326. private _plane;
  119327. private _coloredMaterial;
  119328. private _hoverMaterial;
  119329. private _isEnabled;
  119330. private _parent;
  119331. /** @hidden */
  119332. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119333. /** @hidden */
  119334. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119335. /**
  119336. * Creates a PlaneDragGizmo
  119337. * @param gizmoLayer The utility layer the gizmo will be added to
  119338. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119339. * @param color The color of the gizmo
  119340. */
  119341. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119342. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119343. /**
  119344. * If the gizmo is enabled
  119345. */
  119346. set isEnabled(value: boolean);
  119347. get isEnabled(): boolean;
  119348. /**
  119349. * Disposes of the gizmo
  119350. */
  119351. dispose(): void;
  119352. }
  119353. }
  119354. declare module BABYLON {
  119355. /**
  119356. * Gizmo that enables dragging a mesh along 3 axis
  119357. */
  119358. export class PositionGizmo extends Gizmo {
  119359. /**
  119360. * Internal gizmo used for interactions on the x axis
  119361. */
  119362. xGizmo: AxisDragGizmo;
  119363. /**
  119364. * Internal gizmo used for interactions on the y axis
  119365. */
  119366. yGizmo: AxisDragGizmo;
  119367. /**
  119368. * Internal gizmo used for interactions on the z axis
  119369. */
  119370. zGizmo: AxisDragGizmo;
  119371. /**
  119372. * Internal gizmo used for interactions on the yz plane
  119373. */
  119374. xPlaneGizmo: PlaneDragGizmo;
  119375. /**
  119376. * Internal gizmo used for interactions on the xz plane
  119377. */
  119378. yPlaneGizmo: PlaneDragGizmo;
  119379. /**
  119380. * Internal gizmo used for interactions on the xy plane
  119381. */
  119382. zPlaneGizmo: PlaneDragGizmo;
  119383. /**
  119384. * private variables
  119385. */
  119386. private _meshAttached;
  119387. private _updateGizmoRotationToMatchAttachedMesh;
  119388. private _snapDistance;
  119389. private _scaleRatio;
  119390. /** Fires an event when any of it's sub gizmos are dragged */
  119391. onDragStartObservable: Observable<unknown>;
  119392. /** Fires an event when any of it's sub gizmos are released from dragging */
  119393. onDragEndObservable: Observable<unknown>;
  119394. /**
  119395. * If set to true, planar drag is enabled
  119396. */
  119397. private _planarGizmoEnabled;
  119398. get attachedMesh(): Nullable<AbstractMesh>;
  119399. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119400. /**
  119401. * Creates a PositionGizmo
  119402. * @param gizmoLayer The utility layer the gizmo will be added to
  119403. */
  119404. constructor(gizmoLayer?: UtilityLayerRenderer);
  119405. /**
  119406. * If the planar drag gizmo is enabled
  119407. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119408. */
  119409. set planarGizmoEnabled(value: boolean);
  119410. get planarGizmoEnabled(): boolean;
  119411. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119412. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119413. /**
  119414. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119415. */
  119416. set snapDistance(value: number);
  119417. get snapDistance(): number;
  119418. /**
  119419. * Ratio for the scale of the gizmo (Default: 1)
  119420. */
  119421. set scaleRatio(value: number);
  119422. get scaleRatio(): number;
  119423. /**
  119424. * Disposes of the gizmo
  119425. */
  119426. dispose(): void;
  119427. /**
  119428. * CustomMeshes are not supported by this gizmo
  119429. * @param mesh The mesh to replace the default mesh of the gizmo
  119430. */
  119431. setCustomMesh(mesh: Mesh): void;
  119432. }
  119433. }
  119434. declare module BABYLON {
  119435. /**
  119436. * Single axis drag gizmo
  119437. */
  119438. export class AxisDragGizmo extends Gizmo {
  119439. /**
  119440. * Drag behavior responsible for the gizmos dragging interactions
  119441. */
  119442. dragBehavior: PointerDragBehavior;
  119443. private _pointerObserver;
  119444. /**
  119445. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119446. */
  119447. snapDistance: number;
  119448. /**
  119449. * Event that fires each time the gizmo snaps to a new location.
  119450. * * snapDistance is the the change in distance
  119451. */
  119452. onSnapObservable: Observable<{
  119453. snapDistance: number;
  119454. }>;
  119455. private _isEnabled;
  119456. private _parent;
  119457. private _arrow;
  119458. private _coloredMaterial;
  119459. private _hoverMaterial;
  119460. /** @hidden */
  119461. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119462. /** @hidden */
  119463. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119464. /**
  119465. * Creates an AxisDragGizmo
  119466. * @param gizmoLayer The utility layer the gizmo will be added to
  119467. * @param dragAxis The axis which the gizmo will be able to drag on
  119468. * @param color The color of the gizmo
  119469. */
  119470. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119471. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119472. /**
  119473. * If the gizmo is enabled
  119474. */
  119475. set isEnabled(value: boolean);
  119476. get isEnabled(): boolean;
  119477. /**
  119478. * Disposes of the gizmo
  119479. */
  119480. dispose(): void;
  119481. }
  119482. }
  119483. declare module BABYLON.Debug {
  119484. /**
  119485. * The Axes viewer will show 3 axes in a specific point in space
  119486. */
  119487. export class AxesViewer {
  119488. private _xAxis;
  119489. private _yAxis;
  119490. private _zAxis;
  119491. private _scaleLinesFactor;
  119492. private _instanced;
  119493. /**
  119494. * Gets the hosting scene
  119495. */
  119496. scene: Scene;
  119497. /**
  119498. * Gets or sets a number used to scale line length
  119499. */
  119500. scaleLines: number;
  119501. /** Gets the node hierarchy used to render x-axis */
  119502. get xAxis(): TransformNode;
  119503. /** Gets the node hierarchy used to render y-axis */
  119504. get yAxis(): TransformNode;
  119505. /** Gets the node hierarchy used to render z-axis */
  119506. get zAxis(): TransformNode;
  119507. /**
  119508. * Creates a new AxesViewer
  119509. * @param scene defines the hosting scene
  119510. * @param scaleLines defines a number used to scale line length (1 by default)
  119511. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119512. * @param xAxis defines the node hierarchy used to render the x-axis
  119513. * @param yAxis defines the node hierarchy used to render the y-axis
  119514. * @param zAxis defines the node hierarchy used to render the z-axis
  119515. */
  119516. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119517. /**
  119518. * Force the viewer to update
  119519. * @param position defines the position of the viewer
  119520. * @param xaxis defines the x axis of the viewer
  119521. * @param yaxis defines the y axis of the viewer
  119522. * @param zaxis defines the z axis of the viewer
  119523. */
  119524. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119525. /**
  119526. * Creates an instance of this axes viewer.
  119527. * @returns a new axes viewer with instanced meshes
  119528. */
  119529. createInstance(): AxesViewer;
  119530. /** Releases resources */
  119531. dispose(): void;
  119532. private static _SetRenderingGroupId;
  119533. }
  119534. }
  119535. declare module BABYLON.Debug {
  119536. /**
  119537. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119538. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119539. */
  119540. export class BoneAxesViewer extends AxesViewer {
  119541. /**
  119542. * Gets or sets the target mesh where to display the axes viewer
  119543. */
  119544. mesh: Nullable<Mesh>;
  119545. /**
  119546. * Gets or sets the target bone where to display the axes viewer
  119547. */
  119548. bone: Nullable<Bone>;
  119549. /** Gets current position */
  119550. pos: Vector3;
  119551. /** Gets direction of X axis */
  119552. xaxis: Vector3;
  119553. /** Gets direction of Y axis */
  119554. yaxis: Vector3;
  119555. /** Gets direction of Z axis */
  119556. zaxis: Vector3;
  119557. /**
  119558. * Creates a new BoneAxesViewer
  119559. * @param scene defines the hosting scene
  119560. * @param bone defines the target bone
  119561. * @param mesh defines the target mesh
  119562. * @param scaleLines defines a scaling factor for line length (1 by default)
  119563. */
  119564. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119565. /**
  119566. * Force the viewer to update
  119567. */
  119568. update(): void;
  119569. /** Releases resources */
  119570. dispose(): void;
  119571. }
  119572. }
  119573. declare module BABYLON {
  119574. /**
  119575. * Interface used to define scene explorer extensibility option
  119576. */
  119577. export interface IExplorerExtensibilityOption {
  119578. /**
  119579. * Define the option label
  119580. */
  119581. label: string;
  119582. /**
  119583. * Defines the action to execute on click
  119584. */
  119585. action: (entity: any) => void;
  119586. }
  119587. /**
  119588. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119589. */
  119590. export interface IExplorerExtensibilityGroup {
  119591. /**
  119592. * Defines a predicate to test if a given type mut be extended
  119593. */
  119594. predicate: (entity: any) => boolean;
  119595. /**
  119596. * Gets the list of options added to a type
  119597. */
  119598. entries: IExplorerExtensibilityOption[];
  119599. }
  119600. /**
  119601. * Interface used to define the options to use to create the Inspector
  119602. */
  119603. export interface IInspectorOptions {
  119604. /**
  119605. * Display in overlay mode (default: false)
  119606. */
  119607. overlay?: boolean;
  119608. /**
  119609. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119610. */
  119611. globalRoot?: HTMLElement;
  119612. /**
  119613. * Display the Scene explorer
  119614. */
  119615. showExplorer?: boolean;
  119616. /**
  119617. * Display the property inspector
  119618. */
  119619. showInspector?: boolean;
  119620. /**
  119621. * Display in embed mode (both panes on the right)
  119622. */
  119623. embedMode?: boolean;
  119624. /**
  119625. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119626. */
  119627. handleResize?: boolean;
  119628. /**
  119629. * Allow the panes to popup (default: true)
  119630. */
  119631. enablePopup?: boolean;
  119632. /**
  119633. * Allow the panes to be closed by users (default: true)
  119634. */
  119635. enableClose?: boolean;
  119636. /**
  119637. * Optional list of extensibility entries
  119638. */
  119639. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119640. /**
  119641. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119642. */
  119643. inspectorURL?: string;
  119644. /**
  119645. * Optional initial tab (default to DebugLayerTab.Properties)
  119646. */
  119647. initialTab?: DebugLayerTab;
  119648. }
  119649. interface Scene {
  119650. /**
  119651. * @hidden
  119652. * Backing field
  119653. */
  119654. _debugLayer: DebugLayer;
  119655. /**
  119656. * Gets the debug layer (aka Inspector) associated with the scene
  119657. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119658. */
  119659. debugLayer: DebugLayer;
  119660. }
  119661. /**
  119662. * Enum of inspector action tab
  119663. */
  119664. export enum DebugLayerTab {
  119665. /**
  119666. * Properties tag (default)
  119667. */
  119668. Properties = 0,
  119669. /**
  119670. * Debug tab
  119671. */
  119672. Debug = 1,
  119673. /**
  119674. * Statistics tab
  119675. */
  119676. Statistics = 2,
  119677. /**
  119678. * Tools tab
  119679. */
  119680. Tools = 3,
  119681. /**
  119682. * Settings tab
  119683. */
  119684. Settings = 4
  119685. }
  119686. /**
  119687. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119688. * what is happening in your scene
  119689. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119690. */
  119691. export class DebugLayer {
  119692. /**
  119693. * Define the url to get the inspector script from.
  119694. * By default it uses the babylonjs CDN.
  119695. * @ignoreNaming
  119696. */
  119697. static InspectorURL: string;
  119698. private _scene;
  119699. private BJSINSPECTOR;
  119700. private _onPropertyChangedObservable?;
  119701. /**
  119702. * Observable triggered when a property is changed through the inspector.
  119703. */
  119704. get onPropertyChangedObservable(): any;
  119705. /**
  119706. * Instantiates a new debug layer.
  119707. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119708. * what is happening in your scene
  119709. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119710. * @param scene Defines the scene to inspect
  119711. */
  119712. constructor(scene: Scene);
  119713. /** Creates the inspector window. */
  119714. private _createInspector;
  119715. /**
  119716. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119717. * @param entity defines the entity to select
  119718. * @param lineContainerTitle defines the specific block to highlight
  119719. */
  119720. select(entity: any, lineContainerTitle?: string): void;
  119721. /** Get the inspector from bundle or global */
  119722. private _getGlobalInspector;
  119723. /**
  119724. * Get if the inspector is visible or not.
  119725. * @returns true if visible otherwise, false
  119726. */
  119727. isVisible(): boolean;
  119728. /**
  119729. * Hide the inspector and close its window.
  119730. */
  119731. hide(): void;
  119732. /**
  119733. * Launch the debugLayer.
  119734. * @param config Define the configuration of the inspector
  119735. * @return a promise fulfilled when the debug layer is visible
  119736. */
  119737. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119738. }
  119739. }
  119740. declare module BABYLON {
  119741. /**
  119742. * Class containing static functions to help procedurally build meshes
  119743. */
  119744. export class BoxBuilder {
  119745. /**
  119746. * Creates a box mesh
  119747. * * The parameter `size` sets the size (float) of each box side (default 1)
  119748. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119749. * * 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)
  119750. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119754. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119755. * @param name defines the name of the mesh
  119756. * @param options defines the options used to create the mesh
  119757. * @param scene defines the hosting scene
  119758. * @returns the box mesh
  119759. */
  119760. static CreateBox(name: string, options: {
  119761. size?: number;
  119762. width?: number;
  119763. height?: number;
  119764. depth?: number;
  119765. faceUV?: Vector4[];
  119766. faceColors?: Color4[];
  119767. sideOrientation?: number;
  119768. frontUVs?: Vector4;
  119769. backUVs?: Vector4;
  119770. wrap?: boolean;
  119771. topBaseAt?: number;
  119772. bottomBaseAt?: number;
  119773. updatable?: boolean;
  119774. }, scene?: Nullable<Scene>): Mesh;
  119775. }
  119776. }
  119777. declare module BABYLON.Debug {
  119778. /**
  119779. * Used to show the physics impostor around the specific mesh
  119780. */
  119781. export class PhysicsViewer {
  119782. /** @hidden */
  119783. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119784. /** @hidden */
  119785. protected _meshes: Array<Nullable<AbstractMesh>>;
  119786. /** @hidden */
  119787. protected _scene: Nullable<Scene>;
  119788. /** @hidden */
  119789. protected _numMeshes: number;
  119790. /** @hidden */
  119791. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119792. private _renderFunction;
  119793. private _utilityLayer;
  119794. private _debugBoxMesh;
  119795. private _debugSphereMesh;
  119796. private _debugCylinderMesh;
  119797. private _debugMaterial;
  119798. private _debugMeshMeshes;
  119799. /**
  119800. * Creates a new PhysicsViewer
  119801. * @param scene defines the hosting scene
  119802. */
  119803. constructor(scene: Scene);
  119804. /** @hidden */
  119805. protected _updateDebugMeshes(): void;
  119806. /**
  119807. * Renders a specified physic impostor
  119808. * @param impostor defines the impostor to render
  119809. * @param targetMesh defines the mesh represented by the impostor
  119810. * @returns the new debug mesh used to render the impostor
  119811. */
  119812. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119813. /**
  119814. * Hides a specified physic impostor
  119815. * @param impostor defines the impostor to hide
  119816. */
  119817. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119818. private _getDebugMaterial;
  119819. private _getDebugBoxMesh;
  119820. private _getDebugSphereMesh;
  119821. private _getDebugCylinderMesh;
  119822. private _getDebugMeshMesh;
  119823. private _getDebugMesh;
  119824. /** Releases all resources */
  119825. dispose(): void;
  119826. }
  119827. }
  119828. declare module BABYLON {
  119829. /**
  119830. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119831. * in order to better appreciate the issue one might have.
  119832. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119833. */
  119834. export class RayHelper {
  119835. /**
  119836. * Defines the ray we are currently tryin to visualize.
  119837. */
  119838. ray: Nullable<Ray>;
  119839. private _renderPoints;
  119840. private _renderLine;
  119841. private _renderFunction;
  119842. private _scene;
  119843. private _updateToMeshFunction;
  119844. private _attachedToMesh;
  119845. private _meshSpaceDirection;
  119846. private _meshSpaceOrigin;
  119847. /**
  119848. * Helper function to create a colored helper in a scene in one line.
  119849. * @param ray Defines the ray we are currently tryin to visualize
  119850. * @param scene Defines the scene the ray is used in
  119851. * @param color Defines the color we want to see the ray in
  119852. * @returns The newly created ray helper.
  119853. */
  119854. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119855. /**
  119856. * Instantiate a new ray helper.
  119857. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119858. * in order to better appreciate the issue one might have.
  119859. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119860. * @param ray Defines the ray we are currently tryin to visualize
  119861. */
  119862. constructor(ray: Ray);
  119863. /**
  119864. * Shows the ray we are willing to debug.
  119865. * @param scene Defines the scene the ray needs to be rendered in
  119866. * @param color Defines the color the ray needs to be rendered in
  119867. */
  119868. show(scene: Scene, color?: Color3): void;
  119869. /**
  119870. * Hides the ray we are debugging.
  119871. */
  119872. hide(): void;
  119873. private _render;
  119874. /**
  119875. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119876. * @param mesh Defines the mesh we want the helper attached to
  119877. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119878. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119879. * @param length Defines the length of the ray
  119880. */
  119881. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119882. /**
  119883. * Detach the ray helper from the mesh it has previously been attached to.
  119884. */
  119885. detachFromMesh(): void;
  119886. private _updateToMesh;
  119887. /**
  119888. * Dispose the helper and release its associated resources.
  119889. */
  119890. dispose(): void;
  119891. }
  119892. }
  119893. declare module BABYLON.Debug {
  119894. /**
  119895. * Class used to render a debug view of a given skeleton
  119896. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119897. */
  119898. export class SkeletonViewer {
  119899. /** defines the skeleton to render */
  119900. skeleton: Skeleton;
  119901. /** defines the mesh attached to the skeleton */
  119902. mesh: AbstractMesh;
  119903. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119904. autoUpdateBonesMatrices: boolean;
  119905. /** defines the rendering group id to use with the viewer */
  119906. renderingGroupId: number;
  119907. /** Gets or sets the color used to render the skeleton */
  119908. color: Color3;
  119909. private _scene;
  119910. private _debugLines;
  119911. private _debugMesh;
  119912. private _isEnabled;
  119913. private _renderFunction;
  119914. private _utilityLayer;
  119915. /**
  119916. * Returns the mesh used to render the bones
  119917. */
  119918. get debugMesh(): Nullable<LinesMesh>;
  119919. /**
  119920. * Creates a new SkeletonViewer
  119921. * @param skeleton defines the skeleton to render
  119922. * @param mesh defines the mesh attached to the skeleton
  119923. * @param scene defines the hosting scene
  119924. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119925. * @param renderingGroupId defines the rendering group id to use with the viewer
  119926. */
  119927. constructor(
  119928. /** defines the skeleton to render */
  119929. skeleton: Skeleton,
  119930. /** defines the mesh attached to the skeleton */
  119931. mesh: AbstractMesh, scene: Scene,
  119932. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119933. autoUpdateBonesMatrices?: boolean,
  119934. /** defines the rendering group id to use with the viewer */
  119935. renderingGroupId?: number);
  119936. /** Gets or sets a boolean indicating if the viewer is enabled */
  119937. set isEnabled(value: boolean);
  119938. get isEnabled(): boolean;
  119939. private _getBonePosition;
  119940. private _getLinesForBonesWithLength;
  119941. private _getLinesForBonesNoLength;
  119942. /** Update the viewer to sync with current skeleton state */
  119943. update(): void;
  119944. /** Release associated resources */
  119945. dispose(): void;
  119946. }
  119947. }
  119948. declare module BABYLON {
  119949. /**
  119950. * Options to create the null engine
  119951. */
  119952. export class NullEngineOptions {
  119953. /**
  119954. * Render width (Default: 512)
  119955. */
  119956. renderWidth: number;
  119957. /**
  119958. * Render height (Default: 256)
  119959. */
  119960. renderHeight: number;
  119961. /**
  119962. * Texture size (Default: 512)
  119963. */
  119964. textureSize: number;
  119965. /**
  119966. * If delta time between frames should be constant
  119967. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119968. */
  119969. deterministicLockstep: boolean;
  119970. /**
  119971. * Maximum about of steps between frames (Default: 4)
  119972. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119973. */
  119974. lockstepMaxSteps: number;
  119975. }
  119976. /**
  119977. * The null engine class provides support for headless version of babylon.js.
  119978. * This can be used in server side scenario or for testing purposes
  119979. */
  119980. export class NullEngine extends Engine {
  119981. private _options;
  119982. /**
  119983. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119985. * @returns true if engine is in deterministic lock step mode
  119986. */
  119987. isDeterministicLockStep(): boolean;
  119988. /**
  119989. * Gets the max steps when engine is running in deterministic lock step
  119990. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119991. * @returns the max steps
  119992. */
  119993. getLockstepMaxSteps(): number;
  119994. /**
  119995. * Gets the current hardware scaling level.
  119996. * By default the hardware scaling level is computed from the window device ratio.
  119997. * 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.
  119998. * @returns a number indicating the current hardware scaling level
  119999. */
  120000. getHardwareScalingLevel(): number;
  120001. constructor(options?: NullEngineOptions);
  120002. /**
  120003. * Creates a vertex buffer
  120004. * @param vertices the data for the vertex buffer
  120005. * @returns the new WebGL static buffer
  120006. */
  120007. createVertexBuffer(vertices: FloatArray): DataBuffer;
  120008. /**
  120009. * Creates a new index buffer
  120010. * @param indices defines the content of the index buffer
  120011. * @param updatable defines if the index buffer must be updatable
  120012. * @returns a new webGL buffer
  120013. */
  120014. createIndexBuffer(indices: IndicesArray): DataBuffer;
  120015. /**
  120016. * Clear the current render buffer or the current render target (if any is set up)
  120017. * @param color defines the color to use
  120018. * @param backBuffer defines if the back buffer must be cleared
  120019. * @param depth defines if the depth buffer must be cleared
  120020. * @param stencil defines if the stencil buffer must be cleared
  120021. */
  120022. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120023. /**
  120024. * Gets the current render width
  120025. * @param useScreen defines if screen size must be used (or the current render target if any)
  120026. * @returns a number defining the current render width
  120027. */
  120028. getRenderWidth(useScreen?: boolean): number;
  120029. /**
  120030. * Gets the current render height
  120031. * @param useScreen defines if screen size must be used (or the current render target if any)
  120032. * @returns a number defining the current render height
  120033. */
  120034. getRenderHeight(useScreen?: boolean): number;
  120035. /**
  120036. * Set the WebGL's viewport
  120037. * @param viewport defines the viewport element to be used
  120038. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120039. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120040. */
  120041. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120042. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  120043. /**
  120044. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120045. * @param pipelineContext defines the pipeline context to use
  120046. * @param uniformsNames defines the list of uniform names
  120047. * @returns an array of webGL uniform locations
  120048. */
  120049. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120050. /**
  120051. * Gets the lsit of active attributes for a given webGL program
  120052. * @param pipelineContext defines the pipeline context to use
  120053. * @param attributesNames defines the list of attribute names to get
  120054. * @returns an array of indices indicating the offset of each attribute
  120055. */
  120056. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120057. /**
  120058. * Binds an effect to the webGL context
  120059. * @param effect defines the effect to bind
  120060. */
  120061. bindSamplers(effect: Effect): void;
  120062. /**
  120063. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120064. * @param effect defines the effect to activate
  120065. */
  120066. enableEffect(effect: Effect): void;
  120067. /**
  120068. * Set various states to the webGL context
  120069. * @param culling defines backface culling state
  120070. * @param zOffset defines the value to apply to zOffset (0 by default)
  120071. * @param force defines if states must be applied even if cache is up to date
  120072. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  120073. */
  120074. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120075. /**
  120076. * Set the value of an uniform to an array of int32
  120077. * @param uniform defines the webGL uniform location where to store the value
  120078. * @param array defines the array of int32 to store
  120079. */
  120080. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120081. /**
  120082. * Set the value of an uniform to an array of int32 (stored as vec2)
  120083. * @param uniform defines the webGL uniform location where to store the value
  120084. * @param array defines the array of int32 to store
  120085. */
  120086. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120087. /**
  120088. * Set the value of an uniform to an array of int32 (stored as vec3)
  120089. * @param uniform defines the webGL uniform location where to store the value
  120090. * @param array defines the array of int32 to store
  120091. */
  120092. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120093. /**
  120094. * Set the value of an uniform to an array of int32 (stored as vec4)
  120095. * @param uniform defines the webGL uniform location where to store the value
  120096. * @param array defines the array of int32 to store
  120097. */
  120098. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120099. /**
  120100. * Set the value of an uniform to an array of float32
  120101. * @param uniform defines the webGL uniform location where to store the value
  120102. * @param array defines the array of float32 to store
  120103. */
  120104. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120105. /**
  120106. * Set the value of an uniform to an array of float32 (stored as vec2)
  120107. * @param uniform defines the webGL uniform location where to store the value
  120108. * @param array defines the array of float32 to store
  120109. */
  120110. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120111. /**
  120112. * Set the value of an uniform to an array of float32 (stored as vec3)
  120113. * @param uniform defines the webGL uniform location where to store the value
  120114. * @param array defines the array of float32 to store
  120115. */
  120116. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120117. /**
  120118. * Set the value of an uniform to an array of float32 (stored as vec4)
  120119. * @param uniform defines the webGL uniform location where to store the value
  120120. * @param array defines the array of float32 to store
  120121. */
  120122. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120123. /**
  120124. * Set the value of an uniform to an array of number
  120125. * @param uniform defines the webGL uniform location where to store the value
  120126. * @param array defines the array of number to store
  120127. */
  120128. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120129. /**
  120130. * Set the value of an uniform to an array of number (stored as vec2)
  120131. * @param uniform defines the webGL uniform location where to store the value
  120132. * @param array defines the array of number to store
  120133. */
  120134. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120135. /**
  120136. * Set the value of an uniform to an array of number (stored as vec3)
  120137. * @param uniform defines the webGL uniform location where to store the value
  120138. * @param array defines the array of number to store
  120139. */
  120140. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120141. /**
  120142. * Set the value of an uniform to an array of number (stored as vec4)
  120143. * @param uniform defines the webGL uniform location where to store the value
  120144. * @param array defines the array of number to store
  120145. */
  120146. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120147. /**
  120148. * Set the value of an uniform to an array of float32 (stored as matrices)
  120149. * @param uniform defines the webGL uniform location where to store the value
  120150. * @param matrices defines the array of float32 to store
  120151. */
  120152. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120153. /**
  120154. * Set the value of an uniform to a matrix (3x3)
  120155. * @param uniform defines the webGL uniform location where to store the value
  120156. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120157. */
  120158. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120159. /**
  120160. * Set the value of an uniform to a matrix (2x2)
  120161. * @param uniform defines the webGL uniform location where to store the value
  120162. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120163. */
  120164. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120165. /**
  120166. * Set the value of an uniform to a number (float)
  120167. * @param uniform defines the webGL uniform location where to store the value
  120168. * @param value defines the float number to store
  120169. */
  120170. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120171. /**
  120172. * Set the value of an uniform to a vec2
  120173. * @param uniform defines the webGL uniform location where to store the value
  120174. * @param x defines the 1st component of the value
  120175. * @param y defines the 2nd component of the value
  120176. */
  120177. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120178. /**
  120179. * Set the value of an uniform to a vec3
  120180. * @param uniform defines the webGL uniform location where to store the value
  120181. * @param x defines the 1st component of the value
  120182. * @param y defines the 2nd component of the value
  120183. * @param z defines the 3rd component of the value
  120184. */
  120185. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120186. /**
  120187. * Set the value of an uniform to a boolean
  120188. * @param uniform defines the webGL uniform location where to store the value
  120189. * @param bool defines the boolean to store
  120190. */
  120191. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120192. /**
  120193. * Set the value of an uniform to a vec4
  120194. * @param uniform defines the webGL uniform location where to store the value
  120195. * @param x defines the 1st component of the value
  120196. * @param y defines the 2nd component of the value
  120197. * @param z defines the 3rd component of the value
  120198. * @param w defines the 4th component of the value
  120199. */
  120200. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120201. /**
  120202. * Sets the current alpha mode
  120203. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120204. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120205. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120206. */
  120207. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120208. /**
  120209. * Bind webGl buffers directly to the webGL context
  120210. * @param vertexBuffers defines the vertex buffer to bind
  120211. * @param indexBuffer defines the index buffer to bind
  120212. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120213. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120214. * @param effect defines the effect associated with the vertex buffer
  120215. */
  120216. bindBuffers(vertexBuffers: {
  120217. [key: string]: VertexBuffer;
  120218. }, indexBuffer: DataBuffer, effect: Effect): void;
  120219. /**
  120220. * Force the entire cache to be cleared
  120221. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120222. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120223. */
  120224. wipeCaches(bruteForce?: boolean): void;
  120225. /**
  120226. * Send a draw order
  120227. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120228. * @param indexStart defines the starting index
  120229. * @param indexCount defines the number of index to draw
  120230. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120231. */
  120232. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120233. /**
  120234. * Draw a list of indexed primitives
  120235. * @param fillMode defines the primitive to use
  120236. * @param indexStart defines the starting index
  120237. * @param indexCount defines the number of index to draw
  120238. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120239. */
  120240. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120241. /**
  120242. * Draw a list of unindexed primitives
  120243. * @param fillMode defines the primitive to use
  120244. * @param verticesStart defines the index of first vertex to draw
  120245. * @param verticesCount defines the count of vertices to draw
  120246. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120247. */
  120248. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120249. /** @hidden */
  120250. _createTexture(): WebGLTexture;
  120251. /** @hidden */
  120252. _releaseTexture(texture: InternalTexture): void;
  120253. /**
  120254. * Usually called from Texture.ts.
  120255. * Passed information to create a WebGLTexture
  120256. * @param urlArg defines a value which contains one of the following:
  120257. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120258. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120259. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120260. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120261. * @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)
  120262. * @param scene needed for loading to the correct scene
  120263. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120264. * @param onLoad optional callback to be called upon successful completion
  120265. * @param onError optional callback to be called upon failure
  120266. * @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
  120267. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120268. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120269. * @param forcedExtension defines the extension to use to pick the right loader
  120270. * @param mimeType defines an optional mime type
  120271. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120272. */
  120273. 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;
  120274. /**
  120275. * Creates a new render target texture
  120276. * @param size defines the size of the texture
  120277. * @param options defines the options used to create the texture
  120278. * @returns a new render target texture stored in an InternalTexture
  120279. */
  120280. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120281. /**
  120282. * Update the sampling mode of a given texture
  120283. * @param samplingMode defines the required sampling mode
  120284. * @param texture defines the texture to update
  120285. */
  120286. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120287. /**
  120288. * Binds the frame buffer to the specified texture.
  120289. * @param texture The texture to render to or null for the default canvas
  120290. * @param faceIndex The face of the texture to render to in case of cube texture
  120291. * @param requiredWidth The width of the target to render to
  120292. * @param requiredHeight The height of the target to render to
  120293. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120294. * @param lodLevel defines le lod level to bind to the frame buffer
  120295. */
  120296. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120297. /**
  120298. * Unbind the current render target texture from the webGL context
  120299. * @param texture defines the render target texture to unbind
  120300. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120301. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120302. */
  120303. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120304. /**
  120305. * Creates a dynamic vertex buffer
  120306. * @param vertices the data for the dynamic vertex buffer
  120307. * @returns the new WebGL dynamic buffer
  120308. */
  120309. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120310. /**
  120311. * Update the content of a dynamic texture
  120312. * @param texture defines the texture to update
  120313. * @param canvas defines the canvas containing the source
  120314. * @param invertY defines if data must be stored with Y axis inverted
  120315. * @param premulAlpha defines if alpha is stored as premultiplied
  120316. * @param format defines the format of the data
  120317. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120318. */
  120319. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120320. /**
  120321. * Gets a boolean indicating if all created effects are ready
  120322. * @returns true if all effects are ready
  120323. */
  120324. areAllEffectsReady(): boolean;
  120325. /**
  120326. * @hidden
  120327. * Get the current error code of the webGL context
  120328. * @returns the error code
  120329. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120330. */
  120331. getError(): number;
  120332. /** @hidden */
  120333. _getUnpackAlignement(): number;
  120334. /** @hidden */
  120335. _unpackFlipY(value: boolean): void;
  120336. /**
  120337. * Update a dynamic index buffer
  120338. * @param indexBuffer defines the target index buffer
  120339. * @param indices defines the data to update
  120340. * @param offset defines the offset in the target index buffer where update should start
  120341. */
  120342. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120343. /**
  120344. * Updates a dynamic vertex buffer.
  120345. * @param vertexBuffer the vertex buffer to update
  120346. * @param vertices the data used to update the vertex buffer
  120347. * @param byteOffset the byte offset of the data (optional)
  120348. * @param byteLength the byte length of the data (optional)
  120349. */
  120350. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120351. /** @hidden */
  120352. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120353. /** @hidden */
  120354. _bindTexture(channel: number, texture: InternalTexture): void;
  120355. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120356. /**
  120357. * 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
  120358. */
  120359. releaseEffects(): void;
  120360. displayLoadingUI(): void;
  120361. hideLoadingUI(): void;
  120362. /** @hidden */
  120363. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120364. /** @hidden */
  120365. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120366. /** @hidden */
  120367. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120368. /** @hidden */
  120369. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120370. }
  120371. }
  120372. declare module BABYLON {
  120373. /**
  120374. * @hidden
  120375. **/
  120376. export class _TimeToken {
  120377. _startTimeQuery: Nullable<WebGLQuery>;
  120378. _endTimeQuery: Nullable<WebGLQuery>;
  120379. _timeElapsedQuery: Nullable<WebGLQuery>;
  120380. _timeElapsedQueryEnded: boolean;
  120381. }
  120382. }
  120383. declare module BABYLON {
  120384. /** @hidden */
  120385. export class _OcclusionDataStorage {
  120386. /** @hidden */
  120387. occlusionInternalRetryCounter: number;
  120388. /** @hidden */
  120389. isOcclusionQueryInProgress: boolean;
  120390. /** @hidden */
  120391. isOccluded: boolean;
  120392. /** @hidden */
  120393. occlusionRetryCount: number;
  120394. /** @hidden */
  120395. occlusionType: number;
  120396. /** @hidden */
  120397. occlusionQueryAlgorithmType: number;
  120398. }
  120399. interface Engine {
  120400. /**
  120401. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120402. * @return the new query
  120403. */
  120404. createQuery(): WebGLQuery;
  120405. /**
  120406. * Delete and release a webGL query
  120407. * @param query defines the query to delete
  120408. * @return the current engine
  120409. */
  120410. deleteQuery(query: WebGLQuery): Engine;
  120411. /**
  120412. * Check if a given query has resolved and got its value
  120413. * @param query defines the query to check
  120414. * @returns true if the query got its value
  120415. */
  120416. isQueryResultAvailable(query: WebGLQuery): boolean;
  120417. /**
  120418. * Gets the value of a given query
  120419. * @param query defines the query to check
  120420. * @returns the value of the query
  120421. */
  120422. getQueryResult(query: WebGLQuery): number;
  120423. /**
  120424. * Initiates an occlusion query
  120425. * @param algorithmType defines the algorithm to use
  120426. * @param query defines the query to use
  120427. * @returns the current engine
  120428. * @see http://doc.babylonjs.com/features/occlusionquery
  120429. */
  120430. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120431. /**
  120432. * Ends an occlusion query
  120433. * @see http://doc.babylonjs.com/features/occlusionquery
  120434. * @param algorithmType defines the algorithm to use
  120435. * @returns the current engine
  120436. */
  120437. endOcclusionQuery(algorithmType: number): Engine;
  120438. /**
  120439. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120440. * Please note that only one query can be issued at a time
  120441. * @returns a time token used to track the time span
  120442. */
  120443. startTimeQuery(): Nullable<_TimeToken>;
  120444. /**
  120445. * Ends a time query
  120446. * @param token defines the token used to measure the time span
  120447. * @returns the time spent (in ns)
  120448. */
  120449. endTimeQuery(token: _TimeToken): int;
  120450. /** @hidden */
  120451. _currentNonTimestampToken: Nullable<_TimeToken>;
  120452. /** @hidden */
  120453. _createTimeQuery(): WebGLQuery;
  120454. /** @hidden */
  120455. _deleteTimeQuery(query: WebGLQuery): void;
  120456. /** @hidden */
  120457. _getGlAlgorithmType(algorithmType: number): number;
  120458. /** @hidden */
  120459. _getTimeQueryResult(query: WebGLQuery): any;
  120460. /** @hidden */
  120461. _getTimeQueryAvailability(query: WebGLQuery): any;
  120462. }
  120463. interface AbstractMesh {
  120464. /**
  120465. * Backing filed
  120466. * @hidden
  120467. */
  120468. __occlusionDataStorage: _OcclusionDataStorage;
  120469. /**
  120470. * Access property
  120471. * @hidden
  120472. */
  120473. _occlusionDataStorage: _OcclusionDataStorage;
  120474. /**
  120475. * 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.
  120476. * The default value is -1 which means don't break the query and wait till the result
  120477. * @see http://doc.babylonjs.com/features/occlusionquery
  120478. */
  120479. occlusionRetryCount: number;
  120480. /**
  120481. * 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:
  120482. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120483. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120484. * * 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.
  120485. * @see http://doc.babylonjs.com/features/occlusionquery
  120486. */
  120487. occlusionType: number;
  120488. /**
  120489. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120490. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120491. * * 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.
  120492. * @see http://doc.babylonjs.com/features/occlusionquery
  120493. */
  120494. occlusionQueryAlgorithmType: number;
  120495. /**
  120496. * 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
  120497. * @see http://doc.babylonjs.com/features/occlusionquery
  120498. */
  120499. isOccluded: boolean;
  120500. /**
  120501. * Flag to check the progress status of the query
  120502. * @see http://doc.babylonjs.com/features/occlusionquery
  120503. */
  120504. isOcclusionQueryInProgress: boolean;
  120505. }
  120506. }
  120507. declare module BABYLON {
  120508. /** @hidden */
  120509. export var _forceTransformFeedbackToBundle: boolean;
  120510. interface Engine {
  120511. /**
  120512. * Creates a webGL transform feedback object
  120513. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120514. * @returns the webGL transform feedback object
  120515. */
  120516. createTransformFeedback(): WebGLTransformFeedback;
  120517. /**
  120518. * Delete a webGL transform feedback object
  120519. * @param value defines the webGL transform feedback object to delete
  120520. */
  120521. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120522. /**
  120523. * Bind a webGL transform feedback object to the webgl context
  120524. * @param value defines the webGL transform feedback object to bind
  120525. */
  120526. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120527. /**
  120528. * Begins a transform feedback operation
  120529. * @param usePoints defines if points or triangles must be used
  120530. */
  120531. beginTransformFeedback(usePoints: boolean): void;
  120532. /**
  120533. * Ends a transform feedback operation
  120534. */
  120535. endTransformFeedback(): void;
  120536. /**
  120537. * Specify the varyings to use with transform feedback
  120538. * @param program defines the associated webGL program
  120539. * @param value defines the list of strings representing the varying names
  120540. */
  120541. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120542. /**
  120543. * Bind a webGL buffer for a transform feedback operation
  120544. * @param value defines the webGL buffer to bind
  120545. */
  120546. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120547. }
  120548. }
  120549. declare module BABYLON {
  120550. /**
  120551. * Creation options of the multi render target texture.
  120552. */
  120553. export interface IMultiRenderTargetOptions {
  120554. /**
  120555. * Define if the texture needs to create mip maps after render.
  120556. */
  120557. generateMipMaps?: boolean;
  120558. /**
  120559. * Define the types of all the draw buffers we want to create
  120560. */
  120561. types?: number[];
  120562. /**
  120563. * Define the sampling modes of all the draw buffers we want to create
  120564. */
  120565. samplingModes?: number[];
  120566. /**
  120567. * Define if a depth buffer is required
  120568. */
  120569. generateDepthBuffer?: boolean;
  120570. /**
  120571. * Define if a stencil buffer is required
  120572. */
  120573. generateStencilBuffer?: boolean;
  120574. /**
  120575. * Define if a depth texture is required instead of a depth buffer
  120576. */
  120577. generateDepthTexture?: boolean;
  120578. /**
  120579. * Define the number of desired draw buffers
  120580. */
  120581. textureCount?: number;
  120582. /**
  120583. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120584. */
  120585. doNotChangeAspectRatio?: boolean;
  120586. /**
  120587. * Define the default type of the buffers we are creating
  120588. */
  120589. defaultType?: number;
  120590. }
  120591. /**
  120592. * A multi render target, like a render target provides the ability to render to a texture.
  120593. * Unlike the render target, it can render to several draw buffers in one draw.
  120594. * This is specially interesting in deferred rendering or for any effects requiring more than
  120595. * just one color from a single pass.
  120596. */
  120597. export class MultiRenderTarget extends RenderTargetTexture {
  120598. private _internalTextures;
  120599. private _textures;
  120600. private _multiRenderTargetOptions;
  120601. /**
  120602. * Get if draw buffers are currently supported by the used hardware and browser.
  120603. */
  120604. get isSupported(): boolean;
  120605. /**
  120606. * Get the list of textures generated by the multi render target.
  120607. */
  120608. get textures(): Texture[];
  120609. /**
  120610. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120611. */
  120612. get depthTexture(): Texture;
  120613. /**
  120614. * Set the wrapping mode on U of all the textures we are rendering to.
  120615. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120616. */
  120617. set wrapU(wrap: number);
  120618. /**
  120619. * Set the wrapping mode on V of all the textures we are rendering to.
  120620. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120621. */
  120622. set wrapV(wrap: number);
  120623. /**
  120624. * Instantiate a new multi render target texture.
  120625. * A multi render target, like a render target provides the ability to render to a texture.
  120626. * Unlike the render target, it can render to several draw buffers in one draw.
  120627. * This is specially interesting in deferred rendering or for any effects requiring more than
  120628. * just one color from a single pass.
  120629. * @param name Define the name of the texture
  120630. * @param size Define the size of the buffers to render to
  120631. * @param count Define the number of target we are rendering into
  120632. * @param scene Define the scene the texture belongs to
  120633. * @param options Define the options used to create the multi render target
  120634. */
  120635. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120636. /** @hidden */
  120637. _rebuild(): void;
  120638. private _createInternalTextures;
  120639. private _createTextures;
  120640. /**
  120641. * Define the number of samples used if MSAA is enabled.
  120642. */
  120643. get samples(): number;
  120644. set samples(value: number);
  120645. /**
  120646. * Resize all the textures in the multi render target.
  120647. * Be carrefull as it will recreate all the data in the new texture.
  120648. * @param size Define the new size
  120649. */
  120650. resize(size: any): void;
  120651. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120652. /**
  120653. * Dispose the render targets and their associated resources
  120654. */
  120655. dispose(): void;
  120656. /**
  120657. * Release all the underlying texture used as draw buffers.
  120658. */
  120659. releaseInternalTextures(): void;
  120660. }
  120661. }
  120662. declare module BABYLON {
  120663. interface ThinEngine {
  120664. /**
  120665. * Unbind a list of render target textures from the webGL context
  120666. * This is used only when drawBuffer extension or webGL2 are active
  120667. * @param textures defines the render target textures to unbind
  120668. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120669. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120670. */
  120671. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120672. /**
  120673. * Create a multi render target texture
  120674. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120675. * @param size defines the size of the texture
  120676. * @param options defines the creation options
  120677. * @returns the cube texture as an InternalTexture
  120678. */
  120679. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120680. /**
  120681. * Update the sample count for a given multiple render target texture
  120682. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120683. * @param textures defines the textures to update
  120684. * @param samples defines the sample count to set
  120685. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120686. */
  120687. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120688. }
  120689. }
  120690. declare module BABYLON {
  120691. /**
  120692. * Class used to define an additional view for the engine
  120693. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120694. */
  120695. export class EngineView {
  120696. /** Defines the canvas where to render the view */
  120697. target: HTMLCanvasElement;
  120698. /** Defines an optional camera used to render the view (will use active camera else) */
  120699. camera?: Camera;
  120700. }
  120701. interface Engine {
  120702. /**
  120703. * Gets or sets the HTML element to use for attaching events
  120704. */
  120705. inputElement: Nullable<HTMLElement>;
  120706. /**
  120707. * Gets the current engine view
  120708. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120709. */
  120710. activeView: Nullable<EngineView>;
  120711. /** Gets or sets the list of views */
  120712. views: EngineView[];
  120713. /**
  120714. * Register a new child canvas
  120715. * @param canvas defines the canvas to register
  120716. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120717. * @returns the associated view
  120718. */
  120719. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120720. /**
  120721. * Remove a registered child canvas
  120722. * @param canvas defines the canvas to remove
  120723. * @returns the current engine
  120724. */
  120725. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120726. }
  120727. }
  120728. declare module BABYLON {
  120729. /**
  120730. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120731. */
  120732. export interface CubeMapInfo {
  120733. /**
  120734. * The pixel array for the front face.
  120735. * This is stored in format, left to right, up to down format.
  120736. */
  120737. front: Nullable<ArrayBufferView>;
  120738. /**
  120739. * The pixel array for the back face.
  120740. * This is stored in format, left to right, up to down format.
  120741. */
  120742. back: Nullable<ArrayBufferView>;
  120743. /**
  120744. * The pixel array for the left face.
  120745. * This is stored in format, left to right, up to down format.
  120746. */
  120747. left: Nullable<ArrayBufferView>;
  120748. /**
  120749. * The pixel array for the right face.
  120750. * This is stored in format, left to right, up to down format.
  120751. */
  120752. right: Nullable<ArrayBufferView>;
  120753. /**
  120754. * The pixel array for the up face.
  120755. * This is stored in format, left to right, up to down format.
  120756. */
  120757. up: Nullable<ArrayBufferView>;
  120758. /**
  120759. * The pixel array for the down face.
  120760. * This is stored in format, left to right, up to down format.
  120761. */
  120762. down: Nullable<ArrayBufferView>;
  120763. /**
  120764. * The size of the cubemap stored.
  120765. *
  120766. * Each faces will be size * size pixels.
  120767. */
  120768. size: number;
  120769. /**
  120770. * The format of the texture.
  120771. *
  120772. * RGBA, RGB.
  120773. */
  120774. format: number;
  120775. /**
  120776. * The type of the texture data.
  120777. *
  120778. * UNSIGNED_INT, FLOAT.
  120779. */
  120780. type: number;
  120781. /**
  120782. * Specifies whether the texture is in gamma space.
  120783. */
  120784. gammaSpace: boolean;
  120785. }
  120786. /**
  120787. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120788. */
  120789. export class PanoramaToCubeMapTools {
  120790. private static FACE_FRONT;
  120791. private static FACE_BACK;
  120792. private static FACE_RIGHT;
  120793. private static FACE_LEFT;
  120794. private static FACE_DOWN;
  120795. private static FACE_UP;
  120796. /**
  120797. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120798. *
  120799. * @param float32Array The source data.
  120800. * @param inputWidth The width of the input panorama.
  120801. * @param inputHeight The height of the input panorama.
  120802. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120803. * @return The cubemap data
  120804. */
  120805. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120806. private static CreateCubemapTexture;
  120807. private static CalcProjectionSpherical;
  120808. }
  120809. }
  120810. declare module BABYLON {
  120811. /**
  120812. * Helper class dealing with the extraction of spherical polynomial dataArray
  120813. * from a cube map.
  120814. */
  120815. export class CubeMapToSphericalPolynomialTools {
  120816. private static FileFaces;
  120817. /**
  120818. * Converts a texture to the according Spherical Polynomial data.
  120819. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120820. *
  120821. * @param texture The texture to extract the information from.
  120822. * @return The Spherical Polynomial data.
  120823. */
  120824. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120825. /**
  120826. * Converts a cubemap to the according Spherical Polynomial data.
  120827. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120828. *
  120829. * @param cubeInfo The Cube map to extract the information from.
  120830. * @return The Spherical Polynomial data.
  120831. */
  120832. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120833. }
  120834. }
  120835. declare module BABYLON {
  120836. interface BaseTexture {
  120837. /**
  120838. * Get the polynomial representation of the texture data.
  120839. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120840. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120841. */
  120842. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120843. }
  120844. }
  120845. declare module BABYLON {
  120846. /** @hidden */
  120847. export var rgbdEncodePixelShader: {
  120848. name: string;
  120849. shader: string;
  120850. };
  120851. }
  120852. declare module BABYLON {
  120853. /** @hidden */
  120854. export var rgbdDecodePixelShader: {
  120855. name: string;
  120856. shader: string;
  120857. };
  120858. }
  120859. declare module BABYLON {
  120860. /**
  120861. * Raw texture data and descriptor sufficient for WebGL texture upload
  120862. */
  120863. export interface EnvironmentTextureInfo {
  120864. /**
  120865. * Version of the environment map
  120866. */
  120867. version: number;
  120868. /**
  120869. * Width of image
  120870. */
  120871. width: number;
  120872. /**
  120873. * Irradiance information stored in the file.
  120874. */
  120875. irradiance: any;
  120876. /**
  120877. * Specular information stored in the file.
  120878. */
  120879. specular: any;
  120880. }
  120881. /**
  120882. * Defines One Image in the file. It requires only the position in the file
  120883. * as well as the length.
  120884. */
  120885. interface BufferImageData {
  120886. /**
  120887. * Length of the image data.
  120888. */
  120889. length: number;
  120890. /**
  120891. * Position of the data from the null terminator delimiting the end of the JSON.
  120892. */
  120893. position: number;
  120894. }
  120895. /**
  120896. * Defines the specular data enclosed in the file.
  120897. * This corresponds to the version 1 of the data.
  120898. */
  120899. export interface EnvironmentTextureSpecularInfoV1 {
  120900. /**
  120901. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120902. */
  120903. specularDataPosition?: number;
  120904. /**
  120905. * This contains all the images data needed to reconstruct the cubemap.
  120906. */
  120907. mipmaps: Array<BufferImageData>;
  120908. /**
  120909. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120910. */
  120911. lodGenerationScale: number;
  120912. }
  120913. /**
  120914. * Sets of helpers addressing the serialization and deserialization of environment texture
  120915. * stored in a BabylonJS env file.
  120916. * Those files are usually stored as .env files.
  120917. */
  120918. export class EnvironmentTextureTools {
  120919. /**
  120920. * Magic number identifying the env file.
  120921. */
  120922. private static _MagicBytes;
  120923. /**
  120924. * Gets the environment info from an env file.
  120925. * @param data The array buffer containing the .env bytes.
  120926. * @returns the environment file info (the json header) if successfully parsed.
  120927. */
  120928. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120929. /**
  120930. * Creates an environment texture from a loaded cube texture.
  120931. * @param texture defines the cube texture to convert in env file
  120932. * @return a promise containing the environment data if succesfull.
  120933. */
  120934. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120935. /**
  120936. * Creates a JSON representation of the spherical data.
  120937. * @param texture defines the texture containing the polynomials
  120938. * @return the JSON representation of the spherical info
  120939. */
  120940. private static _CreateEnvTextureIrradiance;
  120941. /**
  120942. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120943. * @param data the image data
  120944. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120945. * @return the views described by info providing access to the underlying buffer
  120946. */
  120947. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120948. /**
  120949. * Uploads the texture info contained in the env file to the GPU.
  120950. * @param texture defines the internal texture to upload to
  120951. * @param data defines the data to load
  120952. * @param info defines the texture info retrieved through the GetEnvInfo method
  120953. * @returns a promise
  120954. */
  120955. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120956. private static _OnImageReadyAsync;
  120957. /**
  120958. * Uploads the levels of image data to the GPU.
  120959. * @param texture defines the internal texture to upload to
  120960. * @param imageData defines the array buffer views of image data [mipmap][face]
  120961. * @returns a promise
  120962. */
  120963. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120964. /**
  120965. * Uploads spherical polynomials information to the texture.
  120966. * @param texture defines the texture we are trying to upload the information to
  120967. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120968. */
  120969. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120970. /** @hidden */
  120971. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120972. }
  120973. }
  120974. declare module BABYLON {
  120975. /**
  120976. * Contains position and normal vectors for a vertex
  120977. */
  120978. export class PositionNormalVertex {
  120979. /** the position of the vertex (defaut: 0,0,0) */
  120980. position: Vector3;
  120981. /** the normal of the vertex (defaut: 0,1,0) */
  120982. normal: Vector3;
  120983. /**
  120984. * Creates a PositionNormalVertex
  120985. * @param position the position of the vertex (defaut: 0,0,0)
  120986. * @param normal the normal of the vertex (defaut: 0,1,0)
  120987. */
  120988. constructor(
  120989. /** the position of the vertex (defaut: 0,0,0) */
  120990. position?: Vector3,
  120991. /** the normal of the vertex (defaut: 0,1,0) */
  120992. normal?: Vector3);
  120993. /**
  120994. * Clones the PositionNormalVertex
  120995. * @returns the cloned PositionNormalVertex
  120996. */
  120997. clone(): PositionNormalVertex;
  120998. }
  120999. /**
  121000. * Contains position, normal and uv vectors for a vertex
  121001. */
  121002. export class PositionNormalTextureVertex {
  121003. /** the position of the vertex (defaut: 0,0,0) */
  121004. position: Vector3;
  121005. /** the normal of the vertex (defaut: 0,1,0) */
  121006. normal: Vector3;
  121007. /** the uv of the vertex (default: 0,0) */
  121008. uv: Vector2;
  121009. /**
  121010. * Creates a PositionNormalTextureVertex
  121011. * @param position the position of the vertex (defaut: 0,0,0)
  121012. * @param normal the normal of the vertex (defaut: 0,1,0)
  121013. * @param uv the uv of the vertex (default: 0,0)
  121014. */
  121015. constructor(
  121016. /** the position of the vertex (defaut: 0,0,0) */
  121017. position?: Vector3,
  121018. /** the normal of the vertex (defaut: 0,1,0) */
  121019. normal?: Vector3,
  121020. /** the uv of the vertex (default: 0,0) */
  121021. uv?: Vector2);
  121022. /**
  121023. * Clones the PositionNormalTextureVertex
  121024. * @returns the cloned PositionNormalTextureVertex
  121025. */
  121026. clone(): PositionNormalTextureVertex;
  121027. }
  121028. }
  121029. declare module BABYLON {
  121030. /** @hidden */
  121031. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  121032. private _genericAttributeLocation;
  121033. private _varyingLocationCount;
  121034. private _varyingLocationMap;
  121035. private _replacements;
  121036. private _textureCount;
  121037. private _uniforms;
  121038. lineProcessor(line: string): string;
  121039. attributeProcessor(attribute: string): string;
  121040. varyingProcessor(varying: string, isFragment: boolean): string;
  121041. uniformProcessor(uniform: string): string;
  121042. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  121043. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  121044. }
  121045. }
  121046. declare module BABYLON {
  121047. /**
  121048. * Container for accessors for natively-stored mesh data buffers.
  121049. */
  121050. class NativeDataBuffer extends DataBuffer {
  121051. /**
  121052. * Accessor value used to identify/retrieve a natively-stored index buffer.
  121053. */
  121054. nativeIndexBuffer?: any;
  121055. /**
  121056. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  121057. */
  121058. nativeVertexBuffer?: any;
  121059. }
  121060. /** @hidden */
  121061. class NativeTexture extends InternalTexture {
  121062. getInternalTexture(): InternalTexture;
  121063. getViewCount(): number;
  121064. }
  121065. /** @hidden */
  121066. export class NativeEngine extends Engine {
  121067. private readonly _native;
  121068. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  121069. private readonly INVALID_HANDLE;
  121070. getHardwareScalingLevel(): number;
  121071. constructor();
  121072. /**
  121073. * Can be used to override the current requestAnimationFrame requester.
  121074. * @hidden
  121075. */
  121076. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121077. /**
  121078. * Override default engine behavior.
  121079. * @param color
  121080. * @param backBuffer
  121081. * @param depth
  121082. * @param stencil
  121083. */
  121084. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121085. /**
  121086. * Gets host document
  121087. * @returns the host document object
  121088. */
  121089. getHostDocument(): Nullable<Document>;
  121090. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121091. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  121092. createVertexBuffer(data: DataArray): NativeDataBuffer;
  121093. recordVertexArrayObject(vertexBuffers: {
  121094. [key: string]: VertexBuffer;
  121095. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121096. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121097. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121098. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121099. /**
  121100. * Draw a list of indexed primitives
  121101. * @param fillMode defines the primitive to use
  121102. * @param indexStart defines the starting index
  121103. * @param indexCount defines the number of index to draw
  121104. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121105. */
  121106. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121107. /**
  121108. * Draw a list of unindexed primitives
  121109. * @param fillMode defines the primitive to use
  121110. * @param verticesStart defines the index of first vertex to draw
  121111. * @param verticesCount defines the count of vertices to draw
  121112. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121113. */
  121114. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121115. createPipelineContext(): IPipelineContext;
  121116. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121117. /** @hidden */
  121118. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121119. /** @hidden */
  121120. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121121. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121122. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121123. protected _setProgram(program: WebGLProgram): void;
  121124. _releaseEffect(effect: Effect): void;
  121125. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121126. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  121127. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  121128. bindSamplers(effect: Effect): void;
  121129. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  121130. getRenderWidth(useScreen?: boolean): number;
  121131. getRenderHeight(useScreen?: boolean): number;
  121132. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  121133. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121134. /**
  121135. * Set the z offset to apply to current rendering
  121136. * @param value defines the offset to apply
  121137. */
  121138. setZOffset(value: number): void;
  121139. /**
  121140. * Gets the current value of the zOffset
  121141. * @returns the current zOffset state
  121142. */
  121143. getZOffset(): number;
  121144. /**
  121145. * Enable or disable depth buffering
  121146. * @param enable defines the state to set
  121147. */
  121148. setDepthBuffer(enable: boolean): void;
  121149. /**
  121150. * Gets a boolean indicating if depth writing is enabled
  121151. * @returns the current depth writing state
  121152. */
  121153. getDepthWrite(): boolean;
  121154. /**
  121155. * Enable or disable depth writing
  121156. * @param enable defines the state to set
  121157. */
  121158. setDepthWrite(enable: boolean): void;
  121159. /**
  121160. * Enable or disable color writing
  121161. * @param enable defines the state to set
  121162. */
  121163. setColorWrite(enable: boolean): void;
  121164. /**
  121165. * Gets a boolean indicating if color writing is enabled
  121166. * @returns the current color writing state
  121167. */
  121168. getColorWrite(): boolean;
  121169. /**
  121170. * Sets alpha constants used by some alpha blending modes
  121171. * @param r defines the red component
  121172. * @param g defines the green component
  121173. * @param b defines the blue component
  121174. * @param a defines the alpha component
  121175. */
  121176. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121177. /**
  121178. * Sets the current alpha mode
  121179. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121180. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121181. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121182. */
  121183. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121184. /**
  121185. * Gets the current alpha mode
  121186. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121187. * @returns the current alpha mode
  121188. */
  121189. getAlphaMode(): number;
  121190. setInt(uniform: WebGLUniformLocation, int: number): void;
  121191. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121192. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121193. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121194. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121195. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121196. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121197. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121198. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121199. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121200. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121201. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121202. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121203. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121204. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121205. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121206. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121207. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121208. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121209. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121210. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121211. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121212. wipeCaches(bruteForce?: boolean): void;
  121213. _createTexture(): WebGLTexture;
  121214. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121215. /**
  121216. * Usually called from Texture.ts.
  121217. * Passed information to create a WebGLTexture
  121218. * @param urlArg defines a value which contains one of the following:
  121219. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121220. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121221. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121223. * @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)
  121224. * @param scene needed for loading to the correct scene
  121225. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121226. * @param onLoad optional callback to be called upon successful completion
  121227. * @param onError optional callback to be called upon failure
  121228. * @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
  121229. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121230. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121231. * @param forcedExtension defines the extension to use to pick the right loader
  121232. * @param mimeType defines an optional mime type
  121233. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121234. */
  121235. 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;
  121236. /**
  121237. * Creates a cube texture
  121238. * @param rootUrl defines the url where the files to load is located
  121239. * @param scene defines the current scene
  121240. * @param files defines the list of files to load (1 per face)
  121241. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121242. * @param onLoad defines an optional callback raised when the texture is loaded
  121243. * @param onError defines an optional callback raised if there is an issue to load the texture
  121244. * @param format defines the format of the data
  121245. * @param forcedExtension defines the extension to use to pick the right loader
  121246. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121247. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121248. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121249. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121250. * @returns the cube texture as an InternalTexture
  121251. */
  121252. 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;
  121253. private _getSamplingFilter;
  121254. private static _GetNativeTextureFormat;
  121255. createRenderTargetTexture(size: number | {
  121256. width: number;
  121257. height: number;
  121258. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121259. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121260. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121261. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121262. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121263. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121264. /**
  121265. * Updates a dynamic vertex buffer.
  121266. * @param vertexBuffer the vertex buffer to update
  121267. * @param data the data used to update the vertex buffer
  121268. * @param byteOffset the byte offset of the data (optional)
  121269. * @param byteLength the byte length of the data (optional)
  121270. */
  121271. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121272. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121273. private _updateAnisotropicLevel;
  121274. private _getAddressMode;
  121275. /** @hidden */
  121276. _bindTexture(channel: number, texture: InternalTexture): void;
  121277. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121278. releaseEffects(): void;
  121279. /** @hidden */
  121280. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121281. /** @hidden */
  121282. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121283. /** @hidden */
  121284. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121285. /** @hidden */
  121286. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121287. }
  121288. }
  121289. declare module BABYLON {
  121290. /**
  121291. * Gather the list of clipboard event types as constants.
  121292. */
  121293. export class ClipboardEventTypes {
  121294. /**
  121295. * The clipboard event is fired when a copy command is active (pressed).
  121296. */
  121297. static readonly COPY: number;
  121298. /**
  121299. * The clipboard event is fired when a cut command is active (pressed).
  121300. */
  121301. static readonly CUT: number;
  121302. /**
  121303. * The clipboard event is fired when a paste command is active (pressed).
  121304. */
  121305. static readonly PASTE: number;
  121306. }
  121307. /**
  121308. * This class is used to store clipboard related info for the onClipboardObservable event.
  121309. */
  121310. export class ClipboardInfo {
  121311. /**
  121312. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121313. */
  121314. type: number;
  121315. /**
  121316. * Defines the related dom event
  121317. */
  121318. event: ClipboardEvent;
  121319. /**
  121320. *Creates an instance of ClipboardInfo.
  121321. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121322. * @param event Defines the related dom event
  121323. */
  121324. constructor(
  121325. /**
  121326. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121327. */
  121328. type: number,
  121329. /**
  121330. * Defines the related dom event
  121331. */
  121332. event: ClipboardEvent);
  121333. /**
  121334. * Get the clipboard event's type from the keycode.
  121335. * @param keyCode Defines the keyCode for the current keyboard event.
  121336. * @return {number}
  121337. */
  121338. static GetTypeFromCharacter(keyCode: number): number;
  121339. }
  121340. }
  121341. declare module BABYLON {
  121342. /**
  121343. * Google Daydream controller
  121344. */
  121345. export class DaydreamController extends WebVRController {
  121346. /**
  121347. * Base Url for the controller model.
  121348. */
  121349. static MODEL_BASE_URL: string;
  121350. /**
  121351. * File name for the controller model.
  121352. */
  121353. static MODEL_FILENAME: string;
  121354. /**
  121355. * Gamepad Id prefix used to identify Daydream Controller.
  121356. */
  121357. static readonly GAMEPAD_ID_PREFIX: string;
  121358. /**
  121359. * Creates a new DaydreamController from a gamepad
  121360. * @param vrGamepad the gamepad that the controller should be created from
  121361. */
  121362. constructor(vrGamepad: any);
  121363. /**
  121364. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121365. * @param scene scene in which to add meshes
  121366. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121367. */
  121368. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121369. /**
  121370. * Called once for each button that changed state since the last frame
  121371. * @param buttonIdx Which button index changed
  121372. * @param state New state of the button
  121373. * @param changes Which properties on the state changed since last frame
  121374. */
  121375. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121376. }
  121377. }
  121378. declare module BABYLON {
  121379. /**
  121380. * Gear VR Controller
  121381. */
  121382. export class GearVRController extends WebVRController {
  121383. /**
  121384. * Base Url for the controller model.
  121385. */
  121386. static MODEL_BASE_URL: string;
  121387. /**
  121388. * File name for the controller model.
  121389. */
  121390. static MODEL_FILENAME: string;
  121391. /**
  121392. * Gamepad Id prefix used to identify this controller.
  121393. */
  121394. static readonly GAMEPAD_ID_PREFIX: string;
  121395. private readonly _buttonIndexToObservableNameMap;
  121396. /**
  121397. * Creates a new GearVRController from a gamepad
  121398. * @param vrGamepad the gamepad that the controller should be created from
  121399. */
  121400. constructor(vrGamepad: any);
  121401. /**
  121402. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121403. * @param scene scene in which to add meshes
  121404. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121405. */
  121406. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121407. /**
  121408. * Called once for each button that changed state since the last frame
  121409. * @param buttonIdx Which button index changed
  121410. * @param state New state of the button
  121411. * @param changes Which properties on the state changed since last frame
  121412. */
  121413. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121414. }
  121415. }
  121416. declare module BABYLON {
  121417. /**
  121418. * Generic Controller
  121419. */
  121420. export class GenericController extends WebVRController {
  121421. /**
  121422. * Base Url for the controller model.
  121423. */
  121424. static readonly MODEL_BASE_URL: string;
  121425. /**
  121426. * File name for the controller model.
  121427. */
  121428. static readonly MODEL_FILENAME: string;
  121429. /**
  121430. * Creates a new GenericController from a gamepad
  121431. * @param vrGamepad the gamepad that the controller should be created from
  121432. */
  121433. constructor(vrGamepad: any);
  121434. /**
  121435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121436. * @param scene scene in which to add meshes
  121437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121438. */
  121439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121440. /**
  121441. * Called once for each button that changed state since the last frame
  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. * Oculus Touch Controller
  121452. */
  121453. export class OculusTouchController extends WebVRController {
  121454. /**
  121455. * Base Url for the controller model.
  121456. */
  121457. static MODEL_BASE_URL: string;
  121458. /**
  121459. * File name for the left controller model.
  121460. */
  121461. static MODEL_LEFT_FILENAME: string;
  121462. /**
  121463. * File name for the right controller model.
  121464. */
  121465. static MODEL_RIGHT_FILENAME: string;
  121466. /**
  121467. * Base Url for the Quest controller model.
  121468. */
  121469. static QUEST_MODEL_BASE_URL: string;
  121470. /**
  121471. * @hidden
  121472. * If the controllers are running on a device that needs the updated Quest controller models
  121473. */
  121474. static _IsQuest: boolean;
  121475. /**
  121476. * Fired when the secondary trigger on this controller is modified
  121477. */
  121478. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121479. /**
  121480. * Fired when the thumb rest on this controller is modified
  121481. */
  121482. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121483. /**
  121484. * Creates a new OculusTouchController from a gamepad
  121485. * @param vrGamepad the gamepad that the controller should be created from
  121486. */
  121487. constructor(vrGamepad: any);
  121488. /**
  121489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121490. * @param scene scene in which to add meshes
  121491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121492. */
  121493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121494. /**
  121495. * Fired when the A button on this controller is modified
  121496. */
  121497. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121498. /**
  121499. * Fired when the B button on this controller is modified
  121500. */
  121501. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121502. /**
  121503. * Fired when the X button on this controller is modified
  121504. */
  121505. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121506. /**
  121507. * Fired when the Y button on this controller is modified
  121508. */
  121509. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121510. /**
  121511. * Called once for each button that changed state since the last frame
  121512. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121513. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121514. * 2) secondary trigger (same)
  121515. * 3) A (right) X (left), touch, pressed = value
  121516. * 4) B / Y
  121517. * 5) thumb rest
  121518. * @param buttonIdx Which button index changed
  121519. * @param state New state of the button
  121520. * @param changes Which properties on the state changed since last frame
  121521. */
  121522. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121523. }
  121524. }
  121525. declare module BABYLON {
  121526. /**
  121527. * Vive Controller
  121528. */
  121529. export class ViveController extends WebVRController {
  121530. /**
  121531. * Base Url for the controller model.
  121532. */
  121533. static MODEL_BASE_URL: string;
  121534. /**
  121535. * File name for the controller model.
  121536. */
  121537. static MODEL_FILENAME: string;
  121538. /**
  121539. * Creates a new ViveController from a gamepad
  121540. * @param vrGamepad the gamepad that the controller should be created from
  121541. */
  121542. constructor(vrGamepad: any);
  121543. /**
  121544. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121545. * @param scene scene in which to add meshes
  121546. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121547. */
  121548. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121549. /**
  121550. * Fired when the left button on this controller is modified
  121551. */
  121552. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121553. /**
  121554. * Fired when the right button on this controller is modified
  121555. */
  121556. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121557. /**
  121558. * Fired when the menu button on this controller is modified
  121559. */
  121560. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121561. /**
  121562. * Called once for each button that changed state since the last frame
  121563. * Vive mapping:
  121564. * 0: touchpad
  121565. * 1: trigger
  121566. * 2: left AND right buttons
  121567. * 3: menu button
  121568. * @param buttonIdx Which button index changed
  121569. * @param state New state of the button
  121570. * @param changes Which properties on the state changed since last frame
  121571. */
  121572. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121573. }
  121574. }
  121575. declare module BABYLON {
  121576. /**
  121577. * Defines the WindowsMotionController object that the state of the windows motion controller
  121578. */
  121579. export class WindowsMotionController extends WebVRController {
  121580. /**
  121581. * The base url used to load the left and right controller models
  121582. */
  121583. static MODEL_BASE_URL: string;
  121584. /**
  121585. * The name of the left controller model file
  121586. */
  121587. static MODEL_LEFT_FILENAME: string;
  121588. /**
  121589. * The name of the right controller model file
  121590. */
  121591. static MODEL_RIGHT_FILENAME: string;
  121592. /**
  121593. * The controller name prefix for this controller type
  121594. */
  121595. static readonly GAMEPAD_ID_PREFIX: string;
  121596. /**
  121597. * The controller id pattern for this controller type
  121598. */
  121599. private static readonly GAMEPAD_ID_PATTERN;
  121600. private _loadedMeshInfo;
  121601. protected readonly _mapping: {
  121602. buttons: string[];
  121603. buttonMeshNames: {
  121604. 'trigger': string;
  121605. 'menu': string;
  121606. 'grip': string;
  121607. 'thumbstick': string;
  121608. 'trackpad': string;
  121609. };
  121610. buttonObservableNames: {
  121611. 'trigger': string;
  121612. 'menu': string;
  121613. 'grip': string;
  121614. 'thumbstick': string;
  121615. 'trackpad': string;
  121616. };
  121617. axisMeshNames: string[];
  121618. pointingPoseMeshName: string;
  121619. };
  121620. /**
  121621. * Fired when the trackpad on this controller is clicked
  121622. */
  121623. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121624. /**
  121625. * Fired when the trackpad on this controller is modified
  121626. */
  121627. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121628. /**
  121629. * The current x and y values of this controller's trackpad
  121630. */
  121631. trackpad: StickValues;
  121632. /**
  121633. * Creates a new WindowsMotionController from a gamepad
  121634. * @param vrGamepad the gamepad that the controller should be created from
  121635. */
  121636. constructor(vrGamepad: any);
  121637. /**
  121638. * Fired when the trigger on this controller is modified
  121639. */
  121640. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121641. /**
  121642. * Fired when the menu button on this controller is modified
  121643. */
  121644. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121645. /**
  121646. * Fired when the grip button on this controller is modified
  121647. */
  121648. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121649. /**
  121650. * Fired when the thumbstick button on this controller is modified
  121651. */
  121652. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121653. /**
  121654. * Fired when the touchpad button on this controller is modified
  121655. */
  121656. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121657. /**
  121658. * Fired when the touchpad values on this controller are modified
  121659. */
  121660. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121661. protected _updateTrackpad(): void;
  121662. /**
  121663. * Called once per frame by the engine.
  121664. */
  121665. update(): void;
  121666. /**
  121667. * Called once for each button that changed state since the last frame
  121668. * @param buttonIdx Which button index changed
  121669. * @param state New state of the button
  121670. * @param changes Which properties on the state changed since last frame
  121671. */
  121672. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121673. /**
  121674. * Moves the buttons on the controller mesh based on their current state
  121675. * @param buttonName the name of the button to move
  121676. * @param buttonValue the value of the button which determines the buttons new position
  121677. */
  121678. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121679. /**
  121680. * Moves the axis on the controller mesh based on its current state
  121681. * @param axis the index of the axis
  121682. * @param axisValue the value of the axis which determines the meshes new position
  121683. * @hidden
  121684. */
  121685. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121686. /**
  121687. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121688. * @param scene scene in which to add meshes
  121689. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121690. */
  121691. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121692. /**
  121693. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121694. * can be transformed by button presses and axes values, based on this._mapping.
  121695. *
  121696. * @param scene scene in which the meshes exist
  121697. * @param meshes list of meshes that make up the controller model to process
  121698. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121699. */
  121700. private processModel;
  121701. private createMeshInfo;
  121702. /**
  121703. * Gets the ray of the controller in the direction the controller is pointing
  121704. * @param length the length the resulting ray should be
  121705. * @returns a ray in the direction the controller is pointing
  121706. */
  121707. getForwardRay(length?: number): Ray;
  121708. /**
  121709. * Disposes of the controller
  121710. */
  121711. dispose(): void;
  121712. }
  121713. /**
  121714. * This class represents a new windows motion controller in XR.
  121715. */
  121716. export class XRWindowsMotionController extends WindowsMotionController {
  121717. /**
  121718. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121719. */
  121720. protected readonly _mapping: {
  121721. buttons: string[];
  121722. buttonMeshNames: {
  121723. 'trigger': string;
  121724. 'menu': string;
  121725. 'grip': string;
  121726. 'thumbstick': string;
  121727. 'trackpad': string;
  121728. };
  121729. buttonObservableNames: {
  121730. 'trigger': string;
  121731. 'menu': string;
  121732. 'grip': string;
  121733. 'thumbstick': string;
  121734. 'trackpad': string;
  121735. };
  121736. axisMeshNames: string[];
  121737. pointingPoseMeshName: string;
  121738. };
  121739. /**
  121740. * Construct a new XR-Based windows motion controller
  121741. *
  121742. * @param gamepadInfo the gamepad object from the browser
  121743. */
  121744. constructor(gamepadInfo: any);
  121745. /**
  121746. * holds the thumbstick values (X,Y)
  121747. */
  121748. thumbstickValues: StickValues;
  121749. /**
  121750. * Fired when the thumbstick on this controller is clicked
  121751. */
  121752. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121753. /**
  121754. * Fired when the thumbstick on this controller is modified
  121755. */
  121756. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121757. /**
  121758. * Fired when the touchpad button on this controller is modified
  121759. */
  121760. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121761. /**
  121762. * Fired when the touchpad values on this controller are modified
  121763. */
  121764. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121765. /**
  121766. * Fired when the thumbstick button on this controller is modified
  121767. * here to prevent breaking changes
  121768. */
  121769. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121770. /**
  121771. * updating the thumbstick(!) and not the trackpad.
  121772. * This is named this way due to the difference between WebVR and XR and to avoid
  121773. * changing the parent class.
  121774. */
  121775. protected _updateTrackpad(): void;
  121776. /**
  121777. * Disposes the class with joy
  121778. */
  121779. dispose(): void;
  121780. }
  121781. }
  121782. declare module BABYLON {
  121783. /**
  121784. * Class containing static functions to help procedurally build meshes
  121785. */
  121786. export class PolyhedronBuilder {
  121787. /**
  121788. * Creates a polyhedron mesh
  121789. * * 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
  121790. * * The parameter `size` (positive float, default 1) sets the polygon size
  121791. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121792. * * 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`
  121793. * * 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
  121794. * * 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)`)
  121795. * * 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
  121796. * * 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
  121797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121800. * @param name defines the name of the mesh
  121801. * @param options defines the options used to create the mesh
  121802. * @param scene defines the hosting scene
  121803. * @returns the polyhedron mesh
  121804. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121805. */
  121806. static CreatePolyhedron(name: string, options: {
  121807. type?: number;
  121808. size?: number;
  121809. sizeX?: number;
  121810. sizeY?: number;
  121811. sizeZ?: number;
  121812. custom?: any;
  121813. faceUV?: Vector4[];
  121814. faceColors?: Color4[];
  121815. flat?: boolean;
  121816. updatable?: boolean;
  121817. sideOrientation?: number;
  121818. frontUVs?: Vector4;
  121819. backUVs?: Vector4;
  121820. }, scene?: Nullable<Scene>): Mesh;
  121821. }
  121822. }
  121823. declare module BABYLON {
  121824. /**
  121825. * Gizmo that enables scaling a mesh along 3 axis
  121826. */
  121827. export class ScaleGizmo extends Gizmo {
  121828. /**
  121829. * Internal gizmo used for interactions on the x axis
  121830. */
  121831. xGizmo: AxisScaleGizmo;
  121832. /**
  121833. * Internal gizmo used for interactions on the y axis
  121834. */
  121835. yGizmo: AxisScaleGizmo;
  121836. /**
  121837. * Internal gizmo used for interactions on the z axis
  121838. */
  121839. zGizmo: AxisScaleGizmo;
  121840. /**
  121841. * Internal gizmo used to scale all axis equally
  121842. */
  121843. uniformScaleGizmo: AxisScaleGizmo;
  121844. private _meshAttached;
  121845. private _updateGizmoRotationToMatchAttachedMesh;
  121846. private _snapDistance;
  121847. private _scaleRatio;
  121848. private _uniformScalingMesh;
  121849. private _octahedron;
  121850. private _sensitivity;
  121851. /** Fires an event when any of it's sub gizmos are dragged */
  121852. onDragStartObservable: Observable<unknown>;
  121853. /** Fires an event when any of it's sub gizmos are released from dragging */
  121854. onDragEndObservable: Observable<unknown>;
  121855. get attachedMesh(): Nullable<AbstractMesh>;
  121856. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121857. /**
  121858. * Creates a ScaleGizmo
  121859. * @param gizmoLayer The utility layer the gizmo will be added to
  121860. */
  121861. constructor(gizmoLayer?: UtilityLayerRenderer);
  121862. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121863. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121864. /**
  121865. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121866. */
  121867. set snapDistance(value: number);
  121868. get snapDistance(): number;
  121869. /**
  121870. * Ratio for the scale of the gizmo (Default: 1)
  121871. */
  121872. set scaleRatio(value: number);
  121873. get scaleRatio(): number;
  121874. /**
  121875. * Sensitivity factor for dragging (Default: 1)
  121876. */
  121877. set sensitivity(value: number);
  121878. get sensitivity(): number;
  121879. /**
  121880. * Disposes of the gizmo
  121881. */
  121882. dispose(): void;
  121883. }
  121884. }
  121885. declare module BABYLON {
  121886. /**
  121887. * Single axis scale gizmo
  121888. */
  121889. export class AxisScaleGizmo extends Gizmo {
  121890. /**
  121891. * Drag behavior responsible for the gizmos dragging interactions
  121892. */
  121893. dragBehavior: PointerDragBehavior;
  121894. private _pointerObserver;
  121895. /**
  121896. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121897. */
  121898. snapDistance: number;
  121899. /**
  121900. * Event that fires each time the gizmo snaps to a new location.
  121901. * * snapDistance is the the change in distance
  121902. */
  121903. onSnapObservable: Observable<{
  121904. snapDistance: number;
  121905. }>;
  121906. /**
  121907. * If the scaling operation should be done on all axis (default: false)
  121908. */
  121909. uniformScaling: boolean;
  121910. /**
  121911. * Custom sensitivity value for the drag strength
  121912. */
  121913. sensitivity: number;
  121914. private _isEnabled;
  121915. private _parent;
  121916. private _arrow;
  121917. private _coloredMaterial;
  121918. private _hoverMaterial;
  121919. /**
  121920. * Creates an AxisScaleGizmo
  121921. * @param gizmoLayer The utility layer the gizmo will be added to
  121922. * @param dragAxis The axis which the gizmo will be able to scale on
  121923. * @param color The color of the gizmo
  121924. */
  121925. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121926. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121927. /**
  121928. * If the gizmo is enabled
  121929. */
  121930. set isEnabled(value: boolean);
  121931. get isEnabled(): boolean;
  121932. /**
  121933. * Disposes of the gizmo
  121934. */
  121935. dispose(): void;
  121936. /**
  121937. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121938. * @param mesh The mesh to replace the default mesh of the gizmo
  121939. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121940. */
  121941. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121942. }
  121943. }
  121944. declare module BABYLON {
  121945. /**
  121946. * Bounding box gizmo
  121947. */
  121948. export class BoundingBoxGizmo extends Gizmo {
  121949. private _lineBoundingBox;
  121950. private _rotateSpheresParent;
  121951. private _scaleBoxesParent;
  121952. private _boundingDimensions;
  121953. private _renderObserver;
  121954. private _pointerObserver;
  121955. private _scaleDragSpeed;
  121956. private _tmpQuaternion;
  121957. private _tmpVector;
  121958. private _tmpRotationMatrix;
  121959. /**
  121960. * 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)
  121961. */
  121962. ignoreChildren: boolean;
  121963. /**
  121964. * 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)
  121965. */
  121966. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121967. /**
  121968. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121969. */
  121970. rotationSphereSize: number;
  121971. /**
  121972. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121973. */
  121974. scaleBoxSize: number;
  121975. /**
  121976. * 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)
  121977. */
  121978. fixedDragMeshScreenSize: boolean;
  121979. /**
  121980. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121981. */
  121982. fixedDragMeshScreenSizeDistanceFactor: number;
  121983. /**
  121984. * Fired when a rotation sphere or scale box is dragged
  121985. */
  121986. onDragStartObservable: Observable<{}>;
  121987. /**
  121988. * Fired when a scale box is dragged
  121989. */
  121990. onScaleBoxDragObservable: Observable<{}>;
  121991. /**
  121992. * Fired when a scale box drag is ended
  121993. */
  121994. onScaleBoxDragEndObservable: Observable<{}>;
  121995. /**
  121996. * Fired when a rotation sphere is dragged
  121997. */
  121998. onRotationSphereDragObservable: Observable<{}>;
  121999. /**
  122000. * Fired when a rotation sphere drag is ended
  122001. */
  122002. onRotationSphereDragEndObservable: Observable<{}>;
  122003. /**
  122004. * 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)
  122005. */
  122006. scalePivot: Nullable<Vector3>;
  122007. /**
  122008. * Mesh used as a pivot to rotate the attached mesh
  122009. */
  122010. private _anchorMesh;
  122011. private _existingMeshScale;
  122012. private _dragMesh;
  122013. private pointerDragBehavior;
  122014. private coloredMaterial;
  122015. private hoverColoredMaterial;
  122016. /**
  122017. * Sets the color of the bounding box gizmo
  122018. * @param color the color to set
  122019. */
  122020. setColor(color: Color3): void;
  122021. /**
  122022. * Creates an BoundingBoxGizmo
  122023. * @param gizmoLayer The utility layer the gizmo will be added to
  122024. * @param color The color of the gizmo
  122025. */
  122026. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  122027. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122028. private _selectNode;
  122029. /**
  122030. * Updates the bounding box information for the Gizmo
  122031. */
  122032. updateBoundingBox(): void;
  122033. private _updateRotationSpheres;
  122034. private _updateScaleBoxes;
  122035. /**
  122036. * Enables rotation on the specified axis and disables rotation on the others
  122037. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  122038. */
  122039. setEnabledRotationAxis(axis: string): void;
  122040. /**
  122041. * Enables/disables scaling
  122042. * @param enable if scaling should be enabled
  122043. */
  122044. setEnabledScaling(enable: boolean): void;
  122045. private _updateDummy;
  122046. /**
  122047. * Enables a pointer drag behavior on the bounding box of the gizmo
  122048. */
  122049. enableDragBehavior(): void;
  122050. /**
  122051. * Disposes of the gizmo
  122052. */
  122053. dispose(): void;
  122054. /**
  122055. * 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)
  122056. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  122057. * @returns the bounding box mesh with the passed in mesh as a child
  122058. */
  122059. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  122060. /**
  122061. * CustomMeshes are not supported by this gizmo
  122062. * @param mesh The mesh to replace the default mesh of the gizmo
  122063. */
  122064. setCustomMesh(mesh: Mesh): void;
  122065. }
  122066. }
  122067. declare module BABYLON {
  122068. /**
  122069. * Single plane rotation gizmo
  122070. */
  122071. export class PlaneRotationGizmo extends Gizmo {
  122072. /**
  122073. * Drag behavior responsible for the gizmos dragging interactions
  122074. */
  122075. dragBehavior: PointerDragBehavior;
  122076. private _pointerObserver;
  122077. /**
  122078. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  122079. */
  122080. snapDistance: number;
  122081. /**
  122082. * Event that fires each time the gizmo snaps to a new location.
  122083. * * snapDistance is the the change in distance
  122084. */
  122085. onSnapObservable: Observable<{
  122086. snapDistance: number;
  122087. }>;
  122088. private _isEnabled;
  122089. private _parent;
  122090. /**
  122091. * Creates a PlaneRotationGizmo
  122092. * @param gizmoLayer The utility layer the gizmo will be added to
  122093. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  122094. * @param color The color of the gizmo
  122095. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122096. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122097. */
  122098. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  122099. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122100. /**
  122101. * If the gizmo is enabled
  122102. */
  122103. set isEnabled(value: boolean);
  122104. get isEnabled(): boolean;
  122105. /**
  122106. * Disposes of the gizmo
  122107. */
  122108. dispose(): void;
  122109. }
  122110. }
  122111. declare module BABYLON {
  122112. /**
  122113. * Gizmo that enables rotating a mesh along 3 axis
  122114. */
  122115. export class RotationGizmo extends Gizmo {
  122116. /**
  122117. * Internal gizmo used for interactions on the x axis
  122118. */
  122119. xGizmo: PlaneRotationGizmo;
  122120. /**
  122121. * Internal gizmo used for interactions on the y axis
  122122. */
  122123. yGizmo: PlaneRotationGizmo;
  122124. /**
  122125. * Internal gizmo used for interactions on the z axis
  122126. */
  122127. zGizmo: PlaneRotationGizmo;
  122128. /** Fires an event when any of it's sub gizmos are dragged */
  122129. onDragStartObservable: Observable<unknown>;
  122130. /** Fires an event when any of it's sub gizmos are released from dragging */
  122131. onDragEndObservable: Observable<unknown>;
  122132. private _meshAttached;
  122133. get attachedMesh(): Nullable<AbstractMesh>;
  122134. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122135. /**
  122136. * Creates a RotationGizmo
  122137. * @param gizmoLayer The utility layer the gizmo will be added to
  122138. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122139. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122140. */
  122141. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  122142. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122143. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122144. /**
  122145. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122146. */
  122147. set snapDistance(value: number);
  122148. get snapDistance(): number;
  122149. /**
  122150. * Ratio for the scale of the gizmo (Default: 1)
  122151. */
  122152. set scaleRatio(value: number);
  122153. get scaleRatio(): number;
  122154. /**
  122155. * Disposes of the gizmo
  122156. */
  122157. dispose(): void;
  122158. /**
  122159. * CustomMeshes are not supported by this gizmo
  122160. * @param mesh The mesh to replace the default mesh of the gizmo
  122161. */
  122162. setCustomMesh(mesh: Mesh): void;
  122163. }
  122164. }
  122165. declare module BABYLON {
  122166. /**
  122167. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122168. */
  122169. export class GizmoManager implements IDisposable {
  122170. private scene;
  122171. /**
  122172. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122173. */
  122174. gizmos: {
  122175. positionGizmo: Nullable<PositionGizmo>;
  122176. rotationGizmo: Nullable<RotationGizmo>;
  122177. scaleGizmo: Nullable<ScaleGizmo>;
  122178. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122179. };
  122180. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122181. clearGizmoOnEmptyPointerEvent: boolean;
  122182. /** Fires an event when the manager is attached to a mesh */
  122183. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122184. private _gizmosEnabled;
  122185. private _pointerObserver;
  122186. private _attachedMesh;
  122187. private _boundingBoxColor;
  122188. private _defaultUtilityLayer;
  122189. private _defaultKeepDepthUtilityLayer;
  122190. /**
  122191. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122192. */
  122193. boundingBoxDragBehavior: SixDofDragBehavior;
  122194. /**
  122195. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122196. */
  122197. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122198. /**
  122199. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122200. */
  122201. usePointerToAttachGizmos: boolean;
  122202. /**
  122203. * Utility layer that the bounding box gizmo belongs to
  122204. */
  122205. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122206. /**
  122207. * Utility layer that all gizmos besides bounding box belong to
  122208. */
  122209. get utilityLayer(): UtilityLayerRenderer;
  122210. /**
  122211. * Instatiates a gizmo manager
  122212. * @param scene the scene to overlay the gizmos on top of
  122213. */
  122214. constructor(scene: Scene);
  122215. /**
  122216. * Attaches a set of gizmos to the specified mesh
  122217. * @param mesh The mesh the gizmo's should be attached to
  122218. */
  122219. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122220. /**
  122221. * If the position gizmo is enabled
  122222. */
  122223. set positionGizmoEnabled(value: boolean);
  122224. get positionGizmoEnabled(): boolean;
  122225. /**
  122226. * If the rotation gizmo is enabled
  122227. */
  122228. set rotationGizmoEnabled(value: boolean);
  122229. get rotationGizmoEnabled(): boolean;
  122230. /**
  122231. * If the scale gizmo is enabled
  122232. */
  122233. set scaleGizmoEnabled(value: boolean);
  122234. get scaleGizmoEnabled(): boolean;
  122235. /**
  122236. * If the boundingBox gizmo is enabled
  122237. */
  122238. set boundingBoxGizmoEnabled(value: boolean);
  122239. get boundingBoxGizmoEnabled(): boolean;
  122240. /**
  122241. * Disposes of the gizmo manager
  122242. */
  122243. dispose(): void;
  122244. }
  122245. }
  122246. declare module BABYLON {
  122247. /**
  122248. * A directional light is defined by a direction (what a surprise!).
  122249. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122250. * 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.
  122251. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122252. */
  122253. export class DirectionalLight extends ShadowLight {
  122254. private _shadowFrustumSize;
  122255. /**
  122256. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122257. */
  122258. get shadowFrustumSize(): number;
  122259. /**
  122260. * Specifies a fix frustum size for the shadow generation.
  122261. */
  122262. set shadowFrustumSize(value: number);
  122263. private _shadowOrthoScale;
  122264. /**
  122265. * Gets the shadow projection scale against the optimal computed one.
  122266. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122267. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122268. */
  122269. get shadowOrthoScale(): number;
  122270. /**
  122271. * Sets the shadow projection scale against the optimal computed one.
  122272. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122273. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122274. */
  122275. set shadowOrthoScale(value: number);
  122276. /**
  122277. * Automatically compute the projection matrix to best fit (including all the casters)
  122278. * on each frame.
  122279. */
  122280. autoUpdateExtends: boolean;
  122281. /**
  122282. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122283. * on each frame. autoUpdateExtends must be set to true for this to work
  122284. */
  122285. autoCalcShadowZBounds: boolean;
  122286. private _orthoLeft;
  122287. private _orthoRight;
  122288. private _orthoTop;
  122289. private _orthoBottom;
  122290. /**
  122291. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122292. * The directional light is emitted from everywhere in the given direction.
  122293. * It can cast shadows.
  122294. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122295. * @param name The friendly name of the light
  122296. * @param direction The direction of the light
  122297. * @param scene The scene the light belongs to
  122298. */
  122299. constructor(name: string, direction: Vector3, scene: Scene);
  122300. /**
  122301. * Returns the string "DirectionalLight".
  122302. * @return The class name
  122303. */
  122304. getClassName(): string;
  122305. /**
  122306. * Returns the integer 1.
  122307. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122308. */
  122309. getTypeID(): number;
  122310. /**
  122311. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122312. * Returns the DirectionalLight Shadow projection matrix.
  122313. */
  122314. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122315. /**
  122316. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122317. * Returns the DirectionalLight Shadow projection matrix.
  122318. */
  122319. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122320. /**
  122321. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122322. * Returns the DirectionalLight Shadow projection matrix.
  122323. */
  122324. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122325. protected _buildUniformLayout(): void;
  122326. /**
  122327. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122328. * @param effect The effect to update
  122329. * @param lightIndex The index of the light in the effect to update
  122330. * @returns The directional light
  122331. */
  122332. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122333. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122334. /**
  122335. * Gets the minZ used for shadow according to both the scene and the light.
  122336. *
  122337. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122338. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122339. * @param activeCamera The camera we are returning the min for
  122340. * @returns the depth min z
  122341. */
  122342. getDepthMinZ(activeCamera: Camera): number;
  122343. /**
  122344. * Gets the maxZ used for shadow according to both the scene and the light.
  122345. *
  122346. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122347. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122348. * @param activeCamera The camera we are returning the max for
  122349. * @returns the depth max z
  122350. */
  122351. getDepthMaxZ(activeCamera: Camera): number;
  122352. /**
  122353. * Prepares the list of defines specific to the light type.
  122354. * @param defines the list of defines
  122355. * @param lightIndex defines the index of the light for the effect
  122356. */
  122357. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122358. }
  122359. }
  122360. declare module BABYLON {
  122361. /**
  122362. * Class containing static functions to help procedurally build meshes
  122363. */
  122364. export class HemisphereBuilder {
  122365. /**
  122366. * Creates a hemisphere mesh
  122367. * @param name defines the name of the mesh
  122368. * @param options defines the options used to create the mesh
  122369. * @param scene defines the hosting scene
  122370. * @returns the hemisphere mesh
  122371. */
  122372. static CreateHemisphere(name: string, options: {
  122373. segments?: number;
  122374. diameter?: number;
  122375. sideOrientation?: number;
  122376. }, scene: any): Mesh;
  122377. }
  122378. }
  122379. declare module BABYLON {
  122380. /**
  122381. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122382. * These values define a cone of light starting from the position, emitting toward the direction.
  122383. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122384. * and the exponent defines the speed of the decay of the light with distance (reach).
  122385. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122386. */
  122387. export class SpotLight extends ShadowLight {
  122388. private _angle;
  122389. private _innerAngle;
  122390. private _cosHalfAngle;
  122391. private _lightAngleScale;
  122392. private _lightAngleOffset;
  122393. /**
  122394. * Gets the cone angle of the spot light in Radians.
  122395. */
  122396. get angle(): number;
  122397. /**
  122398. * Sets the cone angle of the spot light in Radians.
  122399. */
  122400. set angle(value: number);
  122401. /**
  122402. * Only used in gltf falloff mode, this defines the angle where
  122403. * the directional falloff will start before cutting at angle which could be seen
  122404. * as outer angle.
  122405. */
  122406. get innerAngle(): number;
  122407. /**
  122408. * Only used in gltf falloff mode, this defines the angle where
  122409. * the directional falloff will start before cutting at angle which could be seen
  122410. * as outer angle.
  122411. */
  122412. set innerAngle(value: number);
  122413. private _shadowAngleScale;
  122414. /**
  122415. * Allows scaling the angle of the light for shadow generation only.
  122416. */
  122417. get shadowAngleScale(): number;
  122418. /**
  122419. * Allows scaling the angle of the light for shadow generation only.
  122420. */
  122421. set shadowAngleScale(value: number);
  122422. /**
  122423. * The light decay speed with the distance from the emission spot.
  122424. */
  122425. exponent: number;
  122426. private _projectionTextureMatrix;
  122427. /**
  122428. * Allows reading the projecton texture
  122429. */
  122430. get projectionTextureMatrix(): Matrix;
  122431. protected _projectionTextureLightNear: number;
  122432. /**
  122433. * Gets the near clip of the Spotlight for texture projection.
  122434. */
  122435. get projectionTextureLightNear(): number;
  122436. /**
  122437. * Sets the near clip of the Spotlight for texture projection.
  122438. */
  122439. set projectionTextureLightNear(value: number);
  122440. protected _projectionTextureLightFar: number;
  122441. /**
  122442. * Gets the far clip of the Spotlight for texture projection.
  122443. */
  122444. get projectionTextureLightFar(): number;
  122445. /**
  122446. * Sets the far clip of the Spotlight for texture projection.
  122447. */
  122448. set projectionTextureLightFar(value: number);
  122449. protected _projectionTextureUpDirection: Vector3;
  122450. /**
  122451. * Gets the Up vector of the Spotlight for texture projection.
  122452. */
  122453. get projectionTextureUpDirection(): Vector3;
  122454. /**
  122455. * Sets the Up vector of the Spotlight for texture projection.
  122456. */
  122457. set projectionTextureUpDirection(value: Vector3);
  122458. private _projectionTexture;
  122459. /**
  122460. * Gets the projection texture of the light.
  122461. */
  122462. get projectionTexture(): Nullable<BaseTexture>;
  122463. /**
  122464. * Sets the projection texture of the light.
  122465. */
  122466. set projectionTexture(value: Nullable<BaseTexture>);
  122467. private _projectionTextureViewLightDirty;
  122468. private _projectionTextureProjectionLightDirty;
  122469. private _projectionTextureDirty;
  122470. private _projectionTextureViewTargetVector;
  122471. private _projectionTextureViewLightMatrix;
  122472. private _projectionTextureProjectionLightMatrix;
  122473. private _projectionTextureScalingMatrix;
  122474. /**
  122475. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122476. * It can cast shadows.
  122477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122478. * @param name The light friendly name
  122479. * @param position The position of the spot light in the scene
  122480. * @param direction The direction of the light in the scene
  122481. * @param angle The cone angle of the light in Radians
  122482. * @param exponent The light decay speed with the distance from the emission spot
  122483. * @param scene The scene the lights belongs to
  122484. */
  122485. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122486. /**
  122487. * Returns the string "SpotLight".
  122488. * @returns the class name
  122489. */
  122490. getClassName(): string;
  122491. /**
  122492. * Returns the integer 2.
  122493. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122494. */
  122495. getTypeID(): number;
  122496. /**
  122497. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122498. */
  122499. protected _setDirection(value: Vector3): void;
  122500. /**
  122501. * Overrides the position setter to recompute the projection texture view light Matrix.
  122502. */
  122503. protected _setPosition(value: Vector3): void;
  122504. /**
  122505. * 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.
  122506. * Returns the SpotLight.
  122507. */
  122508. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122509. protected _computeProjectionTextureViewLightMatrix(): void;
  122510. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122511. /**
  122512. * Main function for light texture projection matrix computing.
  122513. */
  122514. protected _computeProjectionTextureMatrix(): void;
  122515. protected _buildUniformLayout(): void;
  122516. private _computeAngleValues;
  122517. /**
  122518. * Sets the passed Effect "effect" with the Light textures.
  122519. * @param effect The effect to update
  122520. * @param lightIndex The index of the light in the effect to update
  122521. * @returns The light
  122522. */
  122523. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122524. /**
  122525. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122526. * @param effect The effect to update
  122527. * @param lightIndex The index of the light in the effect to update
  122528. * @returns The spot light
  122529. */
  122530. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122531. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122532. /**
  122533. * Disposes the light and the associated resources.
  122534. */
  122535. dispose(): void;
  122536. /**
  122537. * Prepares the list of defines specific to the light type.
  122538. * @param defines the list of defines
  122539. * @param lightIndex defines the index of the light for the effect
  122540. */
  122541. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122542. }
  122543. }
  122544. declare module BABYLON {
  122545. /**
  122546. * Gizmo that enables viewing a light
  122547. */
  122548. export class LightGizmo extends Gizmo {
  122549. private _lightMesh;
  122550. private _material;
  122551. private _cachedPosition;
  122552. private _cachedForward;
  122553. private _attachedMeshParent;
  122554. /**
  122555. * Creates a LightGizmo
  122556. * @param gizmoLayer The utility layer the gizmo will be added to
  122557. */
  122558. constructor(gizmoLayer?: UtilityLayerRenderer);
  122559. private _light;
  122560. /**
  122561. * The light that the gizmo is attached to
  122562. */
  122563. set light(light: Nullable<Light>);
  122564. get light(): Nullable<Light>;
  122565. /**
  122566. * Gets the material used to render the light gizmo
  122567. */
  122568. get material(): StandardMaterial;
  122569. /**
  122570. * @hidden
  122571. * Updates the gizmo to match the attached mesh's position/rotation
  122572. */
  122573. protected _update(): void;
  122574. private static _Scale;
  122575. /**
  122576. * Creates the lines for a light mesh
  122577. */
  122578. private static _CreateLightLines;
  122579. /**
  122580. * Disposes of the light gizmo
  122581. */
  122582. dispose(): void;
  122583. private static _CreateHemisphericLightMesh;
  122584. private static _CreatePointLightMesh;
  122585. private static _CreateSpotLightMesh;
  122586. private static _CreateDirectionalLightMesh;
  122587. }
  122588. }
  122589. declare module BABYLON {
  122590. /** @hidden */
  122591. export var backgroundFragmentDeclaration: {
  122592. name: string;
  122593. shader: string;
  122594. };
  122595. }
  122596. declare module BABYLON {
  122597. /** @hidden */
  122598. export var backgroundUboDeclaration: {
  122599. name: string;
  122600. shader: string;
  122601. };
  122602. }
  122603. declare module BABYLON {
  122604. /** @hidden */
  122605. export var backgroundPixelShader: {
  122606. name: string;
  122607. shader: string;
  122608. };
  122609. }
  122610. declare module BABYLON {
  122611. /** @hidden */
  122612. export var backgroundVertexDeclaration: {
  122613. name: string;
  122614. shader: string;
  122615. };
  122616. }
  122617. declare module BABYLON {
  122618. /** @hidden */
  122619. export var backgroundVertexShader: {
  122620. name: string;
  122621. shader: string;
  122622. };
  122623. }
  122624. declare module BABYLON {
  122625. /**
  122626. * Background material used to create an efficient environement around your scene.
  122627. */
  122628. export class BackgroundMaterial extends PushMaterial {
  122629. /**
  122630. * Standard reflectance value at parallel view angle.
  122631. */
  122632. static StandardReflectance0: number;
  122633. /**
  122634. * Standard reflectance value at grazing angle.
  122635. */
  122636. static StandardReflectance90: number;
  122637. protected _primaryColor: Color3;
  122638. /**
  122639. * Key light Color (multiply against the environement texture)
  122640. */
  122641. primaryColor: Color3;
  122642. protected __perceptualColor: Nullable<Color3>;
  122643. /**
  122644. * Experimental Internal Use Only.
  122645. *
  122646. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122647. * This acts as a helper to set the primary color to a more "human friendly" value.
  122648. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122649. * output color as close as possible from the chosen value.
  122650. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122651. * part of lighting setup.)
  122652. */
  122653. get _perceptualColor(): Nullable<Color3>;
  122654. set _perceptualColor(value: Nullable<Color3>);
  122655. protected _primaryColorShadowLevel: float;
  122656. /**
  122657. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122658. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122659. */
  122660. get primaryColorShadowLevel(): float;
  122661. set primaryColorShadowLevel(value: float);
  122662. protected _primaryColorHighlightLevel: float;
  122663. /**
  122664. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122665. * The primary color is used at the level chosen to define what the white area would look.
  122666. */
  122667. get primaryColorHighlightLevel(): float;
  122668. set primaryColorHighlightLevel(value: float);
  122669. protected _reflectionTexture: Nullable<BaseTexture>;
  122670. /**
  122671. * Reflection Texture used in the material.
  122672. * Should be author in a specific way for the best result (refer to the documentation).
  122673. */
  122674. reflectionTexture: Nullable<BaseTexture>;
  122675. protected _reflectionBlur: float;
  122676. /**
  122677. * Reflection Texture level of blur.
  122678. *
  122679. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122680. * texture twice.
  122681. */
  122682. reflectionBlur: float;
  122683. protected _diffuseTexture: Nullable<BaseTexture>;
  122684. /**
  122685. * Diffuse Texture used in the material.
  122686. * Should be author in a specific way for the best result (refer to the documentation).
  122687. */
  122688. diffuseTexture: Nullable<BaseTexture>;
  122689. protected _shadowLights: Nullable<IShadowLight[]>;
  122690. /**
  122691. * Specify the list of lights casting shadow on the material.
  122692. * All scene shadow lights will be included if null.
  122693. */
  122694. shadowLights: Nullable<IShadowLight[]>;
  122695. protected _shadowLevel: float;
  122696. /**
  122697. * Helps adjusting the shadow to a softer level if required.
  122698. * 0 means black shadows and 1 means no shadows.
  122699. */
  122700. shadowLevel: float;
  122701. protected _sceneCenter: Vector3;
  122702. /**
  122703. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122704. * It is usually zero but might be interesting to modify according to your setup.
  122705. */
  122706. sceneCenter: Vector3;
  122707. protected _opacityFresnel: boolean;
  122708. /**
  122709. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122710. * This helps ensuring a nice transition when the camera goes under the ground.
  122711. */
  122712. opacityFresnel: boolean;
  122713. protected _reflectionFresnel: boolean;
  122714. /**
  122715. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122716. * This helps adding a mirror texture on the ground.
  122717. */
  122718. reflectionFresnel: boolean;
  122719. protected _reflectionFalloffDistance: number;
  122720. /**
  122721. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122722. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122723. */
  122724. reflectionFalloffDistance: number;
  122725. protected _reflectionAmount: number;
  122726. /**
  122727. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122728. */
  122729. reflectionAmount: number;
  122730. protected _reflectionReflectance0: number;
  122731. /**
  122732. * This specifies the weight of the reflection at grazing angle.
  122733. */
  122734. reflectionReflectance0: number;
  122735. protected _reflectionReflectance90: number;
  122736. /**
  122737. * This specifies the weight of the reflection at a perpendicular point of view.
  122738. */
  122739. reflectionReflectance90: number;
  122740. /**
  122741. * Sets the reflection reflectance fresnel values according to the default standard
  122742. * empirically know to work well :-)
  122743. */
  122744. set reflectionStandardFresnelWeight(value: number);
  122745. protected _useRGBColor: boolean;
  122746. /**
  122747. * Helps to directly use the maps channels instead of their level.
  122748. */
  122749. useRGBColor: boolean;
  122750. protected _enableNoise: boolean;
  122751. /**
  122752. * This helps reducing the banding effect that could occur on the background.
  122753. */
  122754. enableNoise: boolean;
  122755. /**
  122756. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122757. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122758. * Recommended to be keep at 1.0 except for special cases.
  122759. */
  122760. get fovMultiplier(): number;
  122761. set fovMultiplier(value: number);
  122762. private _fovMultiplier;
  122763. /**
  122764. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122765. */
  122766. useEquirectangularFOV: boolean;
  122767. private _maxSimultaneousLights;
  122768. /**
  122769. * Number of Simultaneous lights allowed on the material.
  122770. */
  122771. maxSimultaneousLights: int;
  122772. /**
  122773. * Default configuration related to image processing available in the Background Material.
  122774. */
  122775. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122776. /**
  122777. * Keep track of the image processing observer to allow dispose and replace.
  122778. */
  122779. private _imageProcessingObserver;
  122780. /**
  122781. * Attaches a new image processing configuration to the PBR Material.
  122782. * @param configuration (if null the scene configuration will be use)
  122783. */
  122784. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122785. /**
  122786. * Gets the image processing configuration used either in this material.
  122787. */
  122788. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122789. /**
  122790. * Sets the Default image processing configuration used either in the this material.
  122791. *
  122792. * If sets to null, the scene one is in use.
  122793. */
  122794. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122795. /**
  122796. * Gets wether the color curves effect is enabled.
  122797. */
  122798. get cameraColorCurvesEnabled(): boolean;
  122799. /**
  122800. * Sets wether the color curves effect is enabled.
  122801. */
  122802. set cameraColorCurvesEnabled(value: boolean);
  122803. /**
  122804. * Gets wether the color grading effect is enabled.
  122805. */
  122806. get cameraColorGradingEnabled(): boolean;
  122807. /**
  122808. * Gets wether the color grading effect is enabled.
  122809. */
  122810. set cameraColorGradingEnabled(value: boolean);
  122811. /**
  122812. * Gets wether tonemapping is enabled or not.
  122813. */
  122814. get cameraToneMappingEnabled(): boolean;
  122815. /**
  122816. * Sets wether tonemapping is enabled or not
  122817. */
  122818. set cameraToneMappingEnabled(value: boolean);
  122819. /**
  122820. * The camera exposure used on this material.
  122821. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122822. * This corresponds to a photographic exposure.
  122823. */
  122824. get cameraExposure(): float;
  122825. /**
  122826. * The camera exposure used on this material.
  122827. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122828. * This corresponds to a photographic exposure.
  122829. */
  122830. set cameraExposure(value: float);
  122831. /**
  122832. * Gets The camera contrast used on this material.
  122833. */
  122834. get cameraContrast(): float;
  122835. /**
  122836. * Sets The camera contrast used on this material.
  122837. */
  122838. set cameraContrast(value: float);
  122839. /**
  122840. * Gets the Color Grading 2D Lookup Texture.
  122841. */
  122842. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122843. /**
  122844. * Sets the Color Grading 2D Lookup Texture.
  122845. */
  122846. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122847. /**
  122848. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122850. * 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;
  122851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122852. */
  122853. get cameraColorCurves(): Nullable<ColorCurves>;
  122854. /**
  122855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122857. * 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;
  122858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122859. */
  122860. set cameraColorCurves(value: Nullable<ColorCurves>);
  122861. /**
  122862. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122863. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122864. */
  122865. switchToBGR: boolean;
  122866. private _renderTargets;
  122867. private _reflectionControls;
  122868. private _white;
  122869. private _primaryShadowColor;
  122870. private _primaryHighlightColor;
  122871. /**
  122872. * Instantiates a Background Material in the given scene
  122873. * @param name The friendly name of the material
  122874. * @param scene The scene to add the material to
  122875. */
  122876. constructor(name: string, scene: Scene);
  122877. /**
  122878. * Gets a boolean indicating that current material needs to register RTT
  122879. */
  122880. get hasRenderTargetTextures(): boolean;
  122881. /**
  122882. * The entire material has been created in order to prevent overdraw.
  122883. * @returns false
  122884. */
  122885. needAlphaTesting(): boolean;
  122886. /**
  122887. * The entire material has been created in order to prevent overdraw.
  122888. * @returns true if blending is enable
  122889. */
  122890. needAlphaBlending(): boolean;
  122891. /**
  122892. * Checks wether the material is ready to be rendered for a given mesh.
  122893. * @param mesh The mesh to render
  122894. * @param subMesh The submesh to check against
  122895. * @param useInstances Specify wether or not the material is used with instances
  122896. * @returns true if all the dependencies are ready (Textures, Effects...)
  122897. */
  122898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122899. /**
  122900. * Compute the primary color according to the chosen perceptual color.
  122901. */
  122902. private _computePrimaryColorFromPerceptualColor;
  122903. /**
  122904. * Compute the highlights and shadow colors according to their chosen levels.
  122905. */
  122906. private _computePrimaryColors;
  122907. /**
  122908. * Build the uniform buffer used in the material.
  122909. */
  122910. buildUniformLayout(): void;
  122911. /**
  122912. * Unbind the material.
  122913. */
  122914. unbind(): void;
  122915. /**
  122916. * Bind only the world matrix to the material.
  122917. * @param world The world matrix to bind.
  122918. */
  122919. bindOnlyWorldMatrix(world: Matrix): void;
  122920. /**
  122921. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122922. * @param world The world matrix to bind.
  122923. * @param subMesh The submesh to bind for.
  122924. */
  122925. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122926. /**
  122927. * Checks to see if a texture is used in the material.
  122928. * @param texture - Base texture to use.
  122929. * @returns - Boolean specifying if a texture is used in the material.
  122930. */
  122931. hasTexture(texture: BaseTexture): boolean;
  122932. /**
  122933. * Dispose the material.
  122934. * @param forceDisposeEffect Force disposal of the associated effect.
  122935. * @param forceDisposeTextures Force disposal of the associated textures.
  122936. */
  122937. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122938. /**
  122939. * Clones the material.
  122940. * @param name The cloned name.
  122941. * @returns The cloned material.
  122942. */
  122943. clone(name: string): BackgroundMaterial;
  122944. /**
  122945. * Serializes the current material to its JSON representation.
  122946. * @returns The JSON representation.
  122947. */
  122948. serialize(): any;
  122949. /**
  122950. * Gets the class name of the material
  122951. * @returns "BackgroundMaterial"
  122952. */
  122953. getClassName(): string;
  122954. /**
  122955. * Parse a JSON input to create back a background material.
  122956. * @param source The JSON data to parse
  122957. * @param scene The scene to create the parsed material in
  122958. * @param rootUrl The root url of the assets the material depends upon
  122959. * @returns the instantiated BackgroundMaterial.
  122960. */
  122961. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122962. }
  122963. }
  122964. declare module BABYLON {
  122965. /**
  122966. * Represents the different options available during the creation of
  122967. * a Environment helper.
  122968. *
  122969. * This can control the default ground, skybox and image processing setup of your scene.
  122970. */
  122971. export interface IEnvironmentHelperOptions {
  122972. /**
  122973. * Specifies whether or not to create a ground.
  122974. * True by default.
  122975. */
  122976. createGround: boolean;
  122977. /**
  122978. * Specifies the ground size.
  122979. * 15 by default.
  122980. */
  122981. groundSize: number;
  122982. /**
  122983. * The texture used on the ground for the main color.
  122984. * Comes from the BabylonJS CDN by default.
  122985. *
  122986. * Remarks: Can be either a texture or a url.
  122987. */
  122988. groundTexture: string | BaseTexture;
  122989. /**
  122990. * The color mixed in the ground texture by default.
  122991. * BabylonJS clearColor by default.
  122992. */
  122993. groundColor: Color3;
  122994. /**
  122995. * Specifies the ground opacity.
  122996. * 1 by default.
  122997. */
  122998. groundOpacity: number;
  122999. /**
  123000. * Enables the ground to receive shadows.
  123001. * True by default.
  123002. */
  123003. enableGroundShadow: boolean;
  123004. /**
  123005. * Helps preventing the shadow to be fully black on the ground.
  123006. * 0.5 by default.
  123007. */
  123008. groundShadowLevel: number;
  123009. /**
  123010. * Creates a mirror texture attach to the ground.
  123011. * false by default.
  123012. */
  123013. enableGroundMirror: boolean;
  123014. /**
  123015. * Specifies the ground mirror size ratio.
  123016. * 0.3 by default as the default kernel is 64.
  123017. */
  123018. groundMirrorSizeRatio: number;
  123019. /**
  123020. * Specifies the ground mirror blur kernel size.
  123021. * 64 by default.
  123022. */
  123023. groundMirrorBlurKernel: number;
  123024. /**
  123025. * Specifies the ground mirror visibility amount.
  123026. * 1 by default
  123027. */
  123028. groundMirrorAmount: number;
  123029. /**
  123030. * Specifies the ground mirror reflectance weight.
  123031. * This uses the standard weight of the background material to setup the fresnel effect
  123032. * of the mirror.
  123033. * 1 by default.
  123034. */
  123035. groundMirrorFresnelWeight: number;
  123036. /**
  123037. * Specifies the ground mirror Falloff distance.
  123038. * This can helps reducing the size of the reflection.
  123039. * 0 by Default.
  123040. */
  123041. groundMirrorFallOffDistance: number;
  123042. /**
  123043. * Specifies the ground mirror texture type.
  123044. * Unsigned Int by Default.
  123045. */
  123046. groundMirrorTextureType: number;
  123047. /**
  123048. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  123049. * the shown objects.
  123050. */
  123051. groundYBias: number;
  123052. /**
  123053. * Specifies whether or not to create a skybox.
  123054. * True by default.
  123055. */
  123056. createSkybox: boolean;
  123057. /**
  123058. * Specifies the skybox size.
  123059. * 20 by default.
  123060. */
  123061. skyboxSize: number;
  123062. /**
  123063. * The texture used on the skybox for the main color.
  123064. * Comes from the BabylonJS CDN by default.
  123065. *
  123066. * Remarks: Can be either a texture or a url.
  123067. */
  123068. skyboxTexture: string | BaseTexture;
  123069. /**
  123070. * The color mixed in the skybox texture by default.
  123071. * BabylonJS clearColor by default.
  123072. */
  123073. skyboxColor: Color3;
  123074. /**
  123075. * The background rotation around the Y axis of the scene.
  123076. * This helps aligning the key lights of your scene with the background.
  123077. * 0 by default.
  123078. */
  123079. backgroundYRotation: number;
  123080. /**
  123081. * Compute automatically the size of the elements to best fit with the scene.
  123082. */
  123083. sizeAuto: boolean;
  123084. /**
  123085. * Default position of the rootMesh if autoSize is not true.
  123086. */
  123087. rootPosition: Vector3;
  123088. /**
  123089. * Sets up the image processing in the scene.
  123090. * true by default.
  123091. */
  123092. setupImageProcessing: boolean;
  123093. /**
  123094. * The texture used as your environment texture in the scene.
  123095. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  123096. *
  123097. * Remarks: Can be either a texture or a url.
  123098. */
  123099. environmentTexture: string | BaseTexture;
  123100. /**
  123101. * The value of the exposure to apply to the scene.
  123102. * 0.6 by default if setupImageProcessing is true.
  123103. */
  123104. cameraExposure: number;
  123105. /**
  123106. * The value of the contrast to apply to the scene.
  123107. * 1.6 by default if setupImageProcessing is true.
  123108. */
  123109. cameraContrast: number;
  123110. /**
  123111. * Specifies whether or not tonemapping should be enabled in the scene.
  123112. * true by default if setupImageProcessing is true.
  123113. */
  123114. toneMappingEnabled: boolean;
  123115. }
  123116. /**
  123117. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  123118. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  123119. * It also helps with the default setup of your imageProcessing configuration.
  123120. */
  123121. export class EnvironmentHelper {
  123122. /**
  123123. * Default ground texture URL.
  123124. */
  123125. private static _groundTextureCDNUrl;
  123126. /**
  123127. * Default skybox texture URL.
  123128. */
  123129. private static _skyboxTextureCDNUrl;
  123130. /**
  123131. * Default environment texture URL.
  123132. */
  123133. private static _environmentTextureCDNUrl;
  123134. /**
  123135. * Creates the default options for the helper.
  123136. */
  123137. private static _getDefaultOptions;
  123138. private _rootMesh;
  123139. /**
  123140. * Gets the root mesh created by the helper.
  123141. */
  123142. get rootMesh(): Mesh;
  123143. private _skybox;
  123144. /**
  123145. * Gets the skybox created by the helper.
  123146. */
  123147. get skybox(): Nullable<Mesh>;
  123148. private _skyboxTexture;
  123149. /**
  123150. * Gets the skybox texture created by the helper.
  123151. */
  123152. get skyboxTexture(): Nullable<BaseTexture>;
  123153. private _skyboxMaterial;
  123154. /**
  123155. * Gets the skybox material created by the helper.
  123156. */
  123157. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  123158. private _ground;
  123159. /**
  123160. * Gets the ground mesh created by the helper.
  123161. */
  123162. get ground(): Nullable<Mesh>;
  123163. private _groundTexture;
  123164. /**
  123165. * Gets the ground texture created by the helper.
  123166. */
  123167. get groundTexture(): Nullable<BaseTexture>;
  123168. private _groundMirror;
  123169. /**
  123170. * Gets the ground mirror created by the helper.
  123171. */
  123172. get groundMirror(): Nullable<MirrorTexture>;
  123173. /**
  123174. * Gets the ground mirror render list to helps pushing the meshes
  123175. * you wish in the ground reflection.
  123176. */
  123177. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123178. private _groundMaterial;
  123179. /**
  123180. * Gets the ground material created by the helper.
  123181. */
  123182. get groundMaterial(): Nullable<BackgroundMaterial>;
  123183. /**
  123184. * Stores the creation options.
  123185. */
  123186. private readonly _scene;
  123187. private _options;
  123188. /**
  123189. * This observable will be notified with any error during the creation of the environment,
  123190. * mainly texture creation errors.
  123191. */
  123192. onErrorObservable: Observable<{
  123193. message?: string;
  123194. exception?: any;
  123195. }>;
  123196. /**
  123197. * constructor
  123198. * @param options Defines the options we want to customize the helper
  123199. * @param scene The scene to add the material to
  123200. */
  123201. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123202. /**
  123203. * Updates the background according to the new options
  123204. * @param options
  123205. */
  123206. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123207. /**
  123208. * Sets the primary color of all the available elements.
  123209. * @param color the main color to affect to the ground and the background
  123210. */
  123211. setMainColor(color: Color3): void;
  123212. /**
  123213. * Setup the image processing according to the specified options.
  123214. */
  123215. private _setupImageProcessing;
  123216. /**
  123217. * Setup the environment texture according to the specified options.
  123218. */
  123219. private _setupEnvironmentTexture;
  123220. /**
  123221. * Setup the background according to the specified options.
  123222. */
  123223. private _setupBackground;
  123224. /**
  123225. * Get the scene sizes according to the setup.
  123226. */
  123227. private _getSceneSize;
  123228. /**
  123229. * Setup the ground according to the specified options.
  123230. */
  123231. private _setupGround;
  123232. /**
  123233. * Setup the ground material according to the specified options.
  123234. */
  123235. private _setupGroundMaterial;
  123236. /**
  123237. * Setup the ground diffuse texture according to the specified options.
  123238. */
  123239. private _setupGroundDiffuseTexture;
  123240. /**
  123241. * Setup the ground mirror texture according to the specified options.
  123242. */
  123243. private _setupGroundMirrorTexture;
  123244. /**
  123245. * Setup the ground to receive the mirror texture.
  123246. */
  123247. private _setupMirrorInGroundMaterial;
  123248. /**
  123249. * Setup the skybox according to the specified options.
  123250. */
  123251. private _setupSkybox;
  123252. /**
  123253. * Setup the skybox material according to the specified options.
  123254. */
  123255. private _setupSkyboxMaterial;
  123256. /**
  123257. * Setup the skybox reflection texture according to the specified options.
  123258. */
  123259. private _setupSkyboxReflectionTexture;
  123260. private _errorHandler;
  123261. /**
  123262. * Dispose all the elements created by the Helper.
  123263. */
  123264. dispose(): void;
  123265. }
  123266. }
  123267. declare module BABYLON {
  123268. /**
  123269. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123270. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123271. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123272. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123273. */
  123274. export class PhotoDome extends TransformNode {
  123275. /**
  123276. * Define the image as a Monoscopic panoramic 360 image.
  123277. */
  123278. static readonly MODE_MONOSCOPIC: number;
  123279. /**
  123280. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123281. */
  123282. static readonly MODE_TOPBOTTOM: number;
  123283. /**
  123284. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123285. */
  123286. static readonly MODE_SIDEBYSIDE: number;
  123287. private _useDirectMapping;
  123288. /**
  123289. * The texture being displayed on the sphere
  123290. */
  123291. protected _photoTexture: Texture;
  123292. /**
  123293. * Gets or sets the texture being displayed on the sphere
  123294. */
  123295. get photoTexture(): Texture;
  123296. set photoTexture(value: Texture);
  123297. /**
  123298. * Observable raised when an error occured while loading the 360 image
  123299. */
  123300. onLoadErrorObservable: Observable<string>;
  123301. /**
  123302. * The skybox material
  123303. */
  123304. protected _material: BackgroundMaterial;
  123305. /**
  123306. * The surface used for the skybox
  123307. */
  123308. protected _mesh: Mesh;
  123309. /**
  123310. * Gets the mesh used for the skybox.
  123311. */
  123312. get mesh(): Mesh;
  123313. /**
  123314. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123315. * Also see the options.resolution property.
  123316. */
  123317. get fovMultiplier(): number;
  123318. set fovMultiplier(value: number);
  123319. private _imageMode;
  123320. /**
  123321. * Gets or set the current video mode for the video. It can be:
  123322. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123323. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123324. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123325. */
  123326. get imageMode(): number;
  123327. set imageMode(value: number);
  123328. /**
  123329. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123330. * @param name Element's name, child elements will append suffixes for their own names.
  123331. * @param urlsOfPhoto defines the url of the photo to display
  123332. * @param options defines an object containing optional or exposed sub element properties
  123333. * @param onError defines a callback called when an error occured while loading the texture
  123334. */
  123335. constructor(name: string, urlOfPhoto: string, options: {
  123336. resolution?: number;
  123337. size?: number;
  123338. useDirectMapping?: boolean;
  123339. faceForward?: boolean;
  123340. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123341. private _onBeforeCameraRenderObserver;
  123342. private _changeImageMode;
  123343. /**
  123344. * Releases resources associated with this node.
  123345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123347. */
  123348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123349. }
  123350. }
  123351. declare module BABYLON {
  123352. /**
  123353. * Class used to host RGBD texture specific utilities
  123354. */
  123355. export class RGBDTextureTools {
  123356. /**
  123357. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123358. * @param texture the texture to expand.
  123359. */
  123360. static ExpandRGBDTexture(texture: Texture): void;
  123361. }
  123362. }
  123363. declare module BABYLON {
  123364. /**
  123365. * Class used to host texture specific utilities
  123366. */
  123367. export class BRDFTextureTools {
  123368. private static _instanceNumber;
  123369. /**
  123370. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123371. * @param scene defines the hosting scene
  123372. * @returns the environment BRDF texture
  123373. */
  123374. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123375. private static _environmentBRDFBase64Texture;
  123376. }
  123377. }
  123378. declare module BABYLON {
  123379. /**
  123380. * @hidden
  123381. */
  123382. export interface IMaterialClearCoatDefines {
  123383. CLEARCOAT: boolean;
  123384. CLEARCOAT_DEFAULTIOR: boolean;
  123385. CLEARCOAT_TEXTURE: boolean;
  123386. CLEARCOAT_TEXTUREDIRECTUV: number;
  123387. CLEARCOAT_BUMP: boolean;
  123388. CLEARCOAT_BUMPDIRECTUV: number;
  123389. CLEARCOAT_TINT: boolean;
  123390. CLEARCOAT_TINT_TEXTURE: boolean;
  123391. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123392. /** @hidden */
  123393. _areTexturesDirty: boolean;
  123394. }
  123395. /**
  123396. * Define the code related to the clear coat parameters of the pbr material.
  123397. */
  123398. export class PBRClearCoatConfiguration {
  123399. /**
  123400. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123401. * The default fits with a polyurethane material.
  123402. */
  123403. private static readonly _DefaultIndexOfRefraction;
  123404. private _isEnabled;
  123405. /**
  123406. * Defines if the clear coat is enabled in the material.
  123407. */
  123408. isEnabled: boolean;
  123409. /**
  123410. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123411. */
  123412. intensity: number;
  123413. /**
  123414. * Defines the clear coat layer roughness.
  123415. */
  123416. roughness: number;
  123417. private _indexOfRefraction;
  123418. /**
  123419. * Defines the index of refraction of the clear coat.
  123420. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123421. * The default fits with a polyurethane material.
  123422. * Changing the default value is more performance intensive.
  123423. */
  123424. indexOfRefraction: number;
  123425. private _texture;
  123426. /**
  123427. * Stores the clear coat values in a texture.
  123428. */
  123429. texture: Nullable<BaseTexture>;
  123430. private _bumpTexture;
  123431. /**
  123432. * Define the clear coat specific bump texture.
  123433. */
  123434. bumpTexture: Nullable<BaseTexture>;
  123435. private _isTintEnabled;
  123436. /**
  123437. * Defines if the clear coat tint is enabled in the material.
  123438. */
  123439. isTintEnabled: boolean;
  123440. /**
  123441. * Defines the clear coat tint of the material.
  123442. * This is only use if tint is enabled
  123443. */
  123444. tintColor: Color3;
  123445. /**
  123446. * Defines the distance at which the tint color should be found in the
  123447. * clear coat media.
  123448. * This is only use if tint is enabled
  123449. */
  123450. tintColorAtDistance: number;
  123451. /**
  123452. * Defines the clear coat layer thickness.
  123453. * This is only use if tint is enabled
  123454. */
  123455. tintThickness: number;
  123456. private _tintTexture;
  123457. /**
  123458. * Stores the clear tint values in a texture.
  123459. * rgb is tint
  123460. * a is a thickness factor
  123461. */
  123462. tintTexture: Nullable<BaseTexture>;
  123463. /** @hidden */
  123464. private _internalMarkAllSubMeshesAsTexturesDirty;
  123465. /** @hidden */
  123466. _markAllSubMeshesAsTexturesDirty(): void;
  123467. /**
  123468. * Instantiate a new istance of clear coat configuration.
  123469. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123470. */
  123471. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123472. /**
  123473. * Gets wehter the submesh is ready to be used or not.
  123474. * @param defines the list of "defines" to update.
  123475. * @param scene defines the scene the material belongs to.
  123476. * @param engine defines the engine the material belongs to.
  123477. * @param disableBumpMap defines wether the material disables bump or not.
  123478. * @returns - boolean indicating that the submesh is ready or not.
  123479. */
  123480. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123481. /**
  123482. * Checks to see if a texture is used in the material.
  123483. * @param defines the list of "defines" to update.
  123484. * @param scene defines the scene to the material belongs to.
  123485. */
  123486. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123487. /**
  123488. * Binds the material data.
  123489. * @param uniformBuffer defines the Uniform buffer to fill in.
  123490. * @param scene defines the scene the material belongs to.
  123491. * @param engine defines the engine the material belongs to.
  123492. * @param disableBumpMap defines wether the material disables bump or not.
  123493. * @param isFrozen defines wether the material is frozen or not.
  123494. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123495. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123496. */
  123497. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123498. /**
  123499. * Checks to see if a texture is used in the material.
  123500. * @param texture - Base texture to use.
  123501. * @returns - Boolean specifying if a texture is used in the material.
  123502. */
  123503. hasTexture(texture: BaseTexture): boolean;
  123504. /**
  123505. * Returns an array of the actively used textures.
  123506. * @param activeTextures Array of BaseTextures
  123507. */
  123508. getActiveTextures(activeTextures: BaseTexture[]): void;
  123509. /**
  123510. * Returns the animatable textures.
  123511. * @param animatables Array of animatable textures.
  123512. */
  123513. getAnimatables(animatables: IAnimatable[]): void;
  123514. /**
  123515. * Disposes the resources of the material.
  123516. * @param forceDisposeTextures - Forces the disposal of all textures.
  123517. */
  123518. dispose(forceDisposeTextures?: boolean): void;
  123519. /**
  123520. * Get the current class name of the texture useful for serialization or dynamic coding.
  123521. * @returns "PBRClearCoatConfiguration"
  123522. */
  123523. getClassName(): string;
  123524. /**
  123525. * Add fallbacks to the effect fallbacks list.
  123526. * @param defines defines the Base texture to use.
  123527. * @param fallbacks defines the current fallback list.
  123528. * @param currentRank defines the current fallback rank.
  123529. * @returns the new fallback rank.
  123530. */
  123531. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123532. /**
  123533. * Add the required uniforms to the current list.
  123534. * @param uniforms defines the current uniform list.
  123535. */
  123536. static AddUniforms(uniforms: string[]): void;
  123537. /**
  123538. * Add the required samplers to the current list.
  123539. * @param samplers defines the current sampler list.
  123540. */
  123541. static AddSamplers(samplers: string[]): void;
  123542. /**
  123543. * Add the required uniforms to the current buffer.
  123544. * @param uniformBuffer defines the current uniform buffer.
  123545. */
  123546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123547. /**
  123548. * Makes a duplicate of the current configuration into another one.
  123549. * @param clearCoatConfiguration define the config where to copy the info
  123550. */
  123551. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123552. /**
  123553. * Serializes this clear coat configuration.
  123554. * @returns - An object with the serialized config.
  123555. */
  123556. serialize(): any;
  123557. /**
  123558. * Parses a anisotropy Configuration from a serialized object.
  123559. * @param source - Serialized object.
  123560. * @param scene Defines the scene we are parsing for
  123561. * @param rootUrl Defines the rootUrl to load from
  123562. */
  123563. parse(source: any, scene: Scene, rootUrl: string): void;
  123564. }
  123565. }
  123566. declare module BABYLON {
  123567. /**
  123568. * @hidden
  123569. */
  123570. export interface IMaterialAnisotropicDefines {
  123571. ANISOTROPIC: boolean;
  123572. ANISOTROPIC_TEXTURE: boolean;
  123573. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123574. MAINUV1: boolean;
  123575. _areTexturesDirty: boolean;
  123576. _needUVs: boolean;
  123577. }
  123578. /**
  123579. * Define the code related to the anisotropic parameters of the pbr material.
  123580. */
  123581. export class PBRAnisotropicConfiguration {
  123582. private _isEnabled;
  123583. /**
  123584. * Defines if the anisotropy is enabled in the material.
  123585. */
  123586. isEnabled: boolean;
  123587. /**
  123588. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123589. */
  123590. intensity: number;
  123591. /**
  123592. * Defines if the effect is along the tangents, bitangents or in between.
  123593. * By default, the effect is "strectching" the highlights along the tangents.
  123594. */
  123595. direction: Vector2;
  123596. private _texture;
  123597. /**
  123598. * Stores the anisotropy values in a texture.
  123599. * rg is direction (like normal from -1 to 1)
  123600. * b is a intensity
  123601. */
  123602. texture: Nullable<BaseTexture>;
  123603. /** @hidden */
  123604. private _internalMarkAllSubMeshesAsTexturesDirty;
  123605. /** @hidden */
  123606. _markAllSubMeshesAsTexturesDirty(): void;
  123607. /**
  123608. * Instantiate a new istance of anisotropy configuration.
  123609. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123610. */
  123611. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123612. /**
  123613. * Specifies that the submesh is ready to be used.
  123614. * @param defines the list of "defines" to update.
  123615. * @param scene defines the scene the material belongs to.
  123616. * @returns - boolean indicating that the submesh is ready or not.
  123617. */
  123618. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123619. /**
  123620. * Checks to see if a texture is used in the material.
  123621. * @param defines the list of "defines" to update.
  123622. * @param mesh the mesh we are preparing the defines for.
  123623. * @param scene defines the scene the material belongs to.
  123624. */
  123625. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123626. /**
  123627. * Binds the material data.
  123628. * @param uniformBuffer defines the Uniform buffer to fill in.
  123629. * @param scene defines the scene the material belongs to.
  123630. * @param isFrozen defines wether the material is frozen or not.
  123631. */
  123632. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123633. /**
  123634. * Checks to see if a texture is used in the material.
  123635. * @param texture - Base texture to use.
  123636. * @returns - Boolean specifying if a texture is used in the material.
  123637. */
  123638. hasTexture(texture: BaseTexture): boolean;
  123639. /**
  123640. * Returns an array of the actively used textures.
  123641. * @param activeTextures Array of BaseTextures
  123642. */
  123643. getActiveTextures(activeTextures: BaseTexture[]): void;
  123644. /**
  123645. * Returns the animatable textures.
  123646. * @param animatables Array of animatable textures.
  123647. */
  123648. getAnimatables(animatables: IAnimatable[]): void;
  123649. /**
  123650. * Disposes the resources of the material.
  123651. * @param forceDisposeTextures - Forces the disposal of all textures.
  123652. */
  123653. dispose(forceDisposeTextures?: boolean): void;
  123654. /**
  123655. * Get the current class name of the texture useful for serialization or dynamic coding.
  123656. * @returns "PBRAnisotropicConfiguration"
  123657. */
  123658. getClassName(): string;
  123659. /**
  123660. * Add fallbacks to the effect fallbacks list.
  123661. * @param defines defines the Base texture to use.
  123662. * @param fallbacks defines the current fallback list.
  123663. * @param currentRank defines the current fallback rank.
  123664. * @returns the new fallback rank.
  123665. */
  123666. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123667. /**
  123668. * Add the required uniforms to the current list.
  123669. * @param uniforms defines the current uniform list.
  123670. */
  123671. static AddUniforms(uniforms: string[]): void;
  123672. /**
  123673. * Add the required uniforms to the current buffer.
  123674. * @param uniformBuffer defines the current uniform buffer.
  123675. */
  123676. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123677. /**
  123678. * Add the required samplers to the current list.
  123679. * @param samplers defines the current sampler list.
  123680. */
  123681. static AddSamplers(samplers: string[]): void;
  123682. /**
  123683. * Makes a duplicate of the current configuration into another one.
  123684. * @param anisotropicConfiguration define the config where to copy the info
  123685. */
  123686. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123687. /**
  123688. * Serializes this anisotropy configuration.
  123689. * @returns - An object with the serialized config.
  123690. */
  123691. serialize(): any;
  123692. /**
  123693. * Parses a anisotropy Configuration from a serialized object.
  123694. * @param source - Serialized object.
  123695. * @param scene Defines the scene we are parsing for
  123696. * @param rootUrl Defines the rootUrl to load from
  123697. */
  123698. parse(source: any, scene: Scene, rootUrl: string): void;
  123699. }
  123700. }
  123701. declare module BABYLON {
  123702. /**
  123703. * @hidden
  123704. */
  123705. export interface IMaterialBRDFDefines {
  123706. BRDF_V_HEIGHT_CORRELATED: boolean;
  123707. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123708. SPHERICAL_HARMONICS: boolean;
  123709. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123710. /** @hidden */
  123711. _areMiscDirty: boolean;
  123712. }
  123713. /**
  123714. * Define the code related to the BRDF parameters of the pbr material.
  123715. */
  123716. export class PBRBRDFConfiguration {
  123717. /**
  123718. * Default value used for the energy conservation.
  123719. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123720. */
  123721. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123722. /**
  123723. * Default value used for the Smith Visibility Height Correlated mode.
  123724. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123725. */
  123726. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123727. /**
  123728. * Default value used for the IBL diffuse part.
  123729. * This can help switching back to the polynomials mode globally which is a tiny bit
  123730. * less GPU intensive at the drawback of a lower quality.
  123731. */
  123732. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123733. /**
  123734. * Default value used for activating energy conservation for the specular workflow.
  123735. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123736. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123737. */
  123738. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123739. private _useEnergyConservation;
  123740. /**
  123741. * Defines if the material uses energy conservation.
  123742. */
  123743. useEnergyConservation: boolean;
  123744. private _useSmithVisibilityHeightCorrelated;
  123745. /**
  123746. * LEGACY Mode set to false
  123747. * Defines if the material uses height smith correlated visibility term.
  123748. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123749. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123750. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123751. * Not relying on height correlated will also disable energy conservation.
  123752. */
  123753. useSmithVisibilityHeightCorrelated: boolean;
  123754. private _useSphericalHarmonics;
  123755. /**
  123756. * LEGACY Mode set to false
  123757. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123758. * diffuse part of the IBL.
  123759. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123760. * to the ground truth.
  123761. */
  123762. useSphericalHarmonics: boolean;
  123763. private _useSpecularGlossinessInputEnergyConservation;
  123764. /**
  123765. * Defines if the material uses energy conservation, when the specular workflow is active.
  123766. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123767. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123768. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123769. */
  123770. useSpecularGlossinessInputEnergyConservation: boolean;
  123771. /** @hidden */
  123772. private _internalMarkAllSubMeshesAsMiscDirty;
  123773. /** @hidden */
  123774. _markAllSubMeshesAsMiscDirty(): void;
  123775. /**
  123776. * Instantiate a new istance of clear coat configuration.
  123777. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123778. */
  123779. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123780. /**
  123781. * Checks to see if a texture is used in the material.
  123782. * @param defines the list of "defines" to update.
  123783. */
  123784. prepareDefines(defines: IMaterialBRDFDefines): void;
  123785. /**
  123786. * Get the current class name of the texture useful for serialization or dynamic coding.
  123787. * @returns "PBRClearCoatConfiguration"
  123788. */
  123789. getClassName(): string;
  123790. /**
  123791. * Makes a duplicate of the current configuration into another one.
  123792. * @param brdfConfiguration define the config where to copy the info
  123793. */
  123794. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123795. /**
  123796. * Serializes this BRDF configuration.
  123797. * @returns - An object with the serialized config.
  123798. */
  123799. serialize(): any;
  123800. /**
  123801. * Parses a anisotropy Configuration from a serialized object.
  123802. * @param source - Serialized object.
  123803. * @param scene Defines the scene we are parsing for
  123804. * @param rootUrl Defines the rootUrl to load from
  123805. */
  123806. parse(source: any, scene: Scene, rootUrl: string): void;
  123807. }
  123808. }
  123809. declare module BABYLON {
  123810. /**
  123811. * @hidden
  123812. */
  123813. export interface IMaterialSheenDefines {
  123814. SHEEN: boolean;
  123815. SHEEN_TEXTURE: boolean;
  123816. SHEEN_TEXTUREDIRECTUV: number;
  123817. SHEEN_LINKWITHALBEDO: boolean;
  123818. SHEEN_ROUGHNESS: boolean;
  123819. SHEEN_ALBEDOSCALING: boolean;
  123820. /** @hidden */
  123821. _areTexturesDirty: boolean;
  123822. }
  123823. /**
  123824. * Define the code related to the Sheen parameters of the pbr material.
  123825. */
  123826. export class PBRSheenConfiguration {
  123827. private _isEnabled;
  123828. /**
  123829. * Defines if the material uses sheen.
  123830. */
  123831. isEnabled: boolean;
  123832. private _linkSheenWithAlbedo;
  123833. /**
  123834. * Defines if the sheen is linked to the sheen color.
  123835. */
  123836. linkSheenWithAlbedo: boolean;
  123837. /**
  123838. * Defines the sheen intensity.
  123839. */
  123840. intensity: number;
  123841. /**
  123842. * Defines the sheen color.
  123843. */
  123844. color: Color3;
  123845. private _texture;
  123846. /**
  123847. * Stores the sheen tint values in a texture.
  123848. * rgb is tint
  123849. * a is a intensity
  123850. */
  123851. texture: Nullable<BaseTexture>;
  123852. private _roughness;
  123853. /**
  123854. * Defines the sheen roughness.
  123855. * It is not taken into account if linkSheenWithAlbedo is true.
  123856. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  123857. */
  123858. roughness: Nullable<number>;
  123859. private _albedoScaling;
  123860. /**
  123861. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  123862. * It allows the strength of the sheen effect to not depend on the base color of the material,
  123863. * making it easier to setup and tweak the effect
  123864. */
  123865. albedoScaling: boolean;
  123866. /** @hidden */
  123867. private _internalMarkAllSubMeshesAsTexturesDirty;
  123868. /** @hidden */
  123869. _markAllSubMeshesAsTexturesDirty(): void;
  123870. /**
  123871. * Instantiate a new istance of clear coat configuration.
  123872. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123873. */
  123874. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123875. /**
  123876. * Specifies that the submesh is ready to be used.
  123877. * @param defines the list of "defines" to update.
  123878. * @param scene defines the scene the material belongs to.
  123879. * @returns - boolean indicating that the submesh is ready or not.
  123880. */
  123881. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123882. /**
  123883. * Checks to see if a texture is used in the material.
  123884. * @param defines the list of "defines" to update.
  123885. * @param scene defines the scene the material belongs to.
  123886. */
  123887. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123888. /**
  123889. * Binds the material data.
  123890. * @param uniformBuffer defines the Uniform buffer to fill in.
  123891. * @param scene defines the scene the material belongs to.
  123892. * @param isFrozen defines wether the material is frozen or not.
  123893. */
  123894. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123895. /**
  123896. * Checks to see if a texture is used in the material.
  123897. * @param texture - Base texture to use.
  123898. * @returns - Boolean specifying if a texture is used in the material.
  123899. */
  123900. hasTexture(texture: BaseTexture): boolean;
  123901. /**
  123902. * Returns an array of the actively used textures.
  123903. * @param activeTextures Array of BaseTextures
  123904. */
  123905. getActiveTextures(activeTextures: BaseTexture[]): void;
  123906. /**
  123907. * Returns the animatable textures.
  123908. * @param animatables Array of animatable textures.
  123909. */
  123910. getAnimatables(animatables: IAnimatable[]): void;
  123911. /**
  123912. * Disposes the resources of the material.
  123913. * @param forceDisposeTextures - Forces the disposal of all textures.
  123914. */
  123915. dispose(forceDisposeTextures?: boolean): void;
  123916. /**
  123917. * Get the current class name of the texture useful for serialization or dynamic coding.
  123918. * @returns "PBRSheenConfiguration"
  123919. */
  123920. getClassName(): string;
  123921. /**
  123922. * Add fallbacks to the effect fallbacks list.
  123923. * @param defines defines the Base texture to use.
  123924. * @param fallbacks defines the current fallback list.
  123925. * @param currentRank defines the current fallback rank.
  123926. * @returns the new fallback rank.
  123927. */
  123928. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123929. /**
  123930. * Add the required uniforms to the current list.
  123931. * @param uniforms defines the current uniform list.
  123932. */
  123933. static AddUniforms(uniforms: string[]): void;
  123934. /**
  123935. * Add the required uniforms to the current buffer.
  123936. * @param uniformBuffer defines the current uniform buffer.
  123937. */
  123938. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123939. /**
  123940. * Add the required samplers to the current list.
  123941. * @param samplers defines the current sampler list.
  123942. */
  123943. static AddSamplers(samplers: string[]): void;
  123944. /**
  123945. * Makes a duplicate of the current configuration into another one.
  123946. * @param sheenConfiguration define the config where to copy the info
  123947. */
  123948. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123949. /**
  123950. * Serializes this BRDF configuration.
  123951. * @returns - An object with the serialized config.
  123952. */
  123953. serialize(): any;
  123954. /**
  123955. * Parses a anisotropy Configuration from a serialized object.
  123956. * @param source - Serialized object.
  123957. * @param scene Defines the scene we are parsing for
  123958. * @param rootUrl Defines the rootUrl to load from
  123959. */
  123960. parse(source: any, scene: Scene, rootUrl: string): void;
  123961. }
  123962. }
  123963. declare module BABYLON {
  123964. /**
  123965. * @hidden
  123966. */
  123967. export interface IMaterialSubSurfaceDefines {
  123968. SUBSURFACE: boolean;
  123969. SS_REFRACTION: boolean;
  123970. SS_TRANSLUCENCY: boolean;
  123971. SS_SCATERRING: boolean;
  123972. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123973. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123974. SS_REFRACTIONMAP_3D: boolean;
  123975. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123976. SS_LODINREFRACTIONALPHA: boolean;
  123977. SS_GAMMAREFRACTION: boolean;
  123978. SS_RGBDREFRACTION: boolean;
  123979. SS_LINEARSPECULARREFRACTION: boolean;
  123980. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123981. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123982. /** @hidden */
  123983. _areTexturesDirty: boolean;
  123984. }
  123985. /**
  123986. * Define the code related to the sub surface parameters of the pbr material.
  123987. */
  123988. export class PBRSubSurfaceConfiguration {
  123989. private _isRefractionEnabled;
  123990. /**
  123991. * Defines if the refraction is enabled in the material.
  123992. */
  123993. isRefractionEnabled: boolean;
  123994. private _isTranslucencyEnabled;
  123995. /**
  123996. * Defines if the translucency is enabled in the material.
  123997. */
  123998. isTranslucencyEnabled: boolean;
  123999. private _isScatteringEnabled;
  124000. /**
  124001. * Defines the refraction intensity of the material.
  124002. * The refraction when enabled replaces the Diffuse part of the material.
  124003. * The intensity helps transitionning between diffuse and refraction.
  124004. */
  124005. refractionIntensity: number;
  124006. /**
  124007. * Defines the translucency intensity of the material.
  124008. * When translucency has been enabled, this defines how much of the "translucency"
  124009. * is addded to the diffuse part of the material.
  124010. */
  124011. translucencyIntensity: number;
  124012. /**
  124013. * Defines the scattering intensity of the material.
  124014. * When scattering has been enabled, this defines how much of the "scattered light"
  124015. * is addded to the diffuse part of the material.
  124016. */
  124017. scatteringIntensity: number;
  124018. private _thicknessTexture;
  124019. /**
  124020. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  124021. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  124022. * 0 would mean minimumThickness
  124023. * 1 would mean maximumThickness
  124024. * The other channels might be use as a mask to vary the different effects intensity.
  124025. */
  124026. thicknessTexture: Nullable<BaseTexture>;
  124027. private _refractionTexture;
  124028. /**
  124029. * Defines the texture to use for refraction.
  124030. */
  124031. refractionTexture: Nullable<BaseTexture>;
  124032. private _indexOfRefraction;
  124033. /**
  124034. * Defines the index of refraction used in the material.
  124035. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  124036. */
  124037. indexOfRefraction: number;
  124038. private _invertRefractionY;
  124039. /**
  124040. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124041. */
  124042. invertRefractionY: boolean;
  124043. private _linkRefractionWithTransparency;
  124044. /**
  124045. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124046. * Materials half opaque for instance using refraction could benefit from this control.
  124047. */
  124048. linkRefractionWithTransparency: boolean;
  124049. /**
  124050. * Defines the minimum thickness stored in the thickness map.
  124051. * If no thickness map is defined, this value will be used to simulate thickness.
  124052. */
  124053. minimumThickness: number;
  124054. /**
  124055. * Defines the maximum thickness stored in the thickness map.
  124056. */
  124057. maximumThickness: number;
  124058. /**
  124059. * Defines the volume tint of the material.
  124060. * This is used for both translucency and scattering.
  124061. */
  124062. tintColor: Color3;
  124063. /**
  124064. * Defines the distance at which the tint color should be found in the media.
  124065. * This is used for refraction only.
  124066. */
  124067. tintColorAtDistance: number;
  124068. /**
  124069. * Defines how far each channel transmit through the media.
  124070. * It is defined as a color to simplify it selection.
  124071. */
  124072. diffusionDistance: Color3;
  124073. private _useMaskFromThicknessTexture;
  124074. /**
  124075. * Stores the intensity of the different subsurface effects in the thickness texture.
  124076. * * the green channel is the translucency intensity.
  124077. * * the blue channel is the scattering intensity.
  124078. * * the alpha channel is the refraction intensity.
  124079. */
  124080. useMaskFromThicknessTexture: boolean;
  124081. /** @hidden */
  124082. private _internalMarkAllSubMeshesAsTexturesDirty;
  124083. /** @hidden */
  124084. _markAllSubMeshesAsTexturesDirty(): void;
  124085. /**
  124086. * Instantiate a new istance of sub surface configuration.
  124087. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124088. */
  124089. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124090. /**
  124091. * Gets wehter the submesh is ready to be used or not.
  124092. * @param defines the list of "defines" to update.
  124093. * @param scene defines the scene the material belongs to.
  124094. * @returns - boolean indicating that the submesh is ready or not.
  124095. */
  124096. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  124097. /**
  124098. * Checks to see if a texture is used in the material.
  124099. * @param defines the list of "defines" to update.
  124100. * @param scene defines the scene to the material belongs to.
  124101. */
  124102. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  124103. /**
  124104. * Binds the material data.
  124105. * @param uniformBuffer defines the Uniform buffer to fill in.
  124106. * @param scene defines the scene the material belongs to.
  124107. * @param engine defines the engine the material belongs to.
  124108. * @param isFrozen defines wether the material is frozen or not.
  124109. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  124110. */
  124111. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  124112. /**
  124113. * Unbinds the material from the mesh.
  124114. * @param activeEffect defines the effect that should be unbound from.
  124115. * @returns true if unbound, otherwise false
  124116. */
  124117. unbind(activeEffect: Effect): boolean;
  124118. /**
  124119. * Returns the texture used for refraction or null if none is used.
  124120. * @param scene defines the scene the material belongs to.
  124121. * @returns - Refraction texture if present. If no refraction texture and refraction
  124122. * is linked with transparency, returns environment texture. Otherwise, returns null.
  124123. */
  124124. private _getRefractionTexture;
  124125. /**
  124126. * Returns true if alpha blending should be disabled.
  124127. */
  124128. get disableAlphaBlending(): boolean;
  124129. /**
  124130. * Fills the list of render target textures.
  124131. * @param renderTargets the list of render targets to update
  124132. */
  124133. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  124134. /**
  124135. * Checks to see if a texture is used in the material.
  124136. * @param texture - Base texture to use.
  124137. * @returns - Boolean specifying if a texture is used in the material.
  124138. */
  124139. hasTexture(texture: BaseTexture): boolean;
  124140. /**
  124141. * Gets a boolean indicating that current material needs to register RTT
  124142. * @returns true if this uses a render target otherwise false.
  124143. */
  124144. hasRenderTargetTextures(): boolean;
  124145. /**
  124146. * Returns an array of the actively used textures.
  124147. * @param activeTextures Array of BaseTextures
  124148. */
  124149. getActiveTextures(activeTextures: BaseTexture[]): void;
  124150. /**
  124151. * Returns the animatable textures.
  124152. * @param animatables Array of animatable textures.
  124153. */
  124154. getAnimatables(animatables: IAnimatable[]): void;
  124155. /**
  124156. * Disposes the resources of the material.
  124157. * @param forceDisposeTextures - Forces the disposal of all textures.
  124158. */
  124159. dispose(forceDisposeTextures?: boolean): void;
  124160. /**
  124161. * Get the current class name of the texture useful for serialization or dynamic coding.
  124162. * @returns "PBRSubSurfaceConfiguration"
  124163. */
  124164. getClassName(): string;
  124165. /**
  124166. * Add fallbacks to the effect fallbacks list.
  124167. * @param defines defines the Base texture to use.
  124168. * @param fallbacks defines the current fallback list.
  124169. * @param currentRank defines the current fallback rank.
  124170. * @returns the new fallback rank.
  124171. */
  124172. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124173. /**
  124174. * Add the required uniforms to the current list.
  124175. * @param uniforms defines the current uniform list.
  124176. */
  124177. static AddUniforms(uniforms: string[]): void;
  124178. /**
  124179. * Add the required samplers to the current list.
  124180. * @param samplers defines the current sampler list.
  124181. */
  124182. static AddSamplers(samplers: string[]): void;
  124183. /**
  124184. * Add the required uniforms to the current buffer.
  124185. * @param uniformBuffer defines the current uniform buffer.
  124186. */
  124187. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124188. /**
  124189. * Makes a duplicate of the current configuration into another one.
  124190. * @param configuration define the config where to copy the info
  124191. */
  124192. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124193. /**
  124194. * Serializes this Sub Surface configuration.
  124195. * @returns - An object with the serialized config.
  124196. */
  124197. serialize(): any;
  124198. /**
  124199. * Parses a anisotropy Configuration from a serialized object.
  124200. * @param source - Serialized object.
  124201. * @param scene Defines the scene we are parsing for
  124202. * @param rootUrl Defines the rootUrl to load from
  124203. */
  124204. parse(source: any, scene: Scene, rootUrl: string): void;
  124205. }
  124206. }
  124207. declare module BABYLON {
  124208. /** @hidden */
  124209. export var pbrFragmentDeclaration: {
  124210. name: string;
  124211. shader: string;
  124212. };
  124213. }
  124214. declare module BABYLON {
  124215. /** @hidden */
  124216. export var pbrUboDeclaration: {
  124217. name: string;
  124218. shader: string;
  124219. };
  124220. }
  124221. declare module BABYLON {
  124222. /** @hidden */
  124223. export var pbrFragmentExtraDeclaration: {
  124224. name: string;
  124225. shader: string;
  124226. };
  124227. }
  124228. declare module BABYLON {
  124229. /** @hidden */
  124230. export var pbrFragmentSamplersDeclaration: {
  124231. name: string;
  124232. shader: string;
  124233. };
  124234. }
  124235. declare module BABYLON {
  124236. /** @hidden */
  124237. export var pbrHelperFunctions: {
  124238. name: string;
  124239. shader: string;
  124240. };
  124241. }
  124242. declare module BABYLON {
  124243. /** @hidden */
  124244. export var harmonicsFunctions: {
  124245. name: string;
  124246. shader: string;
  124247. };
  124248. }
  124249. declare module BABYLON {
  124250. /** @hidden */
  124251. export var pbrDirectLightingSetupFunctions: {
  124252. name: string;
  124253. shader: string;
  124254. };
  124255. }
  124256. declare module BABYLON {
  124257. /** @hidden */
  124258. export var pbrDirectLightingFalloffFunctions: {
  124259. name: string;
  124260. shader: string;
  124261. };
  124262. }
  124263. declare module BABYLON {
  124264. /** @hidden */
  124265. export var pbrBRDFFunctions: {
  124266. name: string;
  124267. shader: string;
  124268. };
  124269. }
  124270. declare module BABYLON {
  124271. /** @hidden */
  124272. export var pbrDirectLightingFunctions: {
  124273. name: string;
  124274. shader: string;
  124275. };
  124276. }
  124277. declare module BABYLON {
  124278. /** @hidden */
  124279. export var pbrIBLFunctions: {
  124280. name: string;
  124281. shader: string;
  124282. };
  124283. }
  124284. declare module BABYLON {
  124285. /** @hidden */
  124286. export var pbrDebug: {
  124287. name: string;
  124288. shader: string;
  124289. };
  124290. }
  124291. declare module BABYLON {
  124292. /** @hidden */
  124293. export var pbrPixelShader: {
  124294. name: string;
  124295. shader: string;
  124296. };
  124297. }
  124298. declare module BABYLON {
  124299. /** @hidden */
  124300. export var pbrVertexDeclaration: {
  124301. name: string;
  124302. shader: string;
  124303. };
  124304. }
  124305. declare module BABYLON {
  124306. /** @hidden */
  124307. export var pbrVertexShader: {
  124308. name: string;
  124309. shader: string;
  124310. };
  124311. }
  124312. declare module BABYLON {
  124313. /**
  124314. * Manages the defines for the PBR Material.
  124315. * @hidden
  124316. */
  124317. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124318. PBR: boolean;
  124319. MAINUV1: boolean;
  124320. MAINUV2: boolean;
  124321. UV1: boolean;
  124322. UV2: boolean;
  124323. ALBEDO: boolean;
  124324. GAMMAALBEDO: boolean;
  124325. ALBEDODIRECTUV: number;
  124326. VERTEXCOLOR: boolean;
  124327. AMBIENT: boolean;
  124328. AMBIENTDIRECTUV: number;
  124329. AMBIENTINGRAYSCALE: boolean;
  124330. OPACITY: boolean;
  124331. VERTEXALPHA: boolean;
  124332. OPACITYDIRECTUV: number;
  124333. OPACITYRGB: boolean;
  124334. ALPHATEST: boolean;
  124335. DEPTHPREPASS: boolean;
  124336. ALPHABLEND: boolean;
  124337. ALPHAFROMALBEDO: boolean;
  124338. ALPHATESTVALUE: string;
  124339. SPECULAROVERALPHA: boolean;
  124340. RADIANCEOVERALPHA: boolean;
  124341. ALPHAFRESNEL: boolean;
  124342. LINEARALPHAFRESNEL: boolean;
  124343. PREMULTIPLYALPHA: boolean;
  124344. EMISSIVE: boolean;
  124345. EMISSIVEDIRECTUV: number;
  124346. REFLECTIVITY: boolean;
  124347. REFLECTIVITYDIRECTUV: number;
  124348. SPECULARTERM: boolean;
  124349. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124350. MICROSURFACEAUTOMATIC: boolean;
  124351. LODBASEDMICROSFURACE: boolean;
  124352. MICROSURFACEMAP: boolean;
  124353. MICROSURFACEMAPDIRECTUV: number;
  124354. METALLICWORKFLOW: boolean;
  124355. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124356. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124357. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124358. AOSTOREINMETALMAPRED: boolean;
  124359. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124360. ENVIRONMENTBRDF: boolean;
  124361. ENVIRONMENTBRDF_RGBD: boolean;
  124362. NORMAL: boolean;
  124363. TANGENT: boolean;
  124364. BUMP: boolean;
  124365. BUMPDIRECTUV: number;
  124366. OBJECTSPACE_NORMALMAP: boolean;
  124367. PARALLAX: boolean;
  124368. PARALLAXOCCLUSION: boolean;
  124369. NORMALXYSCALE: boolean;
  124370. LIGHTMAP: boolean;
  124371. LIGHTMAPDIRECTUV: number;
  124372. USELIGHTMAPASSHADOWMAP: boolean;
  124373. GAMMALIGHTMAP: boolean;
  124374. RGBDLIGHTMAP: boolean;
  124375. REFLECTION: boolean;
  124376. REFLECTIONMAP_3D: boolean;
  124377. REFLECTIONMAP_SPHERICAL: boolean;
  124378. REFLECTIONMAP_PLANAR: boolean;
  124379. REFLECTIONMAP_CUBIC: boolean;
  124380. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124381. REFLECTIONMAP_PROJECTION: boolean;
  124382. REFLECTIONMAP_SKYBOX: boolean;
  124383. REFLECTIONMAP_EXPLICIT: boolean;
  124384. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124385. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124386. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124387. INVERTCUBICMAP: boolean;
  124388. USESPHERICALFROMREFLECTIONMAP: boolean;
  124389. USEIRRADIANCEMAP: boolean;
  124390. SPHERICAL_HARMONICS: boolean;
  124391. USESPHERICALINVERTEX: boolean;
  124392. REFLECTIONMAP_OPPOSITEZ: boolean;
  124393. LODINREFLECTIONALPHA: boolean;
  124394. GAMMAREFLECTION: boolean;
  124395. RGBDREFLECTION: boolean;
  124396. LINEARSPECULARREFLECTION: boolean;
  124397. RADIANCEOCCLUSION: boolean;
  124398. HORIZONOCCLUSION: boolean;
  124399. INSTANCES: boolean;
  124400. NUM_BONE_INFLUENCERS: number;
  124401. BonesPerMesh: number;
  124402. BONETEXTURE: boolean;
  124403. NONUNIFORMSCALING: boolean;
  124404. MORPHTARGETS: boolean;
  124405. MORPHTARGETS_NORMAL: boolean;
  124406. MORPHTARGETS_TANGENT: boolean;
  124407. MORPHTARGETS_UV: boolean;
  124408. NUM_MORPH_INFLUENCERS: number;
  124409. IMAGEPROCESSING: boolean;
  124410. VIGNETTE: boolean;
  124411. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124412. VIGNETTEBLENDMODEOPAQUE: boolean;
  124413. TONEMAPPING: boolean;
  124414. TONEMAPPING_ACES: boolean;
  124415. CONTRAST: boolean;
  124416. COLORCURVES: boolean;
  124417. COLORGRADING: boolean;
  124418. COLORGRADING3D: boolean;
  124419. SAMPLER3DGREENDEPTH: boolean;
  124420. SAMPLER3DBGRMAP: boolean;
  124421. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124422. EXPOSURE: boolean;
  124423. MULTIVIEW: boolean;
  124424. USEPHYSICALLIGHTFALLOFF: boolean;
  124425. USEGLTFLIGHTFALLOFF: boolean;
  124426. TWOSIDEDLIGHTING: boolean;
  124427. SHADOWFLOAT: boolean;
  124428. CLIPPLANE: boolean;
  124429. CLIPPLANE2: boolean;
  124430. CLIPPLANE3: boolean;
  124431. CLIPPLANE4: boolean;
  124432. CLIPPLANE5: boolean;
  124433. CLIPPLANE6: boolean;
  124434. POINTSIZE: boolean;
  124435. FOG: boolean;
  124436. LOGARITHMICDEPTH: boolean;
  124437. FORCENORMALFORWARD: boolean;
  124438. SPECULARAA: boolean;
  124439. CLEARCOAT: boolean;
  124440. CLEARCOAT_DEFAULTIOR: boolean;
  124441. CLEARCOAT_TEXTURE: boolean;
  124442. CLEARCOAT_TEXTUREDIRECTUV: number;
  124443. CLEARCOAT_BUMP: boolean;
  124444. CLEARCOAT_BUMPDIRECTUV: number;
  124445. CLEARCOAT_TINT: boolean;
  124446. CLEARCOAT_TINT_TEXTURE: boolean;
  124447. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124448. ANISOTROPIC: boolean;
  124449. ANISOTROPIC_TEXTURE: boolean;
  124450. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124451. BRDF_V_HEIGHT_CORRELATED: boolean;
  124452. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124453. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124454. SHEEN: boolean;
  124455. SHEEN_TEXTURE: boolean;
  124456. SHEEN_TEXTUREDIRECTUV: number;
  124457. SHEEN_LINKWITHALBEDO: boolean;
  124458. SHEEN_ROUGHNESS: boolean;
  124459. SHEEN_ALBEDOSCALING: boolean;
  124460. SUBSURFACE: boolean;
  124461. SS_REFRACTION: boolean;
  124462. SS_TRANSLUCENCY: boolean;
  124463. SS_SCATERRING: boolean;
  124464. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124465. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124466. SS_REFRACTIONMAP_3D: boolean;
  124467. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124468. SS_LODINREFRACTIONALPHA: boolean;
  124469. SS_GAMMAREFRACTION: boolean;
  124470. SS_RGBDREFRACTION: boolean;
  124471. SS_LINEARSPECULARREFRACTION: boolean;
  124472. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124473. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124474. UNLIT: boolean;
  124475. DEBUGMODE: number;
  124476. /**
  124477. * Initializes the PBR Material defines.
  124478. */
  124479. constructor();
  124480. /**
  124481. * Resets the PBR Material defines.
  124482. */
  124483. reset(): void;
  124484. }
  124485. /**
  124486. * The Physically based material base class of BJS.
  124487. *
  124488. * This offers the main features of a standard PBR material.
  124489. * For more information, please refer to the documentation :
  124490. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124491. */
  124492. export abstract class PBRBaseMaterial extends PushMaterial {
  124493. /**
  124494. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124495. */
  124496. static readonly PBRMATERIAL_OPAQUE: number;
  124497. /**
  124498. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124499. */
  124500. static readonly PBRMATERIAL_ALPHATEST: number;
  124501. /**
  124502. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124503. */
  124504. static readonly PBRMATERIAL_ALPHABLEND: number;
  124505. /**
  124506. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124507. * They are also discarded below the alpha cutoff threshold to improve performances.
  124508. */
  124509. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124510. /**
  124511. * Defines the default value of how much AO map is occluding the analytical lights
  124512. * (point spot...).
  124513. */
  124514. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124515. /**
  124516. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124517. */
  124518. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124519. /**
  124520. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124521. * to enhance interoperability with other engines.
  124522. */
  124523. static readonly LIGHTFALLOFF_GLTF: number;
  124524. /**
  124525. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124526. * to enhance interoperability with other materials.
  124527. */
  124528. static readonly LIGHTFALLOFF_STANDARD: number;
  124529. /**
  124530. * Intensity of the direct lights e.g. the four lights available in your scene.
  124531. * This impacts both the direct diffuse and specular highlights.
  124532. */
  124533. protected _directIntensity: number;
  124534. /**
  124535. * Intensity of the emissive part of the material.
  124536. * This helps controlling the emissive effect without modifying the emissive color.
  124537. */
  124538. protected _emissiveIntensity: number;
  124539. /**
  124540. * Intensity of the environment e.g. how much the environment will light the object
  124541. * either through harmonics for rough material or through the refelction for shiny ones.
  124542. */
  124543. protected _environmentIntensity: number;
  124544. /**
  124545. * This is a special control allowing the reduction of the specular highlights coming from the
  124546. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124547. */
  124548. protected _specularIntensity: number;
  124549. /**
  124550. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124551. */
  124552. private _lightingInfos;
  124553. /**
  124554. * Debug Control allowing disabling the bump map on this material.
  124555. */
  124556. protected _disableBumpMap: boolean;
  124557. /**
  124558. * AKA Diffuse Texture in standard nomenclature.
  124559. */
  124560. protected _albedoTexture: Nullable<BaseTexture>;
  124561. /**
  124562. * AKA Occlusion Texture in other nomenclature.
  124563. */
  124564. protected _ambientTexture: Nullable<BaseTexture>;
  124565. /**
  124566. * AKA Occlusion Texture Intensity in other nomenclature.
  124567. */
  124568. protected _ambientTextureStrength: number;
  124569. /**
  124570. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124571. * 1 means it completely occludes it
  124572. * 0 mean it has no impact
  124573. */
  124574. protected _ambientTextureImpactOnAnalyticalLights: number;
  124575. /**
  124576. * Stores the alpha values in a texture.
  124577. */
  124578. protected _opacityTexture: Nullable<BaseTexture>;
  124579. /**
  124580. * Stores the reflection values in a texture.
  124581. */
  124582. protected _reflectionTexture: Nullable<BaseTexture>;
  124583. /**
  124584. * Stores the emissive values in a texture.
  124585. */
  124586. protected _emissiveTexture: Nullable<BaseTexture>;
  124587. /**
  124588. * AKA Specular texture in other nomenclature.
  124589. */
  124590. protected _reflectivityTexture: Nullable<BaseTexture>;
  124591. /**
  124592. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124593. */
  124594. protected _metallicTexture: Nullable<BaseTexture>;
  124595. /**
  124596. * Specifies the metallic scalar of the metallic/roughness workflow.
  124597. * Can also be used to scale the metalness values of the metallic texture.
  124598. */
  124599. protected _metallic: Nullable<number>;
  124600. /**
  124601. * Specifies the roughness scalar of the metallic/roughness workflow.
  124602. * Can also be used to scale the roughness values of the metallic texture.
  124603. */
  124604. protected _roughness: Nullable<number>;
  124605. /**
  124606. * Specifies the an F0 factor to help configuring the material F0.
  124607. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124608. * to 0.5 the previously hard coded value stays the same.
  124609. * Can also be used to scale the F0 values of the metallic texture.
  124610. */
  124611. protected _metallicF0Factor: number;
  124612. /**
  124613. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124614. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124615. * your expectation as it multiplies with the texture data.
  124616. */
  124617. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124618. /**
  124619. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124620. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124621. */
  124622. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124623. /**
  124624. * Stores surface normal data used to displace a mesh in a texture.
  124625. */
  124626. protected _bumpTexture: Nullable<BaseTexture>;
  124627. /**
  124628. * Stores the pre-calculated light information of a mesh in a texture.
  124629. */
  124630. protected _lightmapTexture: Nullable<BaseTexture>;
  124631. /**
  124632. * The color of a material in ambient lighting.
  124633. */
  124634. protected _ambientColor: Color3;
  124635. /**
  124636. * AKA Diffuse Color in other nomenclature.
  124637. */
  124638. protected _albedoColor: Color3;
  124639. /**
  124640. * AKA Specular Color in other nomenclature.
  124641. */
  124642. protected _reflectivityColor: Color3;
  124643. /**
  124644. * The color applied when light is reflected from a material.
  124645. */
  124646. protected _reflectionColor: Color3;
  124647. /**
  124648. * The color applied when light is emitted from a material.
  124649. */
  124650. protected _emissiveColor: Color3;
  124651. /**
  124652. * AKA Glossiness in other nomenclature.
  124653. */
  124654. protected _microSurface: number;
  124655. /**
  124656. * Specifies that the material will use the light map as a show map.
  124657. */
  124658. protected _useLightmapAsShadowmap: boolean;
  124659. /**
  124660. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124661. * makes the reflect vector face the model (under horizon).
  124662. */
  124663. protected _useHorizonOcclusion: boolean;
  124664. /**
  124665. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124666. * too much the area relying on ambient texture to define their ambient occlusion.
  124667. */
  124668. protected _useRadianceOcclusion: boolean;
  124669. /**
  124670. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124671. */
  124672. protected _useAlphaFromAlbedoTexture: boolean;
  124673. /**
  124674. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124675. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124676. */
  124677. protected _useSpecularOverAlpha: boolean;
  124678. /**
  124679. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124680. */
  124681. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124682. /**
  124683. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124684. */
  124685. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124686. /**
  124687. * Specifies if the metallic texture contains the roughness information in its green channel.
  124688. */
  124689. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124690. /**
  124691. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124692. */
  124693. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124694. /**
  124695. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124696. */
  124697. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124698. /**
  124699. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124700. */
  124701. protected _useAmbientInGrayScale: boolean;
  124702. /**
  124703. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124704. * The material will try to infer what glossiness each pixel should be.
  124705. */
  124706. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124707. /**
  124708. * Defines the falloff type used in this material.
  124709. * It by default is Physical.
  124710. */
  124711. protected _lightFalloff: number;
  124712. /**
  124713. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124714. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124715. */
  124716. protected _useRadianceOverAlpha: boolean;
  124717. /**
  124718. * Allows using an object space normal map (instead of tangent space).
  124719. */
  124720. protected _useObjectSpaceNormalMap: boolean;
  124721. /**
  124722. * Allows using the bump map in parallax mode.
  124723. */
  124724. protected _useParallax: boolean;
  124725. /**
  124726. * Allows using the bump map in parallax occlusion mode.
  124727. */
  124728. protected _useParallaxOcclusion: boolean;
  124729. /**
  124730. * Controls the scale bias of the parallax mode.
  124731. */
  124732. protected _parallaxScaleBias: number;
  124733. /**
  124734. * If sets to true, disables all the lights affecting the material.
  124735. */
  124736. protected _disableLighting: boolean;
  124737. /**
  124738. * Number of Simultaneous lights allowed on the material.
  124739. */
  124740. protected _maxSimultaneousLights: number;
  124741. /**
  124742. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124743. */
  124744. protected _invertNormalMapX: boolean;
  124745. /**
  124746. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124747. */
  124748. protected _invertNormalMapY: boolean;
  124749. /**
  124750. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124751. */
  124752. protected _twoSidedLighting: boolean;
  124753. /**
  124754. * Defines the alpha limits in alpha test mode.
  124755. */
  124756. protected _alphaCutOff: number;
  124757. /**
  124758. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124759. */
  124760. protected _forceAlphaTest: boolean;
  124761. /**
  124762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124763. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124764. */
  124765. protected _useAlphaFresnel: boolean;
  124766. /**
  124767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124768. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124769. */
  124770. protected _useLinearAlphaFresnel: boolean;
  124771. /**
  124772. * The transparency mode of the material.
  124773. */
  124774. protected _transparencyMode: Nullable<number>;
  124775. /**
  124776. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124777. * from cos thetav and roughness:
  124778. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124779. */
  124780. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124781. /**
  124782. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124783. */
  124784. protected _forceIrradianceInFragment: boolean;
  124785. /**
  124786. * Force normal to face away from face.
  124787. */
  124788. protected _forceNormalForward: boolean;
  124789. /**
  124790. * Enables specular anti aliasing in the PBR shader.
  124791. * It will both interacts on the Geometry for analytical and IBL lighting.
  124792. * It also prefilter the roughness map based on the bump values.
  124793. */
  124794. protected _enableSpecularAntiAliasing: boolean;
  124795. /**
  124796. * Default configuration related to image processing available in the PBR Material.
  124797. */
  124798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124799. /**
  124800. * Keep track of the image processing observer to allow dispose and replace.
  124801. */
  124802. private _imageProcessingObserver;
  124803. /**
  124804. * Attaches a new image processing configuration to the PBR Material.
  124805. * @param configuration
  124806. */
  124807. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124808. /**
  124809. * Stores the available render targets.
  124810. */
  124811. private _renderTargets;
  124812. /**
  124813. * Sets the global ambient color for the material used in lighting calculations.
  124814. */
  124815. private _globalAmbientColor;
  124816. /**
  124817. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124818. */
  124819. private _useLogarithmicDepth;
  124820. /**
  124821. * If set to true, no lighting calculations will be applied.
  124822. */
  124823. private _unlit;
  124824. private _debugMode;
  124825. /**
  124826. * @hidden
  124827. * This is reserved for the inspector.
  124828. * Defines the material debug mode.
  124829. * It helps seeing only some components of the material while troubleshooting.
  124830. */
  124831. debugMode: number;
  124832. /**
  124833. * @hidden
  124834. * This is reserved for the inspector.
  124835. * Specify from where on screen the debug mode should start.
  124836. * The value goes from -1 (full screen) to 1 (not visible)
  124837. * It helps with side by side comparison against the final render
  124838. * This defaults to -1
  124839. */
  124840. private debugLimit;
  124841. /**
  124842. * @hidden
  124843. * This is reserved for the inspector.
  124844. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124845. * You can use the factor to better multiply the final value.
  124846. */
  124847. private debugFactor;
  124848. /**
  124849. * Defines the clear coat layer parameters for the material.
  124850. */
  124851. readonly clearCoat: PBRClearCoatConfiguration;
  124852. /**
  124853. * Defines the anisotropic parameters for the material.
  124854. */
  124855. readonly anisotropy: PBRAnisotropicConfiguration;
  124856. /**
  124857. * Defines the BRDF parameters for the material.
  124858. */
  124859. readonly brdf: PBRBRDFConfiguration;
  124860. /**
  124861. * Defines the Sheen parameters for the material.
  124862. */
  124863. readonly sheen: PBRSheenConfiguration;
  124864. /**
  124865. * Defines the SubSurface parameters for the material.
  124866. */
  124867. readonly subSurface: PBRSubSurfaceConfiguration;
  124868. /**
  124869. * Custom callback helping to override the default shader used in the material.
  124870. */
  124871. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124872. protected _rebuildInParallel: boolean;
  124873. /**
  124874. * Instantiates a new PBRMaterial instance.
  124875. *
  124876. * @param name The material name
  124877. * @param scene The scene the material will be use in.
  124878. */
  124879. constructor(name: string, scene: Scene);
  124880. /**
  124881. * Gets a boolean indicating that current material needs to register RTT
  124882. */
  124883. get hasRenderTargetTextures(): boolean;
  124884. /**
  124885. * Gets the name of the material class.
  124886. */
  124887. getClassName(): string;
  124888. /**
  124889. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124890. */
  124891. get useLogarithmicDepth(): boolean;
  124892. /**
  124893. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124894. */
  124895. set useLogarithmicDepth(value: boolean);
  124896. /**
  124897. * Gets the current transparency mode.
  124898. */
  124899. get transparencyMode(): Nullable<number>;
  124900. /**
  124901. * Sets the transparency mode of the material.
  124902. *
  124903. * | Value | Type | Description |
  124904. * | ----- | ----------------------------------- | ----------- |
  124905. * | 0 | OPAQUE | |
  124906. * | 1 | ALPHATEST | |
  124907. * | 2 | ALPHABLEND | |
  124908. * | 3 | ALPHATESTANDBLEND | |
  124909. *
  124910. */
  124911. set transparencyMode(value: Nullable<number>);
  124912. /**
  124913. * Returns true if alpha blending should be disabled.
  124914. */
  124915. private get _disableAlphaBlending();
  124916. /**
  124917. * Specifies whether or not this material should be rendered in alpha blend mode.
  124918. */
  124919. needAlphaBlending(): boolean;
  124920. /**
  124921. * Specifies if the mesh will require alpha blending.
  124922. * @param mesh - BJS mesh.
  124923. */
  124924. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124925. /**
  124926. * Specifies whether or not this material should be rendered in alpha test mode.
  124927. */
  124928. needAlphaTesting(): boolean;
  124929. /**
  124930. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124931. */
  124932. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124933. /**
  124934. * Gets the texture used for the alpha test.
  124935. */
  124936. getAlphaTestTexture(): Nullable<BaseTexture>;
  124937. /**
  124938. * Specifies that the submesh is ready to be used.
  124939. * @param mesh - BJS mesh.
  124940. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124941. * @param useInstances - Specifies that instances should be used.
  124942. * @returns - boolean indicating that the submesh is ready or not.
  124943. */
  124944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124945. /**
  124946. * Specifies if the material uses metallic roughness workflow.
  124947. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124948. */
  124949. isMetallicWorkflow(): boolean;
  124950. private _prepareEffect;
  124951. private _prepareDefines;
  124952. /**
  124953. * Force shader compilation
  124954. */
  124955. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124956. /**
  124957. * Initializes the uniform buffer layout for the shader.
  124958. */
  124959. buildUniformLayout(): void;
  124960. /**
  124961. * Unbinds the material from the mesh
  124962. */
  124963. unbind(): void;
  124964. /**
  124965. * Binds the submesh data.
  124966. * @param world - The world matrix.
  124967. * @param mesh - The BJS mesh.
  124968. * @param subMesh - A submesh of the BJS mesh.
  124969. */
  124970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124971. /**
  124972. * Returns the animatable textures.
  124973. * @returns - Array of animatable textures.
  124974. */
  124975. getAnimatables(): IAnimatable[];
  124976. /**
  124977. * Returns the texture used for reflections.
  124978. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124979. */
  124980. private _getReflectionTexture;
  124981. /**
  124982. * Returns an array of the actively used textures.
  124983. * @returns - Array of BaseTextures
  124984. */
  124985. getActiveTextures(): BaseTexture[];
  124986. /**
  124987. * Checks to see if a texture is used in the material.
  124988. * @param texture - Base texture to use.
  124989. * @returns - Boolean specifying if a texture is used in the material.
  124990. */
  124991. hasTexture(texture: BaseTexture): boolean;
  124992. /**
  124993. * Disposes the resources of the material.
  124994. * @param forceDisposeEffect - Forces the disposal of effects.
  124995. * @param forceDisposeTextures - Forces the disposal of all textures.
  124996. */
  124997. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124998. }
  124999. }
  125000. declare module BABYLON {
  125001. /**
  125002. * The Physically based material of BJS.
  125003. *
  125004. * This offers the main features of a standard PBR material.
  125005. * For more information, please refer to the documentation :
  125006. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125007. */
  125008. export class PBRMaterial extends PBRBaseMaterial {
  125009. /**
  125010. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125011. */
  125012. static readonly PBRMATERIAL_OPAQUE: number;
  125013. /**
  125014. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125015. */
  125016. static readonly PBRMATERIAL_ALPHATEST: number;
  125017. /**
  125018. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125019. */
  125020. static readonly PBRMATERIAL_ALPHABLEND: number;
  125021. /**
  125022. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125023. * They are also discarded below the alpha cutoff threshold to improve performances.
  125024. */
  125025. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125026. /**
  125027. * Defines the default value of how much AO map is occluding the analytical lights
  125028. * (point spot...).
  125029. */
  125030. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125031. /**
  125032. * Intensity of the direct lights e.g. the four lights available in your scene.
  125033. * This impacts both the direct diffuse and specular highlights.
  125034. */
  125035. directIntensity: number;
  125036. /**
  125037. * Intensity of the emissive part of the material.
  125038. * This helps controlling the emissive effect without modifying the emissive color.
  125039. */
  125040. emissiveIntensity: number;
  125041. /**
  125042. * Intensity of the environment e.g. how much the environment will light the object
  125043. * either through harmonics for rough material or through the refelction for shiny ones.
  125044. */
  125045. environmentIntensity: number;
  125046. /**
  125047. * This is a special control allowing the reduction of the specular highlights coming from the
  125048. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125049. */
  125050. specularIntensity: number;
  125051. /**
  125052. * Debug Control allowing disabling the bump map on this material.
  125053. */
  125054. disableBumpMap: boolean;
  125055. /**
  125056. * AKA Diffuse Texture in standard nomenclature.
  125057. */
  125058. albedoTexture: BaseTexture;
  125059. /**
  125060. * AKA Occlusion Texture in other nomenclature.
  125061. */
  125062. ambientTexture: BaseTexture;
  125063. /**
  125064. * AKA Occlusion Texture Intensity in other nomenclature.
  125065. */
  125066. ambientTextureStrength: number;
  125067. /**
  125068. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125069. * 1 means it completely occludes it
  125070. * 0 mean it has no impact
  125071. */
  125072. ambientTextureImpactOnAnalyticalLights: number;
  125073. /**
  125074. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  125075. */
  125076. opacityTexture: BaseTexture;
  125077. /**
  125078. * Stores the reflection values in a texture.
  125079. */
  125080. reflectionTexture: Nullable<BaseTexture>;
  125081. /**
  125082. * Stores the emissive values in a texture.
  125083. */
  125084. emissiveTexture: BaseTexture;
  125085. /**
  125086. * AKA Specular texture in other nomenclature.
  125087. */
  125088. reflectivityTexture: BaseTexture;
  125089. /**
  125090. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125091. */
  125092. metallicTexture: BaseTexture;
  125093. /**
  125094. * Specifies the metallic scalar of the metallic/roughness workflow.
  125095. * Can also be used to scale the metalness values of the metallic texture.
  125096. */
  125097. metallic: Nullable<number>;
  125098. /**
  125099. * Specifies the roughness scalar of the metallic/roughness workflow.
  125100. * Can also be used to scale the roughness values of the metallic texture.
  125101. */
  125102. roughness: Nullable<number>;
  125103. /**
  125104. * Specifies the an F0 factor to help configuring the material F0.
  125105. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125106. * to 0.5 the previously hard coded value stays the same.
  125107. * Can also be used to scale the F0 values of the metallic texture.
  125108. */
  125109. metallicF0Factor: number;
  125110. /**
  125111. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125112. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125113. * your expectation as it multiplies with the texture data.
  125114. */
  125115. useMetallicF0FactorFromMetallicTexture: boolean;
  125116. /**
  125117. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125118. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125119. */
  125120. microSurfaceTexture: BaseTexture;
  125121. /**
  125122. * Stores surface normal data used to displace a mesh in a texture.
  125123. */
  125124. bumpTexture: BaseTexture;
  125125. /**
  125126. * Stores the pre-calculated light information of a mesh in a texture.
  125127. */
  125128. lightmapTexture: BaseTexture;
  125129. /**
  125130. * Stores the refracted light information in a texture.
  125131. */
  125132. get refractionTexture(): Nullable<BaseTexture>;
  125133. set refractionTexture(value: Nullable<BaseTexture>);
  125134. /**
  125135. * The color of a material in ambient lighting.
  125136. */
  125137. ambientColor: Color3;
  125138. /**
  125139. * AKA Diffuse Color in other nomenclature.
  125140. */
  125141. albedoColor: Color3;
  125142. /**
  125143. * AKA Specular Color in other nomenclature.
  125144. */
  125145. reflectivityColor: Color3;
  125146. /**
  125147. * The color reflected from the material.
  125148. */
  125149. reflectionColor: Color3;
  125150. /**
  125151. * The color emitted from the material.
  125152. */
  125153. emissiveColor: Color3;
  125154. /**
  125155. * AKA Glossiness in other nomenclature.
  125156. */
  125157. microSurface: number;
  125158. /**
  125159. * source material index of refraction (IOR)' / 'destination material IOR.
  125160. */
  125161. get indexOfRefraction(): number;
  125162. set indexOfRefraction(value: number);
  125163. /**
  125164. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125165. */
  125166. get invertRefractionY(): boolean;
  125167. set invertRefractionY(value: boolean);
  125168. /**
  125169. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125170. * Materials half opaque for instance using refraction could benefit from this control.
  125171. */
  125172. get linkRefractionWithTransparency(): boolean;
  125173. set linkRefractionWithTransparency(value: boolean);
  125174. /**
  125175. * If true, the light map contains occlusion information instead of lighting info.
  125176. */
  125177. useLightmapAsShadowmap: boolean;
  125178. /**
  125179. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125180. */
  125181. useAlphaFromAlbedoTexture: boolean;
  125182. /**
  125183. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125184. */
  125185. forceAlphaTest: boolean;
  125186. /**
  125187. * Defines the alpha limits in alpha test mode.
  125188. */
  125189. alphaCutOff: number;
  125190. /**
  125191. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125192. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125193. */
  125194. useSpecularOverAlpha: boolean;
  125195. /**
  125196. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125197. */
  125198. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125199. /**
  125200. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125201. */
  125202. useRoughnessFromMetallicTextureAlpha: boolean;
  125203. /**
  125204. * Specifies if the metallic texture contains the roughness information in its green channel.
  125205. */
  125206. useRoughnessFromMetallicTextureGreen: boolean;
  125207. /**
  125208. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125209. */
  125210. useMetallnessFromMetallicTextureBlue: boolean;
  125211. /**
  125212. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125213. */
  125214. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125215. /**
  125216. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125217. */
  125218. useAmbientInGrayScale: boolean;
  125219. /**
  125220. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125221. * The material will try to infer what glossiness each pixel should be.
  125222. */
  125223. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125224. /**
  125225. * BJS is using an harcoded light falloff based on a manually sets up range.
  125226. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125227. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125228. */
  125229. get usePhysicalLightFalloff(): boolean;
  125230. /**
  125231. * BJS is using an harcoded light falloff based on a manually sets up range.
  125232. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125233. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125234. */
  125235. set usePhysicalLightFalloff(value: boolean);
  125236. /**
  125237. * In order to support the falloff compatibility with gltf, a special mode has been added
  125238. * to reproduce the gltf light falloff.
  125239. */
  125240. get useGLTFLightFalloff(): boolean;
  125241. /**
  125242. * In order to support the falloff compatibility with gltf, a special mode has been added
  125243. * to reproduce the gltf light falloff.
  125244. */
  125245. set useGLTFLightFalloff(value: boolean);
  125246. /**
  125247. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125248. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125249. */
  125250. useRadianceOverAlpha: boolean;
  125251. /**
  125252. * Allows using an object space normal map (instead of tangent space).
  125253. */
  125254. useObjectSpaceNormalMap: boolean;
  125255. /**
  125256. * Allows using the bump map in parallax mode.
  125257. */
  125258. useParallax: boolean;
  125259. /**
  125260. * Allows using the bump map in parallax occlusion mode.
  125261. */
  125262. useParallaxOcclusion: boolean;
  125263. /**
  125264. * Controls the scale bias of the parallax mode.
  125265. */
  125266. parallaxScaleBias: number;
  125267. /**
  125268. * If sets to true, disables all the lights affecting the material.
  125269. */
  125270. disableLighting: boolean;
  125271. /**
  125272. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125273. */
  125274. forceIrradianceInFragment: boolean;
  125275. /**
  125276. * Number of Simultaneous lights allowed on the material.
  125277. */
  125278. maxSimultaneousLights: number;
  125279. /**
  125280. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125281. */
  125282. invertNormalMapX: boolean;
  125283. /**
  125284. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125285. */
  125286. invertNormalMapY: boolean;
  125287. /**
  125288. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125289. */
  125290. twoSidedLighting: boolean;
  125291. /**
  125292. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125293. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125294. */
  125295. useAlphaFresnel: boolean;
  125296. /**
  125297. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125298. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125299. */
  125300. useLinearAlphaFresnel: boolean;
  125301. /**
  125302. * Let user defines the brdf lookup texture used for IBL.
  125303. * A default 8bit version is embedded but you could point at :
  125304. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125305. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125306. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125307. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125308. */
  125309. environmentBRDFTexture: Nullable<BaseTexture>;
  125310. /**
  125311. * Force normal to face away from face.
  125312. */
  125313. forceNormalForward: boolean;
  125314. /**
  125315. * Enables specular anti aliasing in the PBR shader.
  125316. * It will both interacts on the Geometry for analytical and IBL lighting.
  125317. * It also prefilter the roughness map based on the bump values.
  125318. */
  125319. enableSpecularAntiAliasing: boolean;
  125320. /**
  125321. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125322. * makes the reflect vector face the model (under horizon).
  125323. */
  125324. useHorizonOcclusion: boolean;
  125325. /**
  125326. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125327. * too much the area relying on ambient texture to define their ambient occlusion.
  125328. */
  125329. useRadianceOcclusion: boolean;
  125330. /**
  125331. * If set to true, no lighting calculations will be applied.
  125332. */
  125333. unlit: boolean;
  125334. /**
  125335. * Gets the image processing configuration used either in this material.
  125336. */
  125337. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125338. /**
  125339. * Sets the Default image processing configuration used either in the this material.
  125340. *
  125341. * If sets to null, the scene one is in use.
  125342. */
  125343. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125344. /**
  125345. * Gets wether the color curves effect is enabled.
  125346. */
  125347. get cameraColorCurvesEnabled(): boolean;
  125348. /**
  125349. * Sets wether the color curves effect is enabled.
  125350. */
  125351. set cameraColorCurvesEnabled(value: boolean);
  125352. /**
  125353. * Gets wether the color grading effect is enabled.
  125354. */
  125355. get cameraColorGradingEnabled(): boolean;
  125356. /**
  125357. * Gets wether the color grading effect is enabled.
  125358. */
  125359. set cameraColorGradingEnabled(value: boolean);
  125360. /**
  125361. * Gets wether tonemapping is enabled or not.
  125362. */
  125363. get cameraToneMappingEnabled(): boolean;
  125364. /**
  125365. * Sets wether tonemapping is enabled or not
  125366. */
  125367. set cameraToneMappingEnabled(value: boolean);
  125368. /**
  125369. * The camera exposure used on this material.
  125370. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125371. * This corresponds to a photographic exposure.
  125372. */
  125373. get cameraExposure(): number;
  125374. /**
  125375. * The camera exposure used on this material.
  125376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125377. * This corresponds to a photographic exposure.
  125378. */
  125379. set cameraExposure(value: number);
  125380. /**
  125381. * Gets The camera contrast used on this material.
  125382. */
  125383. get cameraContrast(): number;
  125384. /**
  125385. * Sets The camera contrast used on this material.
  125386. */
  125387. set cameraContrast(value: number);
  125388. /**
  125389. * Gets the Color Grading 2D Lookup Texture.
  125390. */
  125391. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125392. /**
  125393. * Sets the Color Grading 2D Lookup Texture.
  125394. */
  125395. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125396. /**
  125397. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125398. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125399. * 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;
  125400. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125401. */
  125402. get cameraColorCurves(): Nullable<ColorCurves>;
  125403. /**
  125404. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125405. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125406. * 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;
  125407. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125408. */
  125409. set cameraColorCurves(value: Nullable<ColorCurves>);
  125410. /**
  125411. * Instantiates a new PBRMaterial instance.
  125412. *
  125413. * @param name The material name
  125414. * @param scene The scene the material will be use in.
  125415. */
  125416. constructor(name: string, scene: Scene);
  125417. /**
  125418. * Returns the name of this material class.
  125419. */
  125420. getClassName(): string;
  125421. /**
  125422. * Makes a duplicate of the current material.
  125423. * @param name - name to use for the new material.
  125424. */
  125425. clone(name: string): PBRMaterial;
  125426. /**
  125427. * Serializes this PBR Material.
  125428. * @returns - An object with the serialized material.
  125429. */
  125430. serialize(): any;
  125431. /**
  125432. * Parses a PBR Material from a serialized object.
  125433. * @param source - Serialized object.
  125434. * @param scene - BJS scene instance.
  125435. * @param rootUrl - url for the scene object
  125436. * @returns - PBRMaterial
  125437. */
  125438. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125439. }
  125440. }
  125441. declare module BABYLON {
  125442. /**
  125443. * Direct draw surface info
  125444. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125445. */
  125446. export interface DDSInfo {
  125447. /**
  125448. * Width of the texture
  125449. */
  125450. width: number;
  125451. /**
  125452. * Width of the texture
  125453. */
  125454. height: number;
  125455. /**
  125456. * Number of Mipmaps for the texture
  125457. * @see https://en.wikipedia.org/wiki/Mipmap
  125458. */
  125459. mipmapCount: number;
  125460. /**
  125461. * If the textures format is a known fourCC format
  125462. * @see https://www.fourcc.org/
  125463. */
  125464. isFourCC: boolean;
  125465. /**
  125466. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125467. */
  125468. isRGB: boolean;
  125469. /**
  125470. * If the texture is a lumincance format
  125471. */
  125472. isLuminance: boolean;
  125473. /**
  125474. * If this is a cube texture
  125475. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125476. */
  125477. isCube: boolean;
  125478. /**
  125479. * If the texture is a compressed format eg. FOURCC_DXT1
  125480. */
  125481. isCompressed: boolean;
  125482. /**
  125483. * The dxgiFormat of the texture
  125484. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125485. */
  125486. dxgiFormat: number;
  125487. /**
  125488. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125489. */
  125490. textureType: number;
  125491. /**
  125492. * Sphericle polynomial created for the dds texture
  125493. */
  125494. sphericalPolynomial?: SphericalPolynomial;
  125495. }
  125496. /**
  125497. * Class used to provide DDS decompression tools
  125498. */
  125499. export class DDSTools {
  125500. /**
  125501. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125502. */
  125503. static StoreLODInAlphaChannel: boolean;
  125504. /**
  125505. * Gets DDS information from an array buffer
  125506. * @param data defines the array buffer view to read data from
  125507. * @returns the DDS information
  125508. */
  125509. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125510. private static _FloatView;
  125511. private static _Int32View;
  125512. private static _ToHalfFloat;
  125513. private static _FromHalfFloat;
  125514. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125515. private static _GetHalfFloatRGBAArrayBuffer;
  125516. private static _GetFloatRGBAArrayBuffer;
  125517. private static _GetFloatAsUIntRGBAArrayBuffer;
  125518. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125519. private static _GetRGBAArrayBuffer;
  125520. private static _ExtractLongWordOrder;
  125521. private static _GetRGBArrayBuffer;
  125522. private static _GetLuminanceArrayBuffer;
  125523. /**
  125524. * Uploads DDS Levels to a Babylon Texture
  125525. * @hidden
  125526. */
  125527. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125528. }
  125529. interface ThinEngine {
  125530. /**
  125531. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125532. * @param rootUrl defines the url where the file to load is located
  125533. * @param scene defines the current scene
  125534. * @param lodScale defines scale to apply to the mip map selection
  125535. * @param lodOffset defines offset to apply to the mip map selection
  125536. * @param onLoad defines an optional callback raised when the texture is loaded
  125537. * @param onError defines an optional callback raised if there is an issue to load the texture
  125538. * @param format defines the format of the data
  125539. * @param forcedExtension defines the extension to use to pick the right loader
  125540. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125541. * @returns the cube texture as an InternalTexture
  125542. */
  125543. 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;
  125544. }
  125545. }
  125546. declare module BABYLON {
  125547. /**
  125548. * Implementation of the DDS Texture Loader.
  125549. * @hidden
  125550. */
  125551. export class _DDSTextureLoader implements IInternalTextureLoader {
  125552. /**
  125553. * Defines wether the loader supports cascade loading the different faces.
  125554. */
  125555. readonly supportCascades: boolean;
  125556. /**
  125557. * This returns if the loader support the current file information.
  125558. * @param extension defines the file extension of the file being loaded
  125559. * @returns true if the loader can load the specified file
  125560. */
  125561. canLoad(extension: string): boolean;
  125562. /**
  125563. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125564. * @param data contains the texture data
  125565. * @param texture defines the BabylonJS internal texture
  125566. * @param createPolynomials will be true if polynomials have been requested
  125567. * @param onLoad defines the callback to trigger once the texture is ready
  125568. * @param onError defines the callback to trigger in case of error
  125569. */
  125570. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125571. /**
  125572. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125573. * @param data contains the texture data
  125574. * @param texture defines the BabylonJS internal texture
  125575. * @param callback defines the method to call once ready to upload
  125576. */
  125577. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125578. }
  125579. }
  125580. declare module BABYLON {
  125581. /**
  125582. * Implementation of the ENV Texture Loader.
  125583. * @hidden
  125584. */
  125585. export class _ENVTextureLoader implements IInternalTextureLoader {
  125586. /**
  125587. * Defines wether the loader supports cascade loading the different faces.
  125588. */
  125589. readonly supportCascades: boolean;
  125590. /**
  125591. * This returns if the loader support the current file information.
  125592. * @param extension defines the file extension of the file being loaded
  125593. * @returns true if the loader can load the specified file
  125594. */
  125595. canLoad(extension: string): boolean;
  125596. /**
  125597. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125598. * @param data contains the texture data
  125599. * @param texture defines the BabylonJS internal texture
  125600. * @param createPolynomials will be true if polynomials have been requested
  125601. * @param onLoad defines the callback to trigger once the texture is ready
  125602. * @param onError defines the callback to trigger in case of error
  125603. */
  125604. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125605. /**
  125606. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125607. * @param data contains the texture data
  125608. * @param texture defines the BabylonJS internal texture
  125609. * @param callback defines the method to call once ready to upload
  125610. */
  125611. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125612. }
  125613. }
  125614. declare module BABYLON {
  125615. /**
  125616. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125617. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125618. */
  125619. export class KhronosTextureContainer {
  125620. /** contents of the KTX container file */
  125621. data: ArrayBufferView;
  125622. private static HEADER_LEN;
  125623. private static COMPRESSED_2D;
  125624. private static COMPRESSED_3D;
  125625. private static TEX_2D;
  125626. private static TEX_3D;
  125627. /**
  125628. * Gets the openGL type
  125629. */
  125630. glType: number;
  125631. /**
  125632. * Gets the openGL type size
  125633. */
  125634. glTypeSize: number;
  125635. /**
  125636. * Gets the openGL format
  125637. */
  125638. glFormat: number;
  125639. /**
  125640. * Gets the openGL internal format
  125641. */
  125642. glInternalFormat: number;
  125643. /**
  125644. * Gets the base internal format
  125645. */
  125646. glBaseInternalFormat: number;
  125647. /**
  125648. * Gets image width in pixel
  125649. */
  125650. pixelWidth: number;
  125651. /**
  125652. * Gets image height in pixel
  125653. */
  125654. pixelHeight: number;
  125655. /**
  125656. * Gets image depth in pixels
  125657. */
  125658. pixelDepth: number;
  125659. /**
  125660. * Gets the number of array elements
  125661. */
  125662. numberOfArrayElements: number;
  125663. /**
  125664. * Gets the number of faces
  125665. */
  125666. numberOfFaces: number;
  125667. /**
  125668. * Gets the number of mipmap levels
  125669. */
  125670. numberOfMipmapLevels: number;
  125671. /**
  125672. * Gets the bytes of key value data
  125673. */
  125674. bytesOfKeyValueData: number;
  125675. /**
  125676. * Gets the load type
  125677. */
  125678. loadType: number;
  125679. /**
  125680. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125681. */
  125682. isInvalid: boolean;
  125683. /**
  125684. * Creates a new KhronosTextureContainer
  125685. * @param data contents of the KTX container file
  125686. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125687. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125688. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125689. */
  125690. constructor(
  125691. /** contents of the KTX container file */
  125692. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125693. /**
  125694. * Uploads KTX content to a Babylon Texture.
  125695. * It is assumed that the texture has already been created & is currently bound
  125696. * @hidden
  125697. */
  125698. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125699. private _upload2DCompressedLevels;
  125700. /**
  125701. * Checks if the given data starts with a KTX file identifier.
  125702. * @param data the data to check
  125703. * @returns true if the data is a KTX file or false otherwise
  125704. */
  125705. static IsValid(data: ArrayBufferView): boolean;
  125706. }
  125707. }
  125708. declare module BABYLON {
  125709. /**
  125710. * Class for loading KTX2 files
  125711. * !!! Experimental Extension Subject to Changes !!!
  125712. * @hidden
  125713. */
  125714. export class KhronosTextureContainer2 {
  125715. private static _ModulePromise;
  125716. private static _TranscodeFormat;
  125717. constructor(engine: ThinEngine);
  125718. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125719. private _determineTranscodeFormat;
  125720. /**
  125721. * Checks if the given data starts with a KTX2 file identifier.
  125722. * @param data the data to check
  125723. * @returns true if the data is a KTX2 file or false otherwise
  125724. */
  125725. static IsValid(data: ArrayBufferView): boolean;
  125726. }
  125727. }
  125728. declare module BABYLON {
  125729. /**
  125730. * Implementation of the KTX Texture Loader.
  125731. * @hidden
  125732. */
  125733. export class _KTXTextureLoader implements IInternalTextureLoader {
  125734. /**
  125735. * Defines wether the loader supports cascade loading the different faces.
  125736. */
  125737. readonly supportCascades: boolean;
  125738. /**
  125739. * This returns if the loader support the current file information.
  125740. * @param extension defines the file extension of the file being loaded
  125741. * @returns true if the loader can load the specified file
  125742. */
  125743. canLoad(extension: string): boolean;
  125744. /**
  125745. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125746. * @param data contains the texture data
  125747. * @param texture defines the BabylonJS internal texture
  125748. * @param createPolynomials will be true if polynomials have been requested
  125749. * @param onLoad defines the callback to trigger once the texture is ready
  125750. * @param onError defines the callback to trigger in case of error
  125751. */
  125752. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125753. /**
  125754. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125755. * @param data contains the texture data
  125756. * @param texture defines the BabylonJS internal texture
  125757. * @param callback defines the method to call once ready to upload
  125758. */
  125759. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125760. }
  125761. }
  125762. declare module BABYLON {
  125763. /** @hidden */
  125764. export var _forceSceneHelpersToBundle: boolean;
  125765. interface Scene {
  125766. /**
  125767. * Creates a default light for the scene.
  125768. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125769. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125770. */
  125771. createDefaultLight(replace?: boolean): void;
  125772. /**
  125773. * Creates a default camera for the scene.
  125774. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125775. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125776. * @param replace has default false, when true replaces the active camera in the scene
  125777. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125778. */
  125779. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125780. /**
  125781. * Creates a default camera and a default light.
  125782. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125783. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125784. * @param replace has the default false, when true replaces the active camera/light in the scene
  125785. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125786. */
  125787. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125788. /**
  125789. * Creates a new sky box
  125790. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125791. * @param environmentTexture defines the texture to use as environment texture
  125792. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125793. * @param scale defines the overall scale of the skybox
  125794. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125795. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125796. * @returns a new mesh holding the sky box
  125797. */
  125798. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125799. /**
  125800. * Creates a new environment
  125801. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125802. * @param options defines the options you can use to configure the environment
  125803. * @returns the new EnvironmentHelper
  125804. */
  125805. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125806. /**
  125807. * Creates a new VREXperienceHelper
  125808. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125809. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125810. * @returns a new VREXperienceHelper
  125811. */
  125812. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125813. /**
  125814. * Creates a new WebXRDefaultExperience
  125815. * @see http://doc.babylonjs.com/how_to/webxr
  125816. * @param options experience options
  125817. * @returns a promise for a new WebXRDefaultExperience
  125818. */
  125819. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125820. }
  125821. }
  125822. declare module BABYLON {
  125823. /**
  125824. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125825. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125826. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125827. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125828. */
  125829. export class VideoDome extends TransformNode {
  125830. /**
  125831. * Define the video source as a Monoscopic panoramic 360 video.
  125832. */
  125833. static readonly MODE_MONOSCOPIC: number;
  125834. /**
  125835. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125836. */
  125837. static readonly MODE_TOPBOTTOM: number;
  125838. /**
  125839. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125840. */
  125841. static readonly MODE_SIDEBYSIDE: number;
  125842. private _halfDome;
  125843. private _useDirectMapping;
  125844. /**
  125845. * The video texture being displayed on the sphere
  125846. */
  125847. protected _videoTexture: VideoTexture;
  125848. /**
  125849. * Gets the video texture being displayed on the sphere
  125850. */
  125851. get videoTexture(): VideoTexture;
  125852. /**
  125853. * The skybox material
  125854. */
  125855. protected _material: BackgroundMaterial;
  125856. /**
  125857. * The surface used for the skybox
  125858. */
  125859. protected _mesh: Mesh;
  125860. /**
  125861. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125862. */
  125863. private _halfDomeMask;
  125864. /**
  125865. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125866. * Also see the options.resolution property.
  125867. */
  125868. get fovMultiplier(): number;
  125869. set fovMultiplier(value: number);
  125870. private _videoMode;
  125871. /**
  125872. * Gets or set the current video mode for the video. It can be:
  125873. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125874. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125875. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125876. */
  125877. get videoMode(): number;
  125878. set videoMode(value: number);
  125879. /**
  125880. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125881. *
  125882. */
  125883. get halfDome(): boolean;
  125884. /**
  125885. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125886. */
  125887. set halfDome(enabled: boolean);
  125888. /**
  125889. * Oberserver used in Stereoscopic VR Mode.
  125890. */
  125891. private _onBeforeCameraRenderObserver;
  125892. /**
  125893. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125894. * @param name Element's name, child elements will append suffixes for their own names.
  125895. * @param urlsOrVideo defines the url(s) or the video element to use
  125896. * @param options An object containing optional or exposed sub element properties
  125897. */
  125898. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125899. resolution?: number;
  125900. clickToPlay?: boolean;
  125901. autoPlay?: boolean;
  125902. loop?: boolean;
  125903. size?: number;
  125904. poster?: string;
  125905. faceForward?: boolean;
  125906. useDirectMapping?: boolean;
  125907. halfDomeMode?: boolean;
  125908. }, scene: Scene);
  125909. private _changeVideoMode;
  125910. /**
  125911. * Releases resources associated with this node.
  125912. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125913. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125914. */
  125915. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125916. }
  125917. }
  125918. declare module BABYLON {
  125919. /**
  125920. * This class can be used to get instrumentation data from a Babylon engine
  125921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125922. */
  125923. export class EngineInstrumentation implements IDisposable {
  125924. /**
  125925. * Define the instrumented engine.
  125926. */
  125927. engine: Engine;
  125928. private _captureGPUFrameTime;
  125929. private _gpuFrameTimeToken;
  125930. private _gpuFrameTime;
  125931. private _captureShaderCompilationTime;
  125932. private _shaderCompilationTime;
  125933. private _onBeginFrameObserver;
  125934. private _onEndFrameObserver;
  125935. private _onBeforeShaderCompilationObserver;
  125936. private _onAfterShaderCompilationObserver;
  125937. /**
  125938. * Gets the perf counter used for GPU frame time
  125939. */
  125940. get gpuFrameTimeCounter(): PerfCounter;
  125941. /**
  125942. * Gets the GPU frame time capture status
  125943. */
  125944. get captureGPUFrameTime(): boolean;
  125945. /**
  125946. * Enable or disable the GPU frame time capture
  125947. */
  125948. set captureGPUFrameTime(value: boolean);
  125949. /**
  125950. * Gets the perf counter used for shader compilation time
  125951. */
  125952. get shaderCompilationTimeCounter(): PerfCounter;
  125953. /**
  125954. * Gets the shader compilation time capture status
  125955. */
  125956. get captureShaderCompilationTime(): boolean;
  125957. /**
  125958. * Enable or disable the shader compilation time capture
  125959. */
  125960. set captureShaderCompilationTime(value: boolean);
  125961. /**
  125962. * Instantiates a new engine instrumentation.
  125963. * This class can be used to get instrumentation data from a Babylon engine
  125964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125965. * @param engine Defines the engine to instrument
  125966. */
  125967. constructor(
  125968. /**
  125969. * Define the instrumented engine.
  125970. */
  125971. engine: Engine);
  125972. /**
  125973. * Dispose and release associated resources.
  125974. */
  125975. dispose(): void;
  125976. }
  125977. }
  125978. declare module BABYLON {
  125979. /**
  125980. * This class can be used to get instrumentation data from a Babylon engine
  125981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125982. */
  125983. export class SceneInstrumentation implements IDisposable {
  125984. /**
  125985. * Defines the scene to instrument
  125986. */
  125987. scene: Scene;
  125988. private _captureActiveMeshesEvaluationTime;
  125989. private _activeMeshesEvaluationTime;
  125990. private _captureRenderTargetsRenderTime;
  125991. private _renderTargetsRenderTime;
  125992. private _captureFrameTime;
  125993. private _frameTime;
  125994. private _captureRenderTime;
  125995. private _renderTime;
  125996. private _captureInterFrameTime;
  125997. private _interFrameTime;
  125998. private _captureParticlesRenderTime;
  125999. private _particlesRenderTime;
  126000. private _captureSpritesRenderTime;
  126001. private _spritesRenderTime;
  126002. private _capturePhysicsTime;
  126003. private _physicsTime;
  126004. private _captureAnimationsTime;
  126005. private _animationsTime;
  126006. private _captureCameraRenderTime;
  126007. private _cameraRenderTime;
  126008. private _onBeforeActiveMeshesEvaluationObserver;
  126009. private _onAfterActiveMeshesEvaluationObserver;
  126010. private _onBeforeRenderTargetsRenderObserver;
  126011. private _onAfterRenderTargetsRenderObserver;
  126012. private _onAfterRenderObserver;
  126013. private _onBeforeDrawPhaseObserver;
  126014. private _onAfterDrawPhaseObserver;
  126015. private _onBeforeAnimationsObserver;
  126016. private _onBeforeParticlesRenderingObserver;
  126017. private _onAfterParticlesRenderingObserver;
  126018. private _onBeforeSpritesRenderingObserver;
  126019. private _onAfterSpritesRenderingObserver;
  126020. private _onBeforePhysicsObserver;
  126021. private _onAfterPhysicsObserver;
  126022. private _onAfterAnimationsObserver;
  126023. private _onBeforeCameraRenderObserver;
  126024. private _onAfterCameraRenderObserver;
  126025. /**
  126026. * Gets the perf counter used for active meshes evaluation time
  126027. */
  126028. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  126029. /**
  126030. * Gets the active meshes evaluation time capture status
  126031. */
  126032. get captureActiveMeshesEvaluationTime(): boolean;
  126033. /**
  126034. * Enable or disable the active meshes evaluation time capture
  126035. */
  126036. set captureActiveMeshesEvaluationTime(value: boolean);
  126037. /**
  126038. * Gets the perf counter used for render targets render time
  126039. */
  126040. get renderTargetsRenderTimeCounter(): PerfCounter;
  126041. /**
  126042. * Gets the render targets render time capture status
  126043. */
  126044. get captureRenderTargetsRenderTime(): boolean;
  126045. /**
  126046. * Enable or disable the render targets render time capture
  126047. */
  126048. set captureRenderTargetsRenderTime(value: boolean);
  126049. /**
  126050. * Gets the perf counter used for particles render time
  126051. */
  126052. get particlesRenderTimeCounter(): PerfCounter;
  126053. /**
  126054. * Gets the particles render time capture status
  126055. */
  126056. get captureParticlesRenderTime(): boolean;
  126057. /**
  126058. * Enable or disable the particles render time capture
  126059. */
  126060. set captureParticlesRenderTime(value: boolean);
  126061. /**
  126062. * Gets the perf counter used for sprites render time
  126063. */
  126064. get spritesRenderTimeCounter(): PerfCounter;
  126065. /**
  126066. * Gets the sprites render time capture status
  126067. */
  126068. get captureSpritesRenderTime(): boolean;
  126069. /**
  126070. * Enable or disable the sprites render time capture
  126071. */
  126072. set captureSpritesRenderTime(value: boolean);
  126073. /**
  126074. * Gets the perf counter used for physics time
  126075. */
  126076. get physicsTimeCounter(): PerfCounter;
  126077. /**
  126078. * Gets the physics time capture status
  126079. */
  126080. get capturePhysicsTime(): boolean;
  126081. /**
  126082. * Enable or disable the physics time capture
  126083. */
  126084. set capturePhysicsTime(value: boolean);
  126085. /**
  126086. * Gets the perf counter used for animations time
  126087. */
  126088. get animationsTimeCounter(): PerfCounter;
  126089. /**
  126090. * Gets the animations time capture status
  126091. */
  126092. get captureAnimationsTime(): boolean;
  126093. /**
  126094. * Enable or disable the animations time capture
  126095. */
  126096. set captureAnimationsTime(value: boolean);
  126097. /**
  126098. * Gets the perf counter used for frame time capture
  126099. */
  126100. get frameTimeCounter(): PerfCounter;
  126101. /**
  126102. * Gets the frame time capture status
  126103. */
  126104. get captureFrameTime(): boolean;
  126105. /**
  126106. * Enable or disable the frame time capture
  126107. */
  126108. set captureFrameTime(value: boolean);
  126109. /**
  126110. * Gets the perf counter used for inter-frames time capture
  126111. */
  126112. get interFrameTimeCounter(): PerfCounter;
  126113. /**
  126114. * Gets the inter-frames time capture status
  126115. */
  126116. get captureInterFrameTime(): boolean;
  126117. /**
  126118. * Enable or disable the inter-frames time capture
  126119. */
  126120. set captureInterFrameTime(value: boolean);
  126121. /**
  126122. * Gets the perf counter used for render time capture
  126123. */
  126124. get renderTimeCounter(): PerfCounter;
  126125. /**
  126126. * Gets the render time capture status
  126127. */
  126128. get captureRenderTime(): boolean;
  126129. /**
  126130. * Enable or disable the render time capture
  126131. */
  126132. set captureRenderTime(value: boolean);
  126133. /**
  126134. * Gets the perf counter used for camera render time capture
  126135. */
  126136. get cameraRenderTimeCounter(): PerfCounter;
  126137. /**
  126138. * Gets the camera render time capture status
  126139. */
  126140. get captureCameraRenderTime(): boolean;
  126141. /**
  126142. * Enable or disable the camera render time capture
  126143. */
  126144. set captureCameraRenderTime(value: boolean);
  126145. /**
  126146. * Gets the perf counter used for draw calls
  126147. */
  126148. get drawCallsCounter(): PerfCounter;
  126149. /**
  126150. * Instantiates a new scene instrumentation.
  126151. * This class can be used to get instrumentation data from a Babylon engine
  126152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126153. * @param scene Defines the scene to instrument
  126154. */
  126155. constructor(
  126156. /**
  126157. * Defines the scene to instrument
  126158. */
  126159. scene: Scene);
  126160. /**
  126161. * Dispose and release associated resources.
  126162. */
  126163. dispose(): void;
  126164. }
  126165. }
  126166. declare module BABYLON {
  126167. /** @hidden */
  126168. export var glowMapGenerationPixelShader: {
  126169. name: string;
  126170. shader: string;
  126171. };
  126172. }
  126173. declare module BABYLON {
  126174. /** @hidden */
  126175. export var glowMapGenerationVertexShader: {
  126176. name: string;
  126177. shader: string;
  126178. };
  126179. }
  126180. declare module BABYLON {
  126181. /**
  126182. * Effect layer options. This helps customizing the behaviour
  126183. * of the effect layer.
  126184. */
  126185. export interface IEffectLayerOptions {
  126186. /**
  126187. * Multiplication factor apply to the canvas size to compute the render target size
  126188. * used to generated the objects (the smaller the faster).
  126189. */
  126190. mainTextureRatio: number;
  126191. /**
  126192. * Enforces a fixed size texture to ensure effect stability across devices.
  126193. */
  126194. mainTextureFixedSize?: number;
  126195. /**
  126196. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126197. */
  126198. alphaBlendingMode: number;
  126199. /**
  126200. * The camera attached to the layer.
  126201. */
  126202. camera: Nullable<Camera>;
  126203. /**
  126204. * The rendering group to draw the layer in.
  126205. */
  126206. renderingGroupId: number;
  126207. }
  126208. /**
  126209. * The effect layer Helps adding post process effect blended with the main pass.
  126210. *
  126211. * This can be for instance use to generate glow or higlight effects on the scene.
  126212. *
  126213. * The effect layer class can not be used directly and is intented to inherited from to be
  126214. * customized per effects.
  126215. */
  126216. export abstract class EffectLayer {
  126217. private _vertexBuffers;
  126218. private _indexBuffer;
  126219. private _cachedDefines;
  126220. private _effectLayerMapGenerationEffect;
  126221. private _effectLayerOptions;
  126222. private _mergeEffect;
  126223. protected _scene: Scene;
  126224. protected _engine: Engine;
  126225. protected _maxSize: number;
  126226. protected _mainTextureDesiredSize: ISize;
  126227. protected _mainTexture: RenderTargetTexture;
  126228. protected _shouldRender: boolean;
  126229. protected _postProcesses: PostProcess[];
  126230. protected _textures: BaseTexture[];
  126231. protected _emissiveTextureAndColor: {
  126232. texture: Nullable<BaseTexture>;
  126233. color: Color4;
  126234. };
  126235. /**
  126236. * The name of the layer
  126237. */
  126238. name: string;
  126239. /**
  126240. * The clear color of the texture used to generate the glow map.
  126241. */
  126242. neutralColor: Color4;
  126243. /**
  126244. * Specifies whether the highlight layer is enabled or not.
  126245. */
  126246. isEnabled: boolean;
  126247. /**
  126248. * Gets the camera attached to the layer.
  126249. */
  126250. get camera(): Nullable<Camera>;
  126251. /**
  126252. * Gets the rendering group id the layer should render in.
  126253. */
  126254. get renderingGroupId(): number;
  126255. set renderingGroupId(renderingGroupId: number);
  126256. /**
  126257. * An event triggered when the effect layer has been disposed.
  126258. */
  126259. onDisposeObservable: Observable<EffectLayer>;
  126260. /**
  126261. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126262. */
  126263. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126264. /**
  126265. * An event triggered when the generated texture is being merged in the scene.
  126266. */
  126267. onBeforeComposeObservable: Observable<EffectLayer>;
  126268. /**
  126269. * An event triggered when the mesh is rendered into the effect render target.
  126270. */
  126271. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126272. /**
  126273. * An event triggered after the mesh has been rendered into the effect render target.
  126274. */
  126275. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126276. /**
  126277. * An event triggered when the generated texture has been merged in the scene.
  126278. */
  126279. onAfterComposeObservable: Observable<EffectLayer>;
  126280. /**
  126281. * An event triggered when the efffect layer changes its size.
  126282. */
  126283. onSizeChangedObservable: Observable<EffectLayer>;
  126284. /** @hidden */
  126285. static _SceneComponentInitialization: (scene: Scene) => void;
  126286. /**
  126287. * Instantiates a new effect Layer and references it in the scene.
  126288. * @param name The name of the layer
  126289. * @param scene The scene to use the layer in
  126290. */
  126291. constructor(
  126292. /** The Friendly of the effect in the scene */
  126293. name: string, scene: Scene);
  126294. /**
  126295. * Get the effect name of the layer.
  126296. * @return The effect name
  126297. */
  126298. abstract getEffectName(): string;
  126299. /**
  126300. * Checks for the readiness of the element composing the layer.
  126301. * @param subMesh the mesh to check for
  126302. * @param useInstances specify whether or not to use instances to render the mesh
  126303. * @return true if ready otherwise, false
  126304. */
  126305. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126306. /**
  126307. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126308. * @returns true if the effect requires stencil during the main canvas render pass.
  126309. */
  126310. abstract needStencil(): boolean;
  126311. /**
  126312. * Create the merge effect. This is the shader use to blit the information back
  126313. * to the main canvas at the end of the scene rendering.
  126314. * @returns The effect containing the shader used to merge the effect on the main canvas
  126315. */
  126316. protected abstract _createMergeEffect(): Effect;
  126317. /**
  126318. * Creates the render target textures and post processes used in the effect layer.
  126319. */
  126320. protected abstract _createTextureAndPostProcesses(): void;
  126321. /**
  126322. * Implementation specific of rendering the generating effect on the main canvas.
  126323. * @param effect The effect used to render through
  126324. */
  126325. protected abstract _internalRender(effect: Effect): void;
  126326. /**
  126327. * Sets the required values for both the emissive texture and and the main color.
  126328. */
  126329. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126330. /**
  126331. * Free any resources and references associated to a mesh.
  126332. * Internal use
  126333. * @param mesh The mesh to free.
  126334. */
  126335. abstract _disposeMesh(mesh: Mesh): void;
  126336. /**
  126337. * Serializes this layer (Glow or Highlight for example)
  126338. * @returns a serialized layer object
  126339. */
  126340. abstract serialize?(): any;
  126341. /**
  126342. * Initializes the effect layer with the required options.
  126343. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126344. */
  126345. protected _init(options: Partial<IEffectLayerOptions>): void;
  126346. /**
  126347. * Generates the index buffer of the full screen quad blending to the main canvas.
  126348. */
  126349. private _generateIndexBuffer;
  126350. /**
  126351. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126352. */
  126353. private _generateVertexBuffer;
  126354. /**
  126355. * Sets the main texture desired size which is the closest power of two
  126356. * of the engine canvas size.
  126357. */
  126358. private _setMainTextureSize;
  126359. /**
  126360. * Creates the main texture for the effect layer.
  126361. */
  126362. protected _createMainTexture(): void;
  126363. /**
  126364. * Adds specific effects defines.
  126365. * @param defines The defines to add specifics to.
  126366. */
  126367. protected _addCustomEffectDefines(defines: string[]): void;
  126368. /**
  126369. * Checks for the readiness of the element composing the layer.
  126370. * @param subMesh the mesh to check for
  126371. * @param useInstances specify whether or not to use instances to render the mesh
  126372. * @param emissiveTexture the associated emissive texture used to generate the glow
  126373. * @return true if ready otherwise, false
  126374. */
  126375. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126376. /**
  126377. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126378. */
  126379. render(): void;
  126380. /**
  126381. * Determine if a given mesh will be used in the current effect.
  126382. * @param mesh mesh to test
  126383. * @returns true if the mesh will be used
  126384. */
  126385. hasMesh(mesh: AbstractMesh): boolean;
  126386. /**
  126387. * Returns true if the layer contains information to display, otherwise false.
  126388. * @returns true if the glow layer should be rendered
  126389. */
  126390. shouldRender(): boolean;
  126391. /**
  126392. * Returns true if the mesh should render, otherwise false.
  126393. * @param mesh The mesh to render
  126394. * @returns true if it should render otherwise false
  126395. */
  126396. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126397. /**
  126398. * Returns true if the mesh can be rendered, otherwise false.
  126399. * @param mesh The mesh to render
  126400. * @param material The material used on the mesh
  126401. * @returns true if it can be rendered otherwise false
  126402. */
  126403. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126404. /**
  126405. * Returns true if the mesh should render, otherwise false.
  126406. * @param mesh The mesh to render
  126407. * @returns true if it should render otherwise false
  126408. */
  126409. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126410. /**
  126411. * Renders the submesh passed in parameter to the generation map.
  126412. */
  126413. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126414. /**
  126415. * Defines whether the current material of the mesh should be use to render the effect.
  126416. * @param mesh defines the current mesh to render
  126417. */
  126418. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126419. /**
  126420. * Rebuild the required buffers.
  126421. * @hidden Internal use only.
  126422. */
  126423. _rebuild(): void;
  126424. /**
  126425. * Dispose only the render target textures and post process.
  126426. */
  126427. private _disposeTextureAndPostProcesses;
  126428. /**
  126429. * Dispose the highlight layer and free resources.
  126430. */
  126431. dispose(): void;
  126432. /**
  126433. * Gets the class name of the effect layer
  126434. * @returns the string with the class name of the effect layer
  126435. */
  126436. getClassName(): string;
  126437. /**
  126438. * Creates an effect layer from parsed effect layer data
  126439. * @param parsedEffectLayer defines effect layer data
  126440. * @param scene defines the current scene
  126441. * @param rootUrl defines the root URL containing the effect layer information
  126442. * @returns a parsed effect Layer
  126443. */
  126444. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126445. }
  126446. }
  126447. declare module BABYLON {
  126448. interface AbstractScene {
  126449. /**
  126450. * The list of effect layers (highlights/glow) added to the scene
  126451. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126452. * @see http://doc.babylonjs.com/how_to/glow_layer
  126453. */
  126454. effectLayers: Array<EffectLayer>;
  126455. /**
  126456. * Removes the given effect layer from this scene.
  126457. * @param toRemove defines the effect layer to remove
  126458. * @returns the index of the removed effect layer
  126459. */
  126460. removeEffectLayer(toRemove: EffectLayer): number;
  126461. /**
  126462. * Adds the given effect layer to this scene
  126463. * @param newEffectLayer defines the effect layer to add
  126464. */
  126465. addEffectLayer(newEffectLayer: EffectLayer): void;
  126466. }
  126467. /**
  126468. * Defines the layer scene component responsible to manage any effect layers
  126469. * in a given scene.
  126470. */
  126471. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126472. /**
  126473. * The component name helpfull to identify the component in the list of scene components.
  126474. */
  126475. readonly name: string;
  126476. /**
  126477. * The scene the component belongs to.
  126478. */
  126479. scene: Scene;
  126480. private _engine;
  126481. private _renderEffects;
  126482. private _needStencil;
  126483. private _previousStencilState;
  126484. /**
  126485. * Creates a new instance of the component for the given scene
  126486. * @param scene Defines the scene to register the component in
  126487. */
  126488. constructor(scene: Scene);
  126489. /**
  126490. * Registers the component in a given scene
  126491. */
  126492. register(): void;
  126493. /**
  126494. * Rebuilds the elements related to this component in case of
  126495. * context lost for instance.
  126496. */
  126497. rebuild(): void;
  126498. /**
  126499. * Serializes the component data to the specified json object
  126500. * @param serializationObject The object to serialize to
  126501. */
  126502. serialize(serializationObject: any): void;
  126503. /**
  126504. * Adds all the elements from the container to the scene
  126505. * @param container the container holding the elements
  126506. */
  126507. addFromContainer(container: AbstractScene): void;
  126508. /**
  126509. * Removes all the elements in the container from the scene
  126510. * @param container contains the elements to remove
  126511. * @param dispose if the removed element should be disposed (default: false)
  126512. */
  126513. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126514. /**
  126515. * Disposes the component and the associated ressources.
  126516. */
  126517. dispose(): void;
  126518. private _isReadyForMesh;
  126519. private _renderMainTexture;
  126520. private _setStencil;
  126521. private _setStencilBack;
  126522. private _draw;
  126523. private _drawCamera;
  126524. private _drawRenderingGroup;
  126525. }
  126526. }
  126527. declare module BABYLON {
  126528. /** @hidden */
  126529. export var glowMapMergePixelShader: {
  126530. name: string;
  126531. shader: string;
  126532. };
  126533. }
  126534. declare module BABYLON {
  126535. /** @hidden */
  126536. export var glowMapMergeVertexShader: {
  126537. name: string;
  126538. shader: string;
  126539. };
  126540. }
  126541. declare module BABYLON {
  126542. interface AbstractScene {
  126543. /**
  126544. * Return a the first highlight layer of the scene with a given name.
  126545. * @param name The name of the highlight layer to look for.
  126546. * @return The highlight layer if found otherwise null.
  126547. */
  126548. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126549. }
  126550. /**
  126551. * Glow layer options. This helps customizing the behaviour
  126552. * of the glow layer.
  126553. */
  126554. export interface IGlowLayerOptions {
  126555. /**
  126556. * Multiplication factor apply to the canvas size to compute the render target size
  126557. * used to generated the glowing objects (the smaller the faster).
  126558. */
  126559. mainTextureRatio: number;
  126560. /**
  126561. * Enforces a fixed size texture to ensure resize independant blur.
  126562. */
  126563. mainTextureFixedSize?: number;
  126564. /**
  126565. * How big is the kernel of the blur texture.
  126566. */
  126567. blurKernelSize: number;
  126568. /**
  126569. * The camera attached to the layer.
  126570. */
  126571. camera: Nullable<Camera>;
  126572. /**
  126573. * Enable MSAA by chosing the number of samples.
  126574. */
  126575. mainTextureSamples?: number;
  126576. /**
  126577. * The rendering group to draw the layer in.
  126578. */
  126579. renderingGroupId: number;
  126580. }
  126581. /**
  126582. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126583. *
  126584. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126585. *
  126586. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126587. */
  126588. export class GlowLayer extends EffectLayer {
  126589. /**
  126590. * Effect Name of the layer.
  126591. */
  126592. static readonly EffectName: string;
  126593. /**
  126594. * The default blur kernel size used for the glow.
  126595. */
  126596. static DefaultBlurKernelSize: number;
  126597. /**
  126598. * The default texture size ratio used for the glow.
  126599. */
  126600. static DefaultTextureRatio: number;
  126601. /**
  126602. * Sets the kernel size of the blur.
  126603. */
  126604. set blurKernelSize(value: number);
  126605. /**
  126606. * Gets the kernel size of the blur.
  126607. */
  126608. get blurKernelSize(): number;
  126609. /**
  126610. * Sets the glow intensity.
  126611. */
  126612. set intensity(value: number);
  126613. /**
  126614. * Gets the glow intensity.
  126615. */
  126616. get intensity(): number;
  126617. private _options;
  126618. private _intensity;
  126619. private _horizontalBlurPostprocess1;
  126620. private _verticalBlurPostprocess1;
  126621. private _horizontalBlurPostprocess2;
  126622. private _verticalBlurPostprocess2;
  126623. private _blurTexture1;
  126624. private _blurTexture2;
  126625. private _postProcesses1;
  126626. private _postProcesses2;
  126627. private _includedOnlyMeshes;
  126628. private _excludedMeshes;
  126629. private _meshesUsingTheirOwnMaterials;
  126630. /**
  126631. * Callback used to let the user override the color selection on a per mesh basis
  126632. */
  126633. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126634. /**
  126635. * Callback used to let the user override the texture selection on a per mesh basis
  126636. */
  126637. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126638. /**
  126639. * Instantiates a new glow Layer and references it to the scene.
  126640. * @param name The name of the layer
  126641. * @param scene The scene to use the layer in
  126642. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126643. */
  126644. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126645. /**
  126646. * Get the effect name of the layer.
  126647. * @return The effect name
  126648. */
  126649. getEffectName(): string;
  126650. /**
  126651. * Create the merge effect. This is the shader use to blit the information back
  126652. * to the main canvas at the end of the scene rendering.
  126653. */
  126654. protected _createMergeEffect(): Effect;
  126655. /**
  126656. * Creates the render target textures and post processes used in the glow layer.
  126657. */
  126658. protected _createTextureAndPostProcesses(): void;
  126659. /**
  126660. * Checks for the readiness of the element composing the layer.
  126661. * @param subMesh the mesh to check for
  126662. * @param useInstances specify wether or not to use instances to render the mesh
  126663. * @param emissiveTexture the associated emissive texture used to generate the glow
  126664. * @return true if ready otherwise, false
  126665. */
  126666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126667. /**
  126668. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126669. */
  126670. needStencil(): boolean;
  126671. /**
  126672. * Returns true if the mesh can be rendered, otherwise false.
  126673. * @param mesh The mesh to render
  126674. * @param material The material used on the mesh
  126675. * @returns true if it can be rendered otherwise false
  126676. */
  126677. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126678. /**
  126679. * Implementation specific of rendering the generating effect on the main canvas.
  126680. * @param effect The effect used to render through
  126681. */
  126682. protected _internalRender(effect: Effect): void;
  126683. /**
  126684. * Sets the required values for both the emissive texture and and the main color.
  126685. */
  126686. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126687. /**
  126688. * Returns true if the mesh should render, otherwise false.
  126689. * @param mesh The mesh to render
  126690. * @returns true if it should render otherwise false
  126691. */
  126692. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126693. /**
  126694. * Adds specific effects defines.
  126695. * @param defines The defines to add specifics to.
  126696. */
  126697. protected _addCustomEffectDefines(defines: string[]): void;
  126698. /**
  126699. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126700. * @param mesh The mesh to exclude from the glow layer
  126701. */
  126702. addExcludedMesh(mesh: Mesh): void;
  126703. /**
  126704. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126705. * @param mesh The mesh to remove
  126706. */
  126707. removeExcludedMesh(mesh: Mesh): void;
  126708. /**
  126709. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126710. * @param mesh The mesh to include in the glow layer
  126711. */
  126712. addIncludedOnlyMesh(mesh: Mesh): void;
  126713. /**
  126714. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126715. * @param mesh The mesh to remove
  126716. */
  126717. removeIncludedOnlyMesh(mesh: Mesh): void;
  126718. /**
  126719. * Determine if a given mesh will be used in the glow layer
  126720. * @param mesh The mesh to test
  126721. * @returns true if the mesh will be highlighted by the current glow layer
  126722. */
  126723. hasMesh(mesh: AbstractMesh): boolean;
  126724. /**
  126725. * Defines whether the current material of the mesh should be use to render the effect.
  126726. * @param mesh defines the current mesh to render
  126727. */
  126728. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126729. /**
  126730. * Add a mesh to be rendered through its own material and not with emissive only.
  126731. * @param mesh The mesh for which we need to use its material
  126732. */
  126733. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126734. /**
  126735. * Remove a mesh from being rendered through its own material and not with emissive only.
  126736. * @param mesh The mesh for which we need to not use its material
  126737. */
  126738. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126739. /**
  126740. * Free any resources and references associated to a mesh.
  126741. * Internal use
  126742. * @param mesh The mesh to free.
  126743. * @hidden
  126744. */
  126745. _disposeMesh(mesh: Mesh): void;
  126746. /**
  126747. * Gets the class name of the effect layer
  126748. * @returns the string with the class name of the effect layer
  126749. */
  126750. getClassName(): string;
  126751. /**
  126752. * Serializes this glow layer
  126753. * @returns a serialized glow layer object
  126754. */
  126755. serialize(): any;
  126756. /**
  126757. * Creates a Glow Layer from parsed glow layer data
  126758. * @param parsedGlowLayer defines glow layer data
  126759. * @param scene defines the current scene
  126760. * @param rootUrl defines the root URL containing the glow layer information
  126761. * @returns a parsed Glow Layer
  126762. */
  126763. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126764. }
  126765. }
  126766. declare module BABYLON {
  126767. /** @hidden */
  126768. export var glowBlurPostProcessPixelShader: {
  126769. name: string;
  126770. shader: string;
  126771. };
  126772. }
  126773. declare module BABYLON {
  126774. interface AbstractScene {
  126775. /**
  126776. * Return a the first highlight layer of the scene with a given name.
  126777. * @param name The name of the highlight layer to look for.
  126778. * @return The highlight layer if found otherwise null.
  126779. */
  126780. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126781. }
  126782. /**
  126783. * Highlight layer options. This helps customizing the behaviour
  126784. * of the highlight layer.
  126785. */
  126786. export interface IHighlightLayerOptions {
  126787. /**
  126788. * Multiplication factor apply to the canvas size to compute the render target size
  126789. * used to generated the glowing objects (the smaller the faster).
  126790. */
  126791. mainTextureRatio: number;
  126792. /**
  126793. * Enforces a fixed size texture to ensure resize independant blur.
  126794. */
  126795. mainTextureFixedSize?: number;
  126796. /**
  126797. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126798. * of the picture to blur (the smaller the faster).
  126799. */
  126800. blurTextureSizeRatio: number;
  126801. /**
  126802. * How big in texel of the blur texture is the vertical blur.
  126803. */
  126804. blurVerticalSize: number;
  126805. /**
  126806. * How big in texel of the blur texture is the horizontal blur.
  126807. */
  126808. blurHorizontalSize: number;
  126809. /**
  126810. * Alpha blending mode used to apply the blur. Default is combine.
  126811. */
  126812. alphaBlendingMode: number;
  126813. /**
  126814. * The camera attached to the layer.
  126815. */
  126816. camera: Nullable<Camera>;
  126817. /**
  126818. * Should we display highlight as a solid stroke?
  126819. */
  126820. isStroke?: boolean;
  126821. /**
  126822. * The rendering group to draw the layer in.
  126823. */
  126824. renderingGroupId: number;
  126825. }
  126826. /**
  126827. * The highlight layer Helps adding a glow effect around a mesh.
  126828. *
  126829. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126830. * glowy meshes to your scene.
  126831. *
  126832. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126833. */
  126834. export class HighlightLayer extends EffectLayer {
  126835. name: string;
  126836. /**
  126837. * Effect Name of the highlight layer.
  126838. */
  126839. static readonly EffectName: string;
  126840. /**
  126841. * The neutral color used during the preparation of the glow effect.
  126842. * This is black by default as the blend operation is a blend operation.
  126843. */
  126844. static NeutralColor: Color4;
  126845. /**
  126846. * Stencil value used for glowing meshes.
  126847. */
  126848. static GlowingMeshStencilReference: number;
  126849. /**
  126850. * Stencil value used for the other meshes in the scene.
  126851. */
  126852. static NormalMeshStencilReference: number;
  126853. /**
  126854. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126855. */
  126856. innerGlow: boolean;
  126857. /**
  126858. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126859. */
  126860. outerGlow: boolean;
  126861. /**
  126862. * Specifies the horizontal size of the blur.
  126863. */
  126864. set blurHorizontalSize(value: number);
  126865. /**
  126866. * Specifies the vertical size of the blur.
  126867. */
  126868. set blurVerticalSize(value: number);
  126869. /**
  126870. * Gets the horizontal size of the blur.
  126871. */
  126872. get blurHorizontalSize(): number;
  126873. /**
  126874. * Gets the vertical size of the blur.
  126875. */
  126876. get blurVerticalSize(): number;
  126877. /**
  126878. * An event triggered when the highlight layer is being blurred.
  126879. */
  126880. onBeforeBlurObservable: Observable<HighlightLayer>;
  126881. /**
  126882. * An event triggered when the highlight layer has been blurred.
  126883. */
  126884. onAfterBlurObservable: Observable<HighlightLayer>;
  126885. private _instanceGlowingMeshStencilReference;
  126886. private _options;
  126887. private _downSamplePostprocess;
  126888. private _horizontalBlurPostprocess;
  126889. private _verticalBlurPostprocess;
  126890. private _blurTexture;
  126891. private _meshes;
  126892. private _excludedMeshes;
  126893. /**
  126894. * Instantiates a new highlight Layer and references it to the scene..
  126895. * @param name The name of the layer
  126896. * @param scene The scene to use the layer in
  126897. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126898. */
  126899. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126900. /**
  126901. * Get the effect name of the layer.
  126902. * @return The effect name
  126903. */
  126904. getEffectName(): string;
  126905. /**
  126906. * Create the merge effect. This is the shader use to blit the information back
  126907. * to the main canvas at the end of the scene rendering.
  126908. */
  126909. protected _createMergeEffect(): Effect;
  126910. /**
  126911. * Creates the render target textures and post processes used in the highlight layer.
  126912. */
  126913. protected _createTextureAndPostProcesses(): void;
  126914. /**
  126915. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126916. */
  126917. needStencil(): boolean;
  126918. /**
  126919. * Checks for the readiness of the element composing the layer.
  126920. * @param subMesh the mesh to check for
  126921. * @param useInstances specify wether or not to use instances to render the mesh
  126922. * @param emissiveTexture the associated emissive texture used to generate the glow
  126923. * @return true if ready otherwise, false
  126924. */
  126925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126926. /**
  126927. * Implementation specific of rendering the generating effect on the main canvas.
  126928. * @param effect The effect used to render through
  126929. */
  126930. protected _internalRender(effect: Effect): void;
  126931. /**
  126932. * Returns true if the layer contains information to display, otherwise false.
  126933. */
  126934. shouldRender(): boolean;
  126935. /**
  126936. * Returns true if the mesh should render, otherwise false.
  126937. * @param mesh The mesh to render
  126938. * @returns true if it should render otherwise false
  126939. */
  126940. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126941. /**
  126942. * Sets the required values for both the emissive texture and and the main color.
  126943. */
  126944. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126945. /**
  126946. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126947. * @param mesh The mesh to exclude from the highlight layer
  126948. */
  126949. addExcludedMesh(mesh: Mesh): void;
  126950. /**
  126951. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126952. * @param mesh The mesh to highlight
  126953. */
  126954. removeExcludedMesh(mesh: Mesh): void;
  126955. /**
  126956. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126957. * @param mesh mesh to test
  126958. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126959. */
  126960. hasMesh(mesh: AbstractMesh): boolean;
  126961. /**
  126962. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126963. * @param mesh The mesh to highlight
  126964. * @param color The color of the highlight
  126965. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126966. */
  126967. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126968. /**
  126969. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126970. * @param mesh The mesh to highlight
  126971. */
  126972. removeMesh(mesh: Mesh): void;
  126973. /**
  126974. * Remove all the meshes currently referenced in the highlight layer
  126975. */
  126976. removeAllMeshes(): void;
  126977. /**
  126978. * Force the stencil to the normal expected value for none glowing parts
  126979. */
  126980. private _defaultStencilReference;
  126981. /**
  126982. * Free any resources and references associated to a mesh.
  126983. * Internal use
  126984. * @param mesh The mesh to free.
  126985. * @hidden
  126986. */
  126987. _disposeMesh(mesh: Mesh): void;
  126988. /**
  126989. * Dispose the highlight layer and free resources.
  126990. */
  126991. dispose(): void;
  126992. /**
  126993. * Gets the class name of the effect layer
  126994. * @returns the string with the class name of the effect layer
  126995. */
  126996. getClassName(): string;
  126997. /**
  126998. * Serializes this Highlight layer
  126999. * @returns a serialized Highlight layer object
  127000. */
  127001. serialize(): any;
  127002. /**
  127003. * Creates a Highlight layer from parsed Highlight layer data
  127004. * @param parsedHightlightLayer defines the Highlight layer data
  127005. * @param scene defines the current scene
  127006. * @param rootUrl defines the root URL containing the Highlight layer information
  127007. * @returns a parsed Highlight layer
  127008. */
  127009. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  127010. }
  127011. }
  127012. declare module BABYLON {
  127013. interface AbstractScene {
  127014. /**
  127015. * The list of layers (background and foreground) of the scene
  127016. */
  127017. layers: Array<Layer>;
  127018. }
  127019. /**
  127020. * Defines the layer scene component responsible to manage any layers
  127021. * in a given scene.
  127022. */
  127023. export class LayerSceneComponent implements ISceneComponent {
  127024. /**
  127025. * The component name helpfull to identify the component in the list of scene components.
  127026. */
  127027. readonly name: string;
  127028. /**
  127029. * The scene the component belongs to.
  127030. */
  127031. scene: Scene;
  127032. private _engine;
  127033. /**
  127034. * Creates a new instance of the component for the given scene
  127035. * @param scene Defines the scene to register the component in
  127036. */
  127037. constructor(scene: Scene);
  127038. /**
  127039. * Registers the component in a given scene
  127040. */
  127041. register(): void;
  127042. /**
  127043. * Rebuilds the elements related to this component in case of
  127044. * context lost for instance.
  127045. */
  127046. rebuild(): void;
  127047. /**
  127048. * Disposes the component and the associated ressources.
  127049. */
  127050. dispose(): void;
  127051. private _draw;
  127052. private _drawCameraPredicate;
  127053. private _drawCameraBackground;
  127054. private _drawCameraForeground;
  127055. private _drawRenderTargetPredicate;
  127056. private _drawRenderTargetBackground;
  127057. private _drawRenderTargetForeground;
  127058. /**
  127059. * Adds all the elements from the container to the scene
  127060. * @param container the container holding the elements
  127061. */
  127062. addFromContainer(container: AbstractScene): void;
  127063. /**
  127064. * Removes all the elements in the container from the scene
  127065. * @param container contains the elements to remove
  127066. * @param dispose if the removed element should be disposed (default: false)
  127067. */
  127068. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127069. }
  127070. }
  127071. declare module BABYLON {
  127072. /** @hidden */
  127073. export var layerPixelShader: {
  127074. name: string;
  127075. shader: string;
  127076. };
  127077. }
  127078. declare module BABYLON {
  127079. /** @hidden */
  127080. export var layerVertexShader: {
  127081. name: string;
  127082. shader: string;
  127083. };
  127084. }
  127085. declare module BABYLON {
  127086. /**
  127087. * This represents a full screen 2d layer.
  127088. * This can be useful to display a picture in the background of your scene for instance.
  127089. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127090. */
  127091. export class Layer {
  127092. /**
  127093. * Define the name of the layer.
  127094. */
  127095. name: string;
  127096. /**
  127097. * Define the texture the layer should display.
  127098. */
  127099. texture: Nullable<Texture>;
  127100. /**
  127101. * Is the layer in background or foreground.
  127102. */
  127103. isBackground: boolean;
  127104. /**
  127105. * Define the color of the layer (instead of texture).
  127106. */
  127107. color: Color4;
  127108. /**
  127109. * Define the scale of the layer in order to zoom in out of the texture.
  127110. */
  127111. scale: Vector2;
  127112. /**
  127113. * Define an offset for the layer in order to shift the texture.
  127114. */
  127115. offset: Vector2;
  127116. /**
  127117. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  127118. */
  127119. alphaBlendingMode: number;
  127120. /**
  127121. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  127122. * Alpha test will not mix with the background color in case of transparency.
  127123. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  127124. */
  127125. alphaTest: boolean;
  127126. /**
  127127. * Define a mask to restrict the layer to only some of the scene cameras.
  127128. */
  127129. layerMask: number;
  127130. /**
  127131. * Define the list of render target the layer is visible into.
  127132. */
  127133. renderTargetTextures: RenderTargetTexture[];
  127134. /**
  127135. * Define if the layer is only used in renderTarget or if it also
  127136. * renders in the main frame buffer of the canvas.
  127137. */
  127138. renderOnlyInRenderTargetTextures: boolean;
  127139. private _scene;
  127140. private _vertexBuffers;
  127141. private _indexBuffer;
  127142. private _effect;
  127143. private _previousDefines;
  127144. /**
  127145. * An event triggered when the layer is disposed.
  127146. */
  127147. onDisposeObservable: Observable<Layer>;
  127148. private _onDisposeObserver;
  127149. /**
  127150. * Back compatibility with callback before the onDisposeObservable existed.
  127151. * The set callback will be triggered when the layer has been disposed.
  127152. */
  127153. set onDispose(callback: () => void);
  127154. /**
  127155. * An event triggered before rendering the scene
  127156. */
  127157. onBeforeRenderObservable: Observable<Layer>;
  127158. private _onBeforeRenderObserver;
  127159. /**
  127160. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127161. * The set callback will be triggered just before rendering the layer.
  127162. */
  127163. set onBeforeRender(callback: () => void);
  127164. /**
  127165. * An event triggered after rendering the scene
  127166. */
  127167. onAfterRenderObservable: Observable<Layer>;
  127168. private _onAfterRenderObserver;
  127169. /**
  127170. * Back compatibility with callback before the onAfterRenderObservable existed.
  127171. * The set callback will be triggered just after rendering the layer.
  127172. */
  127173. set onAfterRender(callback: () => void);
  127174. /**
  127175. * Instantiates a new layer.
  127176. * This represents a full screen 2d layer.
  127177. * This can be useful to display a picture in the background of your scene for instance.
  127178. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127179. * @param name Define the name of the layer in the scene
  127180. * @param imgUrl Define the url of the texture to display in the layer
  127181. * @param scene Define the scene the layer belongs to
  127182. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127183. * @param color Defines a color for the layer
  127184. */
  127185. constructor(
  127186. /**
  127187. * Define the name of the layer.
  127188. */
  127189. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127190. private _createIndexBuffer;
  127191. /** @hidden */
  127192. _rebuild(): void;
  127193. /**
  127194. * Renders the layer in the scene.
  127195. */
  127196. render(): void;
  127197. /**
  127198. * Disposes and releases the associated ressources.
  127199. */
  127200. dispose(): void;
  127201. }
  127202. }
  127203. declare module BABYLON {
  127204. /** @hidden */
  127205. export var lensFlarePixelShader: {
  127206. name: string;
  127207. shader: string;
  127208. };
  127209. }
  127210. declare module BABYLON {
  127211. /** @hidden */
  127212. export var lensFlareVertexShader: {
  127213. name: string;
  127214. shader: string;
  127215. };
  127216. }
  127217. declare module BABYLON {
  127218. /**
  127219. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127220. * It is usually composed of several `lensFlare`.
  127221. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127222. */
  127223. export class LensFlareSystem {
  127224. /**
  127225. * Define the name of the lens flare system
  127226. */
  127227. name: string;
  127228. /**
  127229. * List of lens flares used in this system.
  127230. */
  127231. lensFlares: LensFlare[];
  127232. /**
  127233. * Define a limit from the border the lens flare can be visible.
  127234. */
  127235. borderLimit: number;
  127236. /**
  127237. * Define a viewport border we do not want to see the lens flare in.
  127238. */
  127239. viewportBorder: number;
  127240. /**
  127241. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127242. */
  127243. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127244. /**
  127245. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127246. */
  127247. layerMask: number;
  127248. /**
  127249. * Define the id of the lens flare system in the scene.
  127250. * (equal to name by default)
  127251. */
  127252. id: string;
  127253. private _scene;
  127254. private _emitter;
  127255. private _vertexBuffers;
  127256. private _indexBuffer;
  127257. private _effect;
  127258. private _positionX;
  127259. private _positionY;
  127260. private _isEnabled;
  127261. /** @hidden */
  127262. static _SceneComponentInitialization: (scene: Scene) => void;
  127263. /**
  127264. * Instantiates a lens flare system.
  127265. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127266. * It is usually composed of several `lensFlare`.
  127267. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127268. * @param name Define the name of the lens flare system in the scene
  127269. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127270. * @param scene Define the scene the lens flare system belongs to
  127271. */
  127272. constructor(
  127273. /**
  127274. * Define the name of the lens flare system
  127275. */
  127276. name: string, emitter: any, scene: Scene);
  127277. /**
  127278. * Define if the lens flare system is enabled.
  127279. */
  127280. get isEnabled(): boolean;
  127281. set isEnabled(value: boolean);
  127282. /**
  127283. * Get the scene the effects belongs to.
  127284. * @returns the scene holding the lens flare system
  127285. */
  127286. getScene(): Scene;
  127287. /**
  127288. * Get the emitter of the lens flare system.
  127289. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127290. * @returns the emitter of the lens flare system
  127291. */
  127292. getEmitter(): any;
  127293. /**
  127294. * Set the emitter of the lens flare system.
  127295. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127296. * @param newEmitter Define the new emitter of the system
  127297. */
  127298. setEmitter(newEmitter: any): void;
  127299. /**
  127300. * Get the lens flare system emitter position.
  127301. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127302. * @returns the position
  127303. */
  127304. getEmitterPosition(): Vector3;
  127305. /**
  127306. * @hidden
  127307. */
  127308. computeEffectivePosition(globalViewport: Viewport): boolean;
  127309. /** @hidden */
  127310. _isVisible(): boolean;
  127311. /**
  127312. * @hidden
  127313. */
  127314. render(): boolean;
  127315. /**
  127316. * Dispose and release the lens flare with its associated resources.
  127317. */
  127318. dispose(): void;
  127319. /**
  127320. * Parse a lens flare system from a JSON repressentation
  127321. * @param parsedLensFlareSystem Define the JSON to parse
  127322. * @param scene Define the scene the parsed system should be instantiated in
  127323. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127324. * @returns the parsed system
  127325. */
  127326. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127327. /**
  127328. * Serialize the current Lens Flare System into a JSON representation.
  127329. * @returns the serialized JSON
  127330. */
  127331. serialize(): any;
  127332. }
  127333. }
  127334. declare module BABYLON {
  127335. /**
  127336. * This represents one of the lens effect in a `lensFlareSystem`.
  127337. * It controls one of the indiviual texture used in the effect.
  127338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127339. */
  127340. export class LensFlare {
  127341. /**
  127342. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127343. */
  127344. size: number;
  127345. /**
  127346. * 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.
  127347. */
  127348. position: number;
  127349. /**
  127350. * Define the lens color.
  127351. */
  127352. color: Color3;
  127353. /**
  127354. * Define the lens texture.
  127355. */
  127356. texture: Nullable<Texture>;
  127357. /**
  127358. * Define the alpha mode to render this particular lens.
  127359. */
  127360. alphaMode: number;
  127361. private _system;
  127362. /**
  127363. * Creates a new Lens Flare.
  127364. * This represents one of the lens effect in a `lensFlareSystem`.
  127365. * It controls one of the indiviual texture used in the effect.
  127366. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127367. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127368. * @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.
  127369. * @param color Define the lens color
  127370. * @param imgUrl Define the lens texture url
  127371. * @param system Define the `lensFlareSystem` this flare is part of
  127372. * @returns The newly created Lens Flare
  127373. */
  127374. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127375. /**
  127376. * Instantiates a new Lens Flare.
  127377. * This represents one of the lens effect in a `lensFlareSystem`.
  127378. * It controls one of the indiviual texture used in the effect.
  127379. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127380. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127381. * @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.
  127382. * @param color Define the lens color
  127383. * @param imgUrl Define the lens texture url
  127384. * @param system Define the `lensFlareSystem` this flare is part of
  127385. */
  127386. constructor(
  127387. /**
  127388. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127389. */
  127390. size: number,
  127391. /**
  127392. * 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.
  127393. */
  127394. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127395. /**
  127396. * Dispose and release the lens flare with its associated resources.
  127397. */
  127398. dispose(): void;
  127399. }
  127400. }
  127401. declare module BABYLON {
  127402. interface AbstractScene {
  127403. /**
  127404. * The list of lens flare system added to the scene
  127405. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127406. */
  127407. lensFlareSystems: Array<LensFlareSystem>;
  127408. /**
  127409. * Removes the given lens flare system from this scene.
  127410. * @param toRemove The lens flare system to remove
  127411. * @returns The index of the removed lens flare system
  127412. */
  127413. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127414. /**
  127415. * Adds the given lens flare system to this scene
  127416. * @param newLensFlareSystem The lens flare system to add
  127417. */
  127418. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127419. /**
  127420. * Gets a lens flare system using its name
  127421. * @param name defines the name to look for
  127422. * @returns the lens flare system or null if not found
  127423. */
  127424. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127425. /**
  127426. * Gets a lens flare system using its id
  127427. * @param id defines the id to look for
  127428. * @returns the lens flare system or null if not found
  127429. */
  127430. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127431. }
  127432. /**
  127433. * Defines the lens flare scene component responsible to manage any lens flares
  127434. * in a given scene.
  127435. */
  127436. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127437. /**
  127438. * The component name helpfull to identify the component in the list of scene components.
  127439. */
  127440. readonly name: string;
  127441. /**
  127442. * The scene the component belongs to.
  127443. */
  127444. scene: Scene;
  127445. /**
  127446. * Creates a new instance of the component for the given scene
  127447. * @param scene Defines the scene to register the component in
  127448. */
  127449. constructor(scene: Scene);
  127450. /**
  127451. * Registers the component in a given scene
  127452. */
  127453. register(): void;
  127454. /**
  127455. * Rebuilds the elements related to this component in case of
  127456. * context lost for instance.
  127457. */
  127458. rebuild(): void;
  127459. /**
  127460. * Adds all the elements from the container to the scene
  127461. * @param container the container holding the elements
  127462. */
  127463. addFromContainer(container: AbstractScene): void;
  127464. /**
  127465. * Removes all the elements in the container from the scene
  127466. * @param container contains the elements to remove
  127467. * @param dispose if the removed element should be disposed (default: false)
  127468. */
  127469. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127470. /**
  127471. * Serializes the component data to the specified json object
  127472. * @param serializationObject The object to serialize to
  127473. */
  127474. serialize(serializationObject: any): void;
  127475. /**
  127476. * Disposes the component and the associated ressources.
  127477. */
  127478. dispose(): void;
  127479. private _draw;
  127480. }
  127481. }
  127482. declare module BABYLON {
  127483. /** @hidden */
  127484. export var depthPixelShader: {
  127485. name: string;
  127486. shader: string;
  127487. };
  127488. }
  127489. declare module BABYLON {
  127490. /** @hidden */
  127491. export var depthVertexShader: {
  127492. name: string;
  127493. shader: string;
  127494. };
  127495. }
  127496. declare module BABYLON {
  127497. /**
  127498. * This represents a depth renderer in Babylon.
  127499. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127500. */
  127501. export class DepthRenderer {
  127502. private _scene;
  127503. private _depthMap;
  127504. private _effect;
  127505. private readonly _storeNonLinearDepth;
  127506. private readonly _clearColor;
  127507. /** Get if the depth renderer is using packed depth or not */
  127508. readonly isPacked: boolean;
  127509. private _cachedDefines;
  127510. private _camera;
  127511. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127512. enabled: boolean;
  127513. /**
  127514. * Specifiess that the depth renderer will only be used within
  127515. * the camera it is created for.
  127516. * This can help forcing its rendering during the camera processing.
  127517. */
  127518. useOnlyInActiveCamera: boolean;
  127519. /** @hidden */
  127520. static _SceneComponentInitialization: (scene: Scene) => void;
  127521. /**
  127522. * Instantiates a depth renderer
  127523. * @param scene The scene the renderer belongs to
  127524. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127525. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127526. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127527. */
  127528. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127529. /**
  127530. * Creates the depth rendering effect and checks if the effect is ready.
  127531. * @param subMesh The submesh to be used to render the depth map of
  127532. * @param useInstances If multiple world instances should be used
  127533. * @returns if the depth renderer is ready to render the depth map
  127534. */
  127535. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127536. /**
  127537. * Gets the texture which the depth map will be written to.
  127538. * @returns The depth map texture
  127539. */
  127540. getDepthMap(): RenderTargetTexture;
  127541. /**
  127542. * Disposes of the depth renderer.
  127543. */
  127544. dispose(): void;
  127545. }
  127546. }
  127547. declare module BABYLON {
  127548. /** @hidden */
  127549. export var minmaxReduxPixelShader: {
  127550. name: string;
  127551. shader: string;
  127552. };
  127553. }
  127554. declare module BABYLON {
  127555. /**
  127556. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127557. * and maximum values from all values of the texture.
  127558. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127559. * The source values are read from the red channel of the texture.
  127560. */
  127561. export class MinMaxReducer {
  127562. /**
  127563. * Observable triggered when the computation has been performed
  127564. */
  127565. onAfterReductionPerformed: Observable<{
  127566. min: number;
  127567. max: number;
  127568. }>;
  127569. protected _camera: Camera;
  127570. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127571. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127572. protected _postProcessManager: PostProcessManager;
  127573. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127574. protected _forceFullscreenViewport: boolean;
  127575. /**
  127576. * Creates a min/max reducer
  127577. * @param camera The camera to use for the post processes
  127578. */
  127579. constructor(camera: Camera);
  127580. /**
  127581. * Gets the texture used to read the values from.
  127582. */
  127583. get sourceTexture(): Nullable<RenderTargetTexture>;
  127584. /**
  127585. * Sets the source texture to read the values from.
  127586. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127587. * because in such textures '1' value must not be taken into account to compute the maximum
  127588. * as this value is used to clear the texture.
  127589. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127590. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127591. * @param depthRedux Indicates if the texture is a depth texture or not
  127592. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127593. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127594. */
  127595. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127596. /**
  127597. * Defines the refresh rate of the computation.
  127598. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127599. */
  127600. get refreshRate(): number;
  127601. set refreshRate(value: number);
  127602. protected _activated: boolean;
  127603. /**
  127604. * Gets the activation status of the reducer
  127605. */
  127606. get activated(): boolean;
  127607. /**
  127608. * Activates the reduction computation.
  127609. * When activated, the observers registered in onAfterReductionPerformed are
  127610. * called after the compuation is performed
  127611. */
  127612. activate(): void;
  127613. /**
  127614. * Deactivates the reduction computation.
  127615. */
  127616. deactivate(): void;
  127617. /**
  127618. * Disposes the min/max reducer
  127619. * @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.
  127620. */
  127621. dispose(disposeAll?: boolean): void;
  127622. }
  127623. }
  127624. declare module BABYLON {
  127625. /**
  127626. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127627. */
  127628. export class DepthReducer extends MinMaxReducer {
  127629. private _depthRenderer;
  127630. private _depthRendererId;
  127631. /**
  127632. * Gets the depth renderer used for the computation.
  127633. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127634. */
  127635. get depthRenderer(): Nullable<DepthRenderer>;
  127636. /**
  127637. * Creates a depth reducer
  127638. * @param camera The camera used to render the depth texture
  127639. */
  127640. constructor(camera: Camera);
  127641. /**
  127642. * Sets the depth renderer to use to generate the depth map
  127643. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127644. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127645. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127646. */
  127647. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127648. /** @hidden */
  127649. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127650. /**
  127651. * Activates the reduction computation.
  127652. * When activated, the observers registered in onAfterReductionPerformed are
  127653. * called after the compuation is performed
  127654. */
  127655. activate(): void;
  127656. /**
  127657. * Deactivates the reduction computation.
  127658. */
  127659. deactivate(): void;
  127660. /**
  127661. * Disposes the depth reducer
  127662. * @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.
  127663. */
  127664. dispose(disposeAll?: boolean): void;
  127665. }
  127666. }
  127667. declare module BABYLON {
  127668. /**
  127669. * A CSM implementation allowing casting shadows on large scenes.
  127670. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127671. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127672. */
  127673. export class CascadedShadowGenerator extends ShadowGenerator {
  127674. private static readonly frustumCornersNDCSpace;
  127675. /**
  127676. * Name of the CSM class
  127677. */
  127678. static CLASSNAME: string;
  127679. /**
  127680. * Defines the default number of cascades used by the CSM.
  127681. */
  127682. static readonly DEFAULT_CASCADES_COUNT: number;
  127683. /**
  127684. * Defines the minimum number of cascades used by the CSM.
  127685. */
  127686. static readonly MIN_CASCADES_COUNT: number;
  127687. /**
  127688. * Defines the maximum number of cascades used by the CSM.
  127689. */
  127690. static readonly MAX_CASCADES_COUNT: number;
  127691. protected _validateFilter(filter: number): number;
  127692. /**
  127693. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127694. */
  127695. penumbraDarkness: number;
  127696. private _numCascades;
  127697. /**
  127698. * Gets or set the number of cascades used by the CSM.
  127699. */
  127700. get numCascades(): number;
  127701. set numCascades(value: number);
  127702. /**
  127703. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127704. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127705. */
  127706. stabilizeCascades: boolean;
  127707. private _freezeShadowCastersBoundingInfo;
  127708. private _freezeShadowCastersBoundingInfoObservable;
  127709. /**
  127710. * Enables or disables the shadow casters bounding info computation.
  127711. * If your shadow casters don't move, you can disable this feature.
  127712. * If it is enabled, the bounding box computation is done every frame.
  127713. */
  127714. get freezeShadowCastersBoundingInfo(): boolean;
  127715. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127716. private _scbiMin;
  127717. private _scbiMax;
  127718. protected _computeShadowCastersBoundingInfo(): void;
  127719. protected _shadowCastersBoundingInfo: BoundingInfo;
  127720. /**
  127721. * Gets or sets the shadow casters bounding info.
  127722. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127723. * so that the system won't overwrite the bounds you provide
  127724. */
  127725. get shadowCastersBoundingInfo(): BoundingInfo;
  127726. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127727. protected _breaksAreDirty: boolean;
  127728. protected _minDistance: number;
  127729. protected _maxDistance: number;
  127730. /**
  127731. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127732. *
  127733. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127734. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127735. * @param min minimal distance for the breaks (default to 0.)
  127736. * @param max maximal distance for the breaks (default to 1.)
  127737. */
  127738. setMinMaxDistance(min: number, max: number): void;
  127739. /** Gets the minimal distance used in the cascade break computation */
  127740. get minDistance(): number;
  127741. /** Gets the maximal distance used in the cascade break computation */
  127742. get maxDistance(): number;
  127743. /**
  127744. * Gets the class name of that object
  127745. * @returns "CascadedShadowGenerator"
  127746. */
  127747. getClassName(): string;
  127748. private _cascadeMinExtents;
  127749. private _cascadeMaxExtents;
  127750. /**
  127751. * Gets a cascade minimum extents
  127752. * @param cascadeIndex index of the cascade
  127753. * @returns the minimum cascade extents
  127754. */
  127755. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127756. /**
  127757. * Gets a cascade maximum extents
  127758. * @param cascadeIndex index of the cascade
  127759. * @returns the maximum cascade extents
  127760. */
  127761. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127762. private _cascades;
  127763. private _currentLayer;
  127764. private _viewSpaceFrustumsZ;
  127765. private _viewMatrices;
  127766. private _projectionMatrices;
  127767. private _transformMatrices;
  127768. private _transformMatricesAsArray;
  127769. private _frustumLengths;
  127770. private _lightSizeUVCorrection;
  127771. private _depthCorrection;
  127772. private _frustumCornersWorldSpace;
  127773. private _frustumCenter;
  127774. private _shadowCameraPos;
  127775. private _shadowMaxZ;
  127776. /**
  127777. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127778. * It defaults to camera.maxZ
  127779. */
  127780. get shadowMaxZ(): number;
  127781. /**
  127782. * Sets the shadow max z distance.
  127783. */
  127784. set shadowMaxZ(value: number);
  127785. protected _debug: boolean;
  127786. /**
  127787. * Gets or sets the debug flag.
  127788. * When enabled, the cascades are materialized by different colors on the screen.
  127789. */
  127790. get debug(): boolean;
  127791. set debug(dbg: boolean);
  127792. private _depthClamp;
  127793. /**
  127794. * Gets or sets the depth clamping value.
  127795. *
  127796. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127797. * to account for the shadow casters far away.
  127798. *
  127799. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127800. */
  127801. get depthClamp(): boolean;
  127802. set depthClamp(value: boolean);
  127803. private _cascadeBlendPercentage;
  127804. /**
  127805. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127806. * It defaults to 0.1 (10% blending).
  127807. */
  127808. get cascadeBlendPercentage(): number;
  127809. set cascadeBlendPercentage(value: number);
  127810. private _lambda;
  127811. /**
  127812. * Gets or set the lambda parameter.
  127813. * This parameter is used to split the camera frustum and create the cascades.
  127814. * 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.
  127815. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127816. */
  127817. get lambda(): number;
  127818. set lambda(value: number);
  127819. /**
  127820. * Gets the view matrix corresponding to a given cascade
  127821. * @param cascadeNum cascade to retrieve the view matrix from
  127822. * @returns the cascade view matrix
  127823. */
  127824. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127825. /**
  127826. * Gets the projection matrix corresponding to a given cascade
  127827. * @param cascadeNum cascade to retrieve the projection matrix from
  127828. * @returns the cascade projection matrix
  127829. */
  127830. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127831. /**
  127832. * Gets the transformation matrix corresponding to a given cascade
  127833. * @param cascadeNum cascade to retrieve the transformation matrix from
  127834. * @returns the cascade transformation matrix
  127835. */
  127836. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127837. private _depthRenderer;
  127838. /**
  127839. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127840. *
  127841. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127842. *
  127843. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127844. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127845. * @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
  127846. */
  127847. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127848. private _depthReducer;
  127849. private _autoCalcDepthBounds;
  127850. /**
  127851. * Gets or sets the autoCalcDepthBounds property.
  127852. *
  127853. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127854. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127855. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127856. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127857. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127858. */
  127859. get autoCalcDepthBounds(): boolean;
  127860. set autoCalcDepthBounds(value: boolean);
  127861. /**
  127862. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127863. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127864. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127865. * for setting the refresh rate on the renderer yourself!
  127866. */
  127867. get autoCalcDepthBoundsRefreshRate(): number;
  127868. set autoCalcDepthBoundsRefreshRate(value: number);
  127869. /**
  127870. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127871. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127872. * you change the camera near/far planes!
  127873. */
  127874. splitFrustum(): void;
  127875. private _splitFrustum;
  127876. private _computeMatrices;
  127877. private _computeFrustumInWorldSpace;
  127878. private _computeCascadeFrustum;
  127879. /** @hidden */
  127880. static _SceneComponentInitialization: (scene: Scene) => void;
  127881. /**
  127882. * Creates a Cascaded Shadow Generator object.
  127883. * A ShadowGenerator is the required tool to use the shadows.
  127884. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127885. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127886. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127887. * @param light The directional light object generating the shadows.
  127888. * @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.
  127889. */
  127890. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127891. protected _initializeGenerator(): void;
  127892. protected _createTargetRenderTexture(): void;
  127893. protected _initializeShadowMap(): void;
  127894. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127895. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127896. /**
  127897. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127898. * @param defines Defines of the material we want to update
  127899. * @param lightIndex Index of the light in the enabled light list of the material
  127900. */
  127901. prepareDefines(defines: any, lightIndex: number): void;
  127902. /**
  127903. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127904. * defined in the generator but impacting the effect).
  127905. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127906. * @param effect The effect we are binfing the information for
  127907. */
  127908. bindShadowLight(lightIndex: string, effect: Effect): void;
  127909. /**
  127910. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127911. * (eq to view projection * shadow projection matrices)
  127912. * @returns The transform matrix used to create the shadow map
  127913. */
  127914. getTransformMatrix(): Matrix;
  127915. /**
  127916. * Disposes the ShadowGenerator.
  127917. * Returns nothing.
  127918. */
  127919. dispose(): void;
  127920. /**
  127921. * Serializes the shadow generator setup to a json object.
  127922. * @returns The serialized JSON object
  127923. */
  127924. serialize(): any;
  127925. /**
  127926. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127927. * @param parsedShadowGenerator The JSON object to parse
  127928. * @param scene The scene to create the shadow map for
  127929. * @returns The parsed shadow generator
  127930. */
  127931. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127932. }
  127933. }
  127934. declare module BABYLON {
  127935. /**
  127936. * Defines the shadow generator component responsible to manage any shadow generators
  127937. * in a given scene.
  127938. */
  127939. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127940. /**
  127941. * The component name helpfull to identify the component in the list of scene components.
  127942. */
  127943. readonly name: string;
  127944. /**
  127945. * The scene the component belongs to.
  127946. */
  127947. scene: Scene;
  127948. /**
  127949. * Creates a new instance of the component for the given scene
  127950. * @param scene Defines the scene to register the component in
  127951. */
  127952. constructor(scene: Scene);
  127953. /**
  127954. * Registers the component in a given scene
  127955. */
  127956. register(): void;
  127957. /**
  127958. * Rebuilds the elements related to this component in case of
  127959. * context lost for instance.
  127960. */
  127961. rebuild(): void;
  127962. /**
  127963. * Serializes the component data to the specified json object
  127964. * @param serializationObject The object to serialize to
  127965. */
  127966. serialize(serializationObject: any): void;
  127967. /**
  127968. * Adds all the elements from the container to the scene
  127969. * @param container the container holding the elements
  127970. */
  127971. addFromContainer(container: AbstractScene): void;
  127972. /**
  127973. * Removes all the elements in the container from the scene
  127974. * @param container contains the elements to remove
  127975. * @param dispose if the removed element should be disposed (default: false)
  127976. */
  127977. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127978. /**
  127979. * Rebuilds the elements related to this component in case of
  127980. * context lost for instance.
  127981. */
  127982. dispose(): void;
  127983. private _gatherRenderTargets;
  127984. }
  127985. }
  127986. declare module BABYLON {
  127987. /**
  127988. * A point light is a light defined by an unique point in world space.
  127989. * The light is emitted in every direction from this point.
  127990. * A good example of a point light is a standard light bulb.
  127991. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127992. */
  127993. export class PointLight extends ShadowLight {
  127994. private _shadowAngle;
  127995. /**
  127996. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127997. * This specifies what angle the shadow will use to be created.
  127998. *
  127999. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128000. */
  128001. get shadowAngle(): number;
  128002. /**
  128003. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128004. * This specifies what angle the shadow will use to be created.
  128005. *
  128006. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128007. */
  128008. set shadowAngle(value: number);
  128009. /**
  128010. * Gets the direction if it has been set.
  128011. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128012. */
  128013. get direction(): Vector3;
  128014. /**
  128015. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128016. */
  128017. set direction(value: Vector3);
  128018. /**
  128019. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  128020. * A PointLight emits the light in every direction.
  128021. * It can cast shadows.
  128022. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  128023. * ```javascript
  128024. * var pointLight = new PointLight("pl", camera.position, scene);
  128025. * ```
  128026. * Documentation : https://doc.babylonjs.com/babylon101/lights
  128027. * @param name The light friendly name
  128028. * @param position The position of the point light in the scene
  128029. * @param scene The scene the lights belongs to
  128030. */
  128031. constructor(name: string, position: Vector3, scene: Scene);
  128032. /**
  128033. * Returns the string "PointLight"
  128034. * @returns the class name
  128035. */
  128036. getClassName(): string;
  128037. /**
  128038. * Returns the integer 0.
  128039. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  128040. */
  128041. getTypeID(): number;
  128042. /**
  128043. * Specifies wether or not the shadowmap should be a cube texture.
  128044. * @returns true if the shadowmap needs to be a cube texture.
  128045. */
  128046. needCube(): boolean;
  128047. /**
  128048. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  128049. * @param faceIndex The index of the face we are computed the direction to generate shadow
  128050. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  128051. */
  128052. getShadowDirection(faceIndex?: number): Vector3;
  128053. /**
  128054. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  128055. * - fov = PI / 2
  128056. * - aspect ratio : 1.0
  128057. * - z-near and far equal to the active camera minZ and maxZ.
  128058. * Returns the PointLight.
  128059. */
  128060. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  128061. protected _buildUniformLayout(): void;
  128062. /**
  128063. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  128064. * @param effect The effect to update
  128065. * @param lightIndex The index of the light in the effect to update
  128066. * @returns The point light
  128067. */
  128068. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  128069. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  128070. /**
  128071. * Prepares the list of defines specific to the light type.
  128072. * @param defines the list of defines
  128073. * @param lightIndex defines the index of the light for the effect
  128074. */
  128075. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  128076. }
  128077. }
  128078. declare module BABYLON {
  128079. /**
  128080. * Header information of HDR texture files.
  128081. */
  128082. export interface HDRInfo {
  128083. /**
  128084. * The height of the texture in pixels.
  128085. */
  128086. height: number;
  128087. /**
  128088. * The width of the texture in pixels.
  128089. */
  128090. width: number;
  128091. /**
  128092. * The index of the beginning of the data in the binary file.
  128093. */
  128094. dataPosition: number;
  128095. }
  128096. /**
  128097. * This groups tools to convert HDR texture to native colors array.
  128098. */
  128099. export class HDRTools {
  128100. private static Ldexp;
  128101. private static Rgbe2float;
  128102. private static readStringLine;
  128103. /**
  128104. * Reads header information from an RGBE texture stored in a native array.
  128105. * More information on this format are available here:
  128106. * https://en.wikipedia.org/wiki/RGBE_image_format
  128107. *
  128108. * @param uint8array The binary file stored in native array.
  128109. * @return The header information.
  128110. */
  128111. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  128112. /**
  128113. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  128114. * This RGBE texture needs to store the information as a panorama.
  128115. *
  128116. * More information on this format are available here:
  128117. * https://en.wikipedia.org/wiki/RGBE_image_format
  128118. *
  128119. * @param buffer The binary file stored in an array buffer.
  128120. * @param size The expected size of the extracted cubemap.
  128121. * @return The Cube Map information.
  128122. */
  128123. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  128124. /**
  128125. * Returns the pixels data extracted from an RGBE texture.
  128126. * This pixels will be stored left to right up to down in the R G B order in one array.
  128127. *
  128128. * More information on this format are available here:
  128129. * https://en.wikipedia.org/wiki/RGBE_image_format
  128130. *
  128131. * @param uint8array The binary file stored in an array buffer.
  128132. * @param hdrInfo The header information of the file.
  128133. * @return The pixels data in RGB right to left up to down order.
  128134. */
  128135. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  128136. private static RGBE_ReadPixels_RLE;
  128137. }
  128138. }
  128139. declare module BABYLON {
  128140. /**
  128141. * This represents a texture coming from an HDR input.
  128142. *
  128143. * The only supported format is currently panorama picture stored in RGBE format.
  128144. * Example of such files can be found on HDRLib: http://hdrlib.com/
  128145. */
  128146. export class HDRCubeTexture extends BaseTexture {
  128147. private static _facesMapping;
  128148. private _generateHarmonics;
  128149. private _noMipmap;
  128150. private _textureMatrix;
  128151. private _size;
  128152. private _onLoad;
  128153. private _onError;
  128154. /**
  128155. * The texture URL.
  128156. */
  128157. url: string;
  128158. /**
  128159. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128160. */
  128161. coordinatesMode: number;
  128162. protected _isBlocking: boolean;
  128163. /**
  128164. * Sets wether or not the texture is blocking during loading.
  128165. */
  128166. set isBlocking(value: boolean);
  128167. /**
  128168. * Gets wether or not the texture is blocking during loading.
  128169. */
  128170. get isBlocking(): boolean;
  128171. protected _rotationY: number;
  128172. /**
  128173. * Sets texture matrix rotation angle around Y axis in radians.
  128174. */
  128175. set rotationY(value: number);
  128176. /**
  128177. * Gets texture matrix rotation angle around Y axis radians.
  128178. */
  128179. get rotationY(): number;
  128180. /**
  128181. * Gets or sets the center of the bounding box associated with the cube texture
  128182. * It must define where the camera used to render the texture was set
  128183. */
  128184. boundingBoxPosition: Vector3;
  128185. private _boundingBoxSize;
  128186. /**
  128187. * Gets or sets the size of the bounding box associated with the cube texture
  128188. * When defined, the cubemap will switch to local mode
  128189. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128190. * @example https://www.babylonjs-playground.com/#RNASML
  128191. */
  128192. set boundingBoxSize(value: Vector3);
  128193. get boundingBoxSize(): Vector3;
  128194. /**
  128195. * Instantiates an HDRTexture from the following parameters.
  128196. *
  128197. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128198. * @param scene The scene the texture will be used in
  128199. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128200. * @param noMipmap Forces to not generate the mipmap if true
  128201. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128202. * @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)
  128203. * @param reserved Reserved flag for internal use.
  128204. */
  128205. 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>);
  128206. /**
  128207. * Get the current class name of the texture useful for serialization or dynamic coding.
  128208. * @returns "HDRCubeTexture"
  128209. */
  128210. getClassName(): string;
  128211. /**
  128212. * Occurs when the file is raw .hdr file.
  128213. */
  128214. private loadTexture;
  128215. clone(): HDRCubeTexture;
  128216. delayLoad(): void;
  128217. /**
  128218. * Get the texture reflection matrix used to rotate/transform the reflection.
  128219. * @returns the reflection matrix
  128220. */
  128221. getReflectionTextureMatrix(): Matrix;
  128222. /**
  128223. * Set the texture reflection matrix used to rotate/transform the reflection.
  128224. * @param value Define the reflection matrix to set
  128225. */
  128226. setReflectionTextureMatrix(value: Matrix): void;
  128227. /**
  128228. * Parses a JSON representation of an HDR Texture in order to create the texture
  128229. * @param parsedTexture Define the JSON representation
  128230. * @param scene Define the scene the texture should be created in
  128231. * @param rootUrl Define the root url in case we need to load relative dependencies
  128232. * @returns the newly created texture after parsing
  128233. */
  128234. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128235. serialize(): any;
  128236. }
  128237. }
  128238. declare module BABYLON {
  128239. /**
  128240. * Class used to control physics engine
  128241. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128242. */
  128243. export class PhysicsEngine implements IPhysicsEngine {
  128244. private _physicsPlugin;
  128245. /**
  128246. * Global value used to control the smallest number supported by the simulation
  128247. */
  128248. static Epsilon: number;
  128249. private _impostors;
  128250. private _joints;
  128251. private _subTimeStep;
  128252. /**
  128253. * Gets the gravity vector used by the simulation
  128254. */
  128255. gravity: Vector3;
  128256. /**
  128257. * Factory used to create the default physics plugin.
  128258. * @returns The default physics plugin
  128259. */
  128260. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128261. /**
  128262. * Creates a new Physics Engine
  128263. * @param gravity defines the gravity vector used by the simulation
  128264. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128265. */
  128266. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128267. /**
  128268. * Sets the gravity vector used by the simulation
  128269. * @param gravity defines the gravity vector to use
  128270. */
  128271. setGravity(gravity: Vector3): void;
  128272. /**
  128273. * Set the time step of the physics engine.
  128274. * Default is 1/60.
  128275. * To slow it down, enter 1/600 for example.
  128276. * To speed it up, 1/30
  128277. * @param newTimeStep defines the new timestep to apply to this world.
  128278. */
  128279. setTimeStep(newTimeStep?: number): void;
  128280. /**
  128281. * Get the time step of the physics engine.
  128282. * @returns the current time step
  128283. */
  128284. getTimeStep(): number;
  128285. /**
  128286. * Set the sub time step of the physics engine.
  128287. * Default is 0 meaning there is no sub steps
  128288. * To increase physics resolution precision, set a small value (like 1 ms)
  128289. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128290. */
  128291. setSubTimeStep(subTimeStep?: number): void;
  128292. /**
  128293. * Get the sub time step of the physics engine.
  128294. * @returns the current sub time step
  128295. */
  128296. getSubTimeStep(): number;
  128297. /**
  128298. * Release all resources
  128299. */
  128300. dispose(): void;
  128301. /**
  128302. * Gets the name of the current physics plugin
  128303. * @returns the name of the plugin
  128304. */
  128305. getPhysicsPluginName(): string;
  128306. /**
  128307. * Adding a new impostor for the impostor tracking.
  128308. * This will be done by the impostor itself.
  128309. * @param impostor the impostor to add
  128310. */
  128311. addImpostor(impostor: PhysicsImpostor): void;
  128312. /**
  128313. * Remove an impostor from the engine.
  128314. * This impostor and its mesh will not longer be updated by the physics engine.
  128315. * @param impostor the impostor to remove
  128316. */
  128317. removeImpostor(impostor: PhysicsImpostor): void;
  128318. /**
  128319. * Add a joint to the physics engine
  128320. * @param mainImpostor defines the main impostor to which the joint is added.
  128321. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128322. * @param joint defines the joint that will connect both impostors.
  128323. */
  128324. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128325. /**
  128326. * Removes a joint from the simulation
  128327. * @param mainImpostor defines the impostor used with the joint
  128328. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128329. * @param joint defines the joint to remove
  128330. */
  128331. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128332. /**
  128333. * Called by the scene. No need to call it.
  128334. * @param delta defines the timespam between frames
  128335. */
  128336. _step(delta: number): void;
  128337. /**
  128338. * Gets the current plugin used to run the simulation
  128339. * @returns current plugin
  128340. */
  128341. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128342. /**
  128343. * Gets the list of physic impostors
  128344. * @returns an array of PhysicsImpostor
  128345. */
  128346. getImpostors(): Array<PhysicsImpostor>;
  128347. /**
  128348. * Gets the impostor for a physics enabled object
  128349. * @param object defines the object impersonated by the impostor
  128350. * @returns the PhysicsImpostor or null if not found
  128351. */
  128352. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128353. /**
  128354. * Gets the impostor for a physics body object
  128355. * @param body defines physics body used by the impostor
  128356. * @returns the PhysicsImpostor or null if not found
  128357. */
  128358. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128359. /**
  128360. * Does a raycast in the physics world
  128361. * @param from when should the ray start?
  128362. * @param to when should the ray end?
  128363. * @returns PhysicsRaycastResult
  128364. */
  128365. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128366. }
  128367. }
  128368. declare module BABYLON {
  128369. /** @hidden */
  128370. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128371. private _useDeltaForWorldStep;
  128372. world: any;
  128373. name: string;
  128374. private _physicsMaterials;
  128375. private _fixedTimeStep;
  128376. private _cannonRaycastResult;
  128377. private _raycastResult;
  128378. private _physicsBodysToRemoveAfterStep;
  128379. BJSCANNON: any;
  128380. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128381. setGravity(gravity: Vector3): void;
  128382. setTimeStep(timeStep: number): void;
  128383. getTimeStep(): number;
  128384. executeStep(delta: number): void;
  128385. private _removeMarkedPhysicsBodiesFromWorld;
  128386. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128387. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128388. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128389. private _processChildMeshes;
  128390. removePhysicsBody(impostor: PhysicsImpostor): void;
  128391. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128392. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128393. private _addMaterial;
  128394. private _checkWithEpsilon;
  128395. private _createShape;
  128396. private _createHeightmap;
  128397. private _minus90X;
  128398. private _plus90X;
  128399. private _tmpPosition;
  128400. private _tmpDeltaPosition;
  128401. private _tmpUnityRotation;
  128402. private _updatePhysicsBodyTransformation;
  128403. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128404. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128405. isSupported(): boolean;
  128406. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128407. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128408. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128409. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128410. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128411. getBodyMass(impostor: PhysicsImpostor): number;
  128412. getBodyFriction(impostor: PhysicsImpostor): number;
  128413. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128414. getBodyRestitution(impostor: PhysicsImpostor): number;
  128415. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128416. sleepBody(impostor: PhysicsImpostor): void;
  128417. wakeUpBody(impostor: PhysicsImpostor): void;
  128418. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128419. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128420. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128421. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128422. getRadius(impostor: PhysicsImpostor): number;
  128423. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128424. dispose(): void;
  128425. private _extendNamespace;
  128426. /**
  128427. * Does a raycast in the physics world
  128428. * @param from when should the ray start?
  128429. * @param to when should the ray end?
  128430. * @returns PhysicsRaycastResult
  128431. */
  128432. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128433. }
  128434. }
  128435. declare module BABYLON {
  128436. /** @hidden */
  128437. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128438. world: any;
  128439. name: string;
  128440. BJSOIMO: any;
  128441. private _raycastResult;
  128442. constructor(iterations?: number, oimoInjection?: any);
  128443. setGravity(gravity: Vector3): void;
  128444. setTimeStep(timeStep: number): void;
  128445. getTimeStep(): number;
  128446. private _tmpImpostorsArray;
  128447. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128448. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128449. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128450. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128451. private _tmpPositionVector;
  128452. removePhysicsBody(impostor: PhysicsImpostor): void;
  128453. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128454. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128455. isSupported(): boolean;
  128456. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128457. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128458. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128459. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128460. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128461. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128462. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128463. getBodyMass(impostor: PhysicsImpostor): number;
  128464. getBodyFriction(impostor: PhysicsImpostor): number;
  128465. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128466. getBodyRestitution(impostor: PhysicsImpostor): number;
  128467. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128468. sleepBody(impostor: PhysicsImpostor): void;
  128469. wakeUpBody(impostor: PhysicsImpostor): void;
  128470. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128471. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128472. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128473. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128474. getRadius(impostor: PhysicsImpostor): number;
  128475. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128476. dispose(): void;
  128477. /**
  128478. * Does a raycast in the physics world
  128479. * @param from when should the ray start?
  128480. * @param to when should the ray end?
  128481. * @returns PhysicsRaycastResult
  128482. */
  128483. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128484. }
  128485. }
  128486. declare module BABYLON {
  128487. /**
  128488. * Class containing static functions to help procedurally build meshes
  128489. */
  128490. export class RibbonBuilder {
  128491. /**
  128492. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128493. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128494. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128495. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128496. * * 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
  128497. * * 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
  128498. * * 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
  128499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128502. * * 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
  128503. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128504. * * 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
  128505. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128507. * @param name defines the name of the mesh
  128508. * @param options defines the options used to create the mesh
  128509. * @param scene defines the hosting scene
  128510. * @returns the ribbon mesh
  128511. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128512. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128513. */
  128514. static CreateRibbon(name: string, options: {
  128515. pathArray: Vector3[][];
  128516. closeArray?: boolean;
  128517. closePath?: boolean;
  128518. offset?: number;
  128519. updatable?: boolean;
  128520. sideOrientation?: number;
  128521. frontUVs?: Vector4;
  128522. backUVs?: Vector4;
  128523. instance?: Mesh;
  128524. invertUV?: boolean;
  128525. uvs?: Vector2[];
  128526. colors?: Color4[];
  128527. }, scene?: Nullable<Scene>): Mesh;
  128528. }
  128529. }
  128530. declare module BABYLON {
  128531. /**
  128532. * Class containing static functions to help procedurally build meshes
  128533. */
  128534. export class ShapeBuilder {
  128535. /**
  128536. * 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.
  128537. * * 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.
  128538. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128539. * * 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.
  128540. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128541. * * 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
  128542. * * 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
  128543. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128548. * @param name defines the name of the mesh
  128549. * @param options defines the options used to create the mesh
  128550. * @param scene defines the hosting scene
  128551. * @returns the extruded shape mesh
  128552. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128554. */
  128555. static ExtrudeShape(name: string, options: {
  128556. shape: Vector3[];
  128557. path: Vector3[];
  128558. scale?: number;
  128559. rotation?: number;
  128560. cap?: number;
  128561. updatable?: boolean;
  128562. sideOrientation?: number;
  128563. frontUVs?: Vector4;
  128564. backUVs?: Vector4;
  128565. instance?: Mesh;
  128566. invertUV?: boolean;
  128567. }, scene?: Nullable<Scene>): Mesh;
  128568. /**
  128569. * Creates an custom extruded shape mesh.
  128570. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128571. * * 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.
  128572. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128573. * * 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
  128574. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128575. * * 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
  128576. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128577. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128578. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128579. * * 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
  128580. * * 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
  128581. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128586. * @param name defines the name of the mesh
  128587. * @param options defines the options used to create the mesh
  128588. * @param scene defines the hosting scene
  128589. * @returns the custom extruded shape mesh
  128590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128593. */
  128594. static ExtrudeShapeCustom(name: string, options: {
  128595. shape: Vector3[];
  128596. path: Vector3[];
  128597. scaleFunction?: any;
  128598. rotationFunction?: any;
  128599. ribbonCloseArray?: boolean;
  128600. ribbonClosePath?: boolean;
  128601. cap?: number;
  128602. updatable?: boolean;
  128603. sideOrientation?: number;
  128604. frontUVs?: Vector4;
  128605. backUVs?: Vector4;
  128606. instance?: Mesh;
  128607. invertUV?: boolean;
  128608. }, scene?: Nullable<Scene>): Mesh;
  128609. private static _ExtrudeShapeGeneric;
  128610. }
  128611. }
  128612. declare module BABYLON {
  128613. /**
  128614. * AmmoJS Physics plugin
  128615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128616. * @see https://github.com/kripken/ammo.js/
  128617. */
  128618. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128619. private _useDeltaForWorldStep;
  128620. /**
  128621. * Reference to the Ammo library
  128622. */
  128623. bjsAMMO: any;
  128624. /**
  128625. * Created ammoJS world which physics bodies are added to
  128626. */
  128627. world: any;
  128628. /**
  128629. * Name of the plugin
  128630. */
  128631. name: string;
  128632. private _timeStep;
  128633. private _fixedTimeStep;
  128634. private _maxSteps;
  128635. private _tmpQuaternion;
  128636. private _tmpAmmoTransform;
  128637. private _tmpAmmoQuaternion;
  128638. private _tmpAmmoConcreteContactResultCallback;
  128639. private _collisionConfiguration;
  128640. private _dispatcher;
  128641. private _overlappingPairCache;
  128642. private _solver;
  128643. private _softBodySolver;
  128644. private _tmpAmmoVectorA;
  128645. private _tmpAmmoVectorB;
  128646. private _tmpAmmoVectorC;
  128647. private _tmpAmmoVectorD;
  128648. private _tmpContactCallbackResult;
  128649. private _tmpAmmoVectorRCA;
  128650. private _tmpAmmoVectorRCB;
  128651. private _raycastResult;
  128652. private static readonly DISABLE_COLLISION_FLAG;
  128653. private static readonly KINEMATIC_FLAG;
  128654. private static readonly DISABLE_DEACTIVATION_FLAG;
  128655. /**
  128656. * Initializes the ammoJS plugin
  128657. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128658. * @param ammoInjection can be used to inject your own ammo reference
  128659. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128660. */
  128661. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128662. /**
  128663. * Sets the gravity of the physics world (m/(s^2))
  128664. * @param gravity Gravity to set
  128665. */
  128666. setGravity(gravity: Vector3): void;
  128667. /**
  128668. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128669. * @param timeStep timestep to use in seconds
  128670. */
  128671. setTimeStep(timeStep: number): void;
  128672. /**
  128673. * 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)
  128674. * @param fixedTimeStep fixedTimeStep to use in seconds
  128675. */
  128676. setFixedTimeStep(fixedTimeStep: number): void;
  128677. /**
  128678. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128679. * @param maxSteps the maximum number of steps by the physics engine per frame
  128680. */
  128681. setMaxSteps(maxSteps: number): void;
  128682. /**
  128683. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128684. * @returns the current timestep in seconds
  128685. */
  128686. getTimeStep(): number;
  128687. /**
  128688. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128689. */
  128690. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128691. private _isImpostorInContact;
  128692. private _isImpostorPairInContact;
  128693. private _stepSimulation;
  128694. /**
  128695. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128696. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128697. * After the step the babylon meshes are set to the position of the physics imposters
  128698. * @param delta amount of time to step forward
  128699. * @param impostors array of imposters to update before/after the step
  128700. */
  128701. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128702. /**
  128703. * Update babylon mesh to match physics world object
  128704. * @param impostor imposter to match
  128705. */
  128706. private _afterSoftStep;
  128707. /**
  128708. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128709. * @param impostor imposter to match
  128710. */
  128711. private _ropeStep;
  128712. /**
  128713. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128714. * @param impostor imposter to match
  128715. */
  128716. private _softbodyOrClothStep;
  128717. private _tmpVector;
  128718. private _tmpMatrix;
  128719. /**
  128720. * Applies an impulse on the imposter
  128721. * @param impostor imposter to apply impulse to
  128722. * @param force amount of force to be applied to the imposter
  128723. * @param contactPoint the location to apply the impulse on the imposter
  128724. */
  128725. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128726. /**
  128727. * Applies a force on the imposter
  128728. * @param impostor imposter to apply force
  128729. * @param force amount of force to be applied to the imposter
  128730. * @param contactPoint the location to apply the force on the imposter
  128731. */
  128732. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128733. /**
  128734. * Creates a physics body using the plugin
  128735. * @param impostor the imposter to create the physics body on
  128736. */
  128737. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128738. /**
  128739. * Removes the physics body from the imposter and disposes of the body's memory
  128740. * @param impostor imposter to remove the physics body from
  128741. */
  128742. removePhysicsBody(impostor: PhysicsImpostor): void;
  128743. /**
  128744. * Generates a joint
  128745. * @param impostorJoint the imposter joint to create the joint with
  128746. */
  128747. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128748. /**
  128749. * Removes a joint
  128750. * @param impostorJoint the imposter joint to remove the joint from
  128751. */
  128752. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128753. private _addMeshVerts;
  128754. /**
  128755. * Initialise the soft body vertices to match its object's (mesh) vertices
  128756. * Softbody vertices (nodes) are in world space and to match this
  128757. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128758. * @param impostor to create the softbody for
  128759. */
  128760. private _softVertexData;
  128761. /**
  128762. * Create an impostor's soft body
  128763. * @param impostor to create the softbody for
  128764. */
  128765. private _createSoftbody;
  128766. /**
  128767. * Create cloth for an impostor
  128768. * @param impostor to create the softbody for
  128769. */
  128770. private _createCloth;
  128771. /**
  128772. * Create rope for an impostor
  128773. * @param impostor to create the softbody for
  128774. */
  128775. private _createRope;
  128776. /**
  128777. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128778. * @param impostor to create the custom physics shape for
  128779. */
  128780. private _createCustom;
  128781. private _addHullVerts;
  128782. private _createShape;
  128783. /**
  128784. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128785. * @param impostor imposter containing the physics body and babylon object
  128786. */
  128787. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128788. /**
  128789. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128790. * @param impostor imposter containing the physics body and babylon object
  128791. * @param newPosition new position
  128792. * @param newRotation new rotation
  128793. */
  128794. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128795. /**
  128796. * If this plugin is supported
  128797. * @returns true if its supported
  128798. */
  128799. isSupported(): boolean;
  128800. /**
  128801. * Sets the linear velocity of the physics body
  128802. * @param impostor imposter to set the velocity on
  128803. * @param velocity velocity to set
  128804. */
  128805. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128806. /**
  128807. * Sets the angular velocity of the physics body
  128808. * @param impostor imposter to set the velocity on
  128809. * @param velocity velocity to set
  128810. */
  128811. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128812. /**
  128813. * gets the linear velocity
  128814. * @param impostor imposter to get linear velocity from
  128815. * @returns linear velocity
  128816. */
  128817. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128818. /**
  128819. * gets the angular velocity
  128820. * @param impostor imposter to get angular velocity from
  128821. * @returns angular velocity
  128822. */
  128823. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128824. /**
  128825. * Sets the mass of physics body
  128826. * @param impostor imposter to set the mass on
  128827. * @param mass mass to set
  128828. */
  128829. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128830. /**
  128831. * Gets the mass of the physics body
  128832. * @param impostor imposter to get the mass from
  128833. * @returns mass
  128834. */
  128835. getBodyMass(impostor: PhysicsImpostor): number;
  128836. /**
  128837. * Gets friction of the impostor
  128838. * @param impostor impostor to get friction from
  128839. * @returns friction value
  128840. */
  128841. getBodyFriction(impostor: PhysicsImpostor): number;
  128842. /**
  128843. * Sets friction of the impostor
  128844. * @param impostor impostor to set friction on
  128845. * @param friction friction value
  128846. */
  128847. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128848. /**
  128849. * Gets restitution of the impostor
  128850. * @param impostor impostor to get restitution from
  128851. * @returns restitution value
  128852. */
  128853. getBodyRestitution(impostor: PhysicsImpostor): number;
  128854. /**
  128855. * Sets resitution of the impostor
  128856. * @param impostor impostor to set resitution on
  128857. * @param restitution resitution value
  128858. */
  128859. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128860. /**
  128861. * Gets pressure inside the impostor
  128862. * @param impostor impostor to get pressure from
  128863. * @returns pressure value
  128864. */
  128865. getBodyPressure(impostor: PhysicsImpostor): number;
  128866. /**
  128867. * Sets pressure inside a soft body impostor
  128868. * Cloth and rope must remain 0 pressure
  128869. * @param impostor impostor to set pressure on
  128870. * @param pressure pressure value
  128871. */
  128872. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128873. /**
  128874. * Gets stiffness of the impostor
  128875. * @param impostor impostor to get stiffness from
  128876. * @returns pressure value
  128877. */
  128878. getBodyStiffness(impostor: PhysicsImpostor): number;
  128879. /**
  128880. * Sets stiffness of the impostor
  128881. * @param impostor impostor to set stiffness on
  128882. * @param stiffness stiffness value from 0 to 1
  128883. */
  128884. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128885. /**
  128886. * Gets velocityIterations of the impostor
  128887. * @param impostor impostor to get velocity iterations from
  128888. * @returns velocityIterations value
  128889. */
  128890. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128891. /**
  128892. * Sets velocityIterations of the impostor
  128893. * @param impostor impostor to set velocity iterations on
  128894. * @param velocityIterations velocityIterations value
  128895. */
  128896. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128897. /**
  128898. * Gets positionIterations of the impostor
  128899. * @param impostor impostor to get position iterations from
  128900. * @returns positionIterations value
  128901. */
  128902. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128903. /**
  128904. * Sets positionIterations of the impostor
  128905. * @param impostor impostor to set position on
  128906. * @param positionIterations positionIterations value
  128907. */
  128908. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128909. /**
  128910. * Append an anchor to a cloth object
  128911. * @param impostor is the cloth impostor to add anchor to
  128912. * @param otherImpostor is the rigid impostor to anchor to
  128913. * @param width ratio across width from 0 to 1
  128914. * @param height ratio up height from 0 to 1
  128915. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128916. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128917. */
  128918. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128919. /**
  128920. * Append an hook to a rope object
  128921. * @param impostor is the rope impostor to add hook to
  128922. * @param otherImpostor is the rigid impostor to hook to
  128923. * @param length ratio along the rope from 0 to 1
  128924. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128925. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128926. */
  128927. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128928. /**
  128929. * Sleeps the physics body and stops it from being active
  128930. * @param impostor impostor to sleep
  128931. */
  128932. sleepBody(impostor: PhysicsImpostor): void;
  128933. /**
  128934. * Activates the physics body
  128935. * @param impostor impostor to activate
  128936. */
  128937. wakeUpBody(impostor: PhysicsImpostor): void;
  128938. /**
  128939. * Updates the distance parameters of the joint
  128940. * @param joint joint to update
  128941. * @param maxDistance maximum distance of the joint
  128942. * @param minDistance minimum distance of the joint
  128943. */
  128944. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128945. /**
  128946. * Sets a motor on the joint
  128947. * @param joint joint to set motor on
  128948. * @param speed speed of the motor
  128949. * @param maxForce maximum force of the motor
  128950. * @param motorIndex index of the motor
  128951. */
  128952. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128953. /**
  128954. * Sets the motors limit
  128955. * @param joint joint to set limit on
  128956. * @param upperLimit upper limit
  128957. * @param lowerLimit lower limit
  128958. */
  128959. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128960. /**
  128961. * Syncs the position and rotation of a mesh with the impostor
  128962. * @param mesh mesh to sync
  128963. * @param impostor impostor to update the mesh with
  128964. */
  128965. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128966. /**
  128967. * Gets the radius of the impostor
  128968. * @param impostor impostor to get radius from
  128969. * @returns the radius
  128970. */
  128971. getRadius(impostor: PhysicsImpostor): number;
  128972. /**
  128973. * Gets the box size of the impostor
  128974. * @param impostor impostor to get box size from
  128975. * @param result the resulting box size
  128976. */
  128977. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128978. /**
  128979. * Disposes of the impostor
  128980. */
  128981. dispose(): void;
  128982. /**
  128983. * Does a raycast in the physics world
  128984. * @param from when should the ray start?
  128985. * @param to when should the ray end?
  128986. * @returns PhysicsRaycastResult
  128987. */
  128988. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128989. }
  128990. }
  128991. declare module BABYLON {
  128992. interface AbstractScene {
  128993. /**
  128994. * The list of reflection probes added to the scene
  128995. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128996. */
  128997. reflectionProbes: Array<ReflectionProbe>;
  128998. /**
  128999. * Removes the given reflection probe from this scene.
  129000. * @param toRemove The reflection probe to remove
  129001. * @returns The index of the removed reflection probe
  129002. */
  129003. removeReflectionProbe(toRemove: ReflectionProbe): number;
  129004. /**
  129005. * Adds the given reflection probe to this scene.
  129006. * @param newReflectionProbe The reflection probe to add
  129007. */
  129008. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  129009. }
  129010. /**
  129011. * Class used to generate realtime reflection / refraction cube textures
  129012. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129013. */
  129014. export class ReflectionProbe {
  129015. /** defines the name of the probe */
  129016. name: string;
  129017. private _scene;
  129018. private _renderTargetTexture;
  129019. private _projectionMatrix;
  129020. private _viewMatrix;
  129021. private _target;
  129022. private _add;
  129023. private _attachedMesh;
  129024. private _invertYAxis;
  129025. /** Gets or sets probe position (center of the cube map) */
  129026. position: Vector3;
  129027. /**
  129028. * Creates a new reflection probe
  129029. * @param name defines the name of the probe
  129030. * @param size defines the texture resolution (for each face)
  129031. * @param scene defines the hosting scene
  129032. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  129033. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  129034. */
  129035. constructor(
  129036. /** defines the name of the probe */
  129037. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  129038. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  129039. get samples(): number;
  129040. set samples(value: number);
  129041. /** Gets or sets the refresh rate to use (on every frame by default) */
  129042. get refreshRate(): number;
  129043. set refreshRate(value: number);
  129044. /**
  129045. * Gets the hosting scene
  129046. * @returns a Scene
  129047. */
  129048. getScene(): Scene;
  129049. /** Gets the internal CubeTexture used to render to */
  129050. get cubeTexture(): RenderTargetTexture;
  129051. /** Gets the list of meshes to render */
  129052. get renderList(): Nullable<AbstractMesh[]>;
  129053. /**
  129054. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  129055. * @param mesh defines the mesh to attach to
  129056. */
  129057. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129058. /**
  129059. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  129060. * @param renderingGroupId The rendering group id corresponding to its index
  129061. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  129062. */
  129063. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  129064. /**
  129065. * Clean all associated resources
  129066. */
  129067. dispose(): void;
  129068. /**
  129069. * Converts the reflection probe information to a readable string for debug purpose.
  129070. * @param fullDetails Supports for multiple levels of logging within scene loading
  129071. * @returns the human readable reflection probe info
  129072. */
  129073. toString(fullDetails?: boolean): string;
  129074. /**
  129075. * Get the class name of the relfection probe.
  129076. * @returns "ReflectionProbe"
  129077. */
  129078. getClassName(): string;
  129079. /**
  129080. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  129081. * @returns The JSON representation of the texture
  129082. */
  129083. serialize(): any;
  129084. /**
  129085. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  129086. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  129087. * @param scene Define the scene the parsed reflection probe should be instantiated in
  129088. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  129089. * @returns The parsed reflection probe if successful
  129090. */
  129091. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  129092. }
  129093. }
  129094. declare module BABYLON {
  129095. /** @hidden */
  129096. export var _BabylonLoaderRegistered: boolean;
  129097. /**
  129098. * Helps setting up some configuration for the babylon file loader.
  129099. */
  129100. export class BabylonFileLoaderConfiguration {
  129101. /**
  129102. * The loader does not allow injecting custom physix engine into the plugins.
  129103. * Unfortunately in ES6, we need to manually inject them into the plugin.
  129104. * So you could set this variable to your engine import to make it work.
  129105. */
  129106. static LoaderInjectedPhysicsEngine: any;
  129107. }
  129108. }
  129109. declare module BABYLON {
  129110. /**
  129111. * The Physically based simple base material of BJS.
  129112. *
  129113. * This enables better naming and convention enforcements on top of the pbrMaterial.
  129114. * It is used as the base class for both the specGloss and metalRough conventions.
  129115. */
  129116. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  129117. /**
  129118. * Number of Simultaneous lights allowed on the material.
  129119. */
  129120. maxSimultaneousLights: number;
  129121. /**
  129122. * If sets to true, disables all the lights affecting the material.
  129123. */
  129124. disableLighting: boolean;
  129125. /**
  129126. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  129127. */
  129128. environmentTexture: BaseTexture;
  129129. /**
  129130. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  129131. */
  129132. invertNormalMapX: boolean;
  129133. /**
  129134. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  129135. */
  129136. invertNormalMapY: boolean;
  129137. /**
  129138. * Normal map used in the model.
  129139. */
  129140. normalTexture: BaseTexture;
  129141. /**
  129142. * Emissivie color used to self-illuminate the model.
  129143. */
  129144. emissiveColor: Color3;
  129145. /**
  129146. * Emissivie texture used to self-illuminate the model.
  129147. */
  129148. emissiveTexture: BaseTexture;
  129149. /**
  129150. * Occlusion Channel Strenght.
  129151. */
  129152. occlusionStrength: number;
  129153. /**
  129154. * Occlusion Texture of the material (adding extra occlusion effects).
  129155. */
  129156. occlusionTexture: BaseTexture;
  129157. /**
  129158. * Defines the alpha limits in alpha test mode.
  129159. */
  129160. alphaCutOff: number;
  129161. /**
  129162. * Gets the current double sided mode.
  129163. */
  129164. get doubleSided(): boolean;
  129165. /**
  129166. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129167. */
  129168. set doubleSided(value: boolean);
  129169. /**
  129170. * Stores the pre-calculated light information of a mesh in a texture.
  129171. */
  129172. lightmapTexture: BaseTexture;
  129173. /**
  129174. * If true, the light map contains occlusion information instead of lighting info.
  129175. */
  129176. useLightmapAsShadowmap: boolean;
  129177. /**
  129178. * Instantiates a new PBRMaterial instance.
  129179. *
  129180. * @param name The material name
  129181. * @param scene The scene the material will be use in.
  129182. */
  129183. constructor(name: string, scene: Scene);
  129184. getClassName(): string;
  129185. }
  129186. }
  129187. declare module BABYLON {
  129188. /**
  129189. * The PBR material of BJS following the metal roughness convention.
  129190. *
  129191. * This fits to the PBR convention in the GLTF definition:
  129192. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129193. */
  129194. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129195. /**
  129196. * The base color has two different interpretations depending on the value of metalness.
  129197. * When the material is a metal, the base color is the specific measured reflectance value
  129198. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129199. * of the material.
  129200. */
  129201. baseColor: Color3;
  129202. /**
  129203. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129204. * well as opacity information in the alpha channel.
  129205. */
  129206. baseTexture: BaseTexture;
  129207. /**
  129208. * Specifies the metallic scalar value of the material.
  129209. * Can also be used to scale the metalness values of the metallic texture.
  129210. */
  129211. metallic: number;
  129212. /**
  129213. * Specifies the roughness scalar value of the material.
  129214. * Can also be used to scale the roughness values of the metallic texture.
  129215. */
  129216. roughness: number;
  129217. /**
  129218. * Texture containing both the metallic value in the B channel and the
  129219. * roughness value in the G channel to keep better precision.
  129220. */
  129221. metallicRoughnessTexture: BaseTexture;
  129222. /**
  129223. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129224. *
  129225. * @param name The material name
  129226. * @param scene The scene the material will be use in.
  129227. */
  129228. constructor(name: string, scene: Scene);
  129229. /**
  129230. * Return the currrent class name of the material.
  129231. */
  129232. getClassName(): string;
  129233. /**
  129234. * Makes a duplicate of the current material.
  129235. * @param name - name to use for the new material.
  129236. */
  129237. clone(name: string): PBRMetallicRoughnessMaterial;
  129238. /**
  129239. * Serialize the material to a parsable JSON object.
  129240. */
  129241. serialize(): any;
  129242. /**
  129243. * Parses a JSON object correponding to the serialize function.
  129244. */
  129245. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129246. }
  129247. }
  129248. declare module BABYLON {
  129249. /**
  129250. * The PBR material of BJS following the specular glossiness convention.
  129251. *
  129252. * This fits to the PBR convention in the GLTF definition:
  129253. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129254. */
  129255. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129256. /**
  129257. * Specifies the diffuse color of the material.
  129258. */
  129259. diffuseColor: Color3;
  129260. /**
  129261. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129262. * channel.
  129263. */
  129264. diffuseTexture: BaseTexture;
  129265. /**
  129266. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129267. */
  129268. specularColor: Color3;
  129269. /**
  129270. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129271. */
  129272. glossiness: number;
  129273. /**
  129274. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129275. */
  129276. specularGlossinessTexture: BaseTexture;
  129277. /**
  129278. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129279. *
  129280. * @param name The material name
  129281. * @param scene The scene the material will be use in.
  129282. */
  129283. constructor(name: string, scene: Scene);
  129284. /**
  129285. * Return the currrent class name of the material.
  129286. */
  129287. getClassName(): string;
  129288. /**
  129289. * Makes a duplicate of the current material.
  129290. * @param name - name to use for the new material.
  129291. */
  129292. clone(name: string): PBRSpecularGlossinessMaterial;
  129293. /**
  129294. * Serialize the material to a parsable JSON object.
  129295. */
  129296. serialize(): any;
  129297. /**
  129298. * Parses a JSON object correponding to the serialize function.
  129299. */
  129300. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129301. }
  129302. }
  129303. declare module BABYLON {
  129304. /**
  129305. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129306. * It can help converting any input color in a desired output one. This can then be used to create effects
  129307. * from sepia, black and white to sixties or futuristic rendering...
  129308. *
  129309. * The only supported format is currently 3dl.
  129310. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129311. */
  129312. export class ColorGradingTexture extends BaseTexture {
  129313. /**
  129314. * The current texture matrix. (will always be identity in color grading texture)
  129315. */
  129316. private _textureMatrix;
  129317. /**
  129318. * The texture URL.
  129319. */
  129320. url: string;
  129321. /**
  129322. * Empty line regex stored for GC.
  129323. */
  129324. private static _noneEmptyLineRegex;
  129325. private _engine;
  129326. /**
  129327. * Instantiates a ColorGradingTexture from the following parameters.
  129328. *
  129329. * @param url The location of the color gradind data (currently only supporting 3dl)
  129330. * @param scene The scene the texture will be used in
  129331. */
  129332. constructor(url: string, scene: Scene);
  129333. /**
  129334. * Returns the texture matrix used in most of the material.
  129335. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129336. */
  129337. getTextureMatrix(): Matrix;
  129338. /**
  129339. * Occurs when the file being loaded is a .3dl LUT file.
  129340. */
  129341. private load3dlTexture;
  129342. /**
  129343. * Starts the loading process of the texture.
  129344. */
  129345. private loadTexture;
  129346. /**
  129347. * Clones the color gradind texture.
  129348. */
  129349. clone(): ColorGradingTexture;
  129350. /**
  129351. * Called during delayed load for textures.
  129352. */
  129353. delayLoad(): void;
  129354. /**
  129355. * Parses a color grading texture serialized by Babylon.
  129356. * @param parsedTexture The texture information being parsedTexture
  129357. * @param scene The scene to load the texture in
  129358. * @param rootUrl The root url of the data assets to load
  129359. * @return A color gradind texture
  129360. */
  129361. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129362. /**
  129363. * Serializes the LUT texture to json format.
  129364. */
  129365. serialize(): any;
  129366. }
  129367. }
  129368. declare module BABYLON {
  129369. /**
  129370. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129371. */
  129372. export class EquiRectangularCubeTexture extends BaseTexture {
  129373. /** The six faces of the cube. */
  129374. private static _FacesMapping;
  129375. private _noMipmap;
  129376. private _onLoad;
  129377. private _onError;
  129378. /** The size of the cubemap. */
  129379. private _size;
  129380. /** The buffer of the image. */
  129381. private _buffer;
  129382. /** The width of the input image. */
  129383. private _width;
  129384. /** The height of the input image. */
  129385. private _height;
  129386. /** The URL to the image. */
  129387. url: string;
  129388. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129389. coordinatesMode: number;
  129390. /**
  129391. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129392. * @param url The location of the image
  129393. * @param scene The scene the texture will be used in
  129394. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129395. * @param noMipmap Forces to not generate the mipmap if true
  129396. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129397. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129398. * @param onLoad — defines a callback called when texture is loaded
  129399. * @param onError — defines a callback called if there is an error
  129400. */
  129401. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129402. /**
  129403. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129404. */
  129405. private loadImage;
  129406. /**
  129407. * Convert the image buffer into a cubemap and create a CubeTexture.
  129408. */
  129409. private loadTexture;
  129410. /**
  129411. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129412. * @param buffer The ArrayBuffer that should be converted.
  129413. * @returns The buffer as Float32Array.
  129414. */
  129415. private getFloat32ArrayFromArrayBuffer;
  129416. /**
  129417. * Get the current class name of the texture useful for serialization or dynamic coding.
  129418. * @returns "EquiRectangularCubeTexture"
  129419. */
  129420. getClassName(): string;
  129421. /**
  129422. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129423. * @returns A clone of the current EquiRectangularCubeTexture.
  129424. */
  129425. clone(): EquiRectangularCubeTexture;
  129426. }
  129427. }
  129428. declare module BABYLON {
  129429. /**
  129430. * Based on jsTGALoader - Javascript loader for TGA file
  129431. * By Vincent Thibault
  129432. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129433. */
  129434. export class TGATools {
  129435. private static _TYPE_INDEXED;
  129436. private static _TYPE_RGB;
  129437. private static _TYPE_GREY;
  129438. private static _TYPE_RLE_INDEXED;
  129439. private static _TYPE_RLE_RGB;
  129440. private static _TYPE_RLE_GREY;
  129441. private static _ORIGIN_MASK;
  129442. private static _ORIGIN_SHIFT;
  129443. private static _ORIGIN_BL;
  129444. private static _ORIGIN_BR;
  129445. private static _ORIGIN_UL;
  129446. private static _ORIGIN_UR;
  129447. /**
  129448. * Gets the header of a TGA file
  129449. * @param data defines the TGA data
  129450. * @returns the header
  129451. */
  129452. static GetTGAHeader(data: Uint8Array): any;
  129453. /**
  129454. * Uploads TGA content to a Babylon Texture
  129455. * @hidden
  129456. */
  129457. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129458. /** @hidden */
  129459. 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;
  129460. /** @hidden */
  129461. 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;
  129462. /** @hidden */
  129463. 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;
  129464. /** @hidden */
  129465. 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;
  129466. /** @hidden */
  129467. 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;
  129468. /** @hidden */
  129469. 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;
  129470. }
  129471. }
  129472. declare module BABYLON {
  129473. /**
  129474. * Implementation of the TGA Texture Loader.
  129475. * @hidden
  129476. */
  129477. export class _TGATextureLoader implements IInternalTextureLoader {
  129478. /**
  129479. * Defines wether the loader supports cascade loading the different faces.
  129480. */
  129481. readonly supportCascades: boolean;
  129482. /**
  129483. * This returns if the loader support the current file information.
  129484. * @param extension defines the file extension of the file being loaded
  129485. * @returns true if the loader can load the specified file
  129486. */
  129487. canLoad(extension: string): boolean;
  129488. /**
  129489. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129490. * @param data contains the texture data
  129491. * @param texture defines the BabylonJS internal texture
  129492. * @param createPolynomials will be true if polynomials have been requested
  129493. * @param onLoad defines the callback to trigger once the texture is ready
  129494. * @param onError defines the callback to trigger in case of error
  129495. */
  129496. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129497. /**
  129498. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129499. * @param data contains the texture data
  129500. * @param texture defines the BabylonJS internal texture
  129501. * @param callback defines the method to call once ready to upload
  129502. */
  129503. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129504. }
  129505. }
  129506. declare module BABYLON {
  129507. /**
  129508. * Info about the .basis files
  129509. */
  129510. class BasisFileInfo {
  129511. /**
  129512. * If the file has alpha
  129513. */
  129514. hasAlpha: boolean;
  129515. /**
  129516. * Info about each image of the basis file
  129517. */
  129518. images: Array<{
  129519. levels: Array<{
  129520. width: number;
  129521. height: number;
  129522. transcodedPixels: ArrayBufferView;
  129523. }>;
  129524. }>;
  129525. }
  129526. /**
  129527. * Result of transcoding a basis file
  129528. */
  129529. class TranscodeResult {
  129530. /**
  129531. * Info about the .basis file
  129532. */
  129533. fileInfo: BasisFileInfo;
  129534. /**
  129535. * Format to use when loading the file
  129536. */
  129537. format: number;
  129538. }
  129539. /**
  129540. * Configuration options for the Basis transcoder
  129541. */
  129542. export class BasisTranscodeConfiguration {
  129543. /**
  129544. * Supported compression formats used to determine the supported output format of the transcoder
  129545. */
  129546. supportedCompressionFormats?: {
  129547. /**
  129548. * etc1 compression format
  129549. */
  129550. etc1?: boolean;
  129551. /**
  129552. * s3tc compression format
  129553. */
  129554. s3tc?: boolean;
  129555. /**
  129556. * pvrtc compression format
  129557. */
  129558. pvrtc?: boolean;
  129559. /**
  129560. * etc2 compression format
  129561. */
  129562. etc2?: boolean;
  129563. };
  129564. /**
  129565. * If mipmap levels should be loaded for transcoded images (Default: true)
  129566. */
  129567. loadMipmapLevels?: boolean;
  129568. /**
  129569. * Index of a single image to load (Default: all images)
  129570. */
  129571. loadSingleImage?: number;
  129572. }
  129573. /**
  129574. * Used to load .Basis files
  129575. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129576. */
  129577. export class BasisTools {
  129578. private static _IgnoreSupportedFormats;
  129579. /**
  129580. * URL to use when loading the basis transcoder
  129581. */
  129582. static JSModuleURL: string;
  129583. /**
  129584. * URL to use when loading the wasm module for the transcoder
  129585. */
  129586. static WasmModuleURL: string;
  129587. /**
  129588. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129589. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129590. * @returns internal format corresponding to the Basis format
  129591. */
  129592. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129593. private static _WorkerPromise;
  129594. private static _Worker;
  129595. private static _actionId;
  129596. private static _CreateWorkerAsync;
  129597. /**
  129598. * Transcodes a loaded image file to compressed pixel data
  129599. * @param data image data to transcode
  129600. * @param config configuration options for the transcoding
  129601. * @returns a promise resulting in the transcoded image
  129602. */
  129603. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129604. /**
  129605. * Loads a texture from the transcode result
  129606. * @param texture texture load to
  129607. * @param transcodeResult the result of transcoding the basis file to load from
  129608. */
  129609. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129610. }
  129611. }
  129612. declare module BABYLON {
  129613. /**
  129614. * Loader for .basis file format
  129615. */
  129616. export class _BasisTextureLoader implements IInternalTextureLoader {
  129617. /**
  129618. * Defines whether the loader supports cascade loading the different faces.
  129619. */
  129620. readonly supportCascades: boolean;
  129621. /**
  129622. * This returns if the loader support the current file information.
  129623. * @param extension defines the file extension of the file being loaded
  129624. * @returns true if the loader can load the specified file
  129625. */
  129626. canLoad(extension: string): boolean;
  129627. /**
  129628. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129629. * @param data contains the texture data
  129630. * @param texture defines the BabylonJS internal texture
  129631. * @param createPolynomials will be true if polynomials have been requested
  129632. * @param onLoad defines the callback to trigger once the texture is ready
  129633. * @param onError defines the callback to trigger in case of error
  129634. */
  129635. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129636. /**
  129637. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129638. * @param data contains the texture data
  129639. * @param texture defines the BabylonJS internal texture
  129640. * @param callback defines the method to call once ready to upload
  129641. */
  129642. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129643. }
  129644. }
  129645. declare module BABYLON {
  129646. /**
  129647. * 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.
  129648. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129649. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129650. */
  129651. export class CustomProceduralTexture extends ProceduralTexture {
  129652. private _animate;
  129653. private _time;
  129654. private _config;
  129655. private _texturePath;
  129656. /**
  129657. * Instantiates a new Custom Procedural Texture.
  129658. * 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.
  129659. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129660. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129661. * @param name Define the name of the texture
  129662. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129663. * @param size Define the size of the texture to create
  129664. * @param scene Define the scene the texture belongs to
  129665. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129666. * @param generateMipMaps Define if the texture should creates mip maps or not
  129667. */
  129668. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129669. private _loadJson;
  129670. /**
  129671. * Is the texture ready to be used ? (rendered at least once)
  129672. * @returns true if ready, otherwise, false.
  129673. */
  129674. isReady(): boolean;
  129675. /**
  129676. * Render the texture to its associated render target.
  129677. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129678. */
  129679. render(useCameraPostProcess?: boolean): void;
  129680. /**
  129681. * Update the list of dependant textures samplers in the shader.
  129682. */
  129683. updateTextures(): void;
  129684. /**
  129685. * Update the uniform values of the procedural texture in the shader.
  129686. */
  129687. updateShaderUniforms(): void;
  129688. /**
  129689. * Define if the texture animates or not.
  129690. */
  129691. get animate(): boolean;
  129692. set animate(value: boolean);
  129693. }
  129694. }
  129695. declare module BABYLON {
  129696. /** @hidden */
  129697. export var noisePixelShader: {
  129698. name: string;
  129699. shader: string;
  129700. };
  129701. }
  129702. declare module BABYLON {
  129703. /**
  129704. * Class used to generate noise procedural textures
  129705. */
  129706. export class NoiseProceduralTexture extends ProceduralTexture {
  129707. private _time;
  129708. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129709. brightness: number;
  129710. /** Defines the number of octaves to process */
  129711. octaves: number;
  129712. /** Defines the level of persistence (0.8 by default) */
  129713. persistence: number;
  129714. /** Gets or sets animation speed factor (default is 1) */
  129715. animationSpeedFactor: number;
  129716. /**
  129717. * Creates a new NoiseProceduralTexture
  129718. * @param name defines the name fo the texture
  129719. * @param size defines the size of the texture (default is 256)
  129720. * @param scene defines the hosting scene
  129721. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129722. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129723. */
  129724. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129725. private _updateShaderUniforms;
  129726. protected _getDefines(): string;
  129727. /** Generate the current state of the procedural texture */
  129728. render(useCameraPostProcess?: boolean): void;
  129729. /**
  129730. * Serializes this noise procedural texture
  129731. * @returns a serialized noise procedural texture object
  129732. */
  129733. serialize(): any;
  129734. /**
  129735. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129736. * @param parsedTexture defines parsed texture data
  129737. * @param scene defines the current scene
  129738. * @param rootUrl defines the root URL containing noise procedural texture information
  129739. * @returns a parsed NoiseProceduralTexture
  129740. */
  129741. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129742. }
  129743. }
  129744. declare module BABYLON {
  129745. /**
  129746. * Raw cube texture where the raw buffers are passed in
  129747. */
  129748. export class RawCubeTexture extends CubeTexture {
  129749. /**
  129750. * Creates a cube texture where the raw buffers are passed in.
  129751. * @param scene defines the scene the texture is attached to
  129752. * @param data defines the array of data to use to create each face
  129753. * @param size defines the size of the textures
  129754. * @param format defines the format of the data
  129755. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129756. * @param generateMipMaps defines if the engine should generate the mip levels
  129757. * @param invertY defines if data must be stored with Y axis inverted
  129758. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129759. * @param compression defines the compression used (null by default)
  129760. */
  129761. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129762. /**
  129763. * Updates the raw cube texture.
  129764. * @param data defines the data to store
  129765. * @param format defines the data format
  129766. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129767. * @param invertY defines if data must be stored with Y axis inverted
  129768. * @param compression defines the compression used (null by default)
  129769. * @param level defines which level of the texture to update
  129770. */
  129771. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129772. /**
  129773. * Updates a raw cube texture with RGBD encoded data.
  129774. * @param data defines the array of data [mipmap][face] to use to create each face
  129775. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129776. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129777. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129778. * @returns a promsie that resolves when the operation is complete
  129779. */
  129780. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129781. /**
  129782. * Clones the raw cube texture.
  129783. * @return a new cube texture
  129784. */
  129785. clone(): CubeTexture;
  129786. /** @hidden */
  129787. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129788. }
  129789. }
  129790. declare module BABYLON {
  129791. /**
  129792. * Class used to store 3D textures containing user data
  129793. */
  129794. export class RawTexture3D extends Texture {
  129795. /** Gets or sets the texture format to use */
  129796. format: number;
  129797. private _engine;
  129798. /**
  129799. * Create a new RawTexture3D
  129800. * @param data defines the data of the texture
  129801. * @param width defines the width of the texture
  129802. * @param height defines the height of the texture
  129803. * @param depth defines the depth of the texture
  129804. * @param format defines the texture format to use
  129805. * @param scene defines the hosting scene
  129806. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129807. * @param invertY defines if texture must be stored with Y axis inverted
  129808. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129809. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129810. */
  129811. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129812. /** Gets or sets the texture format to use */
  129813. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129814. /**
  129815. * Update the texture with new data
  129816. * @param data defines the data to store in the texture
  129817. */
  129818. update(data: ArrayBufferView): void;
  129819. }
  129820. }
  129821. declare module BABYLON {
  129822. /**
  129823. * Class used to store 2D array textures containing user data
  129824. */
  129825. export class RawTexture2DArray extends Texture {
  129826. /** Gets or sets the texture format to use */
  129827. format: number;
  129828. private _engine;
  129829. /**
  129830. * Create a new RawTexture2DArray
  129831. * @param data defines the data of the texture
  129832. * @param width defines the width of the texture
  129833. * @param height defines the height of the texture
  129834. * @param depth defines the number of layers of the texture
  129835. * @param format defines the texture format to use
  129836. * @param scene defines the hosting scene
  129837. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129838. * @param invertY defines if texture must be stored with Y axis inverted
  129839. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129840. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129841. */
  129842. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129843. /** Gets or sets the texture format to use */
  129844. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129845. /**
  129846. * Update the texture with new data
  129847. * @param data defines the data to store in the texture
  129848. */
  129849. update(data: ArrayBufferView): void;
  129850. }
  129851. }
  129852. declare module BABYLON {
  129853. /**
  129854. * Creates a refraction texture used by refraction channel of the standard material.
  129855. * It is like a mirror but to see through a material.
  129856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129857. */
  129858. export class RefractionTexture extends RenderTargetTexture {
  129859. /**
  129860. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129861. * 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.
  129862. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129863. */
  129864. refractionPlane: Plane;
  129865. /**
  129866. * Define how deep under the surface we should see.
  129867. */
  129868. depth: number;
  129869. /**
  129870. * Creates a refraction texture used by refraction channel of the standard material.
  129871. * It is like a mirror but to see through a material.
  129872. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129873. * @param name Define the texture name
  129874. * @param size Define the size of the underlying texture
  129875. * @param scene Define the scene the refraction belongs to
  129876. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129877. */
  129878. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129879. /**
  129880. * Clone the refraction texture.
  129881. * @returns the cloned texture
  129882. */
  129883. clone(): RefractionTexture;
  129884. /**
  129885. * Serialize the texture to a JSON representation you could use in Parse later on
  129886. * @returns the serialized JSON representation
  129887. */
  129888. serialize(): any;
  129889. }
  129890. }
  129891. declare module BABYLON {
  129892. /**
  129893. * Defines the options related to the creation of an HtmlElementTexture
  129894. */
  129895. export interface IHtmlElementTextureOptions {
  129896. /**
  129897. * Defines wether mip maps should be created or not.
  129898. */
  129899. generateMipMaps?: boolean;
  129900. /**
  129901. * Defines the sampling mode of the texture.
  129902. */
  129903. samplingMode?: number;
  129904. /**
  129905. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129906. */
  129907. engine: Nullable<ThinEngine>;
  129908. /**
  129909. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129910. */
  129911. scene: Nullable<Scene>;
  129912. }
  129913. /**
  129914. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129915. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129916. * is automatically managed.
  129917. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129918. * in your application.
  129919. *
  129920. * As the update is not automatic, you need to call them manually.
  129921. */
  129922. export class HtmlElementTexture extends BaseTexture {
  129923. /**
  129924. * The texture URL.
  129925. */
  129926. element: HTMLVideoElement | HTMLCanvasElement;
  129927. private static readonly DefaultOptions;
  129928. private _textureMatrix;
  129929. private _engine;
  129930. private _isVideo;
  129931. private _generateMipMaps;
  129932. private _samplingMode;
  129933. /**
  129934. * Instantiates a HtmlElementTexture from the following parameters.
  129935. *
  129936. * @param name Defines the name of the texture
  129937. * @param element Defines the video or canvas the texture is filled with
  129938. * @param options Defines the other none mandatory texture creation options
  129939. */
  129940. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129941. private _createInternalTexture;
  129942. /**
  129943. * Returns the texture matrix used in most of the material.
  129944. */
  129945. getTextureMatrix(): Matrix;
  129946. /**
  129947. * Updates the content of the texture.
  129948. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129949. */
  129950. update(invertY?: Nullable<boolean>): void;
  129951. }
  129952. }
  129953. declare module BABYLON {
  129954. /**
  129955. * Defines the basic options interface of a TexturePacker Frame
  129956. */
  129957. export interface ITexturePackerFrame {
  129958. /**
  129959. * The frame ID
  129960. */
  129961. id: number;
  129962. /**
  129963. * The frames Scale
  129964. */
  129965. scale: Vector2;
  129966. /**
  129967. * The Frames offset
  129968. */
  129969. offset: Vector2;
  129970. }
  129971. /**
  129972. * This is a support class for frame Data on texture packer sets.
  129973. */
  129974. export class TexturePackerFrame implements ITexturePackerFrame {
  129975. /**
  129976. * The frame ID
  129977. */
  129978. id: number;
  129979. /**
  129980. * The frames Scale
  129981. */
  129982. scale: Vector2;
  129983. /**
  129984. * The Frames offset
  129985. */
  129986. offset: Vector2;
  129987. /**
  129988. * Initializes a texture package frame.
  129989. * @param id The numerical frame identifier
  129990. * @param scale Scalar Vector2 for UV frame
  129991. * @param offset Vector2 for the frame position in UV units.
  129992. * @returns TexturePackerFrame
  129993. */
  129994. constructor(id: number, scale: Vector2, offset: Vector2);
  129995. }
  129996. }
  129997. declare module BABYLON {
  129998. /**
  129999. * Defines the basic options interface of a TexturePacker
  130000. */
  130001. export interface ITexturePackerOptions {
  130002. /**
  130003. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  130004. */
  130005. map?: string[];
  130006. /**
  130007. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130008. */
  130009. uvsIn?: string;
  130010. /**
  130011. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130012. */
  130013. uvsOut?: string;
  130014. /**
  130015. * number representing the layout style. Defaults to LAYOUT_STRIP
  130016. */
  130017. layout?: number;
  130018. /**
  130019. * number of columns if using custom column count layout(2). This defaults to 4.
  130020. */
  130021. colnum?: number;
  130022. /**
  130023. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  130024. */
  130025. updateInputMeshes?: boolean;
  130026. /**
  130027. * boolean flag to dispose all the source textures. Defaults to true.
  130028. */
  130029. disposeSources?: boolean;
  130030. /**
  130031. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  130032. */
  130033. fillBlanks?: boolean;
  130034. /**
  130035. * string value representing the context fill style color. Defaults to 'black'.
  130036. */
  130037. customFillColor?: string;
  130038. /**
  130039. * Width and Height Value of each Frame in the TexturePacker Sets
  130040. */
  130041. frameSize?: number;
  130042. /**
  130043. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  130044. */
  130045. paddingRatio?: number;
  130046. /**
  130047. * Number that declares the fill method for the padding gutter.
  130048. */
  130049. paddingMode?: number;
  130050. /**
  130051. * If in SUBUV_COLOR padding mode what color to use.
  130052. */
  130053. paddingColor?: Color3 | Color4;
  130054. }
  130055. /**
  130056. * Defines the basic interface of a TexturePacker JSON File
  130057. */
  130058. export interface ITexturePackerJSON {
  130059. /**
  130060. * The frame ID
  130061. */
  130062. name: string;
  130063. /**
  130064. * The base64 channel data
  130065. */
  130066. sets: any;
  130067. /**
  130068. * The options of the Packer
  130069. */
  130070. options: ITexturePackerOptions;
  130071. /**
  130072. * The frame data of the Packer
  130073. */
  130074. frames: Array<number>;
  130075. }
  130076. /**
  130077. * This is a support class that generates a series of packed texture sets.
  130078. * @see https://doc.babylonjs.com/babylon101/materials
  130079. */
  130080. export class TexturePacker {
  130081. /** Packer Layout Constant 0 */
  130082. static readonly LAYOUT_STRIP: number;
  130083. /** Packer Layout Constant 1 */
  130084. static readonly LAYOUT_POWER2: number;
  130085. /** Packer Layout Constant 2 */
  130086. static readonly LAYOUT_COLNUM: number;
  130087. /** Packer Layout Constant 0 */
  130088. static readonly SUBUV_WRAP: number;
  130089. /** Packer Layout Constant 1 */
  130090. static readonly SUBUV_EXTEND: number;
  130091. /** Packer Layout Constant 2 */
  130092. static readonly SUBUV_COLOR: number;
  130093. /** The Name of the Texture Package */
  130094. name: string;
  130095. /** The scene scope of the TexturePacker */
  130096. scene: Scene;
  130097. /** The Meshes to target */
  130098. meshes: AbstractMesh[];
  130099. /** Arguments passed with the Constructor */
  130100. options: ITexturePackerOptions;
  130101. /** The promise that is started upon initialization */
  130102. promise: Nullable<Promise<TexturePacker | string>>;
  130103. /** The Container object for the channel sets that are generated */
  130104. sets: object;
  130105. /** The Container array for the frames that are generated */
  130106. frames: TexturePackerFrame[];
  130107. /** The expected number of textures the system is parsing. */
  130108. private _expecting;
  130109. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  130110. private _paddingValue;
  130111. /**
  130112. * Initializes a texture package series from an array of meshes or a single mesh.
  130113. * @param name The name of the package
  130114. * @param meshes The target meshes to compose the package from
  130115. * @param options The arguments that texture packer should follow while building.
  130116. * @param scene The scene which the textures are scoped to.
  130117. * @returns TexturePacker
  130118. */
  130119. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  130120. /**
  130121. * Starts the package process
  130122. * @param resolve The promises resolution function
  130123. * @returns TexturePacker
  130124. */
  130125. private _createFrames;
  130126. /**
  130127. * Calculates the Size of the Channel Sets
  130128. * @returns Vector2
  130129. */
  130130. private _calculateSize;
  130131. /**
  130132. * Calculates the UV data for the frames.
  130133. * @param baseSize the base frameSize
  130134. * @param padding the base frame padding
  130135. * @param dtSize size of the Dynamic Texture for that channel
  130136. * @param dtUnits is 1/dtSize
  130137. * @param update flag to update the input meshes
  130138. */
  130139. private _calculateMeshUVFrames;
  130140. /**
  130141. * Calculates the frames Offset.
  130142. * @param index of the frame
  130143. * @returns Vector2
  130144. */
  130145. private _getFrameOffset;
  130146. /**
  130147. * Updates a Mesh to the frame data
  130148. * @param mesh that is the target
  130149. * @param frameID or the frame index
  130150. */
  130151. private _updateMeshUV;
  130152. /**
  130153. * Updates a Meshes materials to use the texture packer channels
  130154. * @param m is the mesh to target
  130155. * @param force all channels on the packer to be set.
  130156. */
  130157. private _updateTextureReferences;
  130158. /**
  130159. * Public method to set a Mesh to a frame
  130160. * @param m that is the target
  130161. * @param frameID or the frame index
  130162. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130163. */
  130164. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130165. /**
  130166. * Starts the async promise to compile the texture packer.
  130167. * @returns Promise<void>
  130168. */
  130169. processAsync(): Promise<void>;
  130170. /**
  130171. * Disposes all textures associated with this packer
  130172. */
  130173. dispose(): void;
  130174. /**
  130175. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130176. * @param imageType is the image type to use.
  130177. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130178. */
  130179. download(imageType?: string, quality?: number): void;
  130180. /**
  130181. * Public method to load a texturePacker JSON file.
  130182. * @param data of the JSON file in string format.
  130183. */
  130184. updateFromJSON(data: string): void;
  130185. }
  130186. }
  130187. declare module BABYLON {
  130188. /**
  130189. * Enum used to define the target of a block
  130190. */
  130191. export enum NodeMaterialBlockTargets {
  130192. /** Vertex shader */
  130193. Vertex = 1,
  130194. /** Fragment shader */
  130195. Fragment = 2,
  130196. /** Neutral */
  130197. Neutral = 4,
  130198. /** Vertex and Fragment */
  130199. VertexAndFragment = 3
  130200. }
  130201. }
  130202. declare module BABYLON {
  130203. /**
  130204. * Defines the kind of connection point for node based material
  130205. */
  130206. export enum NodeMaterialBlockConnectionPointTypes {
  130207. /** Float */
  130208. Float = 1,
  130209. /** Int */
  130210. Int = 2,
  130211. /** Vector2 */
  130212. Vector2 = 4,
  130213. /** Vector3 */
  130214. Vector3 = 8,
  130215. /** Vector4 */
  130216. Vector4 = 16,
  130217. /** Color3 */
  130218. Color3 = 32,
  130219. /** Color4 */
  130220. Color4 = 64,
  130221. /** Matrix */
  130222. Matrix = 128,
  130223. /** Detect type based on connection */
  130224. AutoDetect = 1024,
  130225. /** Output type that will be defined by input type */
  130226. BasedOnInput = 2048
  130227. }
  130228. }
  130229. declare module BABYLON {
  130230. /**
  130231. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130232. */
  130233. export enum NodeMaterialBlockConnectionPointMode {
  130234. /** Value is an uniform */
  130235. Uniform = 0,
  130236. /** Value is a mesh attribute */
  130237. Attribute = 1,
  130238. /** Value is a varying between vertex and fragment shaders */
  130239. Varying = 2,
  130240. /** Mode is undefined */
  130241. Undefined = 3
  130242. }
  130243. }
  130244. declare module BABYLON {
  130245. /**
  130246. * Enum used to define system values e.g. values automatically provided by the system
  130247. */
  130248. export enum NodeMaterialSystemValues {
  130249. /** World */
  130250. World = 1,
  130251. /** View */
  130252. View = 2,
  130253. /** Projection */
  130254. Projection = 3,
  130255. /** ViewProjection */
  130256. ViewProjection = 4,
  130257. /** WorldView */
  130258. WorldView = 5,
  130259. /** WorldViewProjection */
  130260. WorldViewProjection = 6,
  130261. /** CameraPosition */
  130262. CameraPosition = 7,
  130263. /** Fog Color */
  130264. FogColor = 8,
  130265. /** Delta time */
  130266. DeltaTime = 9
  130267. }
  130268. }
  130269. declare module BABYLON {
  130270. /**
  130271. * Root class for all node material optimizers
  130272. */
  130273. export class NodeMaterialOptimizer {
  130274. /**
  130275. * Function used to optimize a NodeMaterial graph
  130276. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130277. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130278. */
  130279. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130280. }
  130281. }
  130282. declare module BABYLON {
  130283. /**
  130284. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130285. */
  130286. export class TransformBlock extends NodeMaterialBlock {
  130287. /**
  130288. * Defines the value to use to complement W value to transform it to a Vector4
  130289. */
  130290. complementW: number;
  130291. /**
  130292. * Defines the value to use to complement z value to transform it to a Vector4
  130293. */
  130294. complementZ: number;
  130295. /**
  130296. * Creates a new TransformBlock
  130297. * @param name defines the block name
  130298. */
  130299. constructor(name: string);
  130300. /**
  130301. * Gets the current class name
  130302. * @returns the class name
  130303. */
  130304. getClassName(): string;
  130305. /**
  130306. * Gets the vector input
  130307. */
  130308. get vector(): NodeMaterialConnectionPoint;
  130309. /**
  130310. * Gets the output component
  130311. */
  130312. get output(): NodeMaterialConnectionPoint;
  130313. /**
  130314. * Gets the xyz output component
  130315. */
  130316. get xyz(): NodeMaterialConnectionPoint;
  130317. /**
  130318. * Gets the matrix transform input
  130319. */
  130320. get transform(): NodeMaterialConnectionPoint;
  130321. protected _buildBlock(state: NodeMaterialBuildState): this;
  130322. serialize(): any;
  130323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130324. protected _dumpPropertiesCode(): string;
  130325. }
  130326. }
  130327. declare module BABYLON {
  130328. /**
  130329. * Block used to output the vertex position
  130330. */
  130331. export class VertexOutputBlock extends NodeMaterialBlock {
  130332. /**
  130333. * Creates a new VertexOutputBlock
  130334. * @param name defines the block name
  130335. */
  130336. constructor(name: string);
  130337. /**
  130338. * Gets the current class name
  130339. * @returns the class name
  130340. */
  130341. getClassName(): string;
  130342. /**
  130343. * Gets the vector input component
  130344. */
  130345. get vector(): NodeMaterialConnectionPoint;
  130346. protected _buildBlock(state: NodeMaterialBuildState): this;
  130347. }
  130348. }
  130349. declare module BABYLON {
  130350. /**
  130351. * Block used to output the final color
  130352. */
  130353. export class FragmentOutputBlock extends NodeMaterialBlock {
  130354. /**
  130355. * Create a new FragmentOutputBlock
  130356. * @param name defines the block name
  130357. */
  130358. constructor(name: string);
  130359. /**
  130360. * Gets the current class name
  130361. * @returns the class name
  130362. */
  130363. getClassName(): string;
  130364. /**
  130365. * Gets the rgba input component
  130366. */
  130367. get rgba(): NodeMaterialConnectionPoint;
  130368. /**
  130369. * Gets the rgb input component
  130370. */
  130371. get rgb(): NodeMaterialConnectionPoint;
  130372. /**
  130373. * Gets the a input component
  130374. */
  130375. get a(): NodeMaterialConnectionPoint;
  130376. protected _buildBlock(state: NodeMaterialBuildState): this;
  130377. }
  130378. }
  130379. declare module BABYLON {
  130380. /**
  130381. * Block used to read a reflection texture from a sampler
  130382. */
  130383. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130384. private _define3DName;
  130385. private _defineCubicName;
  130386. private _defineExplicitName;
  130387. private _defineProjectionName;
  130388. private _defineLocalCubicName;
  130389. private _defineSphericalName;
  130390. private _definePlanarName;
  130391. private _defineEquirectangularName;
  130392. private _defineMirroredEquirectangularFixedName;
  130393. private _defineEquirectangularFixedName;
  130394. private _defineSkyboxName;
  130395. private _cubeSamplerName;
  130396. private _2DSamplerName;
  130397. private _positionUVWName;
  130398. private _directionWName;
  130399. private _reflectionCoordsName;
  130400. private _reflection2DCoordsName;
  130401. private _reflectionColorName;
  130402. private _reflectionMatrixName;
  130403. /**
  130404. * Gets or sets the texture associated with the node
  130405. */
  130406. texture: Nullable<BaseTexture>;
  130407. /**
  130408. * Create a new TextureBlock
  130409. * @param name defines the block name
  130410. */
  130411. constructor(name: string);
  130412. /**
  130413. * Gets the current class name
  130414. * @returns the class name
  130415. */
  130416. getClassName(): string;
  130417. /**
  130418. * Gets the world position input component
  130419. */
  130420. get position(): NodeMaterialConnectionPoint;
  130421. /**
  130422. * Gets the world position input component
  130423. */
  130424. get worldPosition(): NodeMaterialConnectionPoint;
  130425. /**
  130426. * Gets the world normal input component
  130427. */
  130428. get worldNormal(): NodeMaterialConnectionPoint;
  130429. /**
  130430. * Gets the world input component
  130431. */
  130432. get world(): NodeMaterialConnectionPoint;
  130433. /**
  130434. * Gets the camera (or eye) position component
  130435. */
  130436. get cameraPosition(): NodeMaterialConnectionPoint;
  130437. /**
  130438. * Gets the view input component
  130439. */
  130440. get view(): NodeMaterialConnectionPoint;
  130441. /**
  130442. * Gets the rgb output component
  130443. */
  130444. get rgb(): NodeMaterialConnectionPoint;
  130445. /**
  130446. * Gets the r output component
  130447. */
  130448. get r(): NodeMaterialConnectionPoint;
  130449. /**
  130450. * Gets the g output component
  130451. */
  130452. get g(): NodeMaterialConnectionPoint;
  130453. /**
  130454. * Gets the b output component
  130455. */
  130456. get b(): NodeMaterialConnectionPoint;
  130457. autoConfigure(material: NodeMaterial): void;
  130458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130459. isReady(): boolean;
  130460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130461. private _injectVertexCode;
  130462. private _writeOutput;
  130463. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130464. protected _dumpPropertiesCode(): string;
  130465. serialize(): any;
  130466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130467. }
  130468. }
  130469. declare module BABYLON {
  130470. /**
  130471. * Interface used to configure the node material editor
  130472. */
  130473. export interface INodeMaterialEditorOptions {
  130474. /** Define the URl to load node editor script */
  130475. editorURL?: string;
  130476. }
  130477. /** @hidden */
  130478. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130479. NORMAL: boolean;
  130480. TANGENT: boolean;
  130481. UV1: boolean;
  130482. /** BONES */
  130483. NUM_BONE_INFLUENCERS: number;
  130484. BonesPerMesh: number;
  130485. BONETEXTURE: boolean;
  130486. /** MORPH TARGETS */
  130487. MORPHTARGETS: boolean;
  130488. MORPHTARGETS_NORMAL: boolean;
  130489. MORPHTARGETS_TANGENT: boolean;
  130490. MORPHTARGETS_UV: boolean;
  130491. NUM_MORPH_INFLUENCERS: number;
  130492. /** IMAGE PROCESSING */
  130493. IMAGEPROCESSING: boolean;
  130494. VIGNETTE: boolean;
  130495. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130496. VIGNETTEBLENDMODEOPAQUE: boolean;
  130497. TONEMAPPING: boolean;
  130498. TONEMAPPING_ACES: boolean;
  130499. CONTRAST: boolean;
  130500. EXPOSURE: boolean;
  130501. COLORCURVES: boolean;
  130502. COLORGRADING: boolean;
  130503. COLORGRADING3D: boolean;
  130504. SAMPLER3DGREENDEPTH: boolean;
  130505. SAMPLER3DBGRMAP: boolean;
  130506. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130507. /** MISC. */
  130508. BUMPDIRECTUV: number;
  130509. constructor();
  130510. setValue(name: string, value: boolean): void;
  130511. }
  130512. /**
  130513. * Class used to configure NodeMaterial
  130514. */
  130515. export interface INodeMaterialOptions {
  130516. /**
  130517. * Defines if blocks should emit comments
  130518. */
  130519. emitComments: boolean;
  130520. }
  130521. /**
  130522. * Class used to create a node based material built by assembling shader blocks
  130523. */
  130524. export class NodeMaterial extends PushMaterial {
  130525. private static _BuildIdGenerator;
  130526. private _options;
  130527. private _vertexCompilationState;
  130528. private _fragmentCompilationState;
  130529. private _sharedData;
  130530. private _buildId;
  130531. private _buildWasSuccessful;
  130532. private _cachedWorldViewMatrix;
  130533. private _cachedWorldViewProjectionMatrix;
  130534. private _optimizers;
  130535. private _animationFrame;
  130536. /** Define the Url to load node editor script */
  130537. static EditorURL: string;
  130538. /** Define the Url to load snippets */
  130539. static SnippetUrl: string;
  130540. private BJSNODEMATERIALEDITOR;
  130541. /** Get the inspector from bundle or global */
  130542. private _getGlobalNodeMaterialEditor;
  130543. /**
  130544. * Gets or sets data used by visual editor
  130545. * @see https://nme.babylonjs.com
  130546. */
  130547. editorData: any;
  130548. /**
  130549. * 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)
  130550. */
  130551. ignoreAlpha: boolean;
  130552. /**
  130553. * Defines the maximum number of lights that can be used in the material
  130554. */
  130555. maxSimultaneousLights: number;
  130556. /**
  130557. * Observable raised when the material is built
  130558. */
  130559. onBuildObservable: Observable<NodeMaterial>;
  130560. /**
  130561. * Gets or sets the root nodes of the material vertex shader
  130562. */
  130563. _vertexOutputNodes: NodeMaterialBlock[];
  130564. /**
  130565. * Gets or sets the root nodes of the material fragment (pixel) shader
  130566. */
  130567. _fragmentOutputNodes: NodeMaterialBlock[];
  130568. /** Gets or sets options to control the node material overall behavior */
  130569. get options(): INodeMaterialOptions;
  130570. set options(options: INodeMaterialOptions);
  130571. /**
  130572. * Default configuration related to image processing available in the standard Material.
  130573. */
  130574. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130575. /**
  130576. * Gets the image processing configuration used either in this material.
  130577. */
  130578. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130579. /**
  130580. * Sets the Default image processing configuration used either in the this material.
  130581. *
  130582. * If sets to null, the scene one is in use.
  130583. */
  130584. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130585. /**
  130586. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130587. */
  130588. attachedBlocks: NodeMaterialBlock[];
  130589. /**
  130590. * Create a new node based material
  130591. * @param name defines the material name
  130592. * @param scene defines the hosting scene
  130593. * @param options defines creation option
  130594. */
  130595. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130596. /**
  130597. * Gets the current class name of the material e.g. "NodeMaterial"
  130598. * @returns the class name
  130599. */
  130600. getClassName(): string;
  130601. /**
  130602. * Keep track of the image processing observer to allow dispose and replace.
  130603. */
  130604. private _imageProcessingObserver;
  130605. /**
  130606. * Attaches a new image processing configuration to the Standard Material.
  130607. * @param configuration
  130608. */
  130609. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130610. /**
  130611. * Get a block by its name
  130612. * @param name defines the name of the block to retrieve
  130613. * @returns the required block or null if not found
  130614. */
  130615. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130616. /**
  130617. * Get a block by its name
  130618. * @param predicate defines the predicate used to find the good candidate
  130619. * @returns the required block or null if not found
  130620. */
  130621. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130622. /**
  130623. * Get an input block by its name
  130624. * @param predicate defines the predicate used to find the good candidate
  130625. * @returns the required input block or null if not found
  130626. */
  130627. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130628. /**
  130629. * Gets the list of input blocks attached to this material
  130630. * @returns an array of InputBlocks
  130631. */
  130632. getInputBlocks(): InputBlock[];
  130633. /**
  130634. * Adds a new optimizer to the list of optimizers
  130635. * @param optimizer defines the optimizers to add
  130636. * @returns the current material
  130637. */
  130638. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130639. /**
  130640. * Remove an optimizer from the list of optimizers
  130641. * @param optimizer defines the optimizers to remove
  130642. * @returns the current material
  130643. */
  130644. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130645. /**
  130646. * Add a new block to the list of output nodes
  130647. * @param node defines the node to add
  130648. * @returns the current material
  130649. */
  130650. addOutputNode(node: NodeMaterialBlock): this;
  130651. /**
  130652. * Remove a block from the list of root nodes
  130653. * @param node defines the node to remove
  130654. * @returns the current material
  130655. */
  130656. removeOutputNode(node: NodeMaterialBlock): this;
  130657. private _addVertexOutputNode;
  130658. private _removeVertexOutputNode;
  130659. private _addFragmentOutputNode;
  130660. private _removeFragmentOutputNode;
  130661. /**
  130662. * Specifies if the material will require alpha blending
  130663. * @returns a boolean specifying if alpha blending is needed
  130664. */
  130665. needAlphaBlending(): boolean;
  130666. /**
  130667. * Specifies if this material should be rendered in alpha test mode
  130668. * @returns a boolean specifying if an alpha test is needed.
  130669. */
  130670. needAlphaTesting(): boolean;
  130671. private _initializeBlock;
  130672. private _resetDualBlocks;
  130673. /**
  130674. * Remove a block from the current node material
  130675. * @param block defines the block to remove
  130676. */
  130677. removeBlock(block: NodeMaterialBlock): void;
  130678. /**
  130679. * Build the material and generates the inner effect
  130680. * @param verbose defines if the build should log activity
  130681. */
  130682. build(verbose?: boolean): void;
  130683. /**
  130684. * Runs an otpimization phase to try to improve the shader code
  130685. */
  130686. optimize(): void;
  130687. private _prepareDefinesForAttributes;
  130688. /**
  130689. * Get if the submesh is ready to be used and all its information available.
  130690. * Child classes can use it to update shaders
  130691. * @param mesh defines the mesh to check
  130692. * @param subMesh defines which submesh to check
  130693. * @param useInstances specifies that instances should be used
  130694. * @returns a boolean indicating that the submesh is ready or not
  130695. */
  130696. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130697. /**
  130698. * Get a string representing the shaders built by the current node graph
  130699. */
  130700. get compiledShaders(): string;
  130701. /**
  130702. * Binds the world matrix to the material
  130703. * @param world defines the world transformation matrix
  130704. */
  130705. bindOnlyWorldMatrix(world: Matrix): void;
  130706. /**
  130707. * Binds the submesh to this material by preparing the effect and shader to draw
  130708. * @param world defines the world transformation matrix
  130709. * @param mesh defines the mesh containing the submesh
  130710. * @param subMesh defines the submesh to bind the material to
  130711. */
  130712. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130713. /**
  130714. * Gets the active textures from the material
  130715. * @returns an array of textures
  130716. */
  130717. getActiveTextures(): BaseTexture[];
  130718. /**
  130719. * Gets the list of texture blocks
  130720. * @returns an array of texture blocks
  130721. */
  130722. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130723. /**
  130724. * Specifies if the material uses a texture
  130725. * @param texture defines the texture to check against the material
  130726. * @returns a boolean specifying if the material uses the texture
  130727. */
  130728. hasTexture(texture: BaseTexture): boolean;
  130729. /**
  130730. * Disposes the material
  130731. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130732. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130733. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130734. */
  130735. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130736. /** Creates the node editor window. */
  130737. private _createNodeEditor;
  130738. /**
  130739. * Launch the node material editor
  130740. * @param config Define the configuration of the editor
  130741. * @return a promise fulfilled when the node editor is visible
  130742. */
  130743. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130744. /**
  130745. * Clear the current material
  130746. */
  130747. clear(): void;
  130748. /**
  130749. * Clear the current material and set it to a default state
  130750. */
  130751. setToDefault(): void;
  130752. /**
  130753. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130754. * @param url defines the url to load from
  130755. * @returns a promise that will fullfil when the material is fully loaded
  130756. */
  130757. loadAsync(url: string): Promise<void>;
  130758. private _gatherBlocks;
  130759. /**
  130760. * Generate a string containing the code declaration required to create an equivalent of this material
  130761. * @returns a string
  130762. */
  130763. generateCode(): string;
  130764. /**
  130765. * Serializes this material in a JSON representation
  130766. * @returns the serialized material object
  130767. */
  130768. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130769. private _restoreConnections;
  130770. /**
  130771. * Clear the current graph and load a new one from a serialization object
  130772. * @param source defines the JSON representation of the material
  130773. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130774. */
  130775. loadFromSerialization(source: any, rootUrl?: string): void;
  130776. /**
  130777. * Creates a node material from parsed material data
  130778. * @param source defines the JSON representation of the material
  130779. * @param scene defines the hosting scene
  130780. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130781. * @returns a new node material
  130782. */
  130783. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130784. /**
  130785. * Creates a node material from a snippet saved in a remote file
  130786. * @param name defines the name of the material to create
  130787. * @param url defines the url to load from
  130788. * @param scene defines the hosting scene
  130789. * @returns a promise that will resolve to the new node material
  130790. */
  130791. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130792. /**
  130793. * Creates a node material from a snippet saved by the node material editor
  130794. * @param snippetId defines the snippet to load
  130795. * @param scene defines the hosting scene
  130796. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130797. * @returns a promise that will resolve to the new node material
  130798. */
  130799. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130800. /**
  130801. * Creates a new node material set to default basic configuration
  130802. * @param name defines the name of the material
  130803. * @param scene defines the hosting scene
  130804. * @returns a new NodeMaterial
  130805. */
  130806. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130807. }
  130808. }
  130809. declare module BABYLON {
  130810. /**
  130811. * Block used to read a texture from a sampler
  130812. */
  130813. export class TextureBlock extends NodeMaterialBlock {
  130814. private _defineName;
  130815. private _linearDefineName;
  130816. private _tempTextureRead;
  130817. private _samplerName;
  130818. private _transformedUVName;
  130819. private _textureTransformName;
  130820. private _textureInfoName;
  130821. private _mainUVName;
  130822. private _mainUVDefineName;
  130823. /**
  130824. * Gets or sets the texture associated with the node
  130825. */
  130826. texture: Nullable<Texture>;
  130827. /**
  130828. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130829. */
  130830. convertToGammaSpace: boolean;
  130831. /**
  130832. * Create a new TextureBlock
  130833. * @param name defines the block name
  130834. */
  130835. constructor(name: string);
  130836. /**
  130837. * Gets the current class name
  130838. * @returns the class name
  130839. */
  130840. getClassName(): string;
  130841. /**
  130842. * Gets the uv input component
  130843. */
  130844. get uv(): NodeMaterialConnectionPoint;
  130845. /**
  130846. * Gets the rgba output component
  130847. */
  130848. get rgba(): NodeMaterialConnectionPoint;
  130849. /**
  130850. * Gets the rgb output component
  130851. */
  130852. get rgb(): NodeMaterialConnectionPoint;
  130853. /**
  130854. * Gets the r output component
  130855. */
  130856. get r(): NodeMaterialConnectionPoint;
  130857. /**
  130858. * Gets the g output component
  130859. */
  130860. get g(): NodeMaterialConnectionPoint;
  130861. /**
  130862. * Gets the b output component
  130863. */
  130864. get b(): NodeMaterialConnectionPoint;
  130865. /**
  130866. * Gets the a output component
  130867. */
  130868. get a(): NodeMaterialConnectionPoint;
  130869. get target(): NodeMaterialBlockTargets;
  130870. autoConfigure(material: NodeMaterial): void;
  130871. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130873. isReady(): boolean;
  130874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130875. private get _isMixed();
  130876. private _injectVertexCode;
  130877. private _writeTextureRead;
  130878. private _writeOutput;
  130879. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130880. protected _dumpPropertiesCode(): string;
  130881. serialize(): any;
  130882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130883. }
  130884. }
  130885. declare module BABYLON {
  130886. /**
  130887. * Class used to store shared data between 2 NodeMaterialBuildState
  130888. */
  130889. export class NodeMaterialBuildStateSharedData {
  130890. /**
  130891. * Gets the list of emitted varyings
  130892. */
  130893. temps: string[];
  130894. /**
  130895. * Gets the list of emitted varyings
  130896. */
  130897. varyings: string[];
  130898. /**
  130899. * Gets the varying declaration string
  130900. */
  130901. varyingDeclaration: string;
  130902. /**
  130903. * Input blocks
  130904. */
  130905. inputBlocks: InputBlock[];
  130906. /**
  130907. * Input blocks
  130908. */
  130909. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130910. /**
  130911. * Bindable blocks (Blocks that need to set data to the effect)
  130912. */
  130913. bindableBlocks: NodeMaterialBlock[];
  130914. /**
  130915. * List of blocks that can provide a compilation fallback
  130916. */
  130917. blocksWithFallbacks: NodeMaterialBlock[];
  130918. /**
  130919. * List of blocks that can provide a define update
  130920. */
  130921. blocksWithDefines: NodeMaterialBlock[];
  130922. /**
  130923. * List of blocks that can provide a repeatable content
  130924. */
  130925. repeatableContentBlocks: NodeMaterialBlock[];
  130926. /**
  130927. * List of blocks that can provide a dynamic list of uniforms
  130928. */
  130929. dynamicUniformBlocks: NodeMaterialBlock[];
  130930. /**
  130931. * List of blocks that can block the isReady function for the material
  130932. */
  130933. blockingBlocks: NodeMaterialBlock[];
  130934. /**
  130935. * Gets the list of animated inputs
  130936. */
  130937. animatedInputs: InputBlock[];
  130938. /**
  130939. * Build Id used to avoid multiple recompilations
  130940. */
  130941. buildId: number;
  130942. /** List of emitted variables */
  130943. variableNames: {
  130944. [key: string]: number;
  130945. };
  130946. /** List of emitted defines */
  130947. defineNames: {
  130948. [key: string]: number;
  130949. };
  130950. /** Should emit comments? */
  130951. emitComments: boolean;
  130952. /** Emit build activity */
  130953. verbose: boolean;
  130954. /** Gets or sets the hosting scene */
  130955. scene: Scene;
  130956. /**
  130957. * Gets the compilation hints emitted at compilation time
  130958. */
  130959. hints: {
  130960. needWorldViewMatrix: boolean;
  130961. needWorldViewProjectionMatrix: boolean;
  130962. needAlphaBlending: boolean;
  130963. needAlphaTesting: boolean;
  130964. };
  130965. /**
  130966. * List of compilation checks
  130967. */
  130968. checks: {
  130969. emitVertex: boolean;
  130970. emitFragment: boolean;
  130971. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130972. };
  130973. /** Creates a new shared data */
  130974. constructor();
  130975. /**
  130976. * Emits console errors and exceptions if there is a failing check
  130977. */
  130978. emitErrors(): void;
  130979. }
  130980. }
  130981. declare module BABYLON {
  130982. /**
  130983. * Class used to store node based material build state
  130984. */
  130985. export class NodeMaterialBuildState {
  130986. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130987. supportUniformBuffers: boolean;
  130988. /**
  130989. * Gets the list of emitted attributes
  130990. */
  130991. attributes: string[];
  130992. /**
  130993. * Gets the list of emitted uniforms
  130994. */
  130995. uniforms: string[];
  130996. /**
  130997. * Gets the list of emitted constants
  130998. */
  130999. constants: string[];
  131000. /**
  131001. * Gets the list of emitted samplers
  131002. */
  131003. samplers: string[];
  131004. /**
  131005. * Gets the list of emitted functions
  131006. */
  131007. functions: {
  131008. [key: string]: string;
  131009. };
  131010. /**
  131011. * Gets the list of emitted extensions
  131012. */
  131013. extensions: {
  131014. [key: string]: string;
  131015. };
  131016. /**
  131017. * Gets the target of the compilation state
  131018. */
  131019. target: NodeMaterialBlockTargets;
  131020. /**
  131021. * Gets the list of emitted counters
  131022. */
  131023. counters: {
  131024. [key: string]: number;
  131025. };
  131026. /**
  131027. * Shared data between multiple NodeMaterialBuildState instances
  131028. */
  131029. sharedData: NodeMaterialBuildStateSharedData;
  131030. /** @hidden */
  131031. _vertexState: NodeMaterialBuildState;
  131032. /** @hidden */
  131033. _attributeDeclaration: string;
  131034. /** @hidden */
  131035. _uniformDeclaration: string;
  131036. /** @hidden */
  131037. _constantDeclaration: string;
  131038. /** @hidden */
  131039. _samplerDeclaration: string;
  131040. /** @hidden */
  131041. _varyingTransfer: string;
  131042. private _repeatableContentAnchorIndex;
  131043. /** @hidden */
  131044. _builtCompilationString: string;
  131045. /**
  131046. * Gets the emitted compilation strings
  131047. */
  131048. compilationString: string;
  131049. /**
  131050. * Finalize the compilation strings
  131051. * @param state defines the current compilation state
  131052. */
  131053. finalize(state: NodeMaterialBuildState): void;
  131054. /** @hidden */
  131055. get _repeatableContentAnchor(): string;
  131056. /** @hidden */
  131057. _getFreeVariableName(prefix: string): string;
  131058. /** @hidden */
  131059. _getFreeDefineName(prefix: string): string;
  131060. /** @hidden */
  131061. _excludeVariableName(name: string): void;
  131062. /** @hidden */
  131063. _emit2DSampler(name: string): void;
  131064. /** @hidden */
  131065. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  131066. /** @hidden */
  131067. _emitExtension(name: string, extension: string): void;
  131068. /** @hidden */
  131069. _emitFunction(name: string, code: string, comments: string): void;
  131070. /** @hidden */
  131071. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  131072. replaceStrings?: {
  131073. search: RegExp;
  131074. replace: string;
  131075. }[];
  131076. repeatKey?: string;
  131077. }): string;
  131078. /** @hidden */
  131079. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  131080. repeatKey?: string;
  131081. removeAttributes?: boolean;
  131082. removeUniforms?: boolean;
  131083. removeVaryings?: boolean;
  131084. removeIfDef?: boolean;
  131085. replaceStrings?: {
  131086. search: RegExp;
  131087. replace: string;
  131088. }[];
  131089. }, storeKey?: string): void;
  131090. /** @hidden */
  131091. _registerTempVariable(name: string): boolean;
  131092. /** @hidden */
  131093. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  131094. /** @hidden */
  131095. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  131096. /** @hidden */
  131097. _emitFloat(value: number): string;
  131098. }
  131099. }
  131100. declare module BABYLON {
  131101. /**
  131102. * Defines a block that can be used inside a node based material
  131103. */
  131104. export class NodeMaterialBlock {
  131105. private _buildId;
  131106. private _buildTarget;
  131107. private _target;
  131108. private _isFinalMerger;
  131109. private _isInput;
  131110. protected _isUnique: boolean;
  131111. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  131112. inputsAreExclusive: boolean;
  131113. /** @hidden */
  131114. _codeVariableName: string;
  131115. /** @hidden */
  131116. _inputs: NodeMaterialConnectionPoint[];
  131117. /** @hidden */
  131118. _outputs: NodeMaterialConnectionPoint[];
  131119. /** @hidden */
  131120. _preparationId: number;
  131121. /**
  131122. * Gets or sets the name of the block
  131123. */
  131124. name: string;
  131125. /**
  131126. * Gets or sets the unique id of the node
  131127. */
  131128. uniqueId: number;
  131129. /**
  131130. * Gets or sets the comments associated with this block
  131131. */
  131132. comments: string;
  131133. /**
  131134. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131135. */
  131136. get isUnique(): boolean;
  131137. /**
  131138. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131139. */
  131140. get isFinalMerger(): boolean;
  131141. /**
  131142. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131143. */
  131144. get isInput(): boolean;
  131145. /**
  131146. * Gets or sets the build Id
  131147. */
  131148. get buildId(): number;
  131149. set buildId(value: number);
  131150. /**
  131151. * Gets or sets the target of the block
  131152. */
  131153. get target(): NodeMaterialBlockTargets;
  131154. set target(value: NodeMaterialBlockTargets);
  131155. /**
  131156. * Gets the list of input points
  131157. */
  131158. get inputs(): NodeMaterialConnectionPoint[];
  131159. /** Gets the list of output points */
  131160. get outputs(): NodeMaterialConnectionPoint[];
  131161. /**
  131162. * Find an input by its name
  131163. * @param name defines the name of the input to look for
  131164. * @returns the input or null if not found
  131165. */
  131166. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131167. /**
  131168. * Find an output by its name
  131169. * @param name defines the name of the outputto look for
  131170. * @returns the output or null if not found
  131171. */
  131172. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131173. /**
  131174. * Creates a new NodeMaterialBlock
  131175. * @param name defines the block name
  131176. * @param target defines the target of that block (Vertex by default)
  131177. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131178. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131179. */
  131180. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131181. /**
  131182. * Initialize the block and prepare the context for build
  131183. * @param state defines the state that will be used for the build
  131184. */
  131185. initialize(state: NodeMaterialBuildState): void;
  131186. /**
  131187. * Bind data to effect. Will only be called for blocks with isBindable === true
  131188. * @param effect defines the effect to bind data to
  131189. * @param nodeMaterial defines the hosting NodeMaterial
  131190. * @param mesh defines the mesh that will be rendered
  131191. */
  131192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131193. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131194. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131195. protected _writeFloat(value: number): string;
  131196. /**
  131197. * Gets the current class name e.g. "NodeMaterialBlock"
  131198. * @returns the class name
  131199. */
  131200. getClassName(): string;
  131201. /**
  131202. * Register a new input. Must be called inside a block constructor
  131203. * @param name defines the connection point name
  131204. * @param type defines the connection point type
  131205. * @param isOptional defines a boolean indicating that this input can be omitted
  131206. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131207. * @returns the current block
  131208. */
  131209. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131210. /**
  131211. * Register a new output. Must be called inside a block constructor
  131212. * @param name defines the connection point name
  131213. * @param type defines the connection point type
  131214. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131215. * @returns the current block
  131216. */
  131217. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131218. /**
  131219. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131220. * @param forOutput defines an optional connection point to check compatibility with
  131221. * @returns the first available input or null
  131222. */
  131223. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131224. /**
  131225. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131226. * @param forBlock defines an optional block to check compatibility with
  131227. * @returns the first available input or null
  131228. */
  131229. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131230. /**
  131231. * Gets the sibling of the given output
  131232. * @param current defines the current output
  131233. * @returns the next output in the list or null
  131234. */
  131235. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131236. /**
  131237. * Connect current block with another block
  131238. * @param other defines the block to connect with
  131239. * @param options define the various options to help pick the right connections
  131240. * @returns the current block
  131241. */
  131242. connectTo(other: NodeMaterialBlock, options?: {
  131243. input?: string;
  131244. output?: string;
  131245. outputSwizzle?: string;
  131246. }): this | undefined;
  131247. protected _buildBlock(state: NodeMaterialBuildState): void;
  131248. /**
  131249. * Add uniforms, samplers and uniform buffers at compilation time
  131250. * @param state defines the state to update
  131251. * @param nodeMaterial defines the node material requesting the update
  131252. * @param defines defines the material defines to update
  131253. * @param uniformBuffers defines the list of uniform buffer names
  131254. */
  131255. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131256. /**
  131257. * Add potential fallbacks if shader compilation fails
  131258. * @param mesh defines the mesh to be rendered
  131259. * @param fallbacks defines the current prioritized list of fallbacks
  131260. */
  131261. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131262. /**
  131263. * Initialize defines for shader compilation
  131264. * @param mesh defines the mesh to be rendered
  131265. * @param nodeMaterial defines the node material requesting the update
  131266. * @param defines defines the material defines to update
  131267. * @param useInstances specifies that instances should be used
  131268. */
  131269. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131270. /**
  131271. * Update defines for shader compilation
  131272. * @param mesh defines the mesh to be rendered
  131273. * @param nodeMaterial defines the node material requesting the update
  131274. * @param defines defines the material defines to update
  131275. * @param useInstances specifies that instances should be used
  131276. */
  131277. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131278. /**
  131279. * Lets the block try to connect some inputs automatically
  131280. * @param material defines the hosting NodeMaterial
  131281. */
  131282. autoConfigure(material: NodeMaterial): void;
  131283. /**
  131284. * Function called when a block is declared as repeatable content generator
  131285. * @param vertexShaderState defines the current compilation state for the vertex shader
  131286. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131287. * @param mesh defines the mesh to be rendered
  131288. * @param defines defines the material defines to update
  131289. */
  131290. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131291. /**
  131292. * Checks if the block is ready
  131293. * @param mesh defines the mesh to be rendered
  131294. * @param nodeMaterial defines the node material requesting the update
  131295. * @param defines defines the material defines to update
  131296. * @param useInstances specifies that instances should be used
  131297. * @returns true if the block is ready
  131298. */
  131299. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131300. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131301. private _processBuild;
  131302. /**
  131303. * Compile the current node and generate the shader code
  131304. * @param state defines the current compilation state (uniforms, samplers, current string)
  131305. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131306. * @returns true if already built
  131307. */
  131308. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131309. protected _inputRename(name: string): string;
  131310. protected _outputRename(name: string): string;
  131311. protected _dumpPropertiesCode(): string;
  131312. /** @hidden */
  131313. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131314. /** @hidden */
  131315. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131316. /**
  131317. * Clone the current block to a new identical block
  131318. * @param scene defines the hosting scene
  131319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131320. * @returns a copy of the current block
  131321. */
  131322. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131323. /**
  131324. * Serializes this block in a JSON representation
  131325. * @returns the serialized block object
  131326. */
  131327. serialize(): any;
  131328. /** @hidden */
  131329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131330. /**
  131331. * Release resources
  131332. */
  131333. dispose(): void;
  131334. }
  131335. }
  131336. declare module BABYLON {
  131337. /**
  131338. * Enum defining the type of animations supported by InputBlock
  131339. */
  131340. export enum AnimatedInputBlockTypes {
  131341. /** No animation */
  131342. None = 0,
  131343. /** Time based animation. Will only work for floats */
  131344. Time = 1
  131345. }
  131346. }
  131347. declare module BABYLON {
  131348. /**
  131349. * Block used to expose an input value
  131350. */
  131351. export class InputBlock extends NodeMaterialBlock {
  131352. private _mode;
  131353. private _associatedVariableName;
  131354. private _storedValue;
  131355. private _valueCallback;
  131356. private _type;
  131357. private _animationType;
  131358. /** Gets or set a value used to limit the range of float values */
  131359. min: number;
  131360. /** Gets or set a value used to limit the range of float values */
  131361. max: number;
  131362. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131363. isBoolean: boolean;
  131364. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131365. matrixMode: number;
  131366. /** @hidden */
  131367. _systemValue: Nullable<NodeMaterialSystemValues>;
  131368. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131369. visibleInInspector: boolean;
  131370. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131371. isConstant: boolean;
  131372. /** Gets or sets the group to use to display this block in the Inspector */
  131373. groupInInspector: string;
  131374. /** Gets an observable raised when the value is changed */
  131375. onValueChangedObservable: Observable<InputBlock>;
  131376. /**
  131377. * Gets or sets the connection point type (default is float)
  131378. */
  131379. get type(): NodeMaterialBlockConnectionPointTypes;
  131380. /**
  131381. * Creates a new InputBlock
  131382. * @param name defines the block name
  131383. * @param target defines the target of that block (Vertex by default)
  131384. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131385. */
  131386. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131387. /**
  131388. * Gets the output component
  131389. */
  131390. get output(): NodeMaterialConnectionPoint;
  131391. /**
  131392. * Set the source of this connection point to a vertex attribute
  131393. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131394. * @returns the current connection point
  131395. */
  131396. setAsAttribute(attributeName?: string): InputBlock;
  131397. /**
  131398. * Set the source of this connection point to a system value
  131399. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131400. * @returns the current connection point
  131401. */
  131402. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131403. /**
  131404. * Gets or sets the value of that point.
  131405. * Please note that this value will be ignored if valueCallback is defined
  131406. */
  131407. get value(): any;
  131408. set value(value: any);
  131409. /**
  131410. * Gets or sets a callback used to get the value of that point.
  131411. * Please note that setting this value will force the connection point to ignore the value property
  131412. */
  131413. get valueCallback(): () => any;
  131414. set valueCallback(value: () => any);
  131415. /**
  131416. * Gets or sets the associated variable name in the shader
  131417. */
  131418. get associatedVariableName(): string;
  131419. set associatedVariableName(value: string);
  131420. /** Gets or sets the type of animation applied to the input */
  131421. get animationType(): AnimatedInputBlockTypes;
  131422. set animationType(value: AnimatedInputBlockTypes);
  131423. /**
  131424. * Gets a boolean indicating that this connection point not defined yet
  131425. */
  131426. get isUndefined(): boolean;
  131427. /**
  131428. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131429. * In this case the connection point name must be the name of the uniform to use.
  131430. * Can only be set on inputs
  131431. */
  131432. get isUniform(): boolean;
  131433. set isUniform(value: boolean);
  131434. /**
  131435. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131436. * In this case the connection point name must be the name of the attribute to use
  131437. * Can only be set on inputs
  131438. */
  131439. get isAttribute(): boolean;
  131440. set isAttribute(value: boolean);
  131441. /**
  131442. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131443. * Can only be set on exit points
  131444. */
  131445. get isVarying(): boolean;
  131446. set isVarying(value: boolean);
  131447. /**
  131448. * Gets a boolean indicating that the current connection point is a system value
  131449. */
  131450. get isSystemValue(): boolean;
  131451. /**
  131452. * Gets or sets the current well known value or null if not defined as a system value
  131453. */
  131454. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131455. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131456. /**
  131457. * Gets the current class name
  131458. * @returns the class name
  131459. */
  131460. getClassName(): string;
  131461. /**
  131462. * Animate the input if animationType !== None
  131463. * @param scene defines the rendering scene
  131464. */
  131465. animate(scene: Scene): void;
  131466. private _emitDefine;
  131467. initialize(state: NodeMaterialBuildState): void;
  131468. /**
  131469. * Set the input block to its default value (based on its type)
  131470. */
  131471. setDefaultValue(): void;
  131472. private _emitConstant;
  131473. private _emit;
  131474. /** @hidden */
  131475. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131476. /** @hidden */
  131477. _transmit(effect: Effect, scene: Scene): void;
  131478. protected _buildBlock(state: NodeMaterialBuildState): void;
  131479. protected _dumpPropertiesCode(): string;
  131480. dispose(): void;
  131481. serialize(): any;
  131482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131483. }
  131484. }
  131485. declare module BABYLON {
  131486. /**
  131487. * Enum used to define the compatibility state between two connection points
  131488. */
  131489. export enum NodeMaterialConnectionPointCompatibilityStates {
  131490. /** Points are compatibles */
  131491. Compatible = 0,
  131492. /** Points are incompatible because of their types */
  131493. TypeIncompatible = 1,
  131494. /** Points are incompatible because of their targets (vertex vs fragment) */
  131495. TargetIncompatible = 2
  131496. }
  131497. /**
  131498. * Defines the direction of a connection point
  131499. */
  131500. export enum NodeMaterialConnectionPointDirection {
  131501. /** Input */
  131502. Input = 0,
  131503. /** Output */
  131504. Output = 1
  131505. }
  131506. /**
  131507. * Defines a connection point for a block
  131508. */
  131509. export class NodeMaterialConnectionPoint {
  131510. /** @hidden */
  131511. _ownerBlock: NodeMaterialBlock;
  131512. /** @hidden */
  131513. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131514. private _endpoints;
  131515. private _associatedVariableName;
  131516. private _direction;
  131517. /** @hidden */
  131518. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131519. /** @hidden */
  131520. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131521. private _type;
  131522. /** @hidden */
  131523. _enforceAssociatedVariableName: boolean;
  131524. /** Gets the direction of the point */
  131525. get direction(): NodeMaterialConnectionPointDirection;
  131526. /**
  131527. * Gets or sets the additional types supported by this connection point
  131528. */
  131529. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131530. /**
  131531. * Gets or sets the additional types excluded by this connection point
  131532. */
  131533. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131534. /**
  131535. * Observable triggered when this point is connected
  131536. */
  131537. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131538. /**
  131539. * Gets or sets the associated variable name in the shader
  131540. */
  131541. get associatedVariableName(): string;
  131542. set associatedVariableName(value: string);
  131543. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131544. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131545. /**
  131546. * Gets or sets the connection point type (default is float)
  131547. */
  131548. get type(): NodeMaterialBlockConnectionPointTypes;
  131549. set type(value: NodeMaterialBlockConnectionPointTypes);
  131550. /**
  131551. * Gets or sets the connection point name
  131552. */
  131553. name: string;
  131554. /**
  131555. * Gets or sets a boolean indicating that this connection point can be omitted
  131556. */
  131557. isOptional: boolean;
  131558. /**
  131559. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131560. */
  131561. define: string;
  131562. /** @hidden */
  131563. _prioritizeVertex: boolean;
  131564. private _target;
  131565. /** Gets or sets the target of that connection point */
  131566. get target(): NodeMaterialBlockTargets;
  131567. set target(value: NodeMaterialBlockTargets);
  131568. /**
  131569. * Gets a boolean indicating that the current point is connected
  131570. */
  131571. get isConnected(): boolean;
  131572. /**
  131573. * Gets a boolean indicating that the current point is connected to an input block
  131574. */
  131575. get isConnectedToInputBlock(): boolean;
  131576. /**
  131577. * Gets a the connected input block (if any)
  131578. */
  131579. get connectInputBlock(): Nullable<InputBlock>;
  131580. /** Get the other side of the connection (if any) */
  131581. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131582. /** Get the block that owns this connection point */
  131583. get ownerBlock(): NodeMaterialBlock;
  131584. /** Get the block connected on the other side of this connection (if any) */
  131585. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131586. /** Get the block connected on the endpoints of this connection (if any) */
  131587. get connectedBlocks(): Array<NodeMaterialBlock>;
  131588. /** Gets the list of connected endpoints */
  131589. get endpoints(): NodeMaterialConnectionPoint[];
  131590. /** Gets a boolean indicating if that output point is connected to at least one input */
  131591. get hasEndpoints(): boolean;
  131592. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131593. get isConnectedInVertexShader(): boolean;
  131594. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131595. get isConnectedInFragmentShader(): boolean;
  131596. /**
  131597. * Creates a new connection point
  131598. * @param name defines the connection point name
  131599. * @param ownerBlock defines the block hosting this connection point
  131600. * @param direction defines the direction of the connection point
  131601. */
  131602. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131603. /**
  131604. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131605. * @returns the class name
  131606. */
  131607. getClassName(): string;
  131608. /**
  131609. * Gets a boolean indicating if the current point can be connected to another point
  131610. * @param connectionPoint defines the other connection point
  131611. * @returns a boolean
  131612. */
  131613. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131614. /**
  131615. * Gets a number indicating if the current point can be connected to another point
  131616. * @param connectionPoint defines the other connection point
  131617. * @returns a number defining the compatibility state
  131618. */
  131619. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131620. /**
  131621. * Connect this point to another connection point
  131622. * @param connectionPoint defines the other connection point
  131623. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131624. * @returns the current connection point
  131625. */
  131626. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131627. /**
  131628. * Disconnect this point from one of his endpoint
  131629. * @param endpoint defines the other connection point
  131630. * @returns the current connection point
  131631. */
  131632. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131633. /**
  131634. * Serializes this point in a JSON representation
  131635. * @returns the serialized point object
  131636. */
  131637. serialize(): any;
  131638. /**
  131639. * Release resources
  131640. */
  131641. dispose(): void;
  131642. }
  131643. }
  131644. declare module BABYLON {
  131645. /**
  131646. * Block used to add support for vertex skinning (bones)
  131647. */
  131648. export class BonesBlock extends NodeMaterialBlock {
  131649. /**
  131650. * Creates a new BonesBlock
  131651. * @param name defines the block name
  131652. */
  131653. constructor(name: string);
  131654. /**
  131655. * Initialize the block and prepare the context for build
  131656. * @param state defines the state that will be used for the build
  131657. */
  131658. initialize(state: NodeMaterialBuildState): void;
  131659. /**
  131660. * Gets the current class name
  131661. * @returns the class name
  131662. */
  131663. getClassName(): string;
  131664. /**
  131665. * Gets the matrix indices input component
  131666. */
  131667. get matricesIndices(): NodeMaterialConnectionPoint;
  131668. /**
  131669. * Gets the matrix weights input component
  131670. */
  131671. get matricesWeights(): NodeMaterialConnectionPoint;
  131672. /**
  131673. * Gets the extra matrix indices input component
  131674. */
  131675. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131676. /**
  131677. * Gets the extra matrix weights input component
  131678. */
  131679. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131680. /**
  131681. * Gets the world input component
  131682. */
  131683. get world(): NodeMaterialConnectionPoint;
  131684. /**
  131685. * Gets the output component
  131686. */
  131687. get output(): NodeMaterialConnectionPoint;
  131688. autoConfigure(material: NodeMaterial): void;
  131689. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131692. protected _buildBlock(state: NodeMaterialBuildState): this;
  131693. }
  131694. }
  131695. declare module BABYLON {
  131696. /**
  131697. * Block used to add support for instances
  131698. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131699. */
  131700. export class InstancesBlock extends NodeMaterialBlock {
  131701. /**
  131702. * Creates a new InstancesBlock
  131703. * @param name defines the block name
  131704. */
  131705. constructor(name: string);
  131706. /**
  131707. * Gets the current class name
  131708. * @returns the class name
  131709. */
  131710. getClassName(): string;
  131711. /**
  131712. * Gets the first world row input component
  131713. */
  131714. get world0(): NodeMaterialConnectionPoint;
  131715. /**
  131716. * Gets the second world row input component
  131717. */
  131718. get world1(): NodeMaterialConnectionPoint;
  131719. /**
  131720. * Gets the third world row input component
  131721. */
  131722. get world2(): NodeMaterialConnectionPoint;
  131723. /**
  131724. * Gets the forth world row input component
  131725. */
  131726. get world3(): NodeMaterialConnectionPoint;
  131727. /**
  131728. * Gets the world input component
  131729. */
  131730. get world(): NodeMaterialConnectionPoint;
  131731. /**
  131732. * Gets the output component
  131733. */
  131734. get output(): NodeMaterialConnectionPoint;
  131735. /**
  131736. * Gets the isntanceID component
  131737. */
  131738. get instanceID(): NodeMaterialConnectionPoint;
  131739. autoConfigure(material: NodeMaterial): void;
  131740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131741. protected _buildBlock(state: NodeMaterialBuildState): this;
  131742. }
  131743. }
  131744. declare module BABYLON {
  131745. /**
  131746. * Block used to add morph targets support to vertex shader
  131747. */
  131748. export class MorphTargetsBlock extends NodeMaterialBlock {
  131749. private _repeatableContentAnchor;
  131750. /**
  131751. * Create a new MorphTargetsBlock
  131752. * @param name defines the block name
  131753. */
  131754. constructor(name: string);
  131755. /**
  131756. * Gets the current class name
  131757. * @returns the class name
  131758. */
  131759. getClassName(): string;
  131760. /**
  131761. * Gets the position input component
  131762. */
  131763. get position(): NodeMaterialConnectionPoint;
  131764. /**
  131765. * Gets the normal input component
  131766. */
  131767. get normal(): NodeMaterialConnectionPoint;
  131768. /**
  131769. * Gets the tangent input component
  131770. */
  131771. get tangent(): NodeMaterialConnectionPoint;
  131772. /**
  131773. * Gets the tangent input component
  131774. */
  131775. get uv(): NodeMaterialConnectionPoint;
  131776. /**
  131777. * Gets the position output component
  131778. */
  131779. get positionOutput(): NodeMaterialConnectionPoint;
  131780. /**
  131781. * Gets the normal output component
  131782. */
  131783. get normalOutput(): NodeMaterialConnectionPoint;
  131784. /**
  131785. * Gets the tangent output component
  131786. */
  131787. get tangentOutput(): NodeMaterialConnectionPoint;
  131788. /**
  131789. * Gets the tangent output component
  131790. */
  131791. get uvOutput(): NodeMaterialConnectionPoint;
  131792. initialize(state: NodeMaterialBuildState): void;
  131793. autoConfigure(material: NodeMaterial): void;
  131794. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131795. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131796. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131797. protected _buildBlock(state: NodeMaterialBuildState): this;
  131798. }
  131799. }
  131800. declare module BABYLON {
  131801. /**
  131802. * Block used to get data information from a light
  131803. */
  131804. export class LightInformationBlock extends NodeMaterialBlock {
  131805. private _lightDataUniformName;
  131806. private _lightColorUniformName;
  131807. private _lightTypeDefineName;
  131808. /**
  131809. * Gets or sets the light associated with this block
  131810. */
  131811. light: Nullable<Light>;
  131812. /**
  131813. * Creates a new LightInformationBlock
  131814. * @param name defines the block name
  131815. */
  131816. constructor(name: string);
  131817. /**
  131818. * Gets the current class name
  131819. * @returns the class name
  131820. */
  131821. getClassName(): string;
  131822. /**
  131823. * Gets the world position input component
  131824. */
  131825. get worldPosition(): NodeMaterialConnectionPoint;
  131826. /**
  131827. * Gets the direction output component
  131828. */
  131829. get direction(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the direction output component
  131832. */
  131833. get color(): NodeMaterialConnectionPoint;
  131834. /**
  131835. * Gets the direction output component
  131836. */
  131837. get intensity(): NodeMaterialConnectionPoint;
  131838. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131839. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131840. protected _buildBlock(state: NodeMaterialBuildState): this;
  131841. serialize(): any;
  131842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131843. }
  131844. }
  131845. declare module BABYLON {
  131846. /**
  131847. * Block used to add image processing support to fragment shader
  131848. */
  131849. export class ImageProcessingBlock extends NodeMaterialBlock {
  131850. /**
  131851. * Create a new ImageProcessingBlock
  131852. * @param name defines the block name
  131853. */
  131854. constructor(name: string);
  131855. /**
  131856. * Gets the current class name
  131857. * @returns the class name
  131858. */
  131859. getClassName(): string;
  131860. /**
  131861. * Gets the color input component
  131862. */
  131863. get color(): NodeMaterialConnectionPoint;
  131864. /**
  131865. * Gets the output component
  131866. */
  131867. get output(): NodeMaterialConnectionPoint;
  131868. /**
  131869. * Initialize the block and prepare the context for build
  131870. * @param state defines the state that will be used for the build
  131871. */
  131872. initialize(state: NodeMaterialBuildState): void;
  131873. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131876. protected _buildBlock(state: NodeMaterialBuildState): this;
  131877. }
  131878. }
  131879. declare module BABYLON {
  131880. /**
  131881. * Block used to pertub normals based on a normal map
  131882. */
  131883. export class PerturbNormalBlock extends NodeMaterialBlock {
  131884. private _tangentSpaceParameterName;
  131885. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131886. invertX: boolean;
  131887. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131888. invertY: boolean;
  131889. /**
  131890. * Create a new PerturbNormalBlock
  131891. * @param name defines the block name
  131892. */
  131893. constructor(name: string);
  131894. /**
  131895. * Gets the current class name
  131896. * @returns the class name
  131897. */
  131898. getClassName(): string;
  131899. /**
  131900. * Gets the world position input component
  131901. */
  131902. get worldPosition(): NodeMaterialConnectionPoint;
  131903. /**
  131904. * Gets the world normal input component
  131905. */
  131906. get worldNormal(): NodeMaterialConnectionPoint;
  131907. /**
  131908. * Gets the world tangent input component
  131909. */
  131910. get worldTangent(): NodeMaterialConnectionPoint;
  131911. /**
  131912. * Gets the uv input component
  131913. */
  131914. get uv(): NodeMaterialConnectionPoint;
  131915. /**
  131916. * Gets the normal map color input component
  131917. */
  131918. get normalMapColor(): NodeMaterialConnectionPoint;
  131919. /**
  131920. * Gets the strength input component
  131921. */
  131922. get strength(): NodeMaterialConnectionPoint;
  131923. /**
  131924. * Gets the output component
  131925. */
  131926. get output(): NodeMaterialConnectionPoint;
  131927. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131929. autoConfigure(material: NodeMaterial): void;
  131930. protected _buildBlock(state: NodeMaterialBuildState): this;
  131931. protected _dumpPropertiesCode(): string;
  131932. serialize(): any;
  131933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131934. }
  131935. }
  131936. declare module BABYLON {
  131937. /**
  131938. * Block used to discard a pixel if a value is smaller than a cutoff
  131939. */
  131940. export class DiscardBlock extends NodeMaterialBlock {
  131941. /**
  131942. * Create a new DiscardBlock
  131943. * @param name defines the block name
  131944. */
  131945. constructor(name: string);
  131946. /**
  131947. * Gets the current class name
  131948. * @returns the class name
  131949. */
  131950. getClassName(): string;
  131951. /**
  131952. * Gets the color input component
  131953. */
  131954. get value(): NodeMaterialConnectionPoint;
  131955. /**
  131956. * Gets the cutoff input component
  131957. */
  131958. get cutoff(): NodeMaterialConnectionPoint;
  131959. protected _buildBlock(state: NodeMaterialBuildState): this;
  131960. }
  131961. }
  131962. declare module BABYLON {
  131963. /**
  131964. * Block used to test if the fragment shader is front facing
  131965. */
  131966. export class FrontFacingBlock extends NodeMaterialBlock {
  131967. /**
  131968. * Creates a new FrontFacingBlock
  131969. * @param name defines the block name
  131970. */
  131971. constructor(name: string);
  131972. /**
  131973. * Gets the current class name
  131974. * @returns the class name
  131975. */
  131976. getClassName(): string;
  131977. /**
  131978. * Gets the output component
  131979. */
  131980. get output(): NodeMaterialConnectionPoint;
  131981. protected _buildBlock(state: NodeMaterialBuildState): this;
  131982. }
  131983. }
  131984. declare module BABYLON {
  131985. /**
  131986. * Block used to get the derivative value on x and y of a given input
  131987. */
  131988. export class DerivativeBlock extends NodeMaterialBlock {
  131989. /**
  131990. * Create a new DerivativeBlock
  131991. * @param name defines the block name
  131992. */
  131993. constructor(name: string);
  131994. /**
  131995. * Gets the current class name
  131996. * @returns the class name
  131997. */
  131998. getClassName(): string;
  131999. /**
  132000. * Gets the input component
  132001. */
  132002. get input(): NodeMaterialConnectionPoint;
  132003. /**
  132004. * Gets the derivative output on x
  132005. */
  132006. get dx(): NodeMaterialConnectionPoint;
  132007. /**
  132008. * Gets the derivative output on y
  132009. */
  132010. get dy(): NodeMaterialConnectionPoint;
  132011. protected _buildBlock(state: NodeMaterialBuildState): this;
  132012. }
  132013. }
  132014. declare module BABYLON {
  132015. /**
  132016. * Block used to add support for scene fog
  132017. */
  132018. export class FogBlock extends NodeMaterialBlock {
  132019. private _fogDistanceName;
  132020. private _fogParameters;
  132021. /**
  132022. * Create a new FogBlock
  132023. * @param name defines the block name
  132024. */
  132025. constructor(name: string);
  132026. /**
  132027. * Gets the current class name
  132028. * @returns the class name
  132029. */
  132030. getClassName(): string;
  132031. /**
  132032. * Gets the world position input component
  132033. */
  132034. get worldPosition(): NodeMaterialConnectionPoint;
  132035. /**
  132036. * Gets the view input component
  132037. */
  132038. get view(): NodeMaterialConnectionPoint;
  132039. /**
  132040. * Gets the color input component
  132041. */
  132042. get input(): NodeMaterialConnectionPoint;
  132043. /**
  132044. * Gets the fog color input component
  132045. */
  132046. get fogColor(): NodeMaterialConnectionPoint;
  132047. /**
  132048. * Gets the output component
  132049. */
  132050. get output(): NodeMaterialConnectionPoint;
  132051. autoConfigure(material: NodeMaterial): void;
  132052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132053. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132054. protected _buildBlock(state: NodeMaterialBuildState): this;
  132055. }
  132056. }
  132057. declare module BABYLON {
  132058. /**
  132059. * Block used to add light in the fragment shader
  132060. */
  132061. export class LightBlock extends NodeMaterialBlock {
  132062. private _lightId;
  132063. /**
  132064. * Gets or sets the light associated with this block
  132065. */
  132066. light: Nullable<Light>;
  132067. /**
  132068. * Create a new LightBlock
  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 world position input component
  132079. */
  132080. get worldPosition(): NodeMaterialConnectionPoint;
  132081. /**
  132082. * Gets the world normal input component
  132083. */
  132084. get worldNormal(): NodeMaterialConnectionPoint;
  132085. /**
  132086. * Gets the camera (or eye) position component
  132087. */
  132088. get cameraPosition(): NodeMaterialConnectionPoint;
  132089. /**
  132090. * Gets the glossiness component
  132091. */
  132092. get glossiness(): NodeMaterialConnectionPoint;
  132093. /**
  132094. * Gets the glossinness power component
  132095. */
  132096. get glossPower(): NodeMaterialConnectionPoint;
  132097. /**
  132098. * Gets the diffuse color component
  132099. */
  132100. get diffuseColor(): NodeMaterialConnectionPoint;
  132101. /**
  132102. * Gets the specular color component
  132103. */
  132104. get specularColor(): NodeMaterialConnectionPoint;
  132105. /**
  132106. * Gets the diffuse output component
  132107. */
  132108. get diffuseOutput(): NodeMaterialConnectionPoint;
  132109. /**
  132110. * Gets the specular output component
  132111. */
  132112. get specularOutput(): NodeMaterialConnectionPoint;
  132113. /**
  132114. * Gets the shadow output component
  132115. */
  132116. get shadow(): NodeMaterialConnectionPoint;
  132117. autoConfigure(material: NodeMaterial): void;
  132118. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132119. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132121. private _injectVertexCode;
  132122. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132123. serialize(): any;
  132124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132125. }
  132126. }
  132127. declare module BABYLON {
  132128. /**
  132129. * Block used to multiply 2 values
  132130. */
  132131. export class MultiplyBlock extends NodeMaterialBlock {
  132132. /**
  132133. * Creates a new MultiplyBlock
  132134. * @param name defines the block name
  132135. */
  132136. constructor(name: string);
  132137. /**
  132138. * Gets the current class name
  132139. * @returns the class name
  132140. */
  132141. getClassName(): string;
  132142. /**
  132143. * Gets the left operand input component
  132144. */
  132145. get left(): NodeMaterialConnectionPoint;
  132146. /**
  132147. * Gets the right operand input component
  132148. */
  132149. get right(): NodeMaterialConnectionPoint;
  132150. /**
  132151. * Gets the output component
  132152. */
  132153. get output(): NodeMaterialConnectionPoint;
  132154. protected _buildBlock(state: NodeMaterialBuildState): this;
  132155. }
  132156. }
  132157. declare module BABYLON {
  132158. /**
  132159. * Block used to add 2 vectors
  132160. */
  132161. export class AddBlock extends NodeMaterialBlock {
  132162. /**
  132163. * Creates a new AddBlock
  132164. * @param name defines the block name
  132165. */
  132166. constructor(name: string);
  132167. /**
  132168. * Gets the current class name
  132169. * @returns the class name
  132170. */
  132171. getClassName(): string;
  132172. /**
  132173. * Gets the left operand input component
  132174. */
  132175. get left(): NodeMaterialConnectionPoint;
  132176. /**
  132177. * Gets the right operand input component
  132178. */
  132179. get right(): NodeMaterialConnectionPoint;
  132180. /**
  132181. * Gets the output component
  132182. */
  132183. get output(): NodeMaterialConnectionPoint;
  132184. protected _buildBlock(state: NodeMaterialBuildState): this;
  132185. }
  132186. }
  132187. declare module BABYLON {
  132188. /**
  132189. * Block used to scale a vector by a float
  132190. */
  132191. export class ScaleBlock extends NodeMaterialBlock {
  132192. /**
  132193. * Creates a new ScaleBlock
  132194. * @param name defines the block name
  132195. */
  132196. constructor(name: string);
  132197. /**
  132198. * Gets the current class name
  132199. * @returns the class name
  132200. */
  132201. getClassName(): string;
  132202. /**
  132203. * Gets the input component
  132204. */
  132205. get input(): NodeMaterialConnectionPoint;
  132206. /**
  132207. * Gets the factor input component
  132208. */
  132209. get factor(): NodeMaterialConnectionPoint;
  132210. /**
  132211. * Gets the output component
  132212. */
  132213. get output(): NodeMaterialConnectionPoint;
  132214. protected _buildBlock(state: NodeMaterialBuildState): this;
  132215. }
  132216. }
  132217. declare module BABYLON {
  132218. /**
  132219. * Block used to clamp a float
  132220. */
  132221. export class ClampBlock extends NodeMaterialBlock {
  132222. /** Gets or sets the minimum range */
  132223. minimum: number;
  132224. /** Gets or sets the maximum range */
  132225. maximum: number;
  132226. /**
  132227. * Creates a new ClampBlock
  132228. * @param name defines the block name
  132229. */
  132230. constructor(name: string);
  132231. /**
  132232. * Gets the current class name
  132233. * @returns the class name
  132234. */
  132235. getClassName(): string;
  132236. /**
  132237. * Gets the value input component
  132238. */
  132239. get value(): NodeMaterialConnectionPoint;
  132240. /**
  132241. * Gets the output component
  132242. */
  132243. get output(): NodeMaterialConnectionPoint;
  132244. protected _buildBlock(state: NodeMaterialBuildState): this;
  132245. protected _dumpPropertiesCode(): string;
  132246. serialize(): any;
  132247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132248. }
  132249. }
  132250. declare module BABYLON {
  132251. /**
  132252. * Block used to apply a cross product between 2 vectors
  132253. */
  132254. export class CrossBlock extends NodeMaterialBlock {
  132255. /**
  132256. * Creates a new CrossBlock
  132257. * @param name defines the block name
  132258. */
  132259. constructor(name: string);
  132260. /**
  132261. * Gets the current class name
  132262. * @returns the class name
  132263. */
  132264. getClassName(): string;
  132265. /**
  132266. * Gets the left operand input component
  132267. */
  132268. get left(): NodeMaterialConnectionPoint;
  132269. /**
  132270. * Gets the right operand input component
  132271. */
  132272. get right(): NodeMaterialConnectionPoint;
  132273. /**
  132274. * Gets the output component
  132275. */
  132276. get output(): NodeMaterialConnectionPoint;
  132277. protected _buildBlock(state: NodeMaterialBuildState): this;
  132278. }
  132279. }
  132280. declare module BABYLON {
  132281. /**
  132282. * Block used to apply a dot product between 2 vectors
  132283. */
  132284. export class DotBlock extends NodeMaterialBlock {
  132285. /**
  132286. * Creates a new DotBlock
  132287. * @param name defines the block name
  132288. */
  132289. constructor(name: string);
  132290. /**
  132291. * Gets the current class name
  132292. * @returns the class name
  132293. */
  132294. getClassName(): string;
  132295. /**
  132296. * Gets the left operand input component
  132297. */
  132298. get left(): NodeMaterialConnectionPoint;
  132299. /**
  132300. * Gets the right operand input component
  132301. */
  132302. get right(): NodeMaterialConnectionPoint;
  132303. /**
  132304. * Gets the output component
  132305. */
  132306. get output(): NodeMaterialConnectionPoint;
  132307. protected _buildBlock(state: NodeMaterialBuildState): this;
  132308. }
  132309. }
  132310. declare module BABYLON {
  132311. /**
  132312. * Block used to remap a float from a range to a new one
  132313. */
  132314. export class RemapBlock extends NodeMaterialBlock {
  132315. /**
  132316. * Gets or sets the source range
  132317. */
  132318. sourceRange: Vector2;
  132319. /**
  132320. * Gets or sets the target range
  132321. */
  132322. targetRange: Vector2;
  132323. /**
  132324. * Creates a new RemapBlock
  132325. * @param name defines the block name
  132326. */
  132327. constructor(name: string);
  132328. /**
  132329. * Gets the current class name
  132330. * @returns the class name
  132331. */
  132332. getClassName(): string;
  132333. /**
  132334. * Gets the input component
  132335. */
  132336. get input(): NodeMaterialConnectionPoint;
  132337. /**
  132338. * Gets the source min input component
  132339. */
  132340. get sourceMin(): NodeMaterialConnectionPoint;
  132341. /**
  132342. * Gets the source max input component
  132343. */
  132344. get sourceMax(): NodeMaterialConnectionPoint;
  132345. /**
  132346. * Gets the target min input component
  132347. */
  132348. get targetMin(): NodeMaterialConnectionPoint;
  132349. /**
  132350. * Gets the target max input component
  132351. */
  132352. get targetMax(): NodeMaterialConnectionPoint;
  132353. /**
  132354. * Gets the output component
  132355. */
  132356. get output(): NodeMaterialConnectionPoint;
  132357. protected _buildBlock(state: NodeMaterialBuildState): this;
  132358. protected _dumpPropertiesCode(): string;
  132359. serialize(): any;
  132360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132361. }
  132362. }
  132363. declare module BABYLON {
  132364. /**
  132365. * Block used to normalize a vector
  132366. */
  132367. export class NormalizeBlock extends NodeMaterialBlock {
  132368. /**
  132369. * Creates a new NormalizeBlock
  132370. * @param name defines the block name
  132371. */
  132372. constructor(name: string);
  132373. /**
  132374. * Gets the current class name
  132375. * @returns the class name
  132376. */
  132377. getClassName(): string;
  132378. /**
  132379. * Gets the input component
  132380. */
  132381. get input(): NodeMaterialConnectionPoint;
  132382. /**
  132383. * Gets the output component
  132384. */
  132385. get output(): NodeMaterialConnectionPoint;
  132386. protected _buildBlock(state: NodeMaterialBuildState): this;
  132387. }
  132388. }
  132389. declare module BABYLON {
  132390. /**
  132391. * Operations supported by the Trigonometry block
  132392. */
  132393. export enum TrigonometryBlockOperations {
  132394. /** Cos */
  132395. Cos = 0,
  132396. /** Sin */
  132397. Sin = 1,
  132398. /** Abs */
  132399. Abs = 2,
  132400. /** Exp */
  132401. Exp = 3,
  132402. /** Exp2 */
  132403. Exp2 = 4,
  132404. /** Round */
  132405. Round = 5,
  132406. /** Floor */
  132407. Floor = 6,
  132408. /** Ceiling */
  132409. Ceiling = 7,
  132410. /** Square root */
  132411. Sqrt = 8,
  132412. /** Log */
  132413. Log = 9,
  132414. /** Tangent */
  132415. Tan = 10,
  132416. /** Arc tangent */
  132417. ArcTan = 11,
  132418. /** Arc cosinus */
  132419. ArcCos = 12,
  132420. /** Arc sinus */
  132421. ArcSin = 13,
  132422. /** Fraction */
  132423. Fract = 14,
  132424. /** Sign */
  132425. Sign = 15,
  132426. /** To radians (from degrees) */
  132427. Radians = 16,
  132428. /** To degrees (from radians) */
  132429. Degrees = 17
  132430. }
  132431. /**
  132432. * Block used to apply trigonometry operation to floats
  132433. */
  132434. export class TrigonometryBlock extends NodeMaterialBlock {
  132435. /**
  132436. * Gets or sets the operation applied by the block
  132437. */
  132438. operation: TrigonometryBlockOperations;
  132439. /**
  132440. * Creates a new TrigonometryBlock
  132441. * @param name defines the block name
  132442. */
  132443. constructor(name: string);
  132444. /**
  132445. * Gets the current class name
  132446. * @returns the class name
  132447. */
  132448. getClassName(): string;
  132449. /**
  132450. * Gets the input component
  132451. */
  132452. get input(): NodeMaterialConnectionPoint;
  132453. /**
  132454. * Gets the output component
  132455. */
  132456. get output(): NodeMaterialConnectionPoint;
  132457. protected _buildBlock(state: NodeMaterialBuildState): this;
  132458. serialize(): any;
  132459. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132460. protected _dumpPropertiesCode(): string;
  132461. }
  132462. }
  132463. declare module BABYLON {
  132464. /**
  132465. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132466. */
  132467. export class ColorMergerBlock extends NodeMaterialBlock {
  132468. /**
  132469. * Create a new ColorMergerBlock
  132470. * @param name defines the block name
  132471. */
  132472. constructor(name: string);
  132473. /**
  132474. * Gets the current class name
  132475. * @returns the class name
  132476. */
  132477. getClassName(): string;
  132478. /**
  132479. * Gets the rgb component (input)
  132480. */
  132481. get rgbIn(): NodeMaterialConnectionPoint;
  132482. /**
  132483. * Gets the r component (input)
  132484. */
  132485. get r(): NodeMaterialConnectionPoint;
  132486. /**
  132487. * Gets the g component (input)
  132488. */
  132489. get g(): NodeMaterialConnectionPoint;
  132490. /**
  132491. * Gets the b component (input)
  132492. */
  132493. get b(): NodeMaterialConnectionPoint;
  132494. /**
  132495. * Gets the a component (input)
  132496. */
  132497. get a(): NodeMaterialConnectionPoint;
  132498. /**
  132499. * Gets the rgba component (output)
  132500. */
  132501. get rgba(): NodeMaterialConnectionPoint;
  132502. /**
  132503. * Gets the rgb component (output)
  132504. */
  132505. get rgbOut(): NodeMaterialConnectionPoint;
  132506. /**
  132507. * Gets the rgb component (output)
  132508. * @deprecated Please use rgbOut instead.
  132509. */
  132510. get rgb(): NodeMaterialConnectionPoint;
  132511. protected _buildBlock(state: NodeMaterialBuildState): this;
  132512. }
  132513. }
  132514. declare module BABYLON {
  132515. /**
  132516. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132517. */
  132518. export class VectorMergerBlock extends NodeMaterialBlock {
  132519. /**
  132520. * Create a new VectorMergerBlock
  132521. * @param name defines the block name
  132522. */
  132523. constructor(name: string);
  132524. /**
  132525. * Gets the current class name
  132526. * @returns the class name
  132527. */
  132528. getClassName(): string;
  132529. /**
  132530. * Gets the xyz component (input)
  132531. */
  132532. get xyzIn(): NodeMaterialConnectionPoint;
  132533. /**
  132534. * Gets the xy component (input)
  132535. */
  132536. get xyIn(): NodeMaterialConnectionPoint;
  132537. /**
  132538. * Gets the x component (input)
  132539. */
  132540. get x(): NodeMaterialConnectionPoint;
  132541. /**
  132542. * Gets the y component (input)
  132543. */
  132544. get y(): NodeMaterialConnectionPoint;
  132545. /**
  132546. * Gets the z component (input)
  132547. */
  132548. get z(): NodeMaterialConnectionPoint;
  132549. /**
  132550. * Gets the w component (input)
  132551. */
  132552. get w(): NodeMaterialConnectionPoint;
  132553. /**
  132554. * Gets the xyzw component (output)
  132555. */
  132556. get xyzw(): NodeMaterialConnectionPoint;
  132557. /**
  132558. * Gets the xyz component (output)
  132559. */
  132560. get xyzOut(): NodeMaterialConnectionPoint;
  132561. /**
  132562. * Gets the xy component (output)
  132563. */
  132564. get xyOut(): NodeMaterialConnectionPoint;
  132565. /**
  132566. * Gets the xy component (output)
  132567. * @deprecated Please use xyOut instead.
  132568. */
  132569. get xy(): NodeMaterialConnectionPoint;
  132570. /**
  132571. * Gets the xyz component (output)
  132572. * @deprecated Please use xyzOut instead.
  132573. */
  132574. get xyz(): NodeMaterialConnectionPoint;
  132575. protected _buildBlock(state: NodeMaterialBuildState): this;
  132576. }
  132577. }
  132578. declare module BABYLON {
  132579. /**
  132580. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132581. */
  132582. export class ColorSplitterBlock extends NodeMaterialBlock {
  132583. /**
  132584. * Create a new ColorSplitterBlock
  132585. * @param name defines the block name
  132586. */
  132587. constructor(name: string);
  132588. /**
  132589. * Gets the current class name
  132590. * @returns the class name
  132591. */
  132592. getClassName(): string;
  132593. /**
  132594. * Gets the rgba component (input)
  132595. */
  132596. get rgba(): NodeMaterialConnectionPoint;
  132597. /**
  132598. * Gets the rgb component (input)
  132599. */
  132600. get rgbIn(): NodeMaterialConnectionPoint;
  132601. /**
  132602. * Gets the rgb component (output)
  132603. */
  132604. get rgbOut(): NodeMaterialConnectionPoint;
  132605. /**
  132606. * Gets the r component (output)
  132607. */
  132608. get r(): NodeMaterialConnectionPoint;
  132609. /**
  132610. * Gets the g component (output)
  132611. */
  132612. get g(): NodeMaterialConnectionPoint;
  132613. /**
  132614. * Gets the b component (output)
  132615. */
  132616. get b(): NodeMaterialConnectionPoint;
  132617. /**
  132618. * Gets the a component (output)
  132619. */
  132620. get a(): NodeMaterialConnectionPoint;
  132621. protected _inputRename(name: string): string;
  132622. protected _outputRename(name: string): string;
  132623. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132624. }
  132625. }
  132626. declare module BABYLON {
  132627. /**
  132628. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132629. */
  132630. export class VectorSplitterBlock extends NodeMaterialBlock {
  132631. /**
  132632. * Create a new VectorSplitterBlock
  132633. * @param name defines the block name
  132634. */
  132635. constructor(name: string);
  132636. /**
  132637. * Gets the current class name
  132638. * @returns the class name
  132639. */
  132640. getClassName(): string;
  132641. /**
  132642. * Gets the xyzw component (input)
  132643. */
  132644. get xyzw(): NodeMaterialConnectionPoint;
  132645. /**
  132646. * Gets the xyz component (input)
  132647. */
  132648. get xyzIn(): NodeMaterialConnectionPoint;
  132649. /**
  132650. * Gets the xy component (input)
  132651. */
  132652. get xyIn(): NodeMaterialConnectionPoint;
  132653. /**
  132654. * Gets the xyz component (output)
  132655. */
  132656. get xyzOut(): NodeMaterialConnectionPoint;
  132657. /**
  132658. * Gets the xy component (output)
  132659. */
  132660. get xyOut(): NodeMaterialConnectionPoint;
  132661. /**
  132662. * Gets the x component (output)
  132663. */
  132664. get x(): NodeMaterialConnectionPoint;
  132665. /**
  132666. * Gets the y component (output)
  132667. */
  132668. get y(): NodeMaterialConnectionPoint;
  132669. /**
  132670. * Gets the z component (output)
  132671. */
  132672. get z(): NodeMaterialConnectionPoint;
  132673. /**
  132674. * Gets the w component (output)
  132675. */
  132676. get w(): NodeMaterialConnectionPoint;
  132677. protected _inputRename(name: string): string;
  132678. protected _outputRename(name: string): string;
  132679. protected _buildBlock(state: NodeMaterialBuildState): this;
  132680. }
  132681. }
  132682. declare module BABYLON {
  132683. /**
  132684. * Block used to lerp between 2 values
  132685. */
  132686. export class LerpBlock extends NodeMaterialBlock {
  132687. /**
  132688. * Creates a new LerpBlock
  132689. * @param name defines the block name
  132690. */
  132691. constructor(name: string);
  132692. /**
  132693. * Gets the current class name
  132694. * @returns the class name
  132695. */
  132696. getClassName(): string;
  132697. /**
  132698. * Gets the left operand input component
  132699. */
  132700. get left(): NodeMaterialConnectionPoint;
  132701. /**
  132702. * Gets the right operand input component
  132703. */
  132704. get right(): NodeMaterialConnectionPoint;
  132705. /**
  132706. * Gets the gradient operand input component
  132707. */
  132708. get gradient(): NodeMaterialConnectionPoint;
  132709. /**
  132710. * Gets the output component
  132711. */
  132712. get output(): NodeMaterialConnectionPoint;
  132713. protected _buildBlock(state: NodeMaterialBuildState): this;
  132714. }
  132715. }
  132716. declare module BABYLON {
  132717. /**
  132718. * Block used to divide 2 vectors
  132719. */
  132720. export class DivideBlock extends NodeMaterialBlock {
  132721. /**
  132722. * Creates a new DivideBlock
  132723. * @param name defines the block name
  132724. */
  132725. constructor(name: string);
  132726. /**
  132727. * Gets the current class name
  132728. * @returns the class name
  132729. */
  132730. getClassName(): string;
  132731. /**
  132732. * Gets the left operand input component
  132733. */
  132734. get left(): NodeMaterialConnectionPoint;
  132735. /**
  132736. * Gets the right operand input component
  132737. */
  132738. get right(): NodeMaterialConnectionPoint;
  132739. /**
  132740. * Gets the output component
  132741. */
  132742. get output(): NodeMaterialConnectionPoint;
  132743. protected _buildBlock(state: NodeMaterialBuildState): this;
  132744. }
  132745. }
  132746. declare module BABYLON {
  132747. /**
  132748. * Block used to subtract 2 vectors
  132749. */
  132750. export class SubtractBlock extends NodeMaterialBlock {
  132751. /**
  132752. * Creates a new SubtractBlock
  132753. * @param name defines the block name
  132754. */
  132755. constructor(name: string);
  132756. /**
  132757. * Gets the current class name
  132758. * @returns the class name
  132759. */
  132760. getClassName(): string;
  132761. /**
  132762. * Gets the left operand input component
  132763. */
  132764. get left(): NodeMaterialConnectionPoint;
  132765. /**
  132766. * Gets the right operand input component
  132767. */
  132768. get right(): NodeMaterialConnectionPoint;
  132769. /**
  132770. * Gets the output component
  132771. */
  132772. get output(): NodeMaterialConnectionPoint;
  132773. protected _buildBlock(state: NodeMaterialBuildState): this;
  132774. }
  132775. }
  132776. declare module BABYLON {
  132777. /**
  132778. * Block used to step a value
  132779. */
  132780. export class StepBlock extends NodeMaterialBlock {
  132781. /**
  132782. * Creates a new StepBlock
  132783. * @param name defines the block name
  132784. */
  132785. constructor(name: string);
  132786. /**
  132787. * Gets the current class name
  132788. * @returns the class name
  132789. */
  132790. getClassName(): string;
  132791. /**
  132792. * Gets the value operand input component
  132793. */
  132794. get value(): NodeMaterialConnectionPoint;
  132795. /**
  132796. * Gets the edge operand input component
  132797. */
  132798. get edge(): NodeMaterialConnectionPoint;
  132799. /**
  132800. * Gets the output component
  132801. */
  132802. get output(): NodeMaterialConnectionPoint;
  132803. protected _buildBlock(state: NodeMaterialBuildState): this;
  132804. }
  132805. }
  132806. declare module BABYLON {
  132807. /**
  132808. * Block used to get the opposite (1 - x) of a value
  132809. */
  132810. export class OneMinusBlock extends NodeMaterialBlock {
  132811. /**
  132812. * Creates a new OneMinusBlock
  132813. * @param name defines the block name
  132814. */
  132815. constructor(name: string);
  132816. /**
  132817. * Gets the current class name
  132818. * @returns the class name
  132819. */
  132820. getClassName(): string;
  132821. /**
  132822. * Gets the input component
  132823. */
  132824. get input(): NodeMaterialConnectionPoint;
  132825. /**
  132826. * Gets the output component
  132827. */
  132828. get output(): NodeMaterialConnectionPoint;
  132829. protected _buildBlock(state: NodeMaterialBuildState): this;
  132830. }
  132831. }
  132832. declare module BABYLON {
  132833. /**
  132834. * Block used to get the view direction
  132835. */
  132836. export class ViewDirectionBlock extends NodeMaterialBlock {
  132837. /**
  132838. * Creates a new ViewDirectionBlock
  132839. * @param name defines the block name
  132840. */
  132841. constructor(name: string);
  132842. /**
  132843. * Gets the current class name
  132844. * @returns the class name
  132845. */
  132846. getClassName(): string;
  132847. /**
  132848. * Gets the world position component
  132849. */
  132850. get worldPosition(): NodeMaterialConnectionPoint;
  132851. /**
  132852. * Gets the camera position component
  132853. */
  132854. get cameraPosition(): NodeMaterialConnectionPoint;
  132855. /**
  132856. * Gets the output component
  132857. */
  132858. get output(): NodeMaterialConnectionPoint;
  132859. autoConfigure(material: NodeMaterial): void;
  132860. protected _buildBlock(state: NodeMaterialBuildState): this;
  132861. }
  132862. }
  132863. declare module BABYLON {
  132864. /**
  132865. * Block used to compute fresnel value
  132866. */
  132867. export class FresnelBlock extends NodeMaterialBlock {
  132868. /**
  132869. * Create a new FresnelBlock
  132870. * @param name defines the block name
  132871. */
  132872. constructor(name: string);
  132873. /**
  132874. * Gets the current class name
  132875. * @returns the class name
  132876. */
  132877. getClassName(): string;
  132878. /**
  132879. * Gets the world normal input component
  132880. */
  132881. get worldNormal(): NodeMaterialConnectionPoint;
  132882. /**
  132883. * Gets the view direction input component
  132884. */
  132885. get viewDirection(): NodeMaterialConnectionPoint;
  132886. /**
  132887. * Gets the bias input component
  132888. */
  132889. get bias(): NodeMaterialConnectionPoint;
  132890. /**
  132891. * Gets the camera (or eye) position component
  132892. */
  132893. get power(): NodeMaterialConnectionPoint;
  132894. /**
  132895. * Gets the fresnel output component
  132896. */
  132897. get fresnel(): NodeMaterialConnectionPoint;
  132898. autoConfigure(material: NodeMaterial): void;
  132899. protected _buildBlock(state: NodeMaterialBuildState): this;
  132900. }
  132901. }
  132902. declare module BABYLON {
  132903. /**
  132904. * Block used to get the max of 2 values
  132905. */
  132906. export class MaxBlock extends NodeMaterialBlock {
  132907. /**
  132908. * Creates a new MaxBlock
  132909. * @param name defines the block name
  132910. */
  132911. constructor(name: string);
  132912. /**
  132913. * Gets the current class name
  132914. * @returns the class name
  132915. */
  132916. getClassName(): string;
  132917. /**
  132918. * Gets the left operand input component
  132919. */
  132920. get left(): NodeMaterialConnectionPoint;
  132921. /**
  132922. * Gets the right operand input component
  132923. */
  132924. get right(): NodeMaterialConnectionPoint;
  132925. /**
  132926. * Gets the output component
  132927. */
  132928. get output(): NodeMaterialConnectionPoint;
  132929. protected _buildBlock(state: NodeMaterialBuildState): this;
  132930. }
  132931. }
  132932. declare module BABYLON {
  132933. /**
  132934. * Block used to get the min of 2 values
  132935. */
  132936. export class MinBlock extends NodeMaterialBlock {
  132937. /**
  132938. * Creates a new MinBlock
  132939. * @param name defines the block name
  132940. */
  132941. constructor(name: string);
  132942. /**
  132943. * Gets the current class name
  132944. * @returns the class name
  132945. */
  132946. getClassName(): string;
  132947. /**
  132948. * Gets the left operand input component
  132949. */
  132950. get left(): NodeMaterialConnectionPoint;
  132951. /**
  132952. * Gets the right operand input component
  132953. */
  132954. get right(): NodeMaterialConnectionPoint;
  132955. /**
  132956. * Gets the output component
  132957. */
  132958. get output(): NodeMaterialConnectionPoint;
  132959. protected _buildBlock(state: NodeMaterialBuildState): this;
  132960. }
  132961. }
  132962. declare module BABYLON {
  132963. /**
  132964. * Block used to get the distance between 2 values
  132965. */
  132966. export class DistanceBlock extends NodeMaterialBlock {
  132967. /**
  132968. * Creates a new DistanceBlock
  132969. * @param name defines the block name
  132970. */
  132971. constructor(name: string);
  132972. /**
  132973. * Gets the current class name
  132974. * @returns the class name
  132975. */
  132976. getClassName(): string;
  132977. /**
  132978. * Gets the left operand input component
  132979. */
  132980. get left(): NodeMaterialConnectionPoint;
  132981. /**
  132982. * Gets the right operand input component
  132983. */
  132984. get right(): NodeMaterialConnectionPoint;
  132985. /**
  132986. * Gets the output component
  132987. */
  132988. get output(): NodeMaterialConnectionPoint;
  132989. protected _buildBlock(state: NodeMaterialBuildState): this;
  132990. }
  132991. }
  132992. declare module BABYLON {
  132993. /**
  132994. * Block used to get the length of a vector
  132995. */
  132996. export class LengthBlock extends NodeMaterialBlock {
  132997. /**
  132998. * Creates a new LengthBlock
  132999. * @param name defines the block name
  133000. */
  133001. constructor(name: string);
  133002. /**
  133003. * Gets the current class name
  133004. * @returns the class name
  133005. */
  133006. getClassName(): string;
  133007. /**
  133008. * Gets the value input component
  133009. */
  133010. get value(): NodeMaterialConnectionPoint;
  133011. /**
  133012. * Gets the output component
  133013. */
  133014. get output(): NodeMaterialConnectionPoint;
  133015. protected _buildBlock(state: NodeMaterialBuildState): this;
  133016. }
  133017. }
  133018. declare module BABYLON {
  133019. /**
  133020. * Block used to get negative version of a value (i.e. x * -1)
  133021. */
  133022. export class NegateBlock extends NodeMaterialBlock {
  133023. /**
  133024. * Creates a new NegateBlock
  133025. * @param name defines the block name
  133026. */
  133027. constructor(name: string);
  133028. /**
  133029. * Gets the current class name
  133030. * @returns the class name
  133031. */
  133032. getClassName(): string;
  133033. /**
  133034. * Gets the value input component
  133035. */
  133036. get value(): NodeMaterialConnectionPoint;
  133037. /**
  133038. * Gets the output component
  133039. */
  133040. get output(): NodeMaterialConnectionPoint;
  133041. protected _buildBlock(state: NodeMaterialBuildState): this;
  133042. }
  133043. }
  133044. declare module BABYLON {
  133045. /**
  133046. * Block used to get the value of the first parameter raised to the power of the second
  133047. */
  133048. export class PowBlock extends NodeMaterialBlock {
  133049. /**
  133050. * Creates a new PowBlock
  133051. * @param name defines the block name
  133052. */
  133053. constructor(name: string);
  133054. /**
  133055. * Gets the current class name
  133056. * @returns the class name
  133057. */
  133058. getClassName(): string;
  133059. /**
  133060. * Gets the value operand input component
  133061. */
  133062. get value(): NodeMaterialConnectionPoint;
  133063. /**
  133064. * Gets the power operand input component
  133065. */
  133066. get power(): NodeMaterialConnectionPoint;
  133067. /**
  133068. * Gets the output component
  133069. */
  133070. get output(): NodeMaterialConnectionPoint;
  133071. protected _buildBlock(state: NodeMaterialBuildState): this;
  133072. }
  133073. }
  133074. declare module BABYLON {
  133075. /**
  133076. * Block used to get a random number
  133077. */
  133078. export class RandomNumberBlock extends NodeMaterialBlock {
  133079. /**
  133080. * Creates a new RandomNumberBlock
  133081. * @param name defines the block name
  133082. */
  133083. constructor(name: string);
  133084. /**
  133085. * Gets the current class name
  133086. * @returns the class name
  133087. */
  133088. getClassName(): string;
  133089. /**
  133090. * Gets the seed input component
  133091. */
  133092. get seed(): NodeMaterialConnectionPoint;
  133093. /**
  133094. * Gets the output component
  133095. */
  133096. get output(): NodeMaterialConnectionPoint;
  133097. protected _buildBlock(state: NodeMaterialBuildState): this;
  133098. }
  133099. }
  133100. declare module BABYLON {
  133101. /**
  133102. * Block used to compute arc tangent of 2 values
  133103. */
  133104. export class ArcTan2Block extends NodeMaterialBlock {
  133105. /**
  133106. * Creates a new ArcTan2Block
  133107. * @param name defines the block name
  133108. */
  133109. constructor(name: string);
  133110. /**
  133111. * Gets the current class name
  133112. * @returns the class name
  133113. */
  133114. getClassName(): string;
  133115. /**
  133116. * Gets the x operand input component
  133117. */
  133118. get x(): NodeMaterialConnectionPoint;
  133119. /**
  133120. * Gets the y operand input component
  133121. */
  133122. get y(): NodeMaterialConnectionPoint;
  133123. /**
  133124. * Gets the output component
  133125. */
  133126. get output(): NodeMaterialConnectionPoint;
  133127. protected _buildBlock(state: NodeMaterialBuildState): this;
  133128. }
  133129. }
  133130. declare module BABYLON {
  133131. /**
  133132. * Block used to smooth step a value
  133133. */
  133134. export class SmoothStepBlock extends NodeMaterialBlock {
  133135. /**
  133136. * Creates a new SmoothStepBlock
  133137. * @param name defines the block name
  133138. */
  133139. constructor(name: string);
  133140. /**
  133141. * Gets the current class name
  133142. * @returns the class name
  133143. */
  133144. getClassName(): string;
  133145. /**
  133146. * Gets the value operand input component
  133147. */
  133148. get value(): NodeMaterialConnectionPoint;
  133149. /**
  133150. * Gets the first edge operand input component
  133151. */
  133152. get edge0(): NodeMaterialConnectionPoint;
  133153. /**
  133154. * Gets the second edge operand input component
  133155. */
  133156. get edge1(): 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. * Block used to get the reciprocal (1 / x) of a value
  133167. */
  133168. export class ReciprocalBlock extends NodeMaterialBlock {
  133169. /**
  133170. * Creates a new ReciprocalBlock
  133171. * @param name defines the block name
  133172. */
  133173. constructor(name: string);
  133174. /**
  133175. * Gets the current class name
  133176. * @returns the class name
  133177. */
  133178. getClassName(): string;
  133179. /**
  133180. * Gets the input component
  133181. */
  133182. get input(): NodeMaterialConnectionPoint;
  133183. /**
  133184. * Gets the output component
  133185. */
  133186. get output(): NodeMaterialConnectionPoint;
  133187. protected _buildBlock(state: NodeMaterialBuildState): this;
  133188. }
  133189. }
  133190. declare module BABYLON {
  133191. /**
  133192. * Block used to replace a color by another one
  133193. */
  133194. export class ReplaceColorBlock extends NodeMaterialBlock {
  133195. /**
  133196. * Creates a new ReplaceColorBlock
  133197. * @param name defines the block name
  133198. */
  133199. constructor(name: string);
  133200. /**
  133201. * Gets the current class name
  133202. * @returns the class name
  133203. */
  133204. getClassName(): string;
  133205. /**
  133206. * Gets the value input component
  133207. */
  133208. get value(): NodeMaterialConnectionPoint;
  133209. /**
  133210. * Gets the reference input component
  133211. */
  133212. get reference(): NodeMaterialConnectionPoint;
  133213. /**
  133214. * Gets the distance input component
  133215. */
  133216. get distance(): NodeMaterialConnectionPoint;
  133217. /**
  133218. * Gets the replacement input component
  133219. */
  133220. get replacement(): NodeMaterialConnectionPoint;
  133221. /**
  133222. * Gets the output component
  133223. */
  133224. get output(): NodeMaterialConnectionPoint;
  133225. protected _buildBlock(state: NodeMaterialBuildState): this;
  133226. }
  133227. }
  133228. declare module BABYLON {
  133229. /**
  133230. * Block used to posterize a value
  133231. * @see https://en.wikipedia.org/wiki/Posterization
  133232. */
  133233. export class PosterizeBlock extends NodeMaterialBlock {
  133234. /**
  133235. * Creates a new PosterizeBlock
  133236. * @param name defines the block name
  133237. */
  133238. constructor(name: string);
  133239. /**
  133240. * Gets the current class name
  133241. * @returns the class name
  133242. */
  133243. getClassName(): string;
  133244. /**
  133245. * Gets the value input component
  133246. */
  133247. get value(): NodeMaterialConnectionPoint;
  133248. /**
  133249. * Gets the steps input component
  133250. */
  133251. get steps(): NodeMaterialConnectionPoint;
  133252. /**
  133253. * Gets the output component
  133254. */
  133255. get output(): NodeMaterialConnectionPoint;
  133256. protected _buildBlock(state: NodeMaterialBuildState): this;
  133257. }
  133258. }
  133259. declare module BABYLON {
  133260. /**
  133261. * Operations supported by the Wave block
  133262. */
  133263. export enum WaveBlockKind {
  133264. /** SawTooth */
  133265. SawTooth = 0,
  133266. /** Square */
  133267. Square = 1,
  133268. /** Triangle */
  133269. Triangle = 2
  133270. }
  133271. /**
  133272. * Block used to apply wave operation to floats
  133273. */
  133274. export class WaveBlock extends NodeMaterialBlock {
  133275. /**
  133276. * Gets or sets the kibnd of wave to be applied by the block
  133277. */
  133278. kind: WaveBlockKind;
  133279. /**
  133280. * Creates a new WaveBlock
  133281. * @param name defines the block name
  133282. */
  133283. constructor(name: string);
  133284. /**
  133285. * Gets the current class name
  133286. * @returns the class name
  133287. */
  133288. getClassName(): string;
  133289. /**
  133290. * Gets the input component
  133291. */
  133292. get input(): NodeMaterialConnectionPoint;
  133293. /**
  133294. * Gets the output component
  133295. */
  133296. get output(): NodeMaterialConnectionPoint;
  133297. protected _buildBlock(state: NodeMaterialBuildState): this;
  133298. serialize(): any;
  133299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133300. }
  133301. }
  133302. declare module BABYLON {
  133303. /**
  133304. * Class used to store a color step for the GradientBlock
  133305. */
  133306. export class GradientBlockColorStep {
  133307. /**
  133308. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133309. */
  133310. step: number;
  133311. /**
  133312. * Gets or sets the color associated with this step
  133313. */
  133314. color: Color3;
  133315. /**
  133316. * Creates a new GradientBlockColorStep
  133317. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133318. * @param color defines the color associated with this step
  133319. */
  133320. constructor(
  133321. /**
  133322. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133323. */
  133324. step: number,
  133325. /**
  133326. * Gets or sets the color associated with this step
  133327. */
  133328. color: Color3);
  133329. }
  133330. /**
  133331. * Block used to return a color from a gradient based on an input value between 0 and 1
  133332. */
  133333. export class GradientBlock extends NodeMaterialBlock {
  133334. /**
  133335. * Gets or sets the list of color steps
  133336. */
  133337. colorSteps: GradientBlockColorStep[];
  133338. /**
  133339. * Creates a new GradientBlock
  133340. * @param name defines the block name
  133341. */
  133342. constructor(name: string);
  133343. /**
  133344. * Gets the current class name
  133345. * @returns the class name
  133346. */
  133347. getClassName(): string;
  133348. /**
  133349. * Gets the gradient input component
  133350. */
  133351. get gradient(): NodeMaterialConnectionPoint;
  133352. /**
  133353. * Gets the output component
  133354. */
  133355. get output(): NodeMaterialConnectionPoint;
  133356. private _writeColorConstant;
  133357. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133358. serialize(): any;
  133359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133360. protected _dumpPropertiesCode(): string;
  133361. }
  133362. }
  133363. declare module BABYLON {
  133364. /**
  133365. * Block used to normalize lerp between 2 values
  133366. */
  133367. export class NLerpBlock extends NodeMaterialBlock {
  133368. /**
  133369. * Creates a new NLerpBlock
  133370. * @param name defines the block name
  133371. */
  133372. constructor(name: string);
  133373. /**
  133374. * Gets the current class name
  133375. * @returns the class name
  133376. */
  133377. getClassName(): string;
  133378. /**
  133379. * Gets the left operand input component
  133380. */
  133381. get left(): NodeMaterialConnectionPoint;
  133382. /**
  133383. * Gets the right operand input component
  133384. */
  133385. get right(): NodeMaterialConnectionPoint;
  133386. /**
  133387. * Gets the gradient operand input component
  133388. */
  133389. get gradient(): NodeMaterialConnectionPoint;
  133390. /**
  133391. * Gets the output component
  133392. */
  133393. get output(): NodeMaterialConnectionPoint;
  133394. protected _buildBlock(state: NodeMaterialBuildState): this;
  133395. }
  133396. }
  133397. declare module BABYLON {
  133398. /**
  133399. * block used to Generate a Worley Noise 3D Noise Pattern
  133400. */
  133401. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133402. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133403. manhattanDistance: boolean;
  133404. /**
  133405. * Creates a new WorleyNoise3DBlock
  133406. * @param name defines the block name
  133407. */
  133408. constructor(name: string);
  133409. /**
  133410. * Gets the current class name
  133411. * @returns the class name
  133412. */
  133413. getClassName(): string;
  133414. /**
  133415. * Gets the seed input component
  133416. */
  133417. get seed(): NodeMaterialConnectionPoint;
  133418. /**
  133419. * Gets the jitter input component
  133420. */
  133421. get jitter(): NodeMaterialConnectionPoint;
  133422. /**
  133423. * Gets the output component
  133424. */
  133425. get output(): NodeMaterialConnectionPoint;
  133426. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133427. /**
  133428. * Exposes the properties to the UI?
  133429. */
  133430. protected _dumpPropertiesCode(): string;
  133431. /**
  133432. * Exposes the properties to the Seralize?
  133433. */
  133434. serialize(): any;
  133435. /**
  133436. * Exposes the properties to the deseralize?
  133437. */
  133438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133439. }
  133440. }
  133441. declare module BABYLON {
  133442. /**
  133443. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133444. */
  133445. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133446. /**
  133447. * Creates a new SimplexPerlin3DBlock
  133448. * @param name defines the block name
  133449. */
  133450. constructor(name: string);
  133451. /**
  133452. * Gets the current class name
  133453. * @returns the class name
  133454. */
  133455. getClassName(): string;
  133456. /**
  133457. * Gets the seed operand input component
  133458. */
  133459. get seed(): NodeMaterialConnectionPoint;
  133460. /**
  133461. * Gets the output component
  133462. */
  133463. get output(): NodeMaterialConnectionPoint;
  133464. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133465. }
  133466. }
  133467. declare module BABYLON {
  133468. /**
  133469. * Block used to blend normals
  133470. */
  133471. export class NormalBlendBlock extends NodeMaterialBlock {
  133472. /**
  133473. * Creates a new NormalBlendBlock
  133474. * @param name defines the block name
  133475. */
  133476. constructor(name: string);
  133477. /**
  133478. * Gets the current class name
  133479. * @returns the class name
  133480. */
  133481. getClassName(): string;
  133482. /**
  133483. * Gets the first input component
  133484. */
  133485. get normalMap0(): NodeMaterialConnectionPoint;
  133486. /**
  133487. * Gets the second input component
  133488. */
  133489. get normalMap1(): 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 rotate a 2d vector by a given angle
  133500. */
  133501. export class Rotate2dBlock extends NodeMaterialBlock {
  133502. /**
  133503. * Creates a new Rotate2dBlock
  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 input vector
  133514. */
  133515. get input(): NodeMaterialConnectionPoint;
  133516. /**
  133517. * Gets the input angle
  133518. */
  133519. get angle(): NodeMaterialConnectionPoint;
  133520. /**
  133521. * Gets the output component
  133522. */
  133523. get output(): NodeMaterialConnectionPoint;
  133524. autoConfigure(material: NodeMaterial): void;
  133525. protected _buildBlock(state: NodeMaterialBuildState): this;
  133526. }
  133527. }
  133528. declare module BABYLON {
  133529. /**
  133530. * Block used to get the reflected vector from a direction and a normal
  133531. */
  133532. export class ReflectBlock extends NodeMaterialBlock {
  133533. /**
  133534. * Creates a new ReflectBlock
  133535. * @param name defines the block name
  133536. */
  133537. constructor(name: string);
  133538. /**
  133539. * Gets the current class name
  133540. * @returns the class name
  133541. */
  133542. getClassName(): string;
  133543. /**
  133544. * Gets the incident component
  133545. */
  133546. get incident(): NodeMaterialConnectionPoint;
  133547. /**
  133548. * Gets the normal component
  133549. */
  133550. get normal(): NodeMaterialConnectionPoint;
  133551. /**
  133552. * Gets the output component
  133553. */
  133554. get output(): NodeMaterialConnectionPoint;
  133555. protected _buildBlock(state: NodeMaterialBuildState): this;
  133556. }
  133557. }
  133558. declare module BABYLON {
  133559. /**
  133560. * Block used to get the refracted vector from a direction and a normal
  133561. */
  133562. export class RefractBlock extends NodeMaterialBlock {
  133563. /**
  133564. * Creates a new RefractBlock
  133565. * @param name defines the block name
  133566. */
  133567. constructor(name: string);
  133568. /**
  133569. * Gets the current class name
  133570. * @returns the class name
  133571. */
  133572. getClassName(): string;
  133573. /**
  133574. * Gets the incident component
  133575. */
  133576. get incident(): NodeMaterialConnectionPoint;
  133577. /**
  133578. * Gets the normal component
  133579. */
  133580. get normal(): NodeMaterialConnectionPoint;
  133581. /**
  133582. * Gets the index of refraction component
  133583. */
  133584. get ior(): NodeMaterialConnectionPoint;
  133585. /**
  133586. * Gets the output component
  133587. */
  133588. get output(): NodeMaterialConnectionPoint;
  133589. protected _buildBlock(state: NodeMaterialBuildState): this;
  133590. }
  133591. }
  133592. declare module BABYLON {
  133593. /**
  133594. * Block used to desaturate a color
  133595. */
  133596. export class DesaturateBlock extends NodeMaterialBlock {
  133597. /**
  133598. * Creates a new DesaturateBlock
  133599. * @param name defines the block name
  133600. */
  133601. constructor(name: string);
  133602. /**
  133603. * Gets the current class name
  133604. * @returns the class name
  133605. */
  133606. getClassName(): string;
  133607. /**
  133608. * Gets the color operand input component
  133609. */
  133610. get color(): NodeMaterialConnectionPoint;
  133611. /**
  133612. * Gets the level operand input component
  133613. */
  133614. get level(): NodeMaterialConnectionPoint;
  133615. /**
  133616. * Gets the output component
  133617. */
  133618. get output(): NodeMaterialConnectionPoint;
  133619. protected _buildBlock(state: NodeMaterialBuildState): this;
  133620. }
  133621. }
  133622. declare module BABYLON {
  133623. /**
  133624. * Effect Render Options
  133625. */
  133626. export interface IEffectRendererOptions {
  133627. /**
  133628. * Defines the vertices positions.
  133629. */
  133630. positions?: number[];
  133631. /**
  133632. * Defines the indices.
  133633. */
  133634. indices?: number[];
  133635. }
  133636. /**
  133637. * Helper class to render one or more effects
  133638. */
  133639. export class EffectRenderer {
  133640. private engine;
  133641. private static _DefaultOptions;
  133642. private _vertexBuffers;
  133643. private _indexBuffer;
  133644. private _ringBufferIndex;
  133645. private _ringScreenBuffer;
  133646. private _fullscreenViewport;
  133647. private _getNextFrameBuffer;
  133648. /**
  133649. * Creates an effect renderer
  133650. * @param engine the engine to use for rendering
  133651. * @param options defines the options of the effect renderer
  133652. */
  133653. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133654. /**
  133655. * Sets the current viewport in normalized coordinates 0-1
  133656. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133657. */
  133658. setViewport(viewport?: Viewport): void;
  133659. /**
  133660. * Binds the embedded attributes buffer to the effect.
  133661. * @param effect Defines the effect to bind the attributes for
  133662. */
  133663. bindBuffers(effect: Effect): void;
  133664. /**
  133665. * Sets the current effect wrapper to use during draw.
  133666. * The effect needs to be ready before calling this api.
  133667. * This also sets the default full screen position attribute.
  133668. * @param effectWrapper Defines the effect to draw with
  133669. */
  133670. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133671. /**
  133672. * Draws a full screen quad.
  133673. */
  133674. draw(): void;
  133675. /**
  133676. * renders one or more effects to a specified texture
  133677. * @param effectWrappers list of effects to renderer
  133678. * @param outputTexture texture to draw to, if null it will render to the screen
  133679. */
  133680. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133681. /**
  133682. * Disposes of the effect renderer
  133683. */
  133684. dispose(): void;
  133685. }
  133686. /**
  133687. * Options to create an EffectWrapper
  133688. */
  133689. interface EffectWrapperCreationOptions {
  133690. /**
  133691. * Engine to use to create the effect
  133692. */
  133693. engine: ThinEngine;
  133694. /**
  133695. * Fragment shader for the effect
  133696. */
  133697. fragmentShader: string;
  133698. /**
  133699. * Vertex shader for the effect
  133700. */
  133701. vertexShader?: string;
  133702. /**
  133703. * Attributes to use in the shader
  133704. */
  133705. attributeNames?: Array<string>;
  133706. /**
  133707. * Uniforms to use in the shader
  133708. */
  133709. uniformNames?: Array<string>;
  133710. /**
  133711. * Texture sampler names to use in the shader
  133712. */
  133713. samplerNames?: Array<string>;
  133714. /**
  133715. * The friendly name of the effect displayed in Spector.
  133716. */
  133717. name?: string;
  133718. }
  133719. /**
  133720. * Wraps an effect to be used for rendering
  133721. */
  133722. export class EffectWrapper {
  133723. /**
  133724. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133725. */
  133726. onApplyObservable: Observable<{}>;
  133727. /**
  133728. * The underlying effect
  133729. */
  133730. effect: Effect;
  133731. /**
  133732. * Creates an effect to be renderer
  133733. * @param creationOptions options to create the effect
  133734. */
  133735. constructor(creationOptions: EffectWrapperCreationOptions);
  133736. /**
  133737. * Disposes of the effect wrapper
  133738. */
  133739. dispose(): void;
  133740. }
  133741. }
  133742. declare module BABYLON {
  133743. /**
  133744. * Helper class to push actions to a pool of workers.
  133745. */
  133746. export class WorkerPool implements IDisposable {
  133747. private _workerInfos;
  133748. private _pendingActions;
  133749. /**
  133750. * Constructor
  133751. * @param workers Array of workers to use for actions
  133752. */
  133753. constructor(workers: Array<Worker>);
  133754. /**
  133755. * Terminates all workers and clears any pending actions.
  133756. */
  133757. dispose(): void;
  133758. /**
  133759. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133760. * pended until a worker has completed its action.
  133761. * @param action The action to perform. Call onComplete when the action is complete.
  133762. */
  133763. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133764. private _execute;
  133765. }
  133766. }
  133767. declare module BABYLON {
  133768. /**
  133769. * Configuration for Draco compression
  133770. */
  133771. export interface IDracoCompressionConfiguration {
  133772. /**
  133773. * Configuration for the decoder.
  133774. */
  133775. decoder: {
  133776. /**
  133777. * The url to the WebAssembly module.
  133778. */
  133779. wasmUrl?: string;
  133780. /**
  133781. * The url to the WebAssembly binary.
  133782. */
  133783. wasmBinaryUrl?: string;
  133784. /**
  133785. * The url to the fallback JavaScript module.
  133786. */
  133787. fallbackUrl?: string;
  133788. };
  133789. }
  133790. /**
  133791. * Draco compression (https://google.github.io/draco/)
  133792. *
  133793. * This class wraps the Draco module.
  133794. *
  133795. * **Encoder**
  133796. *
  133797. * The encoder is not currently implemented.
  133798. *
  133799. * **Decoder**
  133800. *
  133801. * 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.
  133802. *
  133803. * To update the configuration, use the following code:
  133804. * ```javascript
  133805. * DracoCompression.Configuration = {
  133806. * decoder: {
  133807. * wasmUrl: "<url to the WebAssembly library>",
  133808. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133809. * fallbackUrl: "<url to the fallback JavaScript library>",
  133810. * }
  133811. * };
  133812. * ```
  133813. *
  133814. * 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.
  133815. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133816. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133817. *
  133818. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133819. * ```javascript
  133820. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133821. * ```
  133822. *
  133823. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133824. */
  133825. export class DracoCompression implements IDisposable {
  133826. private _workerPoolPromise?;
  133827. private _decoderModulePromise?;
  133828. /**
  133829. * The configuration. Defaults to the following urls:
  133830. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133831. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133832. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133833. */
  133834. static Configuration: IDracoCompressionConfiguration;
  133835. /**
  133836. * Returns true if the decoder configuration is available.
  133837. */
  133838. static get DecoderAvailable(): boolean;
  133839. /**
  133840. * Default number of workers to create when creating the draco compression object.
  133841. */
  133842. static DefaultNumWorkers: number;
  133843. private static GetDefaultNumWorkers;
  133844. private static _Default;
  133845. /**
  133846. * Default instance for the draco compression object.
  133847. */
  133848. static get Default(): DracoCompression;
  133849. /**
  133850. * Constructor
  133851. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133852. */
  133853. constructor(numWorkers?: number);
  133854. /**
  133855. * Stop all async operations and release resources.
  133856. */
  133857. dispose(): void;
  133858. /**
  133859. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133860. * @returns a promise that resolves when ready
  133861. */
  133862. whenReadyAsync(): Promise<void>;
  133863. /**
  133864. * Decode Draco compressed mesh data to vertex data.
  133865. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133866. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133867. * @returns A promise that resolves with the decoded vertex data
  133868. */
  133869. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133870. [kind: string]: number;
  133871. }): Promise<VertexData>;
  133872. }
  133873. }
  133874. declare module BABYLON {
  133875. /**
  133876. * Class for building Constructive Solid Geometry
  133877. */
  133878. export class CSG {
  133879. private polygons;
  133880. /**
  133881. * The world matrix
  133882. */
  133883. matrix: Matrix;
  133884. /**
  133885. * Stores the position
  133886. */
  133887. position: Vector3;
  133888. /**
  133889. * Stores the rotation
  133890. */
  133891. rotation: Vector3;
  133892. /**
  133893. * Stores the rotation quaternion
  133894. */
  133895. rotationQuaternion: Nullable<Quaternion>;
  133896. /**
  133897. * Stores the scaling vector
  133898. */
  133899. scaling: Vector3;
  133900. /**
  133901. * Convert the Mesh to CSG
  133902. * @param mesh The Mesh to convert to CSG
  133903. * @returns A new CSG from the Mesh
  133904. */
  133905. static FromMesh(mesh: Mesh): CSG;
  133906. /**
  133907. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133908. * @param polygons Polygons used to construct a CSG solid
  133909. */
  133910. private static FromPolygons;
  133911. /**
  133912. * Clones, or makes a deep copy, of the CSG
  133913. * @returns A new CSG
  133914. */
  133915. clone(): CSG;
  133916. /**
  133917. * Unions this CSG with another CSG
  133918. * @param csg The CSG to union against this CSG
  133919. * @returns The unioned CSG
  133920. */
  133921. union(csg: CSG): CSG;
  133922. /**
  133923. * Unions this CSG with another CSG in place
  133924. * @param csg The CSG to union against this CSG
  133925. */
  133926. unionInPlace(csg: CSG): void;
  133927. /**
  133928. * Subtracts this CSG with another CSG
  133929. * @param csg The CSG to subtract against this CSG
  133930. * @returns A new CSG
  133931. */
  133932. subtract(csg: CSG): CSG;
  133933. /**
  133934. * Subtracts this CSG with another CSG in place
  133935. * @param csg The CSG to subtact against this CSG
  133936. */
  133937. subtractInPlace(csg: CSG): void;
  133938. /**
  133939. * Intersect this CSG with another CSG
  133940. * @param csg The CSG to intersect against this CSG
  133941. * @returns A new CSG
  133942. */
  133943. intersect(csg: CSG): CSG;
  133944. /**
  133945. * Intersects this CSG with another CSG in place
  133946. * @param csg The CSG to intersect against this CSG
  133947. */
  133948. intersectInPlace(csg: CSG): void;
  133949. /**
  133950. * Return a new CSG solid with solid and empty space switched. This solid is
  133951. * not modified.
  133952. * @returns A new CSG solid with solid and empty space switched
  133953. */
  133954. inverse(): CSG;
  133955. /**
  133956. * Inverses the CSG in place
  133957. */
  133958. inverseInPlace(): void;
  133959. /**
  133960. * This is used to keep meshes transformations so they can be restored
  133961. * when we build back a Babylon Mesh
  133962. * NB : All CSG operations are performed in world coordinates
  133963. * @param csg The CSG to copy the transform attributes from
  133964. * @returns This CSG
  133965. */
  133966. copyTransformAttributes(csg: CSG): CSG;
  133967. /**
  133968. * Build Raw mesh from CSG
  133969. * Coordinates here are in world space
  133970. * @param name The name of the mesh geometry
  133971. * @param scene The Scene
  133972. * @param keepSubMeshes Specifies if the submeshes should be kept
  133973. * @returns A new Mesh
  133974. */
  133975. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133976. /**
  133977. * Build Mesh from CSG taking material and transforms into account
  133978. * @param name The name of the Mesh
  133979. * @param material The material of the Mesh
  133980. * @param scene The Scene
  133981. * @param keepSubMeshes Specifies if submeshes should be kept
  133982. * @returns The new Mesh
  133983. */
  133984. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133985. }
  133986. }
  133987. declare module BABYLON {
  133988. /**
  133989. * Class used to create a trail following a mesh
  133990. */
  133991. export class TrailMesh extends Mesh {
  133992. private _generator;
  133993. private _autoStart;
  133994. private _running;
  133995. private _diameter;
  133996. private _length;
  133997. private _sectionPolygonPointsCount;
  133998. private _sectionVectors;
  133999. private _sectionNormalVectors;
  134000. private _beforeRenderObserver;
  134001. /**
  134002. * @constructor
  134003. * @param name The value used by scene.getMeshByName() to do a lookup.
  134004. * @param generator The mesh or transform node to generate a trail.
  134005. * @param scene The scene to add this mesh to.
  134006. * @param diameter Diameter of trailing mesh. Default is 1.
  134007. * @param length Length of trailing mesh. Default is 60.
  134008. * @param autoStart Automatically start trailing mesh. Default true.
  134009. */
  134010. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  134011. /**
  134012. * "TrailMesh"
  134013. * @returns "TrailMesh"
  134014. */
  134015. getClassName(): string;
  134016. private _createMesh;
  134017. /**
  134018. * Start trailing mesh.
  134019. */
  134020. start(): void;
  134021. /**
  134022. * Stop trailing mesh.
  134023. */
  134024. stop(): void;
  134025. /**
  134026. * Update trailing mesh geometry.
  134027. */
  134028. update(): void;
  134029. /**
  134030. * Returns a new TrailMesh object.
  134031. * @param name is a string, the name given to the new mesh
  134032. * @param newGenerator use new generator object for cloned trail mesh
  134033. * @returns a new mesh
  134034. */
  134035. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  134036. /**
  134037. * Serializes this trail mesh
  134038. * @param serializationObject object to write serialization to
  134039. */
  134040. serialize(serializationObject: any): void;
  134041. /**
  134042. * Parses a serialized trail mesh
  134043. * @param parsedMesh the serialized mesh
  134044. * @param scene the scene to create the trail mesh in
  134045. * @returns the created trail mesh
  134046. */
  134047. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  134048. }
  134049. }
  134050. declare module BABYLON {
  134051. /**
  134052. * Class containing static functions to help procedurally build meshes
  134053. */
  134054. export class TiledBoxBuilder {
  134055. /**
  134056. * Creates a box mesh
  134057. * 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)
  134058. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134062. * @param name defines the name of the mesh
  134063. * @param options defines the options used to create the mesh
  134064. * @param scene defines the hosting scene
  134065. * @returns the box mesh
  134066. */
  134067. static CreateTiledBox(name: string, options: {
  134068. pattern?: number;
  134069. width?: number;
  134070. height?: number;
  134071. depth?: number;
  134072. tileSize?: number;
  134073. tileWidth?: number;
  134074. tileHeight?: number;
  134075. alignHorizontal?: number;
  134076. alignVertical?: number;
  134077. faceUV?: Vector4[];
  134078. faceColors?: Color4[];
  134079. sideOrientation?: number;
  134080. updatable?: boolean;
  134081. }, scene?: Nullable<Scene>): Mesh;
  134082. }
  134083. }
  134084. declare module BABYLON {
  134085. /**
  134086. * Class containing static functions to help procedurally build meshes
  134087. */
  134088. export class TorusKnotBuilder {
  134089. /**
  134090. * Creates a torus knot mesh
  134091. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134092. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134093. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134094. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134098. * @param name defines the name of the mesh
  134099. * @param options defines the options used to create the mesh
  134100. * @param scene defines the hosting scene
  134101. * @returns the torus knot mesh
  134102. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134103. */
  134104. static CreateTorusKnot(name: string, options: {
  134105. radius?: number;
  134106. tube?: number;
  134107. radialSegments?: number;
  134108. tubularSegments?: number;
  134109. p?: number;
  134110. q?: number;
  134111. updatable?: boolean;
  134112. sideOrientation?: number;
  134113. frontUVs?: Vector4;
  134114. backUVs?: Vector4;
  134115. }, scene: any): Mesh;
  134116. }
  134117. }
  134118. declare module BABYLON {
  134119. /**
  134120. * Polygon
  134121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  134122. */
  134123. export class Polygon {
  134124. /**
  134125. * Creates a rectangle
  134126. * @param xmin bottom X coord
  134127. * @param ymin bottom Y coord
  134128. * @param xmax top X coord
  134129. * @param ymax top Y coord
  134130. * @returns points that make the resulting rectation
  134131. */
  134132. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134133. /**
  134134. * Creates a circle
  134135. * @param radius radius of circle
  134136. * @param cx scale in x
  134137. * @param cy scale in y
  134138. * @param numberOfSides number of sides that make up the circle
  134139. * @returns points that make the resulting circle
  134140. */
  134141. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134142. /**
  134143. * Creates a polygon from input string
  134144. * @param input Input polygon data
  134145. * @returns the parsed points
  134146. */
  134147. static Parse(input: string): Vector2[];
  134148. /**
  134149. * Starts building a polygon from x and y coordinates
  134150. * @param x x coordinate
  134151. * @param y y coordinate
  134152. * @returns the started path2
  134153. */
  134154. static StartingAt(x: number, y: number): Path2;
  134155. }
  134156. /**
  134157. * Builds a polygon
  134158. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134159. */
  134160. export class PolygonMeshBuilder {
  134161. private _points;
  134162. private _outlinepoints;
  134163. private _holes;
  134164. private _name;
  134165. private _scene;
  134166. private _epoints;
  134167. private _eholes;
  134168. private _addToepoint;
  134169. /**
  134170. * Babylon reference to the earcut plugin.
  134171. */
  134172. bjsEarcut: any;
  134173. /**
  134174. * Creates a PolygonMeshBuilder
  134175. * @param name name of the builder
  134176. * @param contours Path of the polygon
  134177. * @param scene scene to add to when creating the mesh
  134178. * @param earcutInjection can be used to inject your own earcut reference
  134179. */
  134180. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134181. /**
  134182. * Adds a whole within the polygon
  134183. * @param hole Array of points defining the hole
  134184. * @returns this
  134185. */
  134186. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134187. /**
  134188. * Creates the polygon
  134189. * @param updatable If the mesh should be updatable
  134190. * @param depth The depth of the mesh created
  134191. * @returns the created mesh
  134192. */
  134193. build(updatable?: boolean, depth?: number): Mesh;
  134194. /**
  134195. * Creates the polygon
  134196. * @param depth The depth of the mesh created
  134197. * @returns the created VertexData
  134198. */
  134199. buildVertexData(depth?: number): VertexData;
  134200. /**
  134201. * Adds a side to the polygon
  134202. * @param positions points that make the polygon
  134203. * @param normals normals of the polygon
  134204. * @param uvs uvs of the polygon
  134205. * @param indices indices of the polygon
  134206. * @param bounds bounds of the polygon
  134207. * @param points points of the polygon
  134208. * @param depth depth of the polygon
  134209. * @param flip flip of the polygon
  134210. */
  134211. private addSide;
  134212. }
  134213. }
  134214. declare module BABYLON {
  134215. /**
  134216. * Class containing static functions to help procedurally build meshes
  134217. */
  134218. export class PolygonBuilder {
  134219. /**
  134220. * Creates a polygon mesh
  134221. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134222. * * 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
  134223. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134226. * * Remember you can only change the shape positions, not their number when updating a polygon
  134227. * @param name defines the name of the mesh
  134228. * @param options defines the options used to create the mesh
  134229. * @param scene defines the hosting scene
  134230. * @param earcutInjection can be used to inject your own earcut reference
  134231. * @returns the polygon mesh
  134232. */
  134233. static CreatePolygon(name: string, options: {
  134234. shape: Vector3[];
  134235. holes?: Vector3[][];
  134236. depth?: number;
  134237. faceUV?: Vector4[];
  134238. faceColors?: Color4[];
  134239. updatable?: boolean;
  134240. sideOrientation?: number;
  134241. frontUVs?: Vector4;
  134242. backUVs?: Vector4;
  134243. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134244. /**
  134245. * Creates an extruded polygon mesh, with depth in the Y direction.
  134246. * * 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)
  134247. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134248. * @param name defines the name of the mesh
  134249. * @param options defines the options used to create the mesh
  134250. * @param scene defines the hosting scene
  134251. * @param earcutInjection can be used to inject your own earcut reference
  134252. * @returns the polygon mesh
  134253. */
  134254. static ExtrudePolygon(name: string, options: {
  134255. shape: Vector3[];
  134256. holes?: Vector3[][];
  134257. depth?: number;
  134258. faceUV?: Vector4[];
  134259. faceColors?: Color4[];
  134260. updatable?: boolean;
  134261. sideOrientation?: number;
  134262. frontUVs?: Vector4;
  134263. backUVs?: Vector4;
  134264. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134265. }
  134266. }
  134267. declare module BABYLON {
  134268. /**
  134269. * Class containing static functions to help procedurally build meshes
  134270. */
  134271. export class LatheBuilder {
  134272. /**
  134273. * Creates lathe mesh.
  134274. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134275. * * 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
  134276. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134277. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134278. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134279. * * 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
  134280. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134281. * * 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
  134282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134284. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134286. * @param name defines the name of the mesh
  134287. * @param options defines the options used to create the mesh
  134288. * @param scene defines the hosting scene
  134289. * @returns the lathe mesh
  134290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134291. */
  134292. static CreateLathe(name: string, options: {
  134293. shape: Vector3[];
  134294. radius?: number;
  134295. tessellation?: number;
  134296. clip?: number;
  134297. arc?: number;
  134298. closed?: boolean;
  134299. updatable?: boolean;
  134300. sideOrientation?: number;
  134301. frontUVs?: Vector4;
  134302. backUVs?: Vector4;
  134303. cap?: number;
  134304. invertUV?: boolean;
  134305. }, scene?: Nullable<Scene>): Mesh;
  134306. }
  134307. }
  134308. declare module BABYLON {
  134309. /**
  134310. * Class containing static functions to help procedurally build meshes
  134311. */
  134312. export class TiledPlaneBuilder {
  134313. /**
  134314. * Creates a tiled plane mesh
  134315. * * The parameter `pattern` will, depending on value, do nothing or
  134316. * * * flip (reflect about central vertical) alternate tiles across and up
  134317. * * * flip every tile on alternate rows
  134318. * * * rotate (180 degs) alternate tiles across and up
  134319. * * * rotate every tile on alternate rows
  134320. * * * flip and rotate alternate tiles across and up
  134321. * * * flip and rotate every tile on alternate rows
  134322. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134323. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134326. * * 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)
  134327. * * 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)
  134328. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134329. * @param name defines the name of the mesh
  134330. * @param options defines the options used to create the mesh
  134331. * @param scene defines the hosting scene
  134332. * @returns the box mesh
  134333. */
  134334. static CreateTiledPlane(name: string, options: {
  134335. pattern?: number;
  134336. tileSize?: number;
  134337. tileWidth?: number;
  134338. tileHeight?: number;
  134339. size?: number;
  134340. width?: number;
  134341. height?: number;
  134342. alignHorizontal?: number;
  134343. alignVertical?: number;
  134344. sideOrientation?: number;
  134345. frontUVs?: Vector4;
  134346. backUVs?: Vector4;
  134347. updatable?: boolean;
  134348. }, scene?: Nullable<Scene>): Mesh;
  134349. }
  134350. }
  134351. declare module BABYLON {
  134352. /**
  134353. * Class containing static functions to help procedurally build meshes
  134354. */
  134355. export class TubeBuilder {
  134356. /**
  134357. * Creates a tube mesh.
  134358. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134359. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134360. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134361. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134362. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134363. * * 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)
  134364. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134365. * * 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
  134366. * * 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
  134367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134371. * @param name defines the name of the mesh
  134372. * @param options defines the options used to create the mesh
  134373. * @param scene defines the hosting scene
  134374. * @returns the tube mesh
  134375. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134376. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134377. */
  134378. static CreateTube(name: string, options: {
  134379. path: Vector3[];
  134380. radius?: number;
  134381. tessellation?: number;
  134382. radiusFunction?: {
  134383. (i: number, distance: number): number;
  134384. };
  134385. cap?: number;
  134386. arc?: number;
  134387. updatable?: boolean;
  134388. sideOrientation?: number;
  134389. frontUVs?: Vector4;
  134390. backUVs?: Vector4;
  134391. instance?: Mesh;
  134392. invertUV?: boolean;
  134393. }, scene?: Nullable<Scene>): Mesh;
  134394. }
  134395. }
  134396. declare module BABYLON {
  134397. /**
  134398. * Class containing static functions to help procedurally build meshes
  134399. */
  134400. export class IcoSphereBuilder {
  134401. /**
  134402. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134403. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134404. * * 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`)
  134405. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134406. * * 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
  134407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134410. * @param name defines the name of the mesh
  134411. * @param options defines the options used to create the mesh
  134412. * @param scene defines the hosting scene
  134413. * @returns the icosahedron mesh
  134414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134415. */
  134416. static CreateIcoSphere(name: string, options: {
  134417. radius?: number;
  134418. radiusX?: number;
  134419. radiusY?: number;
  134420. radiusZ?: number;
  134421. flat?: boolean;
  134422. subdivisions?: number;
  134423. sideOrientation?: number;
  134424. frontUVs?: Vector4;
  134425. backUVs?: Vector4;
  134426. updatable?: boolean;
  134427. }, scene?: Nullable<Scene>): Mesh;
  134428. }
  134429. }
  134430. declare module BABYLON {
  134431. /**
  134432. * Class containing static functions to help procedurally build meshes
  134433. */
  134434. export class DecalBuilder {
  134435. /**
  134436. * Creates a decal mesh.
  134437. * 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
  134438. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134439. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134440. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134441. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134442. * @param name defines the name of the mesh
  134443. * @param sourceMesh defines the mesh where the decal must be applied
  134444. * @param options defines the options used to create the mesh
  134445. * @param scene defines the hosting scene
  134446. * @returns the decal mesh
  134447. * @see https://doc.babylonjs.com/how_to/decals
  134448. */
  134449. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134450. position?: Vector3;
  134451. normal?: Vector3;
  134452. size?: Vector3;
  134453. angle?: number;
  134454. }): Mesh;
  134455. }
  134456. }
  134457. declare module BABYLON {
  134458. /**
  134459. * Class containing static functions to help procedurally build meshes
  134460. */
  134461. export class MeshBuilder {
  134462. /**
  134463. * Creates a box mesh
  134464. * * The parameter `size` sets the size (float) of each box side (default 1)
  134465. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134466. * * 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)
  134467. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134471. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134472. * @param name defines the name of the mesh
  134473. * @param options defines the options used to create the mesh
  134474. * @param scene defines the hosting scene
  134475. * @returns the box mesh
  134476. */
  134477. static CreateBox(name: string, options: {
  134478. size?: number;
  134479. width?: number;
  134480. height?: number;
  134481. depth?: number;
  134482. faceUV?: Vector4[];
  134483. faceColors?: Color4[];
  134484. sideOrientation?: number;
  134485. frontUVs?: Vector4;
  134486. backUVs?: Vector4;
  134487. updatable?: boolean;
  134488. }, scene?: Nullable<Scene>): Mesh;
  134489. /**
  134490. * Creates a tiled box mesh
  134491. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134493. * @param name defines the name of the mesh
  134494. * @param options defines the options used to create the mesh
  134495. * @param scene defines the hosting scene
  134496. * @returns the tiled box mesh
  134497. */
  134498. static CreateTiledBox(name: string, options: {
  134499. pattern?: number;
  134500. size?: number;
  134501. width?: number;
  134502. height?: number;
  134503. depth: number;
  134504. tileSize?: number;
  134505. tileWidth?: number;
  134506. tileHeight?: number;
  134507. faceUV?: Vector4[];
  134508. faceColors?: Color4[];
  134509. alignHorizontal?: number;
  134510. alignVertical?: number;
  134511. sideOrientation?: number;
  134512. updatable?: boolean;
  134513. }, scene?: Nullable<Scene>): Mesh;
  134514. /**
  134515. * Creates a sphere mesh
  134516. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134517. * * 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`)
  134518. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134519. * * 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
  134520. * * 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)
  134521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134524. * @param name defines the name of the mesh
  134525. * @param options defines the options used to create the mesh
  134526. * @param scene defines the hosting scene
  134527. * @returns the sphere mesh
  134528. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134529. */
  134530. static CreateSphere(name: string, options: {
  134531. segments?: number;
  134532. diameter?: number;
  134533. diameterX?: number;
  134534. diameterY?: number;
  134535. diameterZ?: number;
  134536. arc?: number;
  134537. slice?: number;
  134538. sideOrientation?: number;
  134539. frontUVs?: Vector4;
  134540. backUVs?: Vector4;
  134541. updatable?: boolean;
  134542. }, scene?: Nullable<Scene>): Mesh;
  134543. /**
  134544. * Creates a plane polygonal mesh. By default, this is a disc
  134545. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134546. * * 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
  134547. * * 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
  134548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134551. * @param name defines the name of the mesh
  134552. * @param options defines the options used to create the mesh
  134553. * @param scene defines the hosting scene
  134554. * @returns the plane polygonal mesh
  134555. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134556. */
  134557. static CreateDisc(name: string, options: {
  134558. radius?: number;
  134559. tessellation?: number;
  134560. arc?: number;
  134561. updatable?: boolean;
  134562. sideOrientation?: number;
  134563. frontUVs?: Vector4;
  134564. backUVs?: Vector4;
  134565. }, scene?: Nullable<Scene>): Mesh;
  134566. /**
  134567. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134568. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134569. * * 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`)
  134570. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134571. * * 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
  134572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134575. * @param name defines the name of the mesh
  134576. * @param options defines the options used to create the mesh
  134577. * @param scene defines the hosting scene
  134578. * @returns the icosahedron mesh
  134579. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134580. */
  134581. static CreateIcoSphere(name: string, options: {
  134582. radius?: number;
  134583. radiusX?: number;
  134584. radiusY?: number;
  134585. radiusZ?: number;
  134586. flat?: boolean;
  134587. subdivisions?: number;
  134588. sideOrientation?: number;
  134589. frontUVs?: Vector4;
  134590. backUVs?: Vector4;
  134591. updatable?: boolean;
  134592. }, scene?: Nullable<Scene>): Mesh;
  134593. /**
  134594. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134595. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134596. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134597. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134598. * * 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
  134599. * * 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
  134600. * * 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
  134601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134604. * * 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
  134605. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134606. * * 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
  134607. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134609. * @param name defines the name of the mesh
  134610. * @param options defines the options used to create the mesh
  134611. * @param scene defines the hosting scene
  134612. * @returns the ribbon mesh
  134613. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134615. */
  134616. static CreateRibbon(name: string, options: {
  134617. pathArray: Vector3[][];
  134618. closeArray?: boolean;
  134619. closePath?: boolean;
  134620. offset?: number;
  134621. updatable?: boolean;
  134622. sideOrientation?: number;
  134623. frontUVs?: Vector4;
  134624. backUVs?: Vector4;
  134625. instance?: Mesh;
  134626. invertUV?: boolean;
  134627. uvs?: Vector2[];
  134628. colors?: Color4[];
  134629. }, scene?: Nullable<Scene>): Mesh;
  134630. /**
  134631. * Creates a cylinder or a cone mesh
  134632. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134633. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134634. * * 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.
  134635. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134636. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134637. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134638. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134639. * * 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).
  134640. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134641. * * 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).
  134642. * * 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
  134643. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134644. * * 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
  134645. * * 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.
  134646. * * If `enclose` is false, a ring surface is one element.
  134647. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134648. * * 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
  134649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134652. * @param name defines the name of the mesh
  134653. * @param options defines the options used to create the mesh
  134654. * @param scene defines the hosting scene
  134655. * @returns the cylinder mesh
  134656. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134657. */
  134658. static CreateCylinder(name: string, options: {
  134659. height?: number;
  134660. diameterTop?: number;
  134661. diameterBottom?: number;
  134662. diameter?: number;
  134663. tessellation?: number;
  134664. subdivisions?: number;
  134665. arc?: number;
  134666. faceColors?: Color4[];
  134667. faceUV?: Vector4[];
  134668. updatable?: boolean;
  134669. hasRings?: boolean;
  134670. enclose?: boolean;
  134671. cap?: number;
  134672. sideOrientation?: number;
  134673. frontUVs?: Vector4;
  134674. backUVs?: Vector4;
  134675. }, scene?: Nullable<Scene>): Mesh;
  134676. /**
  134677. * Creates a torus mesh
  134678. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134679. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134680. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134684. * @param name defines the name of the mesh
  134685. * @param options defines the options used to create the mesh
  134686. * @param scene defines the hosting scene
  134687. * @returns the torus mesh
  134688. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134689. */
  134690. static CreateTorus(name: string, options: {
  134691. diameter?: number;
  134692. thickness?: number;
  134693. tessellation?: number;
  134694. updatable?: boolean;
  134695. sideOrientation?: number;
  134696. frontUVs?: Vector4;
  134697. backUVs?: Vector4;
  134698. }, scene?: Nullable<Scene>): Mesh;
  134699. /**
  134700. * Creates a torus knot mesh
  134701. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134702. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134703. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134704. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134708. * @param name defines the name of the mesh
  134709. * @param options defines the options used to create the mesh
  134710. * @param scene defines the hosting scene
  134711. * @returns the torus knot mesh
  134712. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134713. */
  134714. static CreateTorusKnot(name: string, options: {
  134715. radius?: number;
  134716. tube?: number;
  134717. radialSegments?: number;
  134718. tubularSegments?: number;
  134719. p?: number;
  134720. q?: number;
  134721. updatable?: boolean;
  134722. sideOrientation?: number;
  134723. frontUVs?: Vector4;
  134724. backUVs?: Vector4;
  134725. }, scene?: Nullable<Scene>): Mesh;
  134726. /**
  134727. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134728. * * 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
  134729. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134730. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134731. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134732. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134733. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134734. * * 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
  134735. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134738. * @param name defines the name of the new line system
  134739. * @param options defines the options used to create the line system
  134740. * @param scene defines the hosting scene
  134741. * @returns a new line system mesh
  134742. */
  134743. static CreateLineSystem(name: string, options: {
  134744. lines: Vector3[][];
  134745. updatable?: boolean;
  134746. instance?: Nullable<LinesMesh>;
  134747. colors?: Nullable<Color4[][]>;
  134748. useVertexAlpha?: boolean;
  134749. }, scene: Nullable<Scene>): LinesMesh;
  134750. /**
  134751. * Creates a line mesh
  134752. * 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
  134753. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134754. * * The parameter `points` is an array successive Vector3
  134755. * * 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
  134756. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134757. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134758. * * When updating an instance, remember that only point positions can change, not the number of points
  134759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134761. * @param name defines the name of the new line system
  134762. * @param options defines the options used to create the line system
  134763. * @param scene defines the hosting scene
  134764. * @returns a new line mesh
  134765. */
  134766. static CreateLines(name: string, options: {
  134767. points: Vector3[];
  134768. updatable?: boolean;
  134769. instance?: Nullable<LinesMesh>;
  134770. colors?: Color4[];
  134771. useVertexAlpha?: boolean;
  134772. }, scene?: Nullable<Scene>): LinesMesh;
  134773. /**
  134774. * Creates a dashed line mesh
  134775. * * 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
  134776. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134777. * * The parameter `points` is an array successive Vector3
  134778. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134779. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134780. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134781. * * 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
  134782. * * When updating an instance, remember that only point positions can change, not the number of points
  134783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134784. * @param name defines the name of the mesh
  134785. * @param options defines the options used to create the mesh
  134786. * @param scene defines the hosting scene
  134787. * @returns the dashed line mesh
  134788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134789. */
  134790. static CreateDashedLines(name: string, options: {
  134791. points: Vector3[];
  134792. dashSize?: number;
  134793. gapSize?: number;
  134794. dashNb?: number;
  134795. updatable?: boolean;
  134796. instance?: LinesMesh;
  134797. }, scene?: Nullable<Scene>): LinesMesh;
  134798. /**
  134799. * 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.
  134800. * * 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.
  134801. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134802. * * 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.
  134803. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134804. * * 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
  134805. * * 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
  134806. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134811. * @param name defines the name of the mesh
  134812. * @param options defines the options used to create the mesh
  134813. * @param scene defines the hosting scene
  134814. * @returns the extruded shape mesh
  134815. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134817. */
  134818. static ExtrudeShape(name: string, options: {
  134819. shape: Vector3[];
  134820. path: Vector3[];
  134821. scale?: number;
  134822. rotation?: number;
  134823. cap?: number;
  134824. updatable?: boolean;
  134825. sideOrientation?: number;
  134826. frontUVs?: Vector4;
  134827. backUVs?: Vector4;
  134828. instance?: Mesh;
  134829. invertUV?: boolean;
  134830. }, scene?: Nullable<Scene>): Mesh;
  134831. /**
  134832. * Creates an custom extruded shape mesh.
  134833. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134834. * * 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.
  134835. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134836. * * 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
  134837. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134838. * * 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
  134839. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134840. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134841. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134842. * * 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
  134843. * * 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
  134844. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134847. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134849. * @param name defines the name of the mesh
  134850. * @param options defines the options used to create the mesh
  134851. * @param scene defines the hosting scene
  134852. * @returns the custom extruded shape mesh
  134853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134856. */
  134857. static ExtrudeShapeCustom(name: string, options: {
  134858. shape: Vector3[];
  134859. path: Vector3[];
  134860. scaleFunction?: any;
  134861. rotationFunction?: any;
  134862. ribbonCloseArray?: boolean;
  134863. ribbonClosePath?: boolean;
  134864. cap?: number;
  134865. updatable?: boolean;
  134866. sideOrientation?: number;
  134867. frontUVs?: Vector4;
  134868. backUVs?: Vector4;
  134869. instance?: Mesh;
  134870. invertUV?: boolean;
  134871. }, scene?: Nullable<Scene>): Mesh;
  134872. /**
  134873. * Creates lathe mesh.
  134874. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134875. * * 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
  134876. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134877. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134878. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134879. * * 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
  134880. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134881. * * 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
  134882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134886. * @param name defines the name of the mesh
  134887. * @param options defines the options used to create the mesh
  134888. * @param scene defines the hosting scene
  134889. * @returns the lathe mesh
  134890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134891. */
  134892. static CreateLathe(name: string, options: {
  134893. shape: Vector3[];
  134894. radius?: number;
  134895. tessellation?: number;
  134896. clip?: number;
  134897. arc?: number;
  134898. closed?: boolean;
  134899. updatable?: boolean;
  134900. sideOrientation?: number;
  134901. frontUVs?: Vector4;
  134902. backUVs?: Vector4;
  134903. cap?: number;
  134904. invertUV?: boolean;
  134905. }, scene?: Nullable<Scene>): Mesh;
  134906. /**
  134907. * Creates a tiled plane mesh
  134908. * * You can set a limited pattern arrangement with the tiles
  134909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134912. * @param name defines the name of the mesh
  134913. * @param options defines the options used to create the mesh
  134914. * @param scene defines the hosting scene
  134915. * @returns the plane mesh
  134916. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134917. */
  134918. static CreateTiledPlane(name: string, options: {
  134919. pattern?: number;
  134920. tileSize?: number;
  134921. tileWidth?: number;
  134922. tileHeight?: number;
  134923. size?: number;
  134924. width?: number;
  134925. height?: number;
  134926. alignHorizontal?: number;
  134927. alignVertical?: number;
  134928. sideOrientation?: number;
  134929. frontUVs?: Vector4;
  134930. backUVs?: Vector4;
  134931. updatable?: boolean;
  134932. }, scene?: Nullable<Scene>): Mesh;
  134933. /**
  134934. * Creates a plane mesh
  134935. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134936. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134937. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134941. * @param name defines the name of the mesh
  134942. * @param options defines the options used to create the mesh
  134943. * @param scene defines the hosting scene
  134944. * @returns the plane mesh
  134945. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134946. */
  134947. static CreatePlane(name: string, options: {
  134948. size?: number;
  134949. width?: number;
  134950. height?: number;
  134951. sideOrientation?: number;
  134952. frontUVs?: Vector4;
  134953. backUVs?: Vector4;
  134954. updatable?: boolean;
  134955. sourcePlane?: Plane;
  134956. }, scene?: Nullable<Scene>): Mesh;
  134957. /**
  134958. * Creates a ground mesh
  134959. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134960. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134962. * @param name defines the name of the mesh
  134963. * @param options defines the options used to create the mesh
  134964. * @param scene defines the hosting scene
  134965. * @returns the ground mesh
  134966. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134967. */
  134968. static CreateGround(name: string, options: {
  134969. width?: number;
  134970. height?: number;
  134971. subdivisions?: number;
  134972. subdivisionsX?: number;
  134973. subdivisionsY?: number;
  134974. updatable?: boolean;
  134975. }, scene?: Nullable<Scene>): Mesh;
  134976. /**
  134977. * Creates a tiled ground mesh
  134978. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134979. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134980. * * 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
  134981. * * 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
  134982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134983. * @param name defines the name of the mesh
  134984. * @param options defines the options used to create the mesh
  134985. * @param scene defines the hosting scene
  134986. * @returns the tiled ground mesh
  134987. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134988. */
  134989. static CreateTiledGround(name: string, options: {
  134990. xmin: number;
  134991. zmin: number;
  134992. xmax: number;
  134993. zmax: number;
  134994. subdivisions?: {
  134995. w: number;
  134996. h: number;
  134997. };
  134998. precision?: {
  134999. w: number;
  135000. h: number;
  135001. };
  135002. updatable?: boolean;
  135003. }, scene?: Nullable<Scene>): Mesh;
  135004. /**
  135005. * Creates a ground mesh from a height map
  135006. * * The parameter `url` sets the URL of the height map image resource.
  135007. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  135008. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  135009. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  135010. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  135011. * * 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.
  135012. * * 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).
  135013. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  135014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135015. * @param name defines the name of the mesh
  135016. * @param url defines the url to the height map
  135017. * @param options defines the options used to create the mesh
  135018. * @param scene defines the hosting scene
  135019. * @returns the ground mesh
  135020. * @see https://doc.babylonjs.com/babylon101/height_map
  135021. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  135022. */
  135023. static CreateGroundFromHeightMap(name: string, url: string, options: {
  135024. width?: number;
  135025. height?: number;
  135026. subdivisions?: number;
  135027. minHeight?: number;
  135028. maxHeight?: number;
  135029. colorFilter?: Color3;
  135030. alphaFilter?: number;
  135031. updatable?: boolean;
  135032. onReady?: (mesh: GroundMesh) => void;
  135033. }, scene?: Nullable<Scene>): GroundMesh;
  135034. /**
  135035. * Creates a polygon mesh
  135036. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135037. * * 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
  135038. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135041. * * Remember you can only change the shape positions, not their number when updating a polygon
  135042. * @param name defines the name of the mesh
  135043. * @param options defines the options used to create the mesh
  135044. * @param scene defines the hosting scene
  135045. * @param earcutInjection can be used to inject your own earcut reference
  135046. * @returns the polygon mesh
  135047. */
  135048. static CreatePolygon(name: string, options: {
  135049. shape: Vector3[];
  135050. holes?: Vector3[][];
  135051. depth?: number;
  135052. faceUV?: Vector4[];
  135053. faceColors?: Color4[];
  135054. updatable?: boolean;
  135055. sideOrientation?: number;
  135056. frontUVs?: Vector4;
  135057. backUVs?: Vector4;
  135058. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135059. /**
  135060. * Creates an extruded polygon mesh, with depth in the Y direction.
  135061. * * 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)
  135062. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135063. * @param name defines the name of the mesh
  135064. * @param options defines the options used to create the mesh
  135065. * @param scene defines the hosting scene
  135066. * @param earcutInjection can be used to inject your own earcut reference
  135067. * @returns the polygon mesh
  135068. */
  135069. static ExtrudePolygon(name: string, options: {
  135070. shape: Vector3[];
  135071. holes?: Vector3[][];
  135072. depth?: number;
  135073. faceUV?: Vector4[];
  135074. faceColors?: Color4[];
  135075. updatable?: boolean;
  135076. sideOrientation?: number;
  135077. frontUVs?: Vector4;
  135078. backUVs?: Vector4;
  135079. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135080. /**
  135081. * Creates a tube mesh.
  135082. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135083. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135084. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135085. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135086. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135087. * * 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)
  135088. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135089. * * 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
  135090. * * 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
  135091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135095. * @param name defines the name of the mesh
  135096. * @param options defines the options used to create the mesh
  135097. * @param scene defines the hosting scene
  135098. * @returns the tube mesh
  135099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135100. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135101. */
  135102. static CreateTube(name: string, options: {
  135103. path: Vector3[];
  135104. radius?: number;
  135105. tessellation?: number;
  135106. radiusFunction?: {
  135107. (i: number, distance: number): number;
  135108. };
  135109. cap?: number;
  135110. arc?: number;
  135111. updatable?: boolean;
  135112. sideOrientation?: number;
  135113. frontUVs?: Vector4;
  135114. backUVs?: Vector4;
  135115. instance?: Mesh;
  135116. invertUV?: boolean;
  135117. }, scene?: Nullable<Scene>): Mesh;
  135118. /**
  135119. * Creates a polyhedron mesh
  135120. * * 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
  135121. * * The parameter `size` (positive float, default 1) sets the polygon size
  135122. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135123. * * 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`
  135124. * * 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
  135125. * * 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)`)
  135126. * * 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
  135127. * * 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
  135128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135131. * @param name defines the name of the mesh
  135132. * @param options defines the options used to create the mesh
  135133. * @param scene defines the hosting scene
  135134. * @returns the polyhedron mesh
  135135. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135136. */
  135137. static CreatePolyhedron(name: string, options: {
  135138. type?: number;
  135139. size?: number;
  135140. sizeX?: number;
  135141. sizeY?: number;
  135142. sizeZ?: number;
  135143. custom?: any;
  135144. faceUV?: Vector4[];
  135145. faceColors?: Color4[];
  135146. flat?: boolean;
  135147. updatable?: boolean;
  135148. sideOrientation?: number;
  135149. frontUVs?: Vector4;
  135150. backUVs?: Vector4;
  135151. }, scene?: Nullable<Scene>): Mesh;
  135152. /**
  135153. * Creates a decal mesh.
  135154. * 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
  135155. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135156. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135157. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135158. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135159. * @param name defines the name of the mesh
  135160. * @param sourceMesh defines the mesh where the decal must be applied
  135161. * @param options defines the options used to create the mesh
  135162. * @param scene defines the hosting scene
  135163. * @returns the decal mesh
  135164. * @see https://doc.babylonjs.com/how_to/decals
  135165. */
  135166. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135167. position?: Vector3;
  135168. normal?: Vector3;
  135169. size?: Vector3;
  135170. angle?: number;
  135171. }): Mesh;
  135172. }
  135173. }
  135174. declare module BABYLON {
  135175. /**
  135176. * A simplifier interface for future simplification implementations
  135177. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135178. */
  135179. export interface ISimplifier {
  135180. /**
  135181. * Simplification of a given mesh according to the given settings.
  135182. * Since this requires computation, it is assumed that the function runs async.
  135183. * @param settings The settings of the simplification, including quality and distance
  135184. * @param successCallback A callback that will be called after the mesh was simplified.
  135185. * @param errorCallback in case of an error, this callback will be called. optional.
  135186. */
  135187. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135188. }
  135189. /**
  135190. * Expected simplification settings.
  135191. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135192. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135193. */
  135194. export interface ISimplificationSettings {
  135195. /**
  135196. * Gets or sets the expected quality
  135197. */
  135198. quality: number;
  135199. /**
  135200. * Gets or sets the distance when this optimized version should be used
  135201. */
  135202. distance: number;
  135203. /**
  135204. * Gets an already optimized mesh
  135205. */
  135206. optimizeMesh?: boolean;
  135207. }
  135208. /**
  135209. * Class used to specify simplification options
  135210. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135211. */
  135212. export class SimplificationSettings implements ISimplificationSettings {
  135213. /** expected quality */
  135214. quality: number;
  135215. /** distance when this optimized version should be used */
  135216. distance: number;
  135217. /** already optimized mesh */
  135218. optimizeMesh?: boolean | undefined;
  135219. /**
  135220. * Creates a SimplificationSettings
  135221. * @param quality expected quality
  135222. * @param distance distance when this optimized version should be used
  135223. * @param optimizeMesh already optimized mesh
  135224. */
  135225. constructor(
  135226. /** expected quality */
  135227. quality: number,
  135228. /** distance when this optimized version should be used */
  135229. distance: number,
  135230. /** already optimized mesh */
  135231. optimizeMesh?: boolean | undefined);
  135232. }
  135233. /**
  135234. * Interface used to define a simplification task
  135235. */
  135236. export interface ISimplificationTask {
  135237. /**
  135238. * Array of settings
  135239. */
  135240. settings: Array<ISimplificationSettings>;
  135241. /**
  135242. * Simplification type
  135243. */
  135244. simplificationType: SimplificationType;
  135245. /**
  135246. * Mesh to simplify
  135247. */
  135248. mesh: Mesh;
  135249. /**
  135250. * Callback called on success
  135251. */
  135252. successCallback?: () => void;
  135253. /**
  135254. * Defines if parallel processing can be used
  135255. */
  135256. parallelProcessing: boolean;
  135257. }
  135258. /**
  135259. * Queue used to order the simplification tasks
  135260. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135261. */
  135262. export class SimplificationQueue {
  135263. private _simplificationArray;
  135264. /**
  135265. * Gets a boolean indicating that the process is still running
  135266. */
  135267. running: boolean;
  135268. /**
  135269. * Creates a new queue
  135270. */
  135271. constructor();
  135272. /**
  135273. * Adds a new simplification task
  135274. * @param task defines a task to add
  135275. */
  135276. addTask(task: ISimplificationTask): void;
  135277. /**
  135278. * Execute next task
  135279. */
  135280. executeNext(): void;
  135281. /**
  135282. * Execute a simplification task
  135283. * @param task defines the task to run
  135284. */
  135285. runSimplification(task: ISimplificationTask): void;
  135286. private getSimplifier;
  135287. }
  135288. /**
  135289. * The implemented types of simplification
  135290. * At the moment only Quadratic Error Decimation is implemented
  135291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135292. */
  135293. export enum SimplificationType {
  135294. /** Quadratic error decimation */
  135295. QUADRATIC = 0
  135296. }
  135297. /**
  135298. * An implementation of the Quadratic Error simplification algorithm.
  135299. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  135300. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  135301. * @author RaananW
  135302. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135303. */
  135304. export class QuadraticErrorSimplification implements ISimplifier {
  135305. private _mesh;
  135306. private triangles;
  135307. private vertices;
  135308. private references;
  135309. private _reconstructedMesh;
  135310. /** Gets or sets the number pf sync interations */
  135311. syncIterations: number;
  135312. /** Gets or sets the aggressiveness of the simplifier */
  135313. aggressiveness: number;
  135314. /** Gets or sets the number of allowed iterations for decimation */
  135315. decimationIterations: number;
  135316. /** Gets or sets the espilon to use for bounding box computation */
  135317. boundingBoxEpsilon: number;
  135318. /**
  135319. * Creates a new QuadraticErrorSimplification
  135320. * @param _mesh defines the target mesh
  135321. */
  135322. constructor(_mesh: Mesh);
  135323. /**
  135324. * Simplification of a given mesh according to the given settings.
  135325. * Since this requires computation, it is assumed that the function runs async.
  135326. * @param settings The settings of the simplification, including quality and distance
  135327. * @param successCallback A callback that will be called after the mesh was simplified.
  135328. */
  135329. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  135330. private runDecimation;
  135331. private initWithMesh;
  135332. private init;
  135333. private reconstructMesh;
  135334. private initDecimatedMesh;
  135335. private isFlipped;
  135336. private updateTriangles;
  135337. private identifyBorder;
  135338. private updateMesh;
  135339. private vertexError;
  135340. private calculateError;
  135341. }
  135342. }
  135343. declare module BABYLON {
  135344. interface Scene {
  135345. /** @hidden (Backing field) */
  135346. _simplificationQueue: SimplificationQueue;
  135347. /**
  135348. * Gets or sets the simplification queue attached to the scene
  135349. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135350. */
  135351. simplificationQueue: SimplificationQueue;
  135352. }
  135353. interface Mesh {
  135354. /**
  135355. * Simplify the mesh according to the given array of settings.
  135356. * Function will return immediately and will simplify async
  135357. * @param settings a collection of simplification settings
  135358. * @param parallelProcessing should all levels calculate parallel or one after the other
  135359. * @param simplificationType the type of simplification to run
  135360. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135361. * @returns the current mesh
  135362. */
  135363. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135364. }
  135365. /**
  135366. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135367. * created in a scene
  135368. */
  135369. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135370. /**
  135371. * The component name helpfull to identify the component in the list of scene components.
  135372. */
  135373. readonly name: string;
  135374. /**
  135375. * The scene the component belongs to.
  135376. */
  135377. scene: Scene;
  135378. /**
  135379. * Creates a new instance of the component for the given scene
  135380. * @param scene Defines the scene to register the component in
  135381. */
  135382. constructor(scene: Scene);
  135383. /**
  135384. * Registers the component in a given scene
  135385. */
  135386. register(): void;
  135387. /**
  135388. * Rebuilds the elements related to this component in case of
  135389. * context lost for instance.
  135390. */
  135391. rebuild(): void;
  135392. /**
  135393. * Disposes the component and the associated ressources
  135394. */
  135395. dispose(): void;
  135396. private _beforeCameraUpdate;
  135397. }
  135398. }
  135399. declare module BABYLON {
  135400. /**
  135401. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135402. */
  135403. export interface INavigationEnginePlugin {
  135404. /**
  135405. * plugin name
  135406. */
  135407. name: string;
  135408. /**
  135409. * Creates a navigation mesh
  135410. * @param meshes array of all the geometry used to compute the navigatio mesh
  135411. * @param parameters bunch of parameters used to filter geometry
  135412. */
  135413. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135414. /**
  135415. * Create a navigation mesh debug mesh
  135416. * @param scene is where the mesh will be added
  135417. * @returns debug display mesh
  135418. */
  135419. createDebugNavMesh(scene: Scene): Mesh;
  135420. /**
  135421. * Get a navigation mesh constrained position, closest to the parameter position
  135422. * @param position world position
  135423. * @returns the closest point to position constrained by the navigation mesh
  135424. */
  135425. getClosestPoint(position: Vector3): Vector3;
  135426. /**
  135427. * Get a navigation mesh constrained position, within a particular radius
  135428. * @param position world position
  135429. * @param maxRadius the maximum distance to the constrained world position
  135430. * @returns the closest point to position constrained by the navigation mesh
  135431. */
  135432. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135433. /**
  135434. * Compute the final position from a segment made of destination-position
  135435. * @param position world position
  135436. * @param destination world position
  135437. * @returns the resulting point along the navmesh
  135438. */
  135439. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135440. /**
  135441. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135442. * @param start world position
  135443. * @param end world position
  135444. * @returns array containing world position composing the path
  135445. */
  135446. computePath(start: Vector3, end: Vector3): Vector3[];
  135447. /**
  135448. * If this plugin is supported
  135449. * @returns true if plugin is supported
  135450. */
  135451. isSupported(): boolean;
  135452. /**
  135453. * Create a new Crowd so you can add agents
  135454. * @param maxAgents the maximum agent count in the crowd
  135455. * @param maxAgentRadius the maximum radius an agent can have
  135456. * @param scene to attach the crowd to
  135457. * @returns the crowd you can add agents to
  135458. */
  135459. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135460. /**
  135461. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135462. * The queries will try to find a solution within those bounds
  135463. * default is (1,1,1)
  135464. * @param extent x,y,z value that define the extent around the queries point of reference
  135465. */
  135466. setDefaultQueryExtent(extent: Vector3): void;
  135467. /**
  135468. * Get the Bounding box extent specified by setDefaultQueryExtent
  135469. * @returns the box extent values
  135470. */
  135471. getDefaultQueryExtent(): Vector3;
  135472. /**
  135473. * Release all resources
  135474. */
  135475. dispose(): void;
  135476. }
  135477. /**
  135478. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135479. */
  135480. export interface ICrowd {
  135481. /**
  135482. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135483. * You can attach anything to that node. The node position is updated in the scene update tick.
  135484. * @param pos world position that will be constrained by the navigation mesh
  135485. * @param parameters agent parameters
  135486. * @param transform hooked to the agent that will be update by the scene
  135487. * @returns agent index
  135488. */
  135489. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135490. /**
  135491. * Returns the agent position in world space
  135492. * @param index agent index returned by addAgent
  135493. * @returns world space position
  135494. */
  135495. getAgentPosition(index: number): Vector3;
  135496. /**
  135497. * Gets the agent velocity in world space
  135498. * @param index agent index returned by addAgent
  135499. * @returns world space velocity
  135500. */
  135501. getAgentVelocity(index: number): Vector3;
  135502. /**
  135503. * remove a particular agent previously created
  135504. * @param index agent index returned by addAgent
  135505. */
  135506. removeAgent(index: number): void;
  135507. /**
  135508. * get the list of all agents attached to this crowd
  135509. * @returns list of agent indices
  135510. */
  135511. getAgents(): number[];
  135512. /**
  135513. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135514. * @param deltaTime in seconds
  135515. */
  135516. update(deltaTime: number): void;
  135517. /**
  135518. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135519. * @param index agent index returned by addAgent
  135520. * @param destination targeted world position
  135521. */
  135522. agentGoto(index: number, destination: Vector3): void;
  135523. /**
  135524. * Teleport the agent to a new position
  135525. * @param index agent index returned by addAgent
  135526. * @param destination targeted world position
  135527. */
  135528. agentTeleport(index: number, destination: Vector3): void;
  135529. /**
  135530. * Update agent parameters
  135531. * @param index agent index returned by addAgent
  135532. * @param parameters agent parameters
  135533. */
  135534. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135535. /**
  135536. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135537. * The queries will try to find a solution within those bounds
  135538. * default is (1,1,1)
  135539. * @param extent x,y,z value that define the extent around the queries point of reference
  135540. */
  135541. setDefaultQueryExtent(extent: Vector3): void;
  135542. /**
  135543. * Get the Bounding box extent specified by setDefaultQueryExtent
  135544. * @returns the box extent values
  135545. */
  135546. getDefaultQueryExtent(): Vector3;
  135547. /**
  135548. * Release all resources
  135549. */
  135550. dispose(): void;
  135551. }
  135552. /**
  135553. * Configures an agent
  135554. */
  135555. export interface IAgentParameters {
  135556. /**
  135557. * Agent radius. [Limit: >= 0]
  135558. */
  135559. radius: number;
  135560. /**
  135561. * Agent height. [Limit: > 0]
  135562. */
  135563. height: number;
  135564. /**
  135565. * Maximum allowed acceleration. [Limit: >= 0]
  135566. */
  135567. maxAcceleration: number;
  135568. /**
  135569. * Maximum allowed speed. [Limit: >= 0]
  135570. */
  135571. maxSpeed: number;
  135572. /**
  135573. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135574. */
  135575. collisionQueryRange: number;
  135576. /**
  135577. * The path visibility optimization range. [Limit: > 0]
  135578. */
  135579. pathOptimizationRange: number;
  135580. /**
  135581. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135582. */
  135583. separationWeight: number;
  135584. }
  135585. /**
  135586. * Configures the navigation mesh creation
  135587. */
  135588. export interface INavMeshParameters {
  135589. /**
  135590. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135591. */
  135592. cs: number;
  135593. /**
  135594. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135595. */
  135596. ch: number;
  135597. /**
  135598. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135599. */
  135600. walkableSlopeAngle: number;
  135601. /**
  135602. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135603. * be considered walkable. [Limit: >= 3] [Units: vx]
  135604. */
  135605. walkableHeight: number;
  135606. /**
  135607. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135608. */
  135609. walkableClimb: number;
  135610. /**
  135611. * The distance to erode/shrink the walkable area of the heightfield away from
  135612. * obstructions. [Limit: >=0] [Units: vx]
  135613. */
  135614. walkableRadius: number;
  135615. /**
  135616. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135617. */
  135618. maxEdgeLen: number;
  135619. /**
  135620. * The maximum distance a simplfied contour's border edges should deviate
  135621. * the original raw contour. [Limit: >=0] [Units: vx]
  135622. */
  135623. maxSimplificationError: number;
  135624. /**
  135625. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135626. */
  135627. minRegionArea: number;
  135628. /**
  135629. * Any regions with a span count smaller than this value will, if possible,
  135630. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135631. */
  135632. mergeRegionArea: number;
  135633. /**
  135634. * The maximum number of vertices allowed for polygons generated during the
  135635. * contour to polygon conversion process. [Limit: >= 3]
  135636. */
  135637. maxVertsPerPoly: number;
  135638. /**
  135639. * Sets the sampling distance to use when generating the detail mesh.
  135640. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135641. */
  135642. detailSampleDist: number;
  135643. /**
  135644. * The maximum distance the detail mesh surface should deviate from heightfield
  135645. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135646. */
  135647. detailSampleMaxError: number;
  135648. }
  135649. }
  135650. declare module BABYLON {
  135651. /**
  135652. * RecastJS navigation plugin
  135653. */
  135654. export class RecastJSPlugin implements INavigationEnginePlugin {
  135655. /**
  135656. * Reference to the Recast library
  135657. */
  135658. bjsRECAST: any;
  135659. /**
  135660. * plugin name
  135661. */
  135662. name: string;
  135663. /**
  135664. * the first navmesh created. We might extend this to support multiple navmeshes
  135665. */
  135666. navMesh: any;
  135667. /**
  135668. * Initializes the recastJS plugin
  135669. * @param recastInjection can be used to inject your own recast reference
  135670. */
  135671. constructor(recastInjection?: any);
  135672. /**
  135673. * Creates a navigation mesh
  135674. * @param meshes array of all the geometry used to compute the navigatio mesh
  135675. * @param parameters bunch of parameters used to filter geometry
  135676. */
  135677. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135678. /**
  135679. * Create a navigation mesh debug mesh
  135680. * @param scene is where the mesh will be added
  135681. * @returns debug display mesh
  135682. */
  135683. createDebugNavMesh(scene: Scene): Mesh;
  135684. /**
  135685. * Get a navigation mesh constrained position, closest to the parameter position
  135686. * @param position world position
  135687. * @returns the closest point to position constrained by the navigation mesh
  135688. */
  135689. getClosestPoint(position: Vector3): Vector3;
  135690. /**
  135691. * Get a navigation mesh constrained position, within a particular radius
  135692. * @param position world position
  135693. * @param maxRadius the maximum distance to the constrained world position
  135694. * @returns the closest point to position constrained by the navigation mesh
  135695. */
  135696. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135697. /**
  135698. * Compute the final position from a segment made of destination-position
  135699. * @param position world position
  135700. * @param destination world position
  135701. * @returns the resulting point along the navmesh
  135702. */
  135703. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135704. /**
  135705. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135706. * @param start world position
  135707. * @param end world position
  135708. * @returns array containing world position composing the path
  135709. */
  135710. computePath(start: Vector3, end: Vector3): Vector3[];
  135711. /**
  135712. * Create a new Crowd so you can add agents
  135713. * @param maxAgents the maximum agent count in the crowd
  135714. * @param maxAgentRadius the maximum radius an agent can have
  135715. * @param scene to attach the crowd to
  135716. * @returns the crowd you can add agents to
  135717. */
  135718. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135719. /**
  135720. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135721. * The queries will try to find a solution within those bounds
  135722. * default is (1,1,1)
  135723. * @param extent x,y,z value that define the extent around the queries point of reference
  135724. */
  135725. setDefaultQueryExtent(extent: Vector3): void;
  135726. /**
  135727. * Get the Bounding box extent specified by setDefaultQueryExtent
  135728. * @returns the box extent values
  135729. */
  135730. getDefaultQueryExtent(): Vector3;
  135731. /**
  135732. * Disposes
  135733. */
  135734. dispose(): void;
  135735. /**
  135736. * If this plugin is supported
  135737. * @returns true if plugin is supported
  135738. */
  135739. isSupported(): boolean;
  135740. }
  135741. /**
  135742. * Recast detour crowd implementation
  135743. */
  135744. export class RecastJSCrowd implements ICrowd {
  135745. /**
  135746. * Recast/detour plugin
  135747. */
  135748. bjsRECASTPlugin: RecastJSPlugin;
  135749. /**
  135750. * Link to the detour crowd
  135751. */
  135752. recastCrowd: any;
  135753. /**
  135754. * One transform per agent
  135755. */
  135756. transforms: TransformNode[];
  135757. /**
  135758. * All agents created
  135759. */
  135760. agents: number[];
  135761. /**
  135762. * Link to the scene is kept to unregister the crowd from the scene
  135763. */
  135764. private _scene;
  135765. /**
  135766. * Observer for crowd updates
  135767. */
  135768. private _onBeforeAnimationsObserver;
  135769. /**
  135770. * Constructor
  135771. * @param plugin recastJS plugin
  135772. * @param maxAgents the maximum agent count in the crowd
  135773. * @param maxAgentRadius the maximum radius an agent can have
  135774. * @param scene to attach the crowd to
  135775. * @returns the crowd you can add agents to
  135776. */
  135777. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135778. /**
  135779. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135780. * You can attach anything to that node. The node position is updated in the scene update tick.
  135781. * @param pos world position that will be constrained by the navigation mesh
  135782. * @param parameters agent parameters
  135783. * @param transform hooked to the agent that will be update by the scene
  135784. * @returns agent index
  135785. */
  135786. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135787. /**
  135788. * Returns the agent position in world space
  135789. * @param index agent index returned by addAgent
  135790. * @returns world space position
  135791. */
  135792. getAgentPosition(index: number): Vector3;
  135793. /**
  135794. * Returns the agent velocity in world space
  135795. * @param index agent index returned by addAgent
  135796. * @returns world space velocity
  135797. */
  135798. getAgentVelocity(index: number): Vector3;
  135799. /**
  135800. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135801. * @param index agent index returned by addAgent
  135802. * @param destination targeted world position
  135803. */
  135804. agentGoto(index: number, destination: Vector3): void;
  135805. /**
  135806. * Teleport the agent to a new position
  135807. * @param index agent index returned by addAgent
  135808. * @param destination targeted world position
  135809. */
  135810. agentTeleport(index: number, destination: Vector3): void;
  135811. /**
  135812. * Update agent parameters
  135813. * @param index agent index returned by addAgent
  135814. * @param parameters agent parameters
  135815. */
  135816. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135817. /**
  135818. * remove a particular agent previously created
  135819. * @param index agent index returned by addAgent
  135820. */
  135821. removeAgent(index: number): void;
  135822. /**
  135823. * get the list of all agents attached to this crowd
  135824. * @returns list of agent indices
  135825. */
  135826. getAgents(): number[];
  135827. /**
  135828. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135829. * @param deltaTime in seconds
  135830. */
  135831. update(deltaTime: number): void;
  135832. /**
  135833. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135834. * The queries will try to find a solution within those bounds
  135835. * default is (1,1,1)
  135836. * @param extent x,y,z value that define the extent around the queries point of reference
  135837. */
  135838. setDefaultQueryExtent(extent: Vector3): void;
  135839. /**
  135840. * Get the Bounding box extent specified by setDefaultQueryExtent
  135841. * @returns the box extent values
  135842. */
  135843. getDefaultQueryExtent(): Vector3;
  135844. /**
  135845. * Release all resources
  135846. */
  135847. dispose(): void;
  135848. }
  135849. }
  135850. declare module BABYLON {
  135851. /**
  135852. * Class used to enable access to IndexedDB
  135853. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135854. */
  135855. export class Database implements IOfflineProvider {
  135856. private _callbackManifestChecked;
  135857. private _currentSceneUrl;
  135858. private _db;
  135859. private _enableSceneOffline;
  135860. private _enableTexturesOffline;
  135861. private _manifestVersionFound;
  135862. private _mustUpdateRessources;
  135863. private _hasReachedQuota;
  135864. private _isSupported;
  135865. private _idbFactory;
  135866. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135867. private static IsUASupportingBlobStorage;
  135868. /**
  135869. * Gets a boolean indicating if Database storate is enabled (off by default)
  135870. */
  135871. static IDBStorageEnabled: boolean;
  135872. /**
  135873. * Gets a boolean indicating if scene must be saved in the database
  135874. */
  135875. get enableSceneOffline(): boolean;
  135876. /**
  135877. * Gets a boolean indicating if textures must be saved in the database
  135878. */
  135879. get enableTexturesOffline(): boolean;
  135880. /**
  135881. * Creates a new Database
  135882. * @param urlToScene defines the url to load the scene
  135883. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135884. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135885. */
  135886. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135887. private static _ParseURL;
  135888. private static _ReturnFullUrlLocation;
  135889. private _checkManifestFile;
  135890. /**
  135891. * Open the database and make it available
  135892. * @param successCallback defines the callback to call on success
  135893. * @param errorCallback defines the callback to call on error
  135894. */
  135895. open(successCallback: () => void, errorCallback: () => void): void;
  135896. /**
  135897. * Loads an image from the database
  135898. * @param url defines the url to load from
  135899. * @param image defines the target DOM image
  135900. */
  135901. loadImage(url: string, image: HTMLImageElement): void;
  135902. private _loadImageFromDBAsync;
  135903. private _saveImageIntoDBAsync;
  135904. private _checkVersionFromDB;
  135905. private _loadVersionFromDBAsync;
  135906. private _saveVersionIntoDBAsync;
  135907. /**
  135908. * Loads a file from database
  135909. * @param url defines the URL to load from
  135910. * @param sceneLoaded defines a callback to call on success
  135911. * @param progressCallBack defines a callback to call when progress changed
  135912. * @param errorCallback defines a callback to call on error
  135913. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135914. */
  135915. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135916. private _loadFileAsync;
  135917. private _saveFileAsync;
  135918. /**
  135919. * Validates if xhr data is correct
  135920. * @param xhr defines the request to validate
  135921. * @param dataType defines the expected data type
  135922. * @returns true if data is correct
  135923. */
  135924. private static _ValidateXHRData;
  135925. }
  135926. }
  135927. declare module BABYLON {
  135928. /** @hidden */
  135929. export var gpuUpdateParticlesPixelShader: {
  135930. name: string;
  135931. shader: string;
  135932. };
  135933. }
  135934. declare module BABYLON {
  135935. /** @hidden */
  135936. export var gpuUpdateParticlesVertexShader: {
  135937. name: string;
  135938. shader: string;
  135939. };
  135940. }
  135941. declare module BABYLON {
  135942. /** @hidden */
  135943. export var clipPlaneFragmentDeclaration2: {
  135944. name: string;
  135945. shader: string;
  135946. };
  135947. }
  135948. declare module BABYLON {
  135949. /** @hidden */
  135950. export var gpuRenderParticlesPixelShader: {
  135951. name: string;
  135952. shader: string;
  135953. };
  135954. }
  135955. declare module BABYLON {
  135956. /** @hidden */
  135957. export var clipPlaneVertexDeclaration2: {
  135958. name: string;
  135959. shader: string;
  135960. };
  135961. }
  135962. declare module BABYLON {
  135963. /** @hidden */
  135964. export var gpuRenderParticlesVertexShader: {
  135965. name: string;
  135966. shader: string;
  135967. };
  135968. }
  135969. declare module BABYLON {
  135970. /**
  135971. * This represents a GPU particle system in Babylon
  135972. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135973. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135974. */
  135975. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135976. /**
  135977. * The layer mask we are rendering the particles through.
  135978. */
  135979. layerMask: number;
  135980. private _capacity;
  135981. private _activeCount;
  135982. private _currentActiveCount;
  135983. private _accumulatedCount;
  135984. private _renderEffect;
  135985. private _updateEffect;
  135986. private _buffer0;
  135987. private _buffer1;
  135988. private _spriteBuffer;
  135989. private _updateVAO;
  135990. private _renderVAO;
  135991. private _targetIndex;
  135992. private _sourceBuffer;
  135993. private _targetBuffer;
  135994. private _engine;
  135995. private _currentRenderId;
  135996. private _started;
  135997. private _stopped;
  135998. private _timeDelta;
  135999. private _randomTexture;
  136000. private _randomTexture2;
  136001. private _attributesStrideSize;
  136002. private _updateEffectOptions;
  136003. private _randomTextureSize;
  136004. private _actualFrame;
  136005. private readonly _rawTextureWidth;
  136006. /**
  136007. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  136008. */
  136009. static get IsSupported(): boolean;
  136010. /**
  136011. * An event triggered when the system is disposed.
  136012. */
  136013. onDisposeObservable: Observable<GPUParticleSystem>;
  136014. /**
  136015. * Gets the maximum number of particles active at the same time.
  136016. * @returns The max number of active particles.
  136017. */
  136018. getCapacity(): number;
  136019. /**
  136020. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  136021. * to override the particles.
  136022. */
  136023. forceDepthWrite: boolean;
  136024. /**
  136025. * Gets or set the number of active particles
  136026. */
  136027. get activeParticleCount(): number;
  136028. set activeParticleCount(value: number);
  136029. private _preWarmDone;
  136030. /**
  136031. * Specifies if the particles are updated in emitter local space or world space.
  136032. * This is always false for GPU particles
  136033. */
  136034. get isLocal(): boolean;
  136035. set isLocal(value: boolean);
  136036. /**
  136037. * Is this system ready to be used/rendered
  136038. * @return true if the system is ready
  136039. */
  136040. isReady(): boolean;
  136041. /**
  136042. * Gets if the system has been started. (Note: this will still be true after stop is called)
  136043. * @returns True if it has been started, otherwise false.
  136044. */
  136045. isStarted(): boolean;
  136046. /**
  136047. * Starts the particle system and begins to emit
  136048. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  136049. */
  136050. start(delay?: number): void;
  136051. /**
  136052. * Stops the particle system.
  136053. */
  136054. stop(): void;
  136055. /**
  136056. * Remove all active particles
  136057. */
  136058. reset(): void;
  136059. /**
  136060. * Returns the string "GPUParticleSystem"
  136061. * @returns a string containing the class name
  136062. */
  136063. getClassName(): string;
  136064. private _colorGradientsTexture;
  136065. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  136066. /**
  136067. * Adds a new color gradient
  136068. * @param gradient defines the gradient to use (between 0 and 1)
  136069. * @param color1 defines the color to affect to the specified gradient
  136070. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  136071. * @returns the current particle system
  136072. */
  136073. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  136074. /**
  136075. * Remove a specific color gradient
  136076. * @param gradient defines the gradient to remove
  136077. * @returns the current particle system
  136078. */
  136079. removeColorGradient(gradient: number): GPUParticleSystem;
  136080. private _angularSpeedGradientsTexture;
  136081. private _sizeGradientsTexture;
  136082. private _velocityGradientsTexture;
  136083. private _limitVelocityGradientsTexture;
  136084. private _dragGradientsTexture;
  136085. private _addFactorGradient;
  136086. /**
  136087. * Adds a new size gradient
  136088. * @param gradient defines the gradient to use (between 0 and 1)
  136089. * @param factor defines the size factor to affect to the specified gradient
  136090. * @returns the current particle system
  136091. */
  136092. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  136093. /**
  136094. * Remove a specific size gradient
  136095. * @param gradient defines the gradient to remove
  136096. * @returns the current particle system
  136097. */
  136098. removeSizeGradient(gradient: number): GPUParticleSystem;
  136099. /**
  136100. * Adds a new angular speed gradient
  136101. * @param gradient defines the gradient to use (between 0 and 1)
  136102. * @param factor defines the angular speed to affect to the specified gradient
  136103. * @returns the current particle system
  136104. */
  136105. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  136106. /**
  136107. * Remove a specific angular speed gradient
  136108. * @param gradient defines the gradient to remove
  136109. * @returns the current particle system
  136110. */
  136111. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  136112. /**
  136113. * Adds a new velocity gradient
  136114. * @param gradient defines the gradient to use (between 0 and 1)
  136115. * @param factor defines the velocity to affect to the specified gradient
  136116. * @returns the current particle system
  136117. */
  136118. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136119. /**
  136120. * Remove a specific velocity gradient
  136121. * @param gradient defines the gradient to remove
  136122. * @returns the current particle system
  136123. */
  136124. removeVelocityGradient(gradient: number): GPUParticleSystem;
  136125. /**
  136126. * Adds a new limit velocity gradient
  136127. * @param gradient defines the gradient to use (between 0 and 1)
  136128. * @param factor defines the limit velocity value to affect to the specified gradient
  136129. * @returns the current particle system
  136130. */
  136131. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136132. /**
  136133. * Remove a specific limit velocity gradient
  136134. * @param gradient defines the gradient to remove
  136135. * @returns the current particle system
  136136. */
  136137. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  136138. /**
  136139. * Adds a new drag gradient
  136140. * @param gradient defines the gradient to use (between 0 and 1)
  136141. * @param factor defines the drag value to affect to the specified gradient
  136142. * @returns the current particle system
  136143. */
  136144. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  136145. /**
  136146. * Remove a specific drag gradient
  136147. * @param gradient defines the gradient to remove
  136148. * @returns the current particle system
  136149. */
  136150. removeDragGradient(gradient: number): GPUParticleSystem;
  136151. /**
  136152. * Not supported by GPUParticleSystem
  136153. * @param gradient defines the gradient to use (between 0 and 1)
  136154. * @param factor defines the emit rate value to affect to the specified gradient
  136155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136156. * @returns the current particle system
  136157. */
  136158. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136159. /**
  136160. * Not supported by GPUParticleSystem
  136161. * @param gradient defines the gradient to remove
  136162. * @returns the current particle system
  136163. */
  136164. removeEmitRateGradient(gradient: number): IParticleSystem;
  136165. /**
  136166. * Not supported by GPUParticleSystem
  136167. * @param gradient defines the gradient to use (between 0 and 1)
  136168. * @param factor defines the start size value to affect to the specified gradient
  136169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136170. * @returns the current particle system
  136171. */
  136172. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136173. /**
  136174. * Not supported by GPUParticleSystem
  136175. * @param gradient defines the gradient to remove
  136176. * @returns the current particle system
  136177. */
  136178. removeStartSizeGradient(gradient: number): IParticleSystem;
  136179. /**
  136180. * Not supported by GPUParticleSystem
  136181. * @param gradient defines the gradient to use (between 0 and 1)
  136182. * @param min defines the color remap minimal range
  136183. * @param max defines the color remap maximal range
  136184. * @returns the current particle system
  136185. */
  136186. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136187. /**
  136188. * Not supported by GPUParticleSystem
  136189. * @param gradient defines the gradient to remove
  136190. * @returns the current particle system
  136191. */
  136192. removeColorRemapGradient(): IParticleSystem;
  136193. /**
  136194. * Not supported by GPUParticleSystem
  136195. * @param gradient defines the gradient to use (between 0 and 1)
  136196. * @param min defines the alpha remap minimal range
  136197. * @param max defines the alpha remap maximal range
  136198. * @returns the current particle system
  136199. */
  136200. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136201. /**
  136202. * Not supported by GPUParticleSystem
  136203. * @param gradient defines the gradient to remove
  136204. * @returns the current particle system
  136205. */
  136206. removeAlphaRemapGradient(): IParticleSystem;
  136207. /**
  136208. * Not supported by GPUParticleSystem
  136209. * @param gradient defines the gradient to use (between 0 and 1)
  136210. * @param color defines the color to affect to the specified gradient
  136211. * @returns the current particle system
  136212. */
  136213. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136214. /**
  136215. * Not supported by GPUParticleSystem
  136216. * @param gradient defines the gradient to remove
  136217. * @returns the current particle system
  136218. */
  136219. removeRampGradient(): IParticleSystem;
  136220. /**
  136221. * Not supported by GPUParticleSystem
  136222. * @returns the list of ramp gradients
  136223. */
  136224. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136225. /**
  136226. * Not supported by GPUParticleSystem
  136227. * Gets or sets a boolean indicating that ramp gradients must be used
  136228. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136229. */
  136230. get useRampGradients(): boolean;
  136231. set useRampGradients(value: boolean);
  136232. /**
  136233. * Not supported by GPUParticleSystem
  136234. * @param gradient defines the gradient to use (between 0 and 1)
  136235. * @param factor defines the life time factor to affect to the specified gradient
  136236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136237. * @returns the current particle system
  136238. */
  136239. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136240. /**
  136241. * Not supported by GPUParticleSystem
  136242. * @param gradient defines the gradient to remove
  136243. * @returns the current particle system
  136244. */
  136245. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136246. /**
  136247. * Instantiates a GPU particle system.
  136248. * 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.
  136249. * @param name The name of the particle system
  136250. * @param options The options used to create the system
  136251. * @param scene The scene the particle system belongs to
  136252. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136253. */
  136254. constructor(name: string, options: Partial<{
  136255. capacity: number;
  136256. randomTextureSize: number;
  136257. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136258. protected _reset(): void;
  136259. private _createUpdateVAO;
  136260. private _createRenderVAO;
  136261. private _initialize;
  136262. /** @hidden */
  136263. _recreateUpdateEffect(): void;
  136264. /** @hidden */
  136265. _recreateRenderEffect(): void;
  136266. /**
  136267. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136268. * @param preWarm defines if we are in the pre-warmimg phase
  136269. */
  136270. animate(preWarm?: boolean): void;
  136271. private _createFactorGradientTexture;
  136272. private _createSizeGradientTexture;
  136273. private _createAngularSpeedGradientTexture;
  136274. private _createVelocityGradientTexture;
  136275. private _createLimitVelocityGradientTexture;
  136276. private _createDragGradientTexture;
  136277. private _createColorGradientTexture;
  136278. /**
  136279. * Renders the particle system in its current state
  136280. * @param preWarm defines if the system should only update the particles but not render them
  136281. * @returns the current number of particles
  136282. */
  136283. render(preWarm?: boolean): number;
  136284. /**
  136285. * Rebuilds the particle system
  136286. */
  136287. rebuild(): void;
  136288. private _releaseBuffers;
  136289. private _releaseVAOs;
  136290. /**
  136291. * Disposes the particle system and free the associated resources
  136292. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136293. */
  136294. dispose(disposeTexture?: boolean): void;
  136295. /**
  136296. * Clones the particle system.
  136297. * @param name The name of the cloned object
  136298. * @param newEmitter The new emitter to use
  136299. * @returns the cloned particle system
  136300. */
  136301. clone(name: string, newEmitter: any): GPUParticleSystem;
  136302. /**
  136303. * Serializes the particle system to a JSON object.
  136304. * @returns the JSON object
  136305. */
  136306. serialize(): any;
  136307. /**
  136308. * Parses a JSON object to create a GPU particle system.
  136309. * @param parsedParticleSystem The JSON object to parse
  136310. * @param scene The scene to create the particle system in
  136311. * @param rootUrl The root url to use to load external dependencies like texture
  136312. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136313. * @returns the parsed GPU particle system
  136314. */
  136315. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136316. }
  136317. }
  136318. declare module BABYLON {
  136319. /**
  136320. * Represents a set of particle systems working together to create a specific effect
  136321. */
  136322. export class ParticleSystemSet implements IDisposable {
  136323. /**
  136324. * Gets or sets base Assets URL
  136325. */
  136326. static BaseAssetsUrl: string;
  136327. private _emitterCreationOptions;
  136328. private _emitterNode;
  136329. /**
  136330. * Gets the particle system list
  136331. */
  136332. systems: IParticleSystem[];
  136333. /**
  136334. * Gets the emitter node used with this set
  136335. */
  136336. get emitterNode(): Nullable<TransformNode>;
  136337. /**
  136338. * Creates a new emitter mesh as a sphere
  136339. * @param options defines the options used to create the sphere
  136340. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136341. * @param scene defines the hosting scene
  136342. */
  136343. setEmitterAsSphere(options: {
  136344. diameter: number;
  136345. segments: number;
  136346. color: Color3;
  136347. }, renderingGroupId: number, scene: Scene): void;
  136348. /**
  136349. * Starts all particle systems of the set
  136350. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136351. */
  136352. start(emitter?: AbstractMesh): void;
  136353. /**
  136354. * Release all associated resources
  136355. */
  136356. dispose(): void;
  136357. /**
  136358. * Serialize the set into a JSON compatible object
  136359. * @returns a JSON compatible representation of the set
  136360. */
  136361. serialize(): any;
  136362. /**
  136363. * Parse a new ParticleSystemSet from a serialized source
  136364. * @param data defines a JSON compatible representation of the set
  136365. * @param scene defines the hosting scene
  136366. * @param gpu defines if we want GPU particles or CPU particles
  136367. * @returns a new ParticleSystemSet
  136368. */
  136369. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136370. }
  136371. }
  136372. declare module BABYLON {
  136373. /**
  136374. * This class is made for on one-liner static method to help creating particle system set.
  136375. */
  136376. export class ParticleHelper {
  136377. /**
  136378. * Gets or sets base Assets URL
  136379. */
  136380. static BaseAssetsUrl: string;
  136381. /**
  136382. * Create a default particle system that you can tweak
  136383. * @param emitter defines the emitter to use
  136384. * @param capacity defines the system capacity (default is 500 particles)
  136385. * @param scene defines the hosting scene
  136386. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136387. * @returns the new Particle system
  136388. */
  136389. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136390. /**
  136391. * This is the main static method (one-liner) of this helper to create different particle systems
  136392. * @param type This string represents the type to the particle system to create
  136393. * @param scene The scene where the particle system should live
  136394. * @param gpu If the system will use gpu
  136395. * @returns the ParticleSystemSet created
  136396. */
  136397. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136398. /**
  136399. * Static function used to export a particle system to a ParticleSystemSet variable.
  136400. * Please note that the emitter shape is not exported
  136401. * @param systems defines the particle systems to export
  136402. * @returns the created particle system set
  136403. */
  136404. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136405. }
  136406. }
  136407. declare module BABYLON {
  136408. interface Engine {
  136409. /**
  136410. * Create an effect to use with particle systems.
  136411. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136412. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136413. * @param uniformsNames defines a list of attribute names
  136414. * @param samplers defines an array of string used to represent textures
  136415. * @param defines defines the string containing the defines to use to compile the shaders
  136416. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136417. * @param onCompiled defines a function to call when the effect creation is successful
  136418. * @param onError defines a function to call when the effect creation has failed
  136419. * @returns the new Effect
  136420. */
  136421. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136422. }
  136423. interface Mesh {
  136424. /**
  136425. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136426. * @returns an array of IParticleSystem
  136427. */
  136428. getEmittedParticleSystems(): IParticleSystem[];
  136429. /**
  136430. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136431. * @returns an array of IParticleSystem
  136432. */
  136433. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136434. }
  136435. /**
  136436. * @hidden
  136437. */
  136438. export var _IDoNeedToBeInTheBuild: number;
  136439. }
  136440. declare module BABYLON {
  136441. /** Defines the 4 color options */
  136442. export enum PointColor {
  136443. /** color value */
  136444. Color = 2,
  136445. /** uv value */
  136446. UV = 1,
  136447. /** random value */
  136448. Random = 0,
  136449. /** stated value */
  136450. Stated = 3
  136451. }
  136452. /**
  136453. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136454. * 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.
  136455. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136456. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136457. *
  136458. * Full documentation here : TO BE ENTERED
  136459. */
  136460. export class PointsCloudSystem implements IDisposable {
  136461. /**
  136462. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136463. * Example : var p = SPS.particles[i];
  136464. */
  136465. particles: CloudPoint[];
  136466. /**
  136467. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136468. */
  136469. nbParticles: number;
  136470. /**
  136471. * This a counter for your own usage. It's not set by any SPS functions.
  136472. */
  136473. counter: number;
  136474. /**
  136475. * The PCS name. This name is also given to the underlying mesh.
  136476. */
  136477. name: string;
  136478. /**
  136479. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136480. */
  136481. mesh: Mesh;
  136482. /**
  136483. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136484. * Please read :
  136485. */
  136486. vars: any;
  136487. /**
  136488. * @hidden
  136489. */
  136490. _size: number;
  136491. private _scene;
  136492. private _promises;
  136493. private _positions;
  136494. private _indices;
  136495. private _normals;
  136496. private _colors;
  136497. private _uvs;
  136498. private _indices32;
  136499. private _positions32;
  136500. private _colors32;
  136501. private _uvs32;
  136502. private _updatable;
  136503. private _isVisibilityBoxLocked;
  136504. private _alwaysVisible;
  136505. private _groups;
  136506. private _groupCounter;
  136507. private _computeParticleColor;
  136508. private _computeParticleTexture;
  136509. private _computeParticleRotation;
  136510. private _computeBoundingBox;
  136511. private _isReady;
  136512. /**
  136513. * Creates a PCS (Points Cloud System) object
  136514. * @param name (String) is the PCS name, this will be the underlying mesh name
  136515. * @param pointSize (number) is the size for each point
  136516. * @param scene (Scene) is the scene in which the PCS is added
  136517. * @param options defines the options of the PCS e.g.
  136518. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136519. */
  136520. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136521. updatable?: boolean;
  136522. });
  136523. /**
  136524. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136525. * If no points were added to the PCS, the returned mesh is just a single point.
  136526. * @returns a promise for the created mesh
  136527. */
  136528. buildMeshAsync(): Promise<Mesh>;
  136529. /**
  136530. * @hidden
  136531. */
  136532. private _buildMesh;
  136533. private _addParticle;
  136534. private _randomUnitVector;
  136535. private _getColorIndicesForCoord;
  136536. private _setPointsColorOrUV;
  136537. private _colorFromTexture;
  136538. private _calculateDensity;
  136539. /**
  136540. * Adds points to the PCS in random positions within a unit sphere
  136541. * @param nb (positive integer) the number of particles to be created from this model
  136542. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136543. * @returns the number of groups in the system
  136544. */
  136545. addPoints(nb: number, pointFunction?: any): number;
  136546. /**
  136547. * Adds points to the PCS from the surface of the model shape
  136548. * @param mesh is any Mesh object that will be used as a surface model for the points
  136549. * @param nb (positive integer) the number of particles to be created from this model
  136550. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136551. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136552. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136553. * @returns the number of groups in the system
  136554. */
  136555. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136556. /**
  136557. * Adds points to the PCS inside the model shape
  136558. * @param mesh is any Mesh object that will be used as a surface model for the points
  136559. * @param nb (positive integer) the number of particles to be created from this model
  136560. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136561. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136562. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136563. * @returns the number of groups in the system
  136564. */
  136565. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136566. /**
  136567. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136568. * This method calls `updateParticle()` for each particle of the SPS.
  136569. * For an animated SPS, it is usually called within the render loop.
  136570. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136571. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136572. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136573. * @returns the PCS.
  136574. */
  136575. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136576. /**
  136577. * Disposes the PCS.
  136578. */
  136579. dispose(): void;
  136580. /**
  136581. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136582. * doc :
  136583. * @returns the PCS.
  136584. */
  136585. refreshVisibleSize(): PointsCloudSystem;
  136586. /**
  136587. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136588. * @param size the size (float) of the visibility box
  136589. * note : this doesn't lock the PCS mesh bounding box.
  136590. * doc :
  136591. */
  136592. setVisibilityBox(size: number): void;
  136593. /**
  136594. * Gets whether the PCS is always visible or not
  136595. * doc :
  136596. */
  136597. get isAlwaysVisible(): boolean;
  136598. /**
  136599. * Sets the PCS as always visible or not
  136600. * doc :
  136601. */
  136602. set isAlwaysVisible(val: boolean);
  136603. /**
  136604. * Tells to `setParticles()` to compute the particle rotations or not
  136605. * Default value : false. The PCS is faster when it's set to false
  136606. * Note : particle rotations are only applied to parent particles
  136607. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136608. */
  136609. set computeParticleRotation(val: boolean);
  136610. /**
  136611. * Tells to `setParticles()` to compute the particle colors or not.
  136612. * Default value : true. The PCS is faster when it's set to false.
  136613. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136614. */
  136615. set computeParticleColor(val: boolean);
  136616. set computeParticleTexture(val: boolean);
  136617. /**
  136618. * Gets if `setParticles()` computes the particle colors or not.
  136619. * Default value : false. The PCS is faster when it's set to false.
  136620. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136621. */
  136622. get computeParticleColor(): boolean;
  136623. /**
  136624. * Gets if `setParticles()` computes the particle textures or not.
  136625. * Default value : false. The PCS is faster when it's set to false.
  136626. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136627. */
  136628. get computeParticleTexture(): boolean;
  136629. /**
  136630. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136631. */
  136632. set computeBoundingBox(val: boolean);
  136633. /**
  136634. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136635. */
  136636. get computeBoundingBox(): boolean;
  136637. /**
  136638. * This function does nothing. It may be overwritten to set all the particle first values.
  136639. * The PCS doesn't call this function, you may have to call it by your own.
  136640. * doc :
  136641. */
  136642. initParticles(): void;
  136643. /**
  136644. * This function does nothing. It may be overwritten to recycle a particle
  136645. * The PCS doesn't call this function, you can to call it
  136646. * doc :
  136647. * @param particle The particle to recycle
  136648. * @returns the recycled particle
  136649. */
  136650. recycleParticle(particle: CloudPoint): CloudPoint;
  136651. /**
  136652. * Updates a particle : this function should be overwritten by the user.
  136653. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136654. * doc :
  136655. * @example : just set a particle position or velocity and recycle conditions
  136656. * @param particle The particle to update
  136657. * @returns the updated particle
  136658. */
  136659. updateParticle(particle: CloudPoint): CloudPoint;
  136660. /**
  136661. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136662. * This does nothing and may be overwritten by the user.
  136663. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136664. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136665. * @param update the boolean update value actually passed to setParticles()
  136666. */
  136667. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136668. /**
  136669. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136670. * This will be passed three parameters.
  136671. * This does nothing and may be overwritten by the user.
  136672. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136673. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136674. * @param update the boolean update value actually passed to setParticles()
  136675. */
  136676. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136677. }
  136678. }
  136679. declare module BABYLON {
  136680. /**
  136681. * Represents one particle of a points cloud system.
  136682. */
  136683. export class CloudPoint {
  136684. /**
  136685. * particle global index
  136686. */
  136687. idx: number;
  136688. /**
  136689. * The color of the particle
  136690. */
  136691. color: Nullable<Color4>;
  136692. /**
  136693. * The world space position of the particle.
  136694. */
  136695. position: Vector3;
  136696. /**
  136697. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136698. */
  136699. rotation: Vector3;
  136700. /**
  136701. * The world space rotation quaternion of the particle.
  136702. */
  136703. rotationQuaternion: Nullable<Quaternion>;
  136704. /**
  136705. * The uv of the particle.
  136706. */
  136707. uv: Nullable<Vector2>;
  136708. /**
  136709. * The current speed of the particle.
  136710. */
  136711. velocity: Vector3;
  136712. /**
  136713. * The pivot point in the particle local space.
  136714. */
  136715. pivot: Vector3;
  136716. /**
  136717. * Must the particle be translated from its pivot point in its local space ?
  136718. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136719. * Default : false
  136720. */
  136721. translateFromPivot: boolean;
  136722. /**
  136723. * Index of this particle in the global "positions" array (Internal use)
  136724. * @hidden
  136725. */
  136726. _pos: number;
  136727. /**
  136728. * @hidden Index of this particle in the global "indices" array (Internal use)
  136729. */
  136730. _ind: number;
  136731. /**
  136732. * Group this particle belongs to
  136733. */
  136734. _group: PointsGroup;
  136735. /**
  136736. * Group id of this particle
  136737. */
  136738. groupId: number;
  136739. /**
  136740. * Index of the particle in its group id (Internal use)
  136741. */
  136742. idxInGroup: number;
  136743. /**
  136744. * @hidden Particle BoundingInfo object (Internal use)
  136745. */
  136746. _boundingInfo: BoundingInfo;
  136747. /**
  136748. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136749. */
  136750. _pcs: PointsCloudSystem;
  136751. /**
  136752. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136753. */
  136754. _stillInvisible: boolean;
  136755. /**
  136756. * @hidden Last computed particle rotation matrix
  136757. */
  136758. _rotationMatrix: number[];
  136759. /**
  136760. * Parent particle Id, if any.
  136761. * Default null.
  136762. */
  136763. parentId: Nullable<number>;
  136764. /**
  136765. * @hidden Internal global position in the PCS.
  136766. */
  136767. _globalPosition: Vector3;
  136768. /**
  136769. * Creates a Point Cloud object.
  136770. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136771. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136772. * @param group (PointsGroup) is the group the particle belongs to
  136773. * @param groupId (integer) is the group identifier in the PCS.
  136774. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136775. * @param pcs defines the PCS it is associated to
  136776. */
  136777. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136778. /**
  136779. * get point size
  136780. */
  136781. get size(): Vector3;
  136782. /**
  136783. * Set point size
  136784. */
  136785. set size(scale: Vector3);
  136786. /**
  136787. * Legacy support, changed quaternion to rotationQuaternion
  136788. */
  136789. get quaternion(): Nullable<Quaternion>;
  136790. /**
  136791. * Legacy support, changed quaternion to rotationQuaternion
  136792. */
  136793. set quaternion(q: Nullable<Quaternion>);
  136794. /**
  136795. * Returns a boolean. True if the particle intersects a mesh, else false
  136796. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136797. * @param target is the object (point or mesh) what the intersection is computed against
  136798. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136799. * @returns true if it intersects
  136800. */
  136801. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136802. /**
  136803. * get the rotation matrix of the particle
  136804. * @hidden
  136805. */
  136806. getRotationMatrix(m: Matrix): void;
  136807. }
  136808. /**
  136809. * Represents a group of points in a points cloud system
  136810. * * PCS internal tool, don't use it manually.
  136811. */
  136812. export class PointsGroup {
  136813. /**
  136814. * The group id
  136815. * @hidden
  136816. */
  136817. groupID: number;
  136818. /**
  136819. * image data for group (internal use)
  136820. * @hidden
  136821. */
  136822. _groupImageData: Nullable<ArrayBufferView>;
  136823. /**
  136824. * Image Width (internal use)
  136825. * @hidden
  136826. */
  136827. _groupImgWidth: number;
  136828. /**
  136829. * Image Height (internal use)
  136830. * @hidden
  136831. */
  136832. _groupImgHeight: number;
  136833. /**
  136834. * Custom position function (internal use)
  136835. * @hidden
  136836. */
  136837. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136838. /**
  136839. * density per facet for surface points
  136840. * @hidden
  136841. */
  136842. _groupDensity: number[];
  136843. /**
  136844. * Only when points are colored by texture carries pointer to texture list array
  136845. * @hidden
  136846. */
  136847. _textureNb: number;
  136848. /**
  136849. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136850. * PCS internal tool, don't use it manually.
  136851. * @hidden
  136852. */
  136853. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136854. }
  136855. }
  136856. declare module BABYLON {
  136857. interface Scene {
  136858. /** @hidden (Backing field) */
  136859. _physicsEngine: Nullable<IPhysicsEngine>;
  136860. /** @hidden */
  136861. _physicsTimeAccumulator: number;
  136862. /**
  136863. * Gets the current physics engine
  136864. * @returns a IPhysicsEngine or null if none attached
  136865. */
  136866. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136867. /**
  136868. * Enables physics to the current scene
  136869. * @param gravity defines the scene's gravity for the physics engine
  136870. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136871. * @return a boolean indicating if the physics engine was initialized
  136872. */
  136873. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136874. /**
  136875. * Disables and disposes the physics engine associated with the scene
  136876. */
  136877. disablePhysicsEngine(): void;
  136878. /**
  136879. * Gets a boolean indicating if there is an active physics engine
  136880. * @returns a boolean indicating if there is an active physics engine
  136881. */
  136882. isPhysicsEnabled(): boolean;
  136883. /**
  136884. * Deletes a physics compound impostor
  136885. * @param compound defines the compound to delete
  136886. */
  136887. deleteCompoundImpostor(compound: any): void;
  136888. /**
  136889. * An event triggered when physic simulation is about to be run
  136890. */
  136891. onBeforePhysicsObservable: Observable<Scene>;
  136892. /**
  136893. * An event triggered when physic simulation has been done
  136894. */
  136895. onAfterPhysicsObservable: Observable<Scene>;
  136896. }
  136897. interface AbstractMesh {
  136898. /** @hidden */
  136899. _physicsImpostor: Nullable<PhysicsImpostor>;
  136900. /**
  136901. * Gets or sets impostor used for physic simulation
  136902. * @see http://doc.babylonjs.com/features/physics_engine
  136903. */
  136904. physicsImpostor: Nullable<PhysicsImpostor>;
  136905. /**
  136906. * Gets the current physics impostor
  136907. * @see http://doc.babylonjs.com/features/physics_engine
  136908. * @returns a physics impostor or null
  136909. */
  136910. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136911. /** Apply a physic impulse to the mesh
  136912. * @param force defines the force to apply
  136913. * @param contactPoint defines where to apply the force
  136914. * @returns the current mesh
  136915. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136916. */
  136917. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136918. /**
  136919. * Creates a physic joint between two meshes
  136920. * @param otherMesh defines the other mesh to use
  136921. * @param pivot1 defines the pivot to use on this mesh
  136922. * @param pivot2 defines the pivot to use on the other mesh
  136923. * @param options defines additional options (can be plugin dependent)
  136924. * @returns the current mesh
  136925. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136926. */
  136927. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136928. /** @hidden */
  136929. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136930. }
  136931. /**
  136932. * Defines the physics engine scene component responsible to manage a physics engine
  136933. */
  136934. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136935. /**
  136936. * The component name helpful to identify the component in the list of scene components.
  136937. */
  136938. readonly name: string;
  136939. /**
  136940. * The scene the component belongs to.
  136941. */
  136942. scene: Scene;
  136943. /**
  136944. * Creates a new instance of the component for the given scene
  136945. * @param scene Defines the scene to register the component in
  136946. */
  136947. constructor(scene: Scene);
  136948. /**
  136949. * Registers the component in a given scene
  136950. */
  136951. register(): void;
  136952. /**
  136953. * Rebuilds the elements related to this component in case of
  136954. * context lost for instance.
  136955. */
  136956. rebuild(): void;
  136957. /**
  136958. * Disposes the component and the associated ressources
  136959. */
  136960. dispose(): void;
  136961. }
  136962. }
  136963. declare module BABYLON {
  136964. /**
  136965. * A helper for physics simulations
  136966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136967. */
  136968. export class PhysicsHelper {
  136969. private _scene;
  136970. private _physicsEngine;
  136971. /**
  136972. * Initializes the Physics helper
  136973. * @param scene Babylon.js scene
  136974. */
  136975. constructor(scene: Scene);
  136976. /**
  136977. * Applies a radial explosion impulse
  136978. * @param origin the origin of the explosion
  136979. * @param radiusOrEventOptions the radius or the options of radial explosion
  136980. * @param strength the explosion strength
  136981. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136982. * @returns A physics radial explosion event, or null
  136983. */
  136984. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136985. /**
  136986. * Applies a radial explosion force
  136987. * @param origin the origin of the explosion
  136988. * @param radiusOrEventOptions the radius or the options of radial explosion
  136989. * @param strength the explosion strength
  136990. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136991. * @returns A physics radial explosion event, or null
  136992. */
  136993. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136994. /**
  136995. * Creates a gravitational field
  136996. * @param origin the origin of the explosion
  136997. * @param radiusOrEventOptions the radius or the options of radial explosion
  136998. * @param strength the explosion strength
  136999. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137000. * @returns A physics gravitational field event, or null
  137001. */
  137002. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  137003. /**
  137004. * Creates a physics updraft event
  137005. * @param origin the origin of the updraft
  137006. * @param radiusOrEventOptions the radius or the options of the updraft
  137007. * @param strength the strength of the updraft
  137008. * @param height the height of the updraft
  137009. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  137010. * @returns A physics updraft event, or null
  137011. */
  137012. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  137013. /**
  137014. * Creates a physics vortex event
  137015. * @param origin the of the vortex
  137016. * @param radiusOrEventOptions the radius or the options of the vortex
  137017. * @param strength the strength of the vortex
  137018. * @param height the height of the vortex
  137019. * @returns a Physics vortex event, or null
  137020. * A physics vortex event or null
  137021. */
  137022. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  137023. }
  137024. /**
  137025. * Represents a physics radial explosion event
  137026. */
  137027. class PhysicsRadialExplosionEvent {
  137028. private _scene;
  137029. private _options;
  137030. private _sphere;
  137031. private _dataFetched;
  137032. /**
  137033. * Initializes a radial explosioin event
  137034. * @param _scene BabylonJS scene
  137035. * @param _options The options for the vortex event
  137036. */
  137037. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  137038. /**
  137039. * Returns the data related to the radial explosion event (sphere).
  137040. * @returns The radial explosion event data
  137041. */
  137042. getData(): PhysicsRadialExplosionEventData;
  137043. /**
  137044. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  137045. * @param impostor A physics imposter
  137046. * @param origin the origin of the explosion
  137047. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  137048. */
  137049. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  137050. /**
  137051. * Triggers affecterd impostors callbacks
  137052. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  137053. */
  137054. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  137055. /**
  137056. * Disposes the sphere.
  137057. * @param force Specifies if the sphere should be disposed by force
  137058. */
  137059. dispose(force?: boolean): void;
  137060. /*** Helpers ***/
  137061. private _prepareSphere;
  137062. private _intersectsWithSphere;
  137063. }
  137064. /**
  137065. * Represents a gravitational field event
  137066. */
  137067. class PhysicsGravitationalFieldEvent {
  137068. private _physicsHelper;
  137069. private _scene;
  137070. private _origin;
  137071. private _options;
  137072. private _tickCallback;
  137073. private _sphere;
  137074. private _dataFetched;
  137075. /**
  137076. * Initializes the physics gravitational field event
  137077. * @param _physicsHelper A physics helper
  137078. * @param _scene BabylonJS scene
  137079. * @param _origin The origin position of the gravitational field event
  137080. * @param _options The options for the vortex event
  137081. */
  137082. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  137083. /**
  137084. * Returns the data related to the gravitational field event (sphere).
  137085. * @returns A gravitational field event
  137086. */
  137087. getData(): PhysicsGravitationalFieldEventData;
  137088. /**
  137089. * Enables the gravitational field.
  137090. */
  137091. enable(): void;
  137092. /**
  137093. * Disables the gravitational field.
  137094. */
  137095. disable(): void;
  137096. /**
  137097. * Disposes the sphere.
  137098. * @param force The force to dispose from the gravitational field event
  137099. */
  137100. dispose(force?: boolean): void;
  137101. private _tick;
  137102. }
  137103. /**
  137104. * Represents a physics updraft event
  137105. */
  137106. class PhysicsUpdraftEvent {
  137107. private _scene;
  137108. private _origin;
  137109. private _options;
  137110. private _physicsEngine;
  137111. private _originTop;
  137112. private _originDirection;
  137113. private _tickCallback;
  137114. private _cylinder;
  137115. private _cylinderPosition;
  137116. private _dataFetched;
  137117. /**
  137118. * Initializes the physics updraft event
  137119. * @param _scene BabylonJS scene
  137120. * @param _origin The origin position of the updraft
  137121. * @param _options The options for the updraft event
  137122. */
  137123. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  137124. /**
  137125. * Returns the data related to the updraft event (cylinder).
  137126. * @returns A physics updraft event
  137127. */
  137128. getData(): PhysicsUpdraftEventData;
  137129. /**
  137130. * Enables the updraft.
  137131. */
  137132. enable(): void;
  137133. /**
  137134. * Disables the updraft.
  137135. */
  137136. disable(): void;
  137137. /**
  137138. * Disposes the cylinder.
  137139. * @param force Specifies if the updraft should be disposed by force
  137140. */
  137141. dispose(force?: boolean): void;
  137142. private getImpostorHitData;
  137143. private _tick;
  137144. /*** Helpers ***/
  137145. private _prepareCylinder;
  137146. private _intersectsWithCylinder;
  137147. }
  137148. /**
  137149. * Represents a physics vortex event
  137150. */
  137151. class PhysicsVortexEvent {
  137152. private _scene;
  137153. private _origin;
  137154. private _options;
  137155. private _physicsEngine;
  137156. private _originTop;
  137157. private _tickCallback;
  137158. private _cylinder;
  137159. private _cylinderPosition;
  137160. private _dataFetched;
  137161. /**
  137162. * Initializes the physics vortex event
  137163. * @param _scene The BabylonJS scene
  137164. * @param _origin The origin position of the vortex
  137165. * @param _options The options for the vortex event
  137166. */
  137167. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  137168. /**
  137169. * Returns the data related to the vortex event (cylinder).
  137170. * @returns The physics vortex event data
  137171. */
  137172. getData(): PhysicsVortexEventData;
  137173. /**
  137174. * Enables the vortex.
  137175. */
  137176. enable(): void;
  137177. /**
  137178. * Disables the cortex.
  137179. */
  137180. disable(): void;
  137181. /**
  137182. * Disposes the sphere.
  137183. * @param force
  137184. */
  137185. dispose(force?: boolean): void;
  137186. private getImpostorHitData;
  137187. private _tick;
  137188. /*** Helpers ***/
  137189. private _prepareCylinder;
  137190. private _intersectsWithCylinder;
  137191. }
  137192. /**
  137193. * Options fot the radial explosion event
  137194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137195. */
  137196. export class PhysicsRadialExplosionEventOptions {
  137197. /**
  137198. * The radius of the sphere for the radial explosion.
  137199. */
  137200. radius: number;
  137201. /**
  137202. * The strenth of the explosion.
  137203. */
  137204. strength: number;
  137205. /**
  137206. * The strenght of the force in correspondence to the distance of the affected object
  137207. */
  137208. falloff: PhysicsRadialImpulseFalloff;
  137209. /**
  137210. * Sphere options for the radial explosion.
  137211. */
  137212. sphere: {
  137213. segments: number;
  137214. diameter: number;
  137215. };
  137216. /**
  137217. * Sphere options for the radial explosion.
  137218. */
  137219. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137220. }
  137221. /**
  137222. * Options fot the updraft event
  137223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137224. */
  137225. export class PhysicsUpdraftEventOptions {
  137226. /**
  137227. * The radius of the cylinder for the vortex
  137228. */
  137229. radius: number;
  137230. /**
  137231. * The strenth of the updraft.
  137232. */
  137233. strength: number;
  137234. /**
  137235. * The height of the cylinder for the updraft.
  137236. */
  137237. height: number;
  137238. /**
  137239. * The mode for the the updraft.
  137240. */
  137241. updraftMode: PhysicsUpdraftMode;
  137242. }
  137243. /**
  137244. * Options fot the vortex event
  137245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137246. */
  137247. export class PhysicsVortexEventOptions {
  137248. /**
  137249. * The radius of the cylinder for the vortex
  137250. */
  137251. radius: number;
  137252. /**
  137253. * The strenth of the vortex.
  137254. */
  137255. strength: number;
  137256. /**
  137257. * The height of the cylinder for the vortex.
  137258. */
  137259. height: number;
  137260. /**
  137261. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137262. */
  137263. centripetalForceThreshold: number;
  137264. /**
  137265. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137266. */
  137267. centripetalForceMultiplier: number;
  137268. /**
  137269. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137270. */
  137271. centrifugalForceMultiplier: number;
  137272. /**
  137273. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137274. */
  137275. updraftForceMultiplier: number;
  137276. }
  137277. /**
  137278. * The strenght of the force in correspondence to the distance of the affected object
  137279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137280. */
  137281. export enum PhysicsRadialImpulseFalloff {
  137282. /** Defines that impulse is constant in strength across it's whole radius */
  137283. Constant = 0,
  137284. /** Defines that impulse gets weaker if it's further from the origin */
  137285. Linear = 1
  137286. }
  137287. /**
  137288. * The strength of the force in correspondence to the distance of the affected object
  137289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137290. */
  137291. export enum PhysicsUpdraftMode {
  137292. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137293. Center = 0,
  137294. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137295. Perpendicular = 1
  137296. }
  137297. /**
  137298. * Interface for a physics hit data
  137299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137300. */
  137301. export interface PhysicsHitData {
  137302. /**
  137303. * The force applied at the contact point
  137304. */
  137305. force: Vector3;
  137306. /**
  137307. * The contact point
  137308. */
  137309. contactPoint: Vector3;
  137310. /**
  137311. * The distance from the origin to the contact point
  137312. */
  137313. distanceFromOrigin: number;
  137314. }
  137315. /**
  137316. * Interface for radial explosion event data
  137317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137318. */
  137319. export interface PhysicsRadialExplosionEventData {
  137320. /**
  137321. * A sphere used for the radial explosion event
  137322. */
  137323. sphere: Mesh;
  137324. }
  137325. /**
  137326. * Interface for gravitational field event data
  137327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137328. */
  137329. export interface PhysicsGravitationalFieldEventData {
  137330. /**
  137331. * A sphere mesh used for the gravitational field event
  137332. */
  137333. sphere: Mesh;
  137334. }
  137335. /**
  137336. * Interface for updraft event data
  137337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137338. */
  137339. export interface PhysicsUpdraftEventData {
  137340. /**
  137341. * A cylinder used for the updraft event
  137342. */
  137343. cylinder: Mesh;
  137344. }
  137345. /**
  137346. * Interface for vortex event data
  137347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137348. */
  137349. export interface PhysicsVortexEventData {
  137350. /**
  137351. * A cylinder used for the vortex event
  137352. */
  137353. cylinder: Mesh;
  137354. }
  137355. /**
  137356. * Interface for an affected physics impostor
  137357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137358. */
  137359. export interface PhysicsAffectedImpostorWithData {
  137360. /**
  137361. * The impostor affected by the effect
  137362. */
  137363. impostor: PhysicsImpostor;
  137364. /**
  137365. * The data about the hit/horce from the explosion
  137366. */
  137367. hitData: PhysicsHitData;
  137368. }
  137369. }
  137370. declare module BABYLON {
  137371. /** @hidden */
  137372. export var blackAndWhitePixelShader: {
  137373. name: string;
  137374. shader: string;
  137375. };
  137376. }
  137377. declare module BABYLON {
  137378. /**
  137379. * Post process used to render in black and white
  137380. */
  137381. export class BlackAndWhitePostProcess extends PostProcess {
  137382. /**
  137383. * Linear about to convert he result to black and white (default: 1)
  137384. */
  137385. degree: number;
  137386. /**
  137387. * Creates a black and white post process
  137388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137389. * @param name The name of the effect.
  137390. * @param options The required width/height ratio to downsize to before computing the render pass.
  137391. * @param camera The camera to apply the render pass to.
  137392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137393. * @param engine The engine which the post process will be applied. (default: current engine)
  137394. * @param reusable If the post process can be reused on the same frame. (default: false)
  137395. */
  137396. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137397. }
  137398. }
  137399. declare module BABYLON {
  137400. /**
  137401. * This represents a set of one or more post processes in Babylon.
  137402. * A post process can be used to apply a shader to a texture after it is rendered.
  137403. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137404. */
  137405. export class PostProcessRenderEffect {
  137406. private _postProcesses;
  137407. private _getPostProcesses;
  137408. private _singleInstance;
  137409. private _cameras;
  137410. private _indicesForCamera;
  137411. /**
  137412. * Name of the effect
  137413. * @hidden
  137414. */
  137415. _name: string;
  137416. /**
  137417. * Instantiates a post process render effect.
  137418. * A post process can be used to apply a shader to a texture after it is rendered.
  137419. * @param engine The engine the effect is tied to
  137420. * @param name The name of the effect
  137421. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137422. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137423. */
  137424. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137425. /**
  137426. * Checks if all the post processes in the effect are supported.
  137427. */
  137428. get isSupported(): boolean;
  137429. /**
  137430. * Updates the current state of the effect
  137431. * @hidden
  137432. */
  137433. _update(): void;
  137434. /**
  137435. * Attaches the effect on cameras
  137436. * @param cameras The camera to attach to.
  137437. * @hidden
  137438. */
  137439. _attachCameras(cameras: Camera): void;
  137440. /**
  137441. * Attaches the effect on cameras
  137442. * @param cameras The camera to attach to.
  137443. * @hidden
  137444. */
  137445. _attachCameras(cameras: Camera[]): void;
  137446. /**
  137447. * Detaches the effect on cameras
  137448. * @param cameras The camera to detatch from.
  137449. * @hidden
  137450. */
  137451. _detachCameras(cameras: Camera): void;
  137452. /**
  137453. * Detatches the effect on cameras
  137454. * @param cameras The camera to detatch from.
  137455. * @hidden
  137456. */
  137457. _detachCameras(cameras: Camera[]): void;
  137458. /**
  137459. * Enables the effect on given cameras
  137460. * @param cameras The camera to enable.
  137461. * @hidden
  137462. */
  137463. _enable(cameras: Camera): void;
  137464. /**
  137465. * Enables the effect on given cameras
  137466. * @param cameras The camera to enable.
  137467. * @hidden
  137468. */
  137469. _enable(cameras: Nullable<Camera[]>): void;
  137470. /**
  137471. * Disables the effect on the given cameras
  137472. * @param cameras The camera to disable.
  137473. * @hidden
  137474. */
  137475. _disable(cameras: Camera): void;
  137476. /**
  137477. * Disables the effect on the given cameras
  137478. * @param cameras The camera to disable.
  137479. * @hidden
  137480. */
  137481. _disable(cameras: Nullable<Camera[]>): void;
  137482. /**
  137483. * Gets a list of the post processes contained in the effect.
  137484. * @param camera The camera to get the post processes on.
  137485. * @returns The list of the post processes in the effect.
  137486. */
  137487. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137488. }
  137489. }
  137490. declare module BABYLON {
  137491. /** @hidden */
  137492. export var extractHighlightsPixelShader: {
  137493. name: string;
  137494. shader: string;
  137495. };
  137496. }
  137497. declare module BABYLON {
  137498. /**
  137499. * 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.
  137500. */
  137501. export class ExtractHighlightsPostProcess extends PostProcess {
  137502. /**
  137503. * The luminance threshold, pixels below this value will be set to black.
  137504. */
  137505. threshold: number;
  137506. /** @hidden */
  137507. _exposure: number;
  137508. /**
  137509. * Post process which has the input texture to be used when performing highlight extraction
  137510. * @hidden
  137511. */
  137512. _inputPostProcess: Nullable<PostProcess>;
  137513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137514. }
  137515. }
  137516. declare module BABYLON {
  137517. /** @hidden */
  137518. export var bloomMergePixelShader: {
  137519. name: string;
  137520. shader: string;
  137521. };
  137522. }
  137523. declare module BABYLON {
  137524. /**
  137525. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137526. */
  137527. export class BloomMergePostProcess extends PostProcess {
  137528. /** Weight of the bloom to be added to the original input. */
  137529. weight: number;
  137530. /**
  137531. * Creates a new instance of @see BloomMergePostProcess
  137532. * @param name The name of the effect.
  137533. * @param originalFromInput Post process which's input will be used for the merge.
  137534. * @param blurred Blurred highlights post process which's output will be used.
  137535. * @param weight Weight of the bloom to be added to the original input.
  137536. * @param options The required width/height ratio to downsize to before computing the render pass.
  137537. * @param camera The camera to apply the render pass to.
  137538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137539. * @param engine The engine which the post process will be applied. (default: current engine)
  137540. * @param reusable If the post process can be reused on the same frame. (default: false)
  137541. * @param textureType Type of textures used when performing the post process. (default: 0)
  137542. * @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)
  137543. */
  137544. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137545. /** Weight of the bloom to be added to the original input. */
  137546. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137547. }
  137548. }
  137549. declare module BABYLON {
  137550. /**
  137551. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137552. */
  137553. export class BloomEffect extends PostProcessRenderEffect {
  137554. private bloomScale;
  137555. /**
  137556. * @hidden Internal
  137557. */
  137558. _effects: Array<PostProcess>;
  137559. /**
  137560. * @hidden Internal
  137561. */
  137562. _downscale: ExtractHighlightsPostProcess;
  137563. private _blurX;
  137564. private _blurY;
  137565. private _merge;
  137566. /**
  137567. * The luminance threshold to find bright areas of the image to bloom.
  137568. */
  137569. get threshold(): number;
  137570. set threshold(value: number);
  137571. /**
  137572. * The strength of the bloom.
  137573. */
  137574. get weight(): number;
  137575. set weight(value: number);
  137576. /**
  137577. * Specifies the size of the bloom blur kernel, relative to the final output size
  137578. */
  137579. get kernel(): number;
  137580. set kernel(value: number);
  137581. /**
  137582. * Creates a new instance of @see BloomEffect
  137583. * @param scene The scene the effect belongs to.
  137584. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137585. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137586. * @param bloomWeight The the strength of bloom.
  137587. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137588. * @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)
  137589. */
  137590. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137591. /**
  137592. * Disposes each of the internal effects for a given camera.
  137593. * @param camera The camera to dispose the effect on.
  137594. */
  137595. disposeEffects(camera: Camera): void;
  137596. /**
  137597. * @hidden Internal
  137598. */
  137599. _updateEffects(): void;
  137600. /**
  137601. * Internal
  137602. * @returns if all the contained post processes are ready.
  137603. * @hidden
  137604. */
  137605. _isReady(): boolean;
  137606. }
  137607. }
  137608. declare module BABYLON {
  137609. /** @hidden */
  137610. export var chromaticAberrationPixelShader: {
  137611. name: string;
  137612. shader: string;
  137613. };
  137614. }
  137615. declare module BABYLON {
  137616. /**
  137617. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137618. */
  137619. export class ChromaticAberrationPostProcess extends PostProcess {
  137620. /**
  137621. * The amount of seperation of rgb channels (default: 30)
  137622. */
  137623. aberrationAmount: number;
  137624. /**
  137625. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137626. */
  137627. radialIntensity: number;
  137628. /**
  137629. * 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))
  137630. */
  137631. direction: Vector2;
  137632. /**
  137633. * 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))
  137634. */
  137635. centerPosition: Vector2;
  137636. /**
  137637. * Creates a new instance ChromaticAberrationPostProcess
  137638. * @param name The name of the effect.
  137639. * @param screenWidth The width of the screen to apply the effect on.
  137640. * @param screenHeight The height of the screen to apply the effect on.
  137641. * @param options The required width/height ratio to downsize to before computing the render pass.
  137642. * @param camera The camera to apply the render pass to.
  137643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137644. * @param engine The engine which the post process will be applied. (default: current engine)
  137645. * @param reusable If the post process can be reused on the same frame. (default: false)
  137646. * @param textureType Type of textures used when performing the post process. (default: 0)
  137647. * @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)
  137648. */
  137649. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137650. }
  137651. }
  137652. declare module BABYLON {
  137653. /** @hidden */
  137654. export var circleOfConfusionPixelShader: {
  137655. name: string;
  137656. shader: string;
  137657. };
  137658. }
  137659. declare module BABYLON {
  137660. /**
  137661. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137662. */
  137663. export class CircleOfConfusionPostProcess extends PostProcess {
  137664. /**
  137665. * 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.
  137666. */
  137667. lensSize: number;
  137668. /**
  137669. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137670. */
  137671. fStop: number;
  137672. /**
  137673. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137674. */
  137675. focusDistance: number;
  137676. /**
  137677. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137678. */
  137679. focalLength: number;
  137680. private _depthTexture;
  137681. /**
  137682. * Creates a new instance CircleOfConfusionPostProcess
  137683. * @param name The name of the effect.
  137684. * @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.
  137685. * @param options The required width/height ratio to downsize to before computing the render pass.
  137686. * @param camera The camera to apply the render pass to.
  137687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137688. * @param engine The engine which the post process will be applied. (default: current engine)
  137689. * @param reusable If the post process can be reused on the same frame. (default: false)
  137690. * @param textureType Type of textures used when performing the post process. (default: 0)
  137691. * @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)
  137692. */
  137693. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137694. /**
  137695. * 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.
  137696. */
  137697. set depthTexture(value: RenderTargetTexture);
  137698. }
  137699. }
  137700. declare module BABYLON {
  137701. /** @hidden */
  137702. export var colorCorrectionPixelShader: {
  137703. name: string;
  137704. shader: string;
  137705. };
  137706. }
  137707. declare module BABYLON {
  137708. /**
  137709. *
  137710. * This post-process allows the modification of rendered colors by using
  137711. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137712. *
  137713. * The object needs to be provided an url to a texture containing the color
  137714. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137715. * Use an image editing software to tweak the LUT to match your needs.
  137716. *
  137717. * For an example of a color LUT, see here:
  137718. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137719. * For explanations on color grading, see here:
  137720. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137721. *
  137722. */
  137723. export class ColorCorrectionPostProcess extends PostProcess {
  137724. private _colorTableTexture;
  137725. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137726. }
  137727. }
  137728. declare module BABYLON {
  137729. /** @hidden */
  137730. export var convolutionPixelShader: {
  137731. name: string;
  137732. shader: string;
  137733. };
  137734. }
  137735. declare module BABYLON {
  137736. /**
  137737. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137738. * input texture to perform effects such as edge detection or sharpening
  137739. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137740. */
  137741. export class ConvolutionPostProcess extends PostProcess {
  137742. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137743. kernel: number[];
  137744. /**
  137745. * Creates a new instance ConvolutionPostProcess
  137746. * @param name The name of the effect.
  137747. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137748. * @param options The required width/height ratio to downsize to before computing the render pass.
  137749. * @param camera The camera to apply the render pass to.
  137750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137751. * @param engine The engine which the post process will be applied. (default: current engine)
  137752. * @param reusable If the post process can be reused on the same frame. (default: false)
  137753. * @param textureType Type of textures used when performing the post process. (default: 0)
  137754. */
  137755. constructor(name: string,
  137756. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137757. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137758. /**
  137759. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137760. */
  137761. static EdgeDetect0Kernel: number[];
  137762. /**
  137763. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137764. */
  137765. static EdgeDetect1Kernel: number[];
  137766. /**
  137767. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137768. */
  137769. static EdgeDetect2Kernel: number[];
  137770. /**
  137771. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137772. */
  137773. static SharpenKernel: number[];
  137774. /**
  137775. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137776. */
  137777. static EmbossKernel: number[];
  137778. /**
  137779. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137780. */
  137781. static GaussianKernel: number[];
  137782. }
  137783. }
  137784. declare module BABYLON {
  137785. /**
  137786. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137787. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137788. * based on samples that have a large difference in distance than the center pixel.
  137789. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137790. */
  137791. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137792. direction: Vector2;
  137793. /**
  137794. * Creates a new instance CircleOfConfusionPostProcess
  137795. * @param name The name of the effect.
  137796. * @param scene The scene the effect belongs to.
  137797. * @param direction The direction the blur should be applied.
  137798. * @param kernel The size of the kernel used to blur.
  137799. * @param options The required width/height ratio to downsize to before computing the render pass.
  137800. * @param camera The camera to apply the render pass to.
  137801. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137802. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137804. * @param engine The engine which the post process will be applied. (default: current engine)
  137805. * @param reusable If the post process can be reused on the same frame. (default: false)
  137806. * @param textureType Type of textures used when performing the post process. (default: 0)
  137807. * @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)
  137808. */
  137809. 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);
  137810. }
  137811. }
  137812. declare module BABYLON {
  137813. /** @hidden */
  137814. export var depthOfFieldMergePixelShader: {
  137815. name: string;
  137816. shader: string;
  137817. };
  137818. }
  137819. declare module BABYLON {
  137820. /**
  137821. * Options to be set when merging outputs from the default pipeline.
  137822. */
  137823. export class DepthOfFieldMergePostProcessOptions {
  137824. /**
  137825. * The original image to merge on top of
  137826. */
  137827. originalFromInput: PostProcess;
  137828. /**
  137829. * Parameters to perform the merge of the depth of field effect
  137830. */
  137831. depthOfField?: {
  137832. circleOfConfusion: PostProcess;
  137833. blurSteps: Array<PostProcess>;
  137834. };
  137835. /**
  137836. * Parameters to perform the merge of bloom effect
  137837. */
  137838. bloom?: {
  137839. blurred: PostProcess;
  137840. weight: number;
  137841. };
  137842. }
  137843. /**
  137844. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137845. */
  137846. export class DepthOfFieldMergePostProcess extends PostProcess {
  137847. private blurSteps;
  137848. /**
  137849. * Creates a new instance of DepthOfFieldMergePostProcess
  137850. * @param name The name of the effect.
  137851. * @param originalFromInput Post process which's input will be used for the merge.
  137852. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137853. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137854. * @param options The required width/height ratio to downsize to before computing the render pass.
  137855. * @param camera The camera to apply the render pass to.
  137856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137857. * @param engine The engine which the post process will be applied. (default: current engine)
  137858. * @param reusable If the post process can be reused on the same frame. (default: false)
  137859. * @param textureType Type of textures used when performing the post process. (default: 0)
  137860. * @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)
  137861. */
  137862. 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);
  137863. /**
  137864. * Updates the effect with the current post process compile time values and recompiles the shader.
  137865. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137866. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137867. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137868. * @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
  137869. * @param onCompiled Called when the shader has been compiled.
  137870. * @param onError Called if there is an error when compiling a shader.
  137871. */
  137872. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137873. }
  137874. }
  137875. declare module BABYLON {
  137876. /**
  137877. * Specifies the level of max blur that should be applied when using the depth of field effect
  137878. */
  137879. export enum DepthOfFieldEffectBlurLevel {
  137880. /**
  137881. * Subtle blur
  137882. */
  137883. Low = 0,
  137884. /**
  137885. * Medium blur
  137886. */
  137887. Medium = 1,
  137888. /**
  137889. * Large blur
  137890. */
  137891. High = 2
  137892. }
  137893. /**
  137894. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137895. */
  137896. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137897. private _circleOfConfusion;
  137898. /**
  137899. * @hidden Internal, blurs from high to low
  137900. */
  137901. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137902. private _depthOfFieldBlurY;
  137903. private _dofMerge;
  137904. /**
  137905. * @hidden Internal post processes in depth of field effect
  137906. */
  137907. _effects: Array<PostProcess>;
  137908. /**
  137909. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137910. */
  137911. set focalLength(value: number);
  137912. get focalLength(): number;
  137913. /**
  137914. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137915. */
  137916. set fStop(value: number);
  137917. get fStop(): number;
  137918. /**
  137919. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137920. */
  137921. set focusDistance(value: number);
  137922. get focusDistance(): number;
  137923. /**
  137924. * 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.
  137925. */
  137926. set lensSize(value: number);
  137927. get lensSize(): number;
  137928. /**
  137929. * Creates a new instance DepthOfFieldEffect
  137930. * @param scene The scene the effect belongs to.
  137931. * @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.
  137932. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137933. * @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)
  137934. */
  137935. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137936. /**
  137937. * Get the current class name of the current effet
  137938. * @returns "DepthOfFieldEffect"
  137939. */
  137940. getClassName(): string;
  137941. /**
  137942. * 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.
  137943. */
  137944. set depthTexture(value: RenderTargetTexture);
  137945. /**
  137946. * Disposes each of the internal effects for a given camera.
  137947. * @param camera The camera to dispose the effect on.
  137948. */
  137949. disposeEffects(camera: Camera): void;
  137950. /**
  137951. * @hidden Internal
  137952. */
  137953. _updateEffects(): void;
  137954. /**
  137955. * Internal
  137956. * @returns if all the contained post processes are ready.
  137957. * @hidden
  137958. */
  137959. _isReady(): boolean;
  137960. }
  137961. }
  137962. declare module BABYLON {
  137963. /** @hidden */
  137964. export var displayPassPixelShader: {
  137965. name: string;
  137966. shader: string;
  137967. };
  137968. }
  137969. declare module BABYLON {
  137970. /**
  137971. * DisplayPassPostProcess which produces an output the same as it's input
  137972. */
  137973. export class DisplayPassPostProcess extends PostProcess {
  137974. /**
  137975. * Creates the DisplayPassPostProcess
  137976. * @param name The name of the effect.
  137977. * @param options The required width/height ratio to downsize to before computing the render pass.
  137978. * @param camera The camera to apply the render pass to.
  137979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137980. * @param engine The engine which the post process will be applied. (default: current engine)
  137981. * @param reusable If the post process can be reused on the same frame. (default: false)
  137982. */
  137983. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137984. }
  137985. }
  137986. declare module BABYLON {
  137987. /** @hidden */
  137988. export var filterPixelShader: {
  137989. name: string;
  137990. shader: string;
  137991. };
  137992. }
  137993. declare module BABYLON {
  137994. /**
  137995. * Applies a kernel filter to the image
  137996. */
  137997. export class FilterPostProcess extends PostProcess {
  137998. /** The matrix to be applied to the image */
  137999. kernelMatrix: Matrix;
  138000. /**
  138001. *
  138002. * @param name The name of the effect.
  138003. * @param kernelMatrix The matrix to be applied to the image
  138004. * @param options The required width/height ratio to downsize to before computing the render pass.
  138005. * @param camera The camera to apply the render pass to.
  138006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138007. * @param engine The engine which the post process will be applied. (default: current engine)
  138008. * @param reusable If the post process can be reused on the same frame. (default: false)
  138009. */
  138010. constructor(name: string,
  138011. /** The matrix to be applied to the image */
  138012. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138013. }
  138014. }
  138015. declare module BABYLON {
  138016. /** @hidden */
  138017. export var fxaaPixelShader: {
  138018. name: string;
  138019. shader: string;
  138020. };
  138021. }
  138022. declare module BABYLON {
  138023. /** @hidden */
  138024. export var fxaaVertexShader: {
  138025. name: string;
  138026. shader: string;
  138027. };
  138028. }
  138029. declare module BABYLON {
  138030. /**
  138031. * Fxaa post process
  138032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  138033. */
  138034. export class FxaaPostProcess extends PostProcess {
  138035. /** @hidden */
  138036. texelWidth: number;
  138037. /** @hidden */
  138038. texelHeight: number;
  138039. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138040. private _getDefines;
  138041. }
  138042. }
  138043. declare module BABYLON {
  138044. /** @hidden */
  138045. export var grainPixelShader: {
  138046. name: string;
  138047. shader: string;
  138048. };
  138049. }
  138050. declare module BABYLON {
  138051. /**
  138052. * The GrainPostProcess adds noise to the image at mid luminance levels
  138053. */
  138054. export class GrainPostProcess extends PostProcess {
  138055. /**
  138056. * The intensity of the grain added (default: 30)
  138057. */
  138058. intensity: number;
  138059. /**
  138060. * If the grain should be randomized on every frame
  138061. */
  138062. animated: boolean;
  138063. /**
  138064. * Creates a new instance of @see GrainPostProcess
  138065. * @param name The name of the effect.
  138066. * @param options The required width/height ratio to downsize to before computing the render pass.
  138067. * @param camera The camera to apply the render pass to.
  138068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138069. * @param engine The engine which the post process will be applied. (default: current engine)
  138070. * @param reusable If the post process can be reused on the same frame. (default: false)
  138071. * @param textureType Type of textures used when performing the post process. (default: 0)
  138072. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  138073. */
  138074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138075. }
  138076. }
  138077. declare module BABYLON {
  138078. /** @hidden */
  138079. export var highlightsPixelShader: {
  138080. name: string;
  138081. shader: string;
  138082. };
  138083. }
  138084. declare module BABYLON {
  138085. /**
  138086. * Extracts highlights from the image
  138087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138088. */
  138089. export class HighlightsPostProcess extends PostProcess {
  138090. /**
  138091. * Extracts highlights from the image
  138092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138093. * @param name The name of the effect.
  138094. * @param options The required width/height ratio to downsize to before computing the render pass.
  138095. * @param camera The camera to apply the render pass to.
  138096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138097. * @param engine The engine which the post process will be applied. (default: current engine)
  138098. * @param reusable If the post process can be reused on the same frame. (default: false)
  138099. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  138100. */
  138101. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138102. }
  138103. }
  138104. declare module BABYLON {
  138105. /** @hidden */
  138106. export var mrtFragmentDeclaration: {
  138107. name: string;
  138108. shader: string;
  138109. };
  138110. }
  138111. declare module BABYLON {
  138112. /** @hidden */
  138113. export var geometryPixelShader: {
  138114. name: string;
  138115. shader: string;
  138116. };
  138117. }
  138118. declare module BABYLON {
  138119. /** @hidden */
  138120. export var geometryVertexShader: {
  138121. name: string;
  138122. shader: string;
  138123. };
  138124. }
  138125. declare module BABYLON {
  138126. /** @hidden */
  138127. interface ISavedTransformationMatrix {
  138128. world: Matrix;
  138129. viewProjection: Matrix;
  138130. }
  138131. /**
  138132. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  138133. */
  138134. export class GeometryBufferRenderer {
  138135. /**
  138136. * Constant used to retrieve the position texture index in the G-Buffer textures array
  138137. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  138138. */
  138139. static readonly POSITION_TEXTURE_TYPE: number;
  138140. /**
  138141. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  138142. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  138143. */
  138144. static readonly VELOCITY_TEXTURE_TYPE: number;
  138145. /**
  138146. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  138147. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  138148. */
  138149. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  138150. /**
  138151. * Dictionary used to store the previous transformation matrices of each rendered mesh
  138152. * in order to compute objects velocities when enableVelocity is set to "true"
  138153. * @hidden
  138154. */
  138155. _previousTransformationMatrices: {
  138156. [index: number]: ISavedTransformationMatrix;
  138157. };
  138158. /**
  138159. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  138160. * in order to compute objects velocities when enableVelocity is set to "true"
  138161. * @hidden
  138162. */
  138163. _previousBonesTransformationMatrices: {
  138164. [index: number]: Float32Array;
  138165. };
  138166. /**
  138167. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  138168. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  138169. */
  138170. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  138171. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  138172. renderTransparentMeshes: boolean;
  138173. private _scene;
  138174. private _multiRenderTarget;
  138175. private _ratio;
  138176. private _enablePosition;
  138177. private _enableVelocity;
  138178. private _enableReflectivity;
  138179. private _positionIndex;
  138180. private _velocityIndex;
  138181. private _reflectivityIndex;
  138182. protected _effect: Effect;
  138183. protected _cachedDefines: string;
  138184. /**
  138185. * Set the render list (meshes to be rendered) used in the G buffer.
  138186. */
  138187. set renderList(meshes: Mesh[]);
  138188. /**
  138189. * Gets wether or not G buffer are supported by the running hardware.
  138190. * This requires draw buffer supports
  138191. */
  138192. get isSupported(): boolean;
  138193. /**
  138194. * Returns the index of the given texture type in the G-Buffer textures array
  138195. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138196. * @returns the index of the given texture type in the G-Buffer textures array
  138197. */
  138198. getTextureIndex(textureType: number): number;
  138199. /**
  138200. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138201. */
  138202. get enablePosition(): boolean;
  138203. /**
  138204. * Sets whether or not objects positions are enabled for the G buffer.
  138205. */
  138206. set enablePosition(enable: boolean);
  138207. /**
  138208. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138209. */
  138210. get enableVelocity(): boolean;
  138211. /**
  138212. * Sets wether or not objects velocities are enabled for the G buffer.
  138213. */
  138214. set enableVelocity(enable: boolean);
  138215. /**
  138216. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138217. */
  138218. get enableReflectivity(): boolean;
  138219. /**
  138220. * Sets wether or not objects roughness are enabled for the G buffer.
  138221. */
  138222. set enableReflectivity(enable: boolean);
  138223. /**
  138224. * Gets the scene associated with the buffer.
  138225. */
  138226. get scene(): Scene;
  138227. /**
  138228. * Gets the ratio used by the buffer during its creation.
  138229. * How big is the buffer related to the main canvas.
  138230. */
  138231. get ratio(): number;
  138232. /** @hidden */
  138233. static _SceneComponentInitialization: (scene: Scene) => void;
  138234. /**
  138235. * Creates a new G Buffer for the scene
  138236. * @param scene The scene the buffer belongs to
  138237. * @param ratio How big is the buffer related to the main canvas.
  138238. */
  138239. constructor(scene: Scene, ratio?: number);
  138240. /**
  138241. * Checks wether everything is ready to render a submesh to the G buffer.
  138242. * @param subMesh the submesh to check readiness for
  138243. * @param useInstances is the mesh drawn using instance or not
  138244. * @returns true if ready otherwise false
  138245. */
  138246. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138247. /**
  138248. * Gets the current underlying G Buffer.
  138249. * @returns the buffer
  138250. */
  138251. getGBuffer(): MultiRenderTarget;
  138252. /**
  138253. * Gets the number of samples used to render the buffer (anti aliasing).
  138254. */
  138255. get samples(): number;
  138256. /**
  138257. * Sets the number of samples used to render the buffer (anti aliasing).
  138258. */
  138259. set samples(value: number);
  138260. /**
  138261. * Disposes the renderer and frees up associated resources.
  138262. */
  138263. dispose(): void;
  138264. protected _createRenderTargets(): void;
  138265. private _copyBonesTransformationMatrices;
  138266. }
  138267. }
  138268. declare module BABYLON {
  138269. interface Scene {
  138270. /** @hidden (Backing field) */
  138271. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138272. /**
  138273. * Gets or Sets the current geometry buffer associated to the scene.
  138274. */
  138275. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138276. /**
  138277. * Enables a GeometryBufferRender and associates it with the scene
  138278. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138279. * @returns the GeometryBufferRenderer
  138280. */
  138281. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138282. /**
  138283. * Disables the GeometryBufferRender associated with the scene
  138284. */
  138285. disableGeometryBufferRenderer(): void;
  138286. }
  138287. /**
  138288. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138289. * in several rendering techniques.
  138290. */
  138291. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138292. /**
  138293. * The component name helpful to identify the component in the list of scene components.
  138294. */
  138295. readonly name: string;
  138296. /**
  138297. * The scene the component belongs to.
  138298. */
  138299. scene: Scene;
  138300. /**
  138301. * Creates a new instance of the component for the given scene
  138302. * @param scene Defines the scene to register the component in
  138303. */
  138304. constructor(scene: Scene);
  138305. /**
  138306. * Registers the component in a given scene
  138307. */
  138308. register(): void;
  138309. /**
  138310. * Rebuilds the elements related to this component in case of
  138311. * context lost for instance.
  138312. */
  138313. rebuild(): void;
  138314. /**
  138315. * Disposes the component and the associated ressources
  138316. */
  138317. dispose(): void;
  138318. private _gatherRenderTargets;
  138319. }
  138320. }
  138321. declare module BABYLON {
  138322. /** @hidden */
  138323. export var motionBlurPixelShader: {
  138324. name: string;
  138325. shader: string;
  138326. };
  138327. }
  138328. declare module BABYLON {
  138329. /**
  138330. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138331. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138332. * As an example, all you have to do is to create the post-process:
  138333. * var mb = new BABYLON.MotionBlurPostProcess(
  138334. * 'mb', // The name of the effect.
  138335. * scene, // The scene containing the objects to blur according to their velocity.
  138336. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138337. * camera // The camera to apply the render pass to.
  138338. * );
  138339. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138340. */
  138341. export class MotionBlurPostProcess extends PostProcess {
  138342. /**
  138343. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138344. */
  138345. motionStrength: number;
  138346. /**
  138347. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138348. */
  138349. get motionBlurSamples(): number;
  138350. /**
  138351. * Sets the number of iterations to be used for motion blur quality
  138352. */
  138353. set motionBlurSamples(samples: number);
  138354. private _motionBlurSamples;
  138355. private _geometryBufferRenderer;
  138356. /**
  138357. * Creates a new instance MotionBlurPostProcess
  138358. * @param name The name of the effect.
  138359. * @param scene The scene containing the objects to blur according to their velocity.
  138360. * @param options The required width/height ratio to downsize to before computing the render pass.
  138361. * @param camera The camera to apply the render pass to.
  138362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138363. * @param engine The engine which the post process will be applied. (default: current engine)
  138364. * @param reusable If the post process can be reused on the same frame. (default: false)
  138365. * @param textureType Type of textures used when performing the post process. (default: 0)
  138366. * @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)
  138367. */
  138368. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138369. /**
  138370. * Excludes the given skinned mesh from computing bones velocities.
  138371. * 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.
  138372. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138373. */
  138374. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138375. /**
  138376. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138377. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138378. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138379. */
  138380. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138381. /**
  138382. * Disposes the post process.
  138383. * @param camera The camera to dispose the post process on.
  138384. */
  138385. dispose(camera?: Camera): void;
  138386. }
  138387. }
  138388. declare module BABYLON {
  138389. /** @hidden */
  138390. export var refractionPixelShader: {
  138391. name: string;
  138392. shader: string;
  138393. };
  138394. }
  138395. declare module BABYLON {
  138396. /**
  138397. * Post process which applies a refractin texture
  138398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138399. */
  138400. export class RefractionPostProcess extends PostProcess {
  138401. /** the base color of the refraction (used to taint the rendering) */
  138402. color: Color3;
  138403. /** simulated refraction depth */
  138404. depth: number;
  138405. /** the coefficient of the base color (0 to remove base color tainting) */
  138406. colorLevel: number;
  138407. private _refTexture;
  138408. private _ownRefractionTexture;
  138409. /**
  138410. * Gets or sets the refraction texture
  138411. * Please note that you are responsible for disposing the texture if you set it manually
  138412. */
  138413. get refractionTexture(): Texture;
  138414. set refractionTexture(value: Texture);
  138415. /**
  138416. * Initializes the RefractionPostProcess
  138417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138418. * @param name The name of the effect.
  138419. * @param refractionTextureUrl Url of the refraction texture to use
  138420. * @param color the base color of the refraction (used to taint the rendering)
  138421. * @param depth simulated refraction depth
  138422. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138423. * @param camera The camera to apply the render pass to.
  138424. * @param options The required width/height ratio to downsize to before computing the render pass.
  138425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138426. * @param engine The engine which the post process will be applied. (default: current engine)
  138427. * @param reusable If the post process can be reused on the same frame. (default: false)
  138428. */
  138429. constructor(name: string, refractionTextureUrl: string,
  138430. /** the base color of the refraction (used to taint the rendering) */
  138431. color: Color3,
  138432. /** simulated refraction depth */
  138433. depth: number,
  138434. /** the coefficient of the base color (0 to remove base color tainting) */
  138435. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138436. /**
  138437. * Disposes of the post process
  138438. * @param camera Camera to dispose post process on
  138439. */
  138440. dispose(camera: Camera): void;
  138441. }
  138442. }
  138443. declare module BABYLON {
  138444. /** @hidden */
  138445. export var sharpenPixelShader: {
  138446. name: string;
  138447. shader: string;
  138448. };
  138449. }
  138450. declare module BABYLON {
  138451. /**
  138452. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138453. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138454. */
  138455. export class SharpenPostProcess extends PostProcess {
  138456. /**
  138457. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138458. */
  138459. colorAmount: number;
  138460. /**
  138461. * How much sharpness should be applied (default: 0.3)
  138462. */
  138463. edgeAmount: number;
  138464. /**
  138465. * Creates a new instance ConvolutionPostProcess
  138466. * @param name The name of the effect.
  138467. * @param options The required width/height ratio to downsize to before computing the render pass.
  138468. * @param camera The camera to apply the render pass to.
  138469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138470. * @param engine The engine which the post process will be applied. (default: current engine)
  138471. * @param reusable If the post process can be reused on the same frame. (default: false)
  138472. * @param textureType Type of textures used when performing the post process. (default: 0)
  138473. * @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)
  138474. */
  138475. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138476. }
  138477. }
  138478. declare module BABYLON {
  138479. /**
  138480. * PostProcessRenderPipeline
  138481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138482. */
  138483. export class PostProcessRenderPipeline {
  138484. private engine;
  138485. private _renderEffects;
  138486. private _renderEffectsForIsolatedPass;
  138487. /**
  138488. * List of inspectable custom properties (used by the Inspector)
  138489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138490. */
  138491. inspectableCustomProperties: IInspectable[];
  138492. /**
  138493. * @hidden
  138494. */
  138495. protected _cameras: Camera[];
  138496. /** @hidden */
  138497. _name: string;
  138498. /**
  138499. * Gets pipeline name
  138500. */
  138501. get name(): string;
  138502. /** Gets the list of attached cameras */
  138503. get cameras(): Camera[];
  138504. /**
  138505. * Initializes a PostProcessRenderPipeline
  138506. * @param engine engine to add the pipeline to
  138507. * @param name name of the pipeline
  138508. */
  138509. constructor(engine: Engine, name: string);
  138510. /**
  138511. * Gets the class name
  138512. * @returns "PostProcessRenderPipeline"
  138513. */
  138514. getClassName(): string;
  138515. /**
  138516. * If all the render effects in the pipeline are supported
  138517. */
  138518. get isSupported(): boolean;
  138519. /**
  138520. * Adds an effect to the pipeline
  138521. * @param renderEffect the effect to add
  138522. */
  138523. addEffect(renderEffect: PostProcessRenderEffect): void;
  138524. /** @hidden */
  138525. _rebuild(): void;
  138526. /** @hidden */
  138527. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138528. /** @hidden */
  138529. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138530. /** @hidden */
  138531. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138532. /** @hidden */
  138533. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138534. /** @hidden */
  138535. _attachCameras(cameras: Camera, unique: boolean): void;
  138536. /** @hidden */
  138537. _attachCameras(cameras: Camera[], unique: boolean): void;
  138538. /** @hidden */
  138539. _detachCameras(cameras: Camera): void;
  138540. /** @hidden */
  138541. _detachCameras(cameras: Nullable<Camera[]>): void;
  138542. /** @hidden */
  138543. _update(): void;
  138544. /** @hidden */
  138545. _reset(): void;
  138546. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138547. /**
  138548. * Disposes of the pipeline
  138549. */
  138550. dispose(): void;
  138551. }
  138552. }
  138553. declare module BABYLON {
  138554. /**
  138555. * PostProcessRenderPipelineManager class
  138556. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138557. */
  138558. export class PostProcessRenderPipelineManager {
  138559. private _renderPipelines;
  138560. /**
  138561. * Initializes a PostProcessRenderPipelineManager
  138562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138563. */
  138564. constructor();
  138565. /**
  138566. * Gets the list of supported render pipelines
  138567. */
  138568. get supportedPipelines(): PostProcessRenderPipeline[];
  138569. /**
  138570. * Adds a pipeline to the manager
  138571. * @param renderPipeline The pipeline to add
  138572. */
  138573. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138574. /**
  138575. * Attaches a camera to the pipeline
  138576. * @param renderPipelineName The name of the pipeline to attach to
  138577. * @param cameras the camera to attach
  138578. * @param unique if the camera can be attached multiple times to the pipeline
  138579. */
  138580. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138581. /**
  138582. * Detaches a camera from the pipeline
  138583. * @param renderPipelineName The name of the pipeline to detach from
  138584. * @param cameras the camera to detach
  138585. */
  138586. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138587. /**
  138588. * Enables an effect by name on a pipeline
  138589. * @param renderPipelineName the name of the pipeline to enable the effect in
  138590. * @param renderEffectName the name of the effect to enable
  138591. * @param cameras the cameras that the effect should be enabled on
  138592. */
  138593. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138594. /**
  138595. * Disables an effect by name on a pipeline
  138596. * @param renderPipelineName the name of the pipeline to disable the effect in
  138597. * @param renderEffectName the name of the effect to disable
  138598. * @param cameras the cameras that the effect should be disabled on
  138599. */
  138600. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138601. /**
  138602. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138603. */
  138604. update(): void;
  138605. /** @hidden */
  138606. _rebuild(): void;
  138607. /**
  138608. * Disposes of the manager and pipelines
  138609. */
  138610. dispose(): void;
  138611. }
  138612. }
  138613. declare module BABYLON {
  138614. interface Scene {
  138615. /** @hidden (Backing field) */
  138616. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138617. /**
  138618. * Gets the postprocess render pipeline manager
  138619. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138620. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138621. */
  138622. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138623. }
  138624. /**
  138625. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138626. */
  138627. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138628. /**
  138629. * The component name helpfull to identify the component in the list of scene components.
  138630. */
  138631. readonly name: string;
  138632. /**
  138633. * The scene the component belongs to.
  138634. */
  138635. scene: Scene;
  138636. /**
  138637. * Creates a new instance of the component for the given scene
  138638. * @param scene Defines the scene to register the component in
  138639. */
  138640. constructor(scene: Scene);
  138641. /**
  138642. * Registers the component in a given scene
  138643. */
  138644. register(): void;
  138645. /**
  138646. * Rebuilds the elements related to this component in case of
  138647. * context lost for instance.
  138648. */
  138649. rebuild(): void;
  138650. /**
  138651. * Disposes the component and the associated ressources
  138652. */
  138653. dispose(): void;
  138654. private _gatherRenderTargets;
  138655. }
  138656. }
  138657. declare module BABYLON {
  138658. /**
  138659. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138660. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138661. */
  138662. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138663. private _scene;
  138664. private _camerasToBeAttached;
  138665. /**
  138666. * ID of the sharpen post process,
  138667. */
  138668. private readonly SharpenPostProcessId;
  138669. /**
  138670. * @ignore
  138671. * ID of the image processing post process;
  138672. */
  138673. readonly ImageProcessingPostProcessId: string;
  138674. /**
  138675. * @ignore
  138676. * ID of the Fast Approximate Anti-Aliasing post process;
  138677. */
  138678. readonly FxaaPostProcessId: string;
  138679. /**
  138680. * ID of the chromatic aberration post process,
  138681. */
  138682. private readonly ChromaticAberrationPostProcessId;
  138683. /**
  138684. * ID of the grain post process
  138685. */
  138686. private readonly GrainPostProcessId;
  138687. /**
  138688. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138689. */
  138690. sharpen: SharpenPostProcess;
  138691. private _sharpenEffect;
  138692. private bloom;
  138693. /**
  138694. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138695. */
  138696. depthOfField: DepthOfFieldEffect;
  138697. /**
  138698. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138699. */
  138700. fxaa: FxaaPostProcess;
  138701. /**
  138702. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138703. */
  138704. imageProcessing: ImageProcessingPostProcess;
  138705. /**
  138706. * Chromatic aberration post process which will shift rgb colors in the image
  138707. */
  138708. chromaticAberration: ChromaticAberrationPostProcess;
  138709. private _chromaticAberrationEffect;
  138710. /**
  138711. * Grain post process which add noise to the image
  138712. */
  138713. grain: GrainPostProcess;
  138714. private _grainEffect;
  138715. /**
  138716. * Glow post process which adds a glow to emissive areas of the image
  138717. */
  138718. private _glowLayer;
  138719. /**
  138720. * Animations which can be used to tweak settings over a period of time
  138721. */
  138722. animations: Animation[];
  138723. private _imageProcessingConfigurationObserver;
  138724. private _sharpenEnabled;
  138725. private _bloomEnabled;
  138726. private _depthOfFieldEnabled;
  138727. private _depthOfFieldBlurLevel;
  138728. private _fxaaEnabled;
  138729. private _imageProcessingEnabled;
  138730. private _defaultPipelineTextureType;
  138731. private _bloomScale;
  138732. private _chromaticAberrationEnabled;
  138733. private _grainEnabled;
  138734. private _buildAllowed;
  138735. /**
  138736. * Gets active scene
  138737. */
  138738. get scene(): Scene;
  138739. /**
  138740. * Enable or disable the sharpen process from the pipeline
  138741. */
  138742. set sharpenEnabled(enabled: boolean);
  138743. get sharpenEnabled(): boolean;
  138744. private _resizeObserver;
  138745. private _hardwareScaleLevel;
  138746. private _bloomKernel;
  138747. /**
  138748. * Specifies the size of the bloom blur kernel, relative to the final output size
  138749. */
  138750. get bloomKernel(): number;
  138751. set bloomKernel(value: number);
  138752. /**
  138753. * Specifies the weight of the bloom in the final rendering
  138754. */
  138755. private _bloomWeight;
  138756. /**
  138757. * Specifies the luma threshold for the area that will be blurred by the bloom
  138758. */
  138759. private _bloomThreshold;
  138760. private _hdr;
  138761. /**
  138762. * The strength of the bloom.
  138763. */
  138764. set bloomWeight(value: number);
  138765. get bloomWeight(): number;
  138766. /**
  138767. * The strength of the bloom.
  138768. */
  138769. set bloomThreshold(value: number);
  138770. get bloomThreshold(): number;
  138771. /**
  138772. * The scale of the bloom, lower value will provide better performance.
  138773. */
  138774. set bloomScale(value: number);
  138775. get bloomScale(): number;
  138776. /**
  138777. * Enable or disable the bloom from the pipeline
  138778. */
  138779. set bloomEnabled(enabled: boolean);
  138780. get bloomEnabled(): boolean;
  138781. private _rebuildBloom;
  138782. /**
  138783. * If the depth of field is enabled.
  138784. */
  138785. get depthOfFieldEnabled(): boolean;
  138786. set depthOfFieldEnabled(enabled: boolean);
  138787. /**
  138788. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138789. */
  138790. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138791. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138792. /**
  138793. * If the anti aliasing is enabled.
  138794. */
  138795. set fxaaEnabled(enabled: boolean);
  138796. get fxaaEnabled(): boolean;
  138797. private _samples;
  138798. /**
  138799. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138800. */
  138801. set samples(sampleCount: number);
  138802. get samples(): number;
  138803. /**
  138804. * If image processing is enabled.
  138805. */
  138806. set imageProcessingEnabled(enabled: boolean);
  138807. get imageProcessingEnabled(): boolean;
  138808. /**
  138809. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138810. */
  138811. set glowLayerEnabled(enabled: boolean);
  138812. get glowLayerEnabled(): boolean;
  138813. /**
  138814. * Gets the glow layer (or null if not defined)
  138815. */
  138816. get glowLayer(): Nullable<GlowLayer>;
  138817. /**
  138818. * Enable or disable the chromaticAberration process from the pipeline
  138819. */
  138820. set chromaticAberrationEnabled(enabled: boolean);
  138821. get chromaticAberrationEnabled(): boolean;
  138822. /**
  138823. * Enable or disable the grain process from the pipeline
  138824. */
  138825. set grainEnabled(enabled: boolean);
  138826. get grainEnabled(): boolean;
  138827. /**
  138828. * @constructor
  138829. * @param name - The rendering pipeline name (default: "")
  138830. * @param hdr - If high dynamic range textures should be used (default: true)
  138831. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138832. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138833. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138834. */
  138835. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138836. /**
  138837. * Get the class name
  138838. * @returns "DefaultRenderingPipeline"
  138839. */
  138840. getClassName(): string;
  138841. /**
  138842. * Force the compilation of the entire pipeline.
  138843. */
  138844. prepare(): void;
  138845. private _hasCleared;
  138846. private _prevPostProcess;
  138847. private _prevPrevPostProcess;
  138848. private _setAutoClearAndTextureSharing;
  138849. private _depthOfFieldSceneObserver;
  138850. private _buildPipeline;
  138851. private _disposePostProcesses;
  138852. /**
  138853. * Adds a camera to the pipeline
  138854. * @param camera the camera to be added
  138855. */
  138856. addCamera(camera: Camera): void;
  138857. /**
  138858. * Removes a camera from the pipeline
  138859. * @param camera the camera to remove
  138860. */
  138861. removeCamera(camera: Camera): void;
  138862. /**
  138863. * Dispose of the pipeline and stop all post processes
  138864. */
  138865. dispose(): void;
  138866. /**
  138867. * Serialize the rendering pipeline (Used when exporting)
  138868. * @returns the serialized object
  138869. */
  138870. serialize(): any;
  138871. /**
  138872. * Parse the serialized pipeline
  138873. * @param source Source pipeline.
  138874. * @param scene The scene to load the pipeline to.
  138875. * @param rootUrl The URL of the serialized pipeline.
  138876. * @returns An instantiated pipeline from the serialized object.
  138877. */
  138878. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138879. }
  138880. }
  138881. declare module BABYLON {
  138882. /** @hidden */
  138883. export var lensHighlightsPixelShader: {
  138884. name: string;
  138885. shader: string;
  138886. };
  138887. }
  138888. declare module BABYLON {
  138889. /** @hidden */
  138890. export var depthOfFieldPixelShader: {
  138891. name: string;
  138892. shader: string;
  138893. };
  138894. }
  138895. declare module BABYLON {
  138896. /**
  138897. * BABYLON.JS Chromatic Aberration GLSL Shader
  138898. * Author: Olivier Guyot
  138899. * Separates very slightly R, G and B colors on the edges of the screen
  138900. * Inspired by Francois Tarlier & Martins Upitis
  138901. */
  138902. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138903. /**
  138904. * @ignore
  138905. * The chromatic aberration PostProcess id in the pipeline
  138906. */
  138907. LensChromaticAberrationEffect: string;
  138908. /**
  138909. * @ignore
  138910. * The highlights enhancing PostProcess id in the pipeline
  138911. */
  138912. HighlightsEnhancingEffect: string;
  138913. /**
  138914. * @ignore
  138915. * The depth-of-field PostProcess id in the pipeline
  138916. */
  138917. LensDepthOfFieldEffect: string;
  138918. private _scene;
  138919. private _depthTexture;
  138920. private _grainTexture;
  138921. private _chromaticAberrationPostProcess;
  138922. private _highlightsPostProcess;
  138923. private _depthOfFieldPostProcess;
  138924. private _edgeBlur;
  138925. private _grainAmount;
  138926. private _chromaticAberration;
  138927. private _distortion;
  138928. private _highlightsGain;
  138929. private _highlightsThreshold;
  138930. private _dofDistance;
  138931. private _dofAperture;
  138932. private _dofDarken;
  138933. private _dofPentagon;
  138934. private _blurNoise;
  138935. /**
  138936. * @constructor
  138937. *
  138938. * Effect parameters are as follow:
  138939. * {
  138940. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138941. * edge_blur: number; // from 0 to x (1 for realism)
  138942. * distortion: number; // from 0 to x (1 for realism)
  138943. * grain_amount: number; // from 0 to 1
  138944. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138945. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138946. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138947. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138948. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138949. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138950. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138951. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138952. * }
  138953. * Note: if an effect parameter is unset, effect is disabled
  138954. *
  138955. * @param name The rendering pipeline name
  138956. * @param parameters - An object containing all parameters (see above)
  138957. * @param scene The scene linked to this pipeline
  138958. * @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)
  138959. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138960. */
  138961. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138962. /**
  138963. * Get the class name
  138964. * @returns "LensRenderingPipeline"
  138965. */
  138966. getClassName(): string;
  138967. /**
  138968. * Gets associated scene
  138969. */
  138970. get scene(): Scene;
  138971. /**
  138972. * Gets or sets the edge blur
  138973. */
  138974. get edgeBlur(): number;
  138975. set edgeBlur(value: number);
  138976. /**
  138977. * Gets or sets the grain amount
  138978. */
  138979. get grainAmount(): number;
  138980. set grainAmount(value: number);
  138981. /**
  138982. * Gets or sets the chromatic aberration amount
  138983. */
  138984. get chromaticAberration(): number;
  138985. set chromaticAberration(value: number);
  138986. /**
  138987. * Gets or sets the depth of field aperture
  138988. */
  138989. get dofAperture(): number;
  138990. set dofAperture(value: number);
  138991. /**
  138992. * Gets or sets the edge distortion
  138993. */
  138994. get edgeDistortion(): number;
  138995. set edgeDistortion(value: number);
  138996. /**
  138997. * Gets or sets the depth of field distortion
  138998. */
  138999. get dofDistortion(): number;
  139000. set dofDistortion(value: number);
  139001. /**
  139002. * Gets or sets the darken out of focus amount
  139003. */
  139004. get darkenOutOfFocus(): number;
  139005. set darkenOutOfFocus(value: number);
  139006. /**
  139007. * Gets or sets a boolean indicating if blur noise is enabled
  139008. */
  139009. get blurNoise(): boolean;
  139010. set blurNoise(value: boolean);
  139011. /**
  139012. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  139013. */
  139014. get pentagonBokeh(): boolean;
  139015. set pentagonBokeh(value: boolean);
  139016. /**
  139017. * Gets or sets the highlight grain amount
  139018. */
  139019. get highlightsGain(): number;
  139020. set highlightsGain(value: number);
  139021. /**
  139022. * Gets or sets the highlight threshold
  139023. */
  139024. get highlightsThreshold(): number;
  139025. set highlightsThreshold(value: number);
  139026. /**
  139027. * Sets the amount of blur at the edges
  139028. * @param amount blur amount
  139029. */
  139030. setEdgeBlur(amount: number): void;
  139031. /**
  139032. * Sets edge blur to 0
  139033. */
  139034. disableEdgeBlur(): void;
  139035. /**
  139036. * Sets the amout of grain
  139037. * @param amount Amount of grain
  139038. */
  139039. setGrainAmount(amount: number): void;
  139040. /**
  139041. * Set grain amount to 0
  139042. */
  139043. disableGrain(): void;
  139044. /**
  139045. * Sets the chromatic aberration amount
  139046. * @param amount amount of chromatic aberration
  139047. */
  139048. setChromaticAberration(amount: number): void;
  139049. /**
  139050. * Sets chromatic aberration amount to 0
  139051. */
  139052. disableChromaticAberration(): void;
  139053. /**
  139054. * Sets the EdgeDistortion amount
  139055. * @param amount amount of EdgeDistortion
  139056. */
  139057. setEdgeDistortion(amount: number): void;
  139058. /**
  139059. * Sets edge distortion to 0
  139060. */
  139061. disableEdgeDistortion(): void;
  139062. /**
  139063. * Sets the FocusDistance amount
  139064. * @param amount amount of FocusDistance
  139065. */
  139066. setFocusDistance(amount: number): void;
  139067. /**
  139068. * Disables depth of field
  139069. */
  139070. disableDepthOfField(): void;
  139071. /**
  139072. * Sets the Aperture amount
  139073. * @param amount amount of Aperture
  139074. */
  139075. setAperture(amount: number): void;
  139076. /**
  139077. * Sets the DarkenOutOfFocus amount
  139078. * @param amount amount of DarkenOutOfFocus
  139079. */
  139080. setDarkenOutOfFocus(amount: number): void;
  139081. private _pentagonBokehIsEnabled;
  139082. /**
  139083. * Creates a pentagon bokeh effect
  139084. */
  139085. enablePentagonBokeh(): void;
  139086. /**
  139087. * Disables the pentagon bokeh effect
  139088. */
  139089. disablePentagonBokeh(): void;
  139090. /**
  139091. * Enables noise blur
  139092. */
  139093. enableNoiseBlur(): void;
  139094. /**
  139095. * Disables noise blur
  139096. */
  139097. disableNoiseBlur(): void;
  139098. /**
  139099. * Sets the HighlightsGain amount
  139100. * @param amount amount of HighlightsGain
  139101. */
  139102. setHighlightsGain(amount: number): void;
  139103. /**
  139104. * Sets the HighlightsThreshold amount
  139105. * @param amount amount of HighlightsThreshold
  139106. */
  139107. setHighlightsThreshold(amount: number): void;
  139108. /**
  139109. * Disables highlights
  139110. */
  139111. disableHighlights(): void;
  139112. /**
  139113. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  139114. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  139115. */
  139116. dispose(disableDepthRender?: boolean): void;
  139117. private _createChromaticAberrationPostProcess;
  139118. private _createHighlightsPostProcess;
  139119. private _createDepthOfFieldPostProcess;
  139120. private _createGrainTexture;
  139121. }
  139122. }
  139123. declare module BABYLON {
  139124. /** @hidden */
  139125. export var ssao2PixelShader: {
  139126. name: string;
  139127. shader: string;
  139128. };
  139129. }
  139130. declare module BABYLON {
  139131. /** @hidden */
  139132. export var ssaoCombinePixelShader: {
  139133. name: string;
  139134. shader: string;
  139135. };
  139136. }
  139137. declare module BABYLON {
  139138. /**
  139139. * Render pipeline to produce ssao effect
  139140. */
  139141. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  139142. /**
  139143. * @ignore
  139144. * The PassPostProcess id in the pipeline that contains the original scene color
  139145. */
  139146. SSAOOriginalSceneColorEffect: string;
  139147. /**
  139148. * @ignore
  139149. * The SSAO PostProcess id in the pipeline
  139150. */
  139151. SSAORenderEffect: string;
  139152. /**
  139153. * @ignore
  139154. * The horizontal blur PostProcess id in the pipeline
  139155. */
  139156. SSAOBlurHRenderEffect: string;
  139157. /**
  139158. * @ignore
  139159. * The vertical blur PostProcess id in the pipeline
  139160. */
  139161. SSAOBlurVRenderEffect: string;
  139162. /**
  139163. * @ignore
  139164. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139165. */
  139166. SSAOCombineRenderEffect: string;
  139167. /**
  139168. * The output strength of the SSAO post-process. Default value is 1.0.
  139169. */
  139170. totalStrength: number;
  139171. /**
  139172. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  139173. */
  139174. maxZ: number;
  139175. /**
  139176. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  139177. */
  139178. minZAspect: number;
  139179. private _samples;
  139180. /**
  139181. * Number of samples used for the SSAO calculations. Default value is 8
  139182. */
  139183. set samples(n: number);
  139184. get samples(): number;
  139185. private _textureSamples;
  139186. /**
  139187. * Number of samples to use for antialiasing
  139188. */
  139189. set textureSamples(n: number);
  139190. get textureSamples(): number;
  139191. /**
  139192. * Ratio object used for SSAO ratio and blur ratio
  139193. */
  139194. private _ratio;
  139195. /**
  139196. * Dynamically generated sphere sampler.
  139197. */
  139198. private _sampleSphere;
  139199. /**
  139200. * Blur filter offsets
  139201. */
  139202. private _samplerOffsets;
  139203. private _expensiveBlur;
  139204. /**
  139205. * If bilateral blur should be used
  139206. */
  139207. set expensiveBlur(b: boolean);
  139208. get expensiveBlur(): boolean;
  139209. /**
  139210. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139211. */
  139212. radius: number;
  139213. /**
  139214. * The base color of the SSAO post-process
  139215. * The final result is "base + ssao" between [0, 1]
  139216. */
  139217. base: number;
  139218. /**
  139219. * Support test.
  139220. */
  139221. static get IsSupported(): boolean;
  139222. private _scene;
  139223. private _depthTexture;
  139224. private _normalTexture;
  139225. private _randomTexture;
  139226. private _originalColorPostProcess;
  139227. private _ssaoPostProcess;
  139228. private _blurHPostProcess;
  139229. private _blurVPostProcess;
  139230. private _ssaoCombinePostProcess;
  139231. /**
  139232. * Gets active scene
  139233. */
  139234. get scene(): Scene;
  139235. /**
  139236. * @constructor
  139237. * @param name The rendering pipeline name
  139238. * @param scene The scene linked to this pipeline
  139239. * @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 }
  139240. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139241. */
  139242. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139243. /**
  139244. * Get the class name
  139245. * @returns "SSAO2RenderingPipeline"
  139246. */
  139247. getClassName(): string;
  139248. /**
  139249. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139250. */
  139251. dispose(disableGeometryBufferRenderer?: boolean): void;
  139252. private _createBlurPostProcess;
  139253. /** @hidden */
  139254. _rebuild(): void;
  139255. private _bits;
  139256. private _radicalInverse_VdC;
  139257. private _hammersley;
  139258. private _hemisphereSample_uniform;
  139259. private _generateHemisphere;
  139260. private _createSSAOPostProcess;
  139261. private _createSSAOCombinePostProcess;
  139262. private _createRandomTexture;
  139263. /**
  139264. * Serialize the rendering pipeline (Used when exporting)
  139265. * @returns the serialized object
  139266. */
  139267. serialize(): any;
  139268. /**
  139269. * Parse the serialized pipeline
  139270. * @param source Source pipeline.
  139271. * @param scene The scene to load the pipeline to.
  139272. * @param rootUrl The URL of the serialized pipeline.
  139273. * @returns An instantiated pipeline from the serialized object.
  139274. */
  139275. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139276. }
  139277. }
  139278. declare module BABYLON {
  139279. /** @hidden */
  139280. export var ssaoPixelShader: {
  139281. name: string;
  139282. shader: string;
  139283. };
  139284. }
  139285. declare module BABYLON {
  139286. /**
  139287. * Render pipeline to produce ssao effect
  139288. */
  139289. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139290. /**
  139291. * @ignore
  139292. * The PassPostProcess id in the pipeline that contains the original scene color
  139293. */
  139294. SSAOOriginalSceneColorEffect: string;
  139295. /**
  139296. * @ignore
  139297. * The SSAO PostProcess id in the pipeline
  139298. */
  139299. SSAORenderEffect: string;
  139300. /**
  139301. * @ignore
  139302. * The horizontal blur PostProcess id in the pipeline
  139303. */
  139304. SSAOBlurHRenderEffect: string;
  139305. /**
  139306. * @ignore
  139307. * The vertical blur PostProcess id in the pipeline
  139308. */
  139309. SSAOBlurVRenderEffect: string;
  139310. /**
  139311. * @ignore
  139312. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139313. */
  139314. SSAOCombineRenderEffect: string;
  139315. /**
  139316. * The output strength of the SSAO post-process. Default value is 1.0.
  139317. */
  139318. totalStrength: number;
  139319. /**
  139320. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139321. */
  139322. radius: number;
  139323. /**
  139324. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139325. * Must not be equal to fallOff and superior to fallOff.
  139326. * Default value is 0.0075
  139327. */
  139328. area: number;
  139329. /**
  139330. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139331. * Must not be equal to area and inferior to area.
  139332. * Default value is 0.000001
  139333. */
  139334. fallOff: number;
  139335. /**
  139336. * The base color of the SSAO post-process
  139337. * The final result is "base + ssao" between [0, 1]
  139338. */
  139339. base: number;
  139340. private _scene;
  139341. private _depthTexture;
  139342. private _randomTexture;
  139343. private _originalColorPostProcess;
  139344. private _ssaoPostProcess;
  139345. private _blurHPostProcess;
  139346. private _blurVPostProcess;
  139347. private _ssaoCombinePostProcess;
  139348. private _firstUpdate;
  139349. /**
  139350. * Gets active scene
  139351. */
  139352. get scene(): Scene;
  139353. /**
  139354. * @constructor
  139355. * @param name - The rendering pipeline name
  139356. * @param scene - The scene linked to this pipeline
  139357. * @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 }
  139358. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139359. */
  139360. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139361. /**
  139362. * Get the class name
  139363. * @returns "SSAORenderingPipeline"
  139364. */
  139365. getClassName(): string;
  139366. /**
  139367. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139368. */
  139369. dispose(disableDepthRender?: boolean): void;
  139370. private _createBlurPostProcess;
  139371. /** @hidden */
  139372. _rebuild(): void;
  139373. private _createSSAOPostProcess;
  139374. private _createSSAOCombinePostProcess;
  139375. private _createRandomTexture;
  139376. }
  139377. }
  139378. declare module BABYLON {
  139379. /** @hidden */
  139380. export var screenSpaceReflectionPixelShader: {
  139381. name: string;
  139382. shader: string;
  139383. };
  139384. }
  139385. declare module BABYLON {
  139386. /**
  139387. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139388. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139389. */
  139390. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139391. /**
  139392. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139393. */
  139394. threshold: number;
  139395. /**
  139396. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139397. */
  139398. strength: number;
  139399. /**
  139400. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139401. */
  139402. reflectionSpecularFalloffExponent: number;
  139403. /**
  139404. * 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]
  139405. */
  139406. step: number;
  139407. /**
  139408. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139409. */
  139410. roughnessFactor: number;
  139411. private _geometryBufferRenderer;
  139412. private _enableSmoothReflections;
  139413. private _reflectionSamples;
  139414. private _smoothSteps;
  139415. /**
  139416. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139417. * @param name The name of the effect.
  139418. * @param scene The scene containing the objects to calculate reflections.
  139419. * @param options The required width/height ratio to downsize to before computing the render pass.
  139420. * @param camera The camera to apply the render pass to.
  139421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139422. * @param engine The engine which the post process will be applied. (default: current engine)
  139423. * @param reusable If the post process can be reused on the same frame. (default: false)
  139424. * @param textureType Type of textures used when performing the post process. (default: 0)
  139425. * @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)
  139426. */
  139427. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139428. /**
  139429. * Gets wether or not smoothing reflections is enabled.
  139430. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139431. */
  139432. get enableSmoothReflections(): boolean;
  139433. /**
  139434. * Sets wether or not smoothing reflections is enabled.
  139435. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139436. */
  139437. set enableSmoothReflections(enabled: boolean);
  139438. /**
  139439. * Gets the number of samples taken while computing reflections. More samples count is high,
  139440. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139441. */
  139442. get reflectionSamples(): number;
  139443. /**
  139444. * Sets the number of samples taken while computing reflections. More samples count is high,
  139445. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139446. */
  139447. set reflectionSamples(samples: number);
  139448. /**
  139449. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139450. * more the post-process will require GPU power and can generate a drop in FPS.
  139451. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139452. */
  139453. get smoothSteps(): number;
  139454. set smoothSteps(steps: number);
  139455. private _updateEffectDefines;
  139456. }
  139457. }
  139458. declare module BABYLON {
  139459. /** @hidden */
  139460. export var standardPixelShader: {
  139461. name: string;
  139462. shader: string;
  139463. };
  139464. }
  139465. declare module BABYLON {
  139466. /**
  139467. * Standard rendering pipeline
  139468. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139469. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139470. */
  139471. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139472. /**
  139473. * Public members
  139474. */
  139475. /**
  139476. * Post-process which contains the original scene color before the pipeline applies all the effects
  139477. */
  139478. originalPostProcess: Nullable<PostProcess>;
  139479. /**
  139480. * Post-process used to down scale an image x4
  139481. */
  139482. downSampleX4PostProcess: Nullable<PostProcess>;
  139483. /**
  139484. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139485. */
  139486. brightPassPostProcess: Nullable<PostProcess>;
  139487. /**
  139488. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139489. */
  139490. blurHPostProcesses: PostProcess[];
  139491. /**
  139492. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139493. */
  139494. blurVPostProcesses: PostProcess[];
  139495. /**
  139496. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139497. */
  139498. textureAdderPostProcess: Nullable<PostProcess>;
  139499. /**
  139500. * Post-process used to create volumetric lighting effect
  139501. */
  139502. volumetricLightPostProcess: Nullable<PostProcess>;
  139503. /**
  139504. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139505. */
  139506. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139507. /**
  139508. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139509. */
  139510. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139511. /**
  139512. * Post-process used to merge the volumetric light effect and the real scene color
  139513. */
  139514. volumetricLightMergePostProces: Nullable<PostProcess>;
  139515. /**
  139516. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139517. */
  139518. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139519. /**
  139520. * Base post-process used to calculate the average luminance of the final image for HDR
  139521. */
  139522. luminancePostProcess: Nullable<PostProcess>;
  139523. /**
  139524. * Post-processes used to create down sample post-processes in order to get
  139525. * the average luminance of the final image for HDR
  139526. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139527. */
  139528. luminanceDownSamplePostProcesses: PostProcess[];
  139529. /**
  139530. * Post-process used to create a HDR effect (light adaptation)
  139531. */
  139532. hdrPostProcess: Nullable<PostProcess>;
  139533. /**
  139534. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139535. */
  139536. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139537. /**
  139538. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139539. */
  139540. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139541. /**
  139542. * Post-process used to merge the final HDR post-process and the real scene color
  139543. */
  139544. hdrFinalPostProcess: Nullable<PostProcess>;
  139545. /**
  139546. * Post-process used to create a lens flare effect
  139547. */
  139548. lensFlarePostProcess: Nullable<PostProcess>;
  139549. /**
  139550. * Post-process that merges the result of the lens flare post-process and the real scene color
  139551. */
  139552. lensFlareComposePostProcess: Nullable<PostProcess>;
  139553. /**
  139554. * Post-process used to create a motion blur effect
  139555. */
  139556. motionBlurPostProcess: Nullable<PostProcess>;
  139557. /**
  139558. * Post-process used to create a depth of field effect
  139559. */
  139560. depthOfFieldPostProcess: Nullable<PostProcess>;
  139561. /**
  139562. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139563. */
  139564. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139565. /**
  139566. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139567. */
  139568. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139569. /**
  139570. * Represents the brightness threshold in order to configure the illuminated surfaces
  139571. */
  139572. brightThreshold: number;
  139573. /**
  139574. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139575. */
  139576. blurWidth: number;
  139577. /**
  139578. * Sets if the blur for highlighted surfaces must be only horizontal
  139579. */
  139580. horizontalBlur: boolean;
  139581. /**
  139582. * Gets the overall exposure used by the pipeline
  139583. */
  139584. get exposure(): number;
  139585. /**
  139586. * Sets the overall exposure used by the pipeline
  139587. */
  139588. set exposure(value: number);
  139589. /**
  139590. * Texture used typically to simulate "dirty" on camera lens
  139591. */
  139592. lensTexture: Nullable<Texture>;
  139593. /**
  139594. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139595. */
  139596. volumetricLightCoefficient: number;
  139597. /**
  139598. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139599. */
  139600. volumetricLightPower: number;
  139601. /**
  139602. * Used the set the blur intensity to smooth the volumetric lights
  139603. */
  139604. volumetricLightBlurScale: number;
  139605. /**
  139606. * Light (spot or directional) used to generate the volumetric lights rays
  139607. * The source light must have a shadow generate so the pipeline can get its
  139608. * depth map
  139609. */
  139610. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139611. /**
  139612. * For eye adaptation, represents the minimum luminance the eye can see
  139613. */
  139614. hdrMinimumLuminance: number;
  139615. /**
  139616. * For eye adaptation, represents the decrease luminance speed
  139617. */
  139618. hdrDecreaseRate: number;
  139619. /**
  139620. * For eye adaptation, represents the increase luminance speed
  139621. */
  139622. hdrIncreaseRate: number;
  139623. /**
  139624. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139625. */
  139626. get hdrAutoExposure(): boolean;
  139627. /**
  139628. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139629. */
  139630. set hdrAutoExposure(value: boolean);
  139631. /**
  139632. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139633. */
  139634. lensColorTexture: Nullable<Texture>;
  139635. /**
  139636. * The overall strengh for the lens flare effect
  139637. */
  139638. lensFlareStrength: number;
  139639. /**
  139640. * Dispersion coefficient for lens flare ghosts
  139641. */
  139642. lensFlareGhostDispersal: number;
  139643. /**
  139644. * Main lens flare halo width
  139645. */
  139646. lensFlareHaloWidth: number;
  139647. /**
  139648. * Based on the lens distortion effect, defines how much the lens flare result
  139649. * is distorted
  139650. */
  139651. lensFlareDistortionStrength: number;
  139652. /**
  139653. * Configures the blur intensity used for for lens flare (halo)
  139654. */
  139655. lensFlareBlurWidth: number;
  139656. /**
  139657. * Lens star texture must be used to simulate rays on the flares and is available
  139658. * in the documentation
  139659. */
  139660. lensStarTexture: Nullable<Texture>;
  139661. /**
  139662. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139663. * flare effect by taking account of the dirt texture
  139664. */
  139665. lensFlareDirtTexture: Nullable<Texture>;
  139666. /**
  139667. * Represents the focal length for the depth of field effect
  139668. */
  139669. depthOfFieldDistance: number;
  139670. /**
  139671. * Represents the blur intensity for the blurred part of the depth of field effect
  139672. */
  139673. depthOfFieldBlurWidth: number;
  139674. /**
  139675. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139676. */
  139677. get motionStrength(): number;
  139678. /**
  139679. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139680. */
  139681. set motionStrength(strength: number);
  139682. /**
  139683. * Gets wether or not the motion blur post-process is object based or screen based.
  139684. */
  139685. get objectBasedMotionBlur(): boolean;
  139686. /**
  139687. * Sets wether or not the motion blur post-process should be object based or screen based
  139688. */
  139689. set objectBasedMotionBlur(value: boolean);
  139690. /**
  139691. * List of animations for the pipeline (IAnimatable implementation)
  139692. */
  139693. animations: Animation[];
  139694. /**
  139695. * Private members
  139696. */
  139697. private _scene;
  139698. private _currentDepthOfFieldSource;
  139699. private _basePostProcess;
  139700. private _fixedExposure;
  139701. private _currentExposure;
  139702. private _hdrAutoExposure;
  139703. private _hdrCurrentLuminance;
  139704. private _motionStrength;
  139705. private _isObjectBasedMotionBlur;
  139706. private _floatTextureType;
  139707. private _camerasToBeAttached;
  139708. private _ratio;
  139709. private _bloomEnabled;
  139710. private _depthOfFieldEnabled;
  139711. private _vlsEnabled;
  139712. private _lensFlareEnabled;
  139713. private _hdrEnabled;
  139714. private _motionBlurEnabled;
  139715. private _fxaaEnabled;
  139716. private _screenSpaceReflectionsEnabled;
  139717. private _motionBlurSamples;
  139718. private _volumetricLightStepsCount;
  139719. private _samples;
  139720. /**
  139721. * @ignore
  139722. * Specifies if the bloom pipeline is enabled
  139723. */
  139724. get BloomEnabled(): boolean;
  139725. set BloomEnabled(enabled: boolean);
  139726. /**
  139727. * @ignore
  139728. * Specifies if the depth of field pipeline is enabed
  139729. */
  139730. get DepthOfFieldEnabled(): boolean;
  139731. set DepthOfFieldEnabled(enabled: boolean);
  139732. /**
  139733. * @ignore
  139734. * Specifies if the lens flare pipeline is enabed
  139735. */
  139736. get LensFlareEnabled(): boolean;
  139737. set LensFlareEnabled(enabled: boolean);
  139738. /**
  139739. * @ignore
  139740. * Specifies if the HDR pipeline is enabled
  139741. */
  139742. get HDREnabled(): boolean;
  139743. set HDREnabled(enabled: boolean);
  139744. /**
  139745. * @ignore
  139746. * Specifies if the volumetric lights scattering effect is enabled
  139747. */
  139748. get VLSEnabled(): boolean;
  139749. set VLSEnabled(enabled: boolean);
  139750. /**
  139751. * @ignore
  139752. * Specifies if the motion blur effect is enabled
  139753. */
  139754. get MotionBlurEnabled(): boolean;
  139755. set MotionBlurEnabled(enabled: boolean);
  139756. /**
  139757. * Specifies if anti-aliasing is enabled
  139758. */
  139759. get fxaaEnabled(): boolean;
  139760. set fxaaEnabled(enabled: boolean);
  139761. /**
  139762. * Specifies if screen space reflections are enabled.
  139763. */
  139764. get screenSpaceReflectionsEnabled(): boolean;
  139765. set screenSpaceReflectionsEnabled(enabled: boolean);
  139766. /**
  139767. * Specifies the number of steps used to calculate the volumetric lights
  139768. * Typically in interval [50, 200]
  139769. */
  139770. get volumetricLightStepsCount(): number;
  139771. set volumetricLightStepsCount(count: number);
  139772. /**
  139773. * Specifies the number of samples used for the motion blur effect
  139774. * Typically in interval [16, 64]
  139775. */
  139776. get motionBlurSamples(): number;
  139777. set motionBlurSamples(samples: number);
  139778. /**
  139779. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139780. */
  139781. get samples(): number;
  139782. set samples(sampleCount: number);
  139783. /**
  139784. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139785. * @constructor
  139786. * @param name The rendering pipeline name
  139787. * @param scene The scene linked to this pipeline
  139788. * @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)
  139789. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139790. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139791. */
  139792. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139793. private _buildPipeline;
  139794. private _createDownSampleX4PostProcess;
  139795. private _createBrightPassPostProcess;
  139796. private _createBlurPostProcesses;
  139797. private _createTextureAdderPostProcess;
  139798. private _createVolumetricLightPostProcess;
  139799. private _createLuminancePostProcesses;
  139800. private _createHdrPostProcess;
  139801. private _createLensFlarePostProcess;
  139802. private _createDepthOfFieldPostProcess;
  139803. private _createMotionBlurPostProcess;
  139804. private _getDepthTexture;
  139805. private _disposePostProcesses;
  139806. /**
  139807. * Dispose of the pipeline and stop all post processes
  139808. */
  139809. dispose(): void;
  139810. /**
  139811. * Serialize the rendering pipeline (Used when exporting)
  139812. * @returns the serialized object
  139813. */
  139814. serialize(): any;
  139815. /**
  139816. * Parse the serialized pipeline
  139817. * @param source Source pipeline.
  139818. * @param scene The scene to load the pipeline to.
  139819. * @param rootUrl The URL of the serialized pipeline.
  139820. * @returns An instantiated pipeline from the serialized object.
  139821. */
  139822. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139823. /**
  139824. * Luminance steps
  139825. */
  139826. static LuminanceSteps: number;
  139827. }
  139828. }
  139829. declare module BABYLON {
  139830. /** @hidden */
  139831. export var tonemapPixelShader: {
  139832. name: string;
  139833. shader: string;
  139834. };
  139835. }
  139836. declare module BABYLON {
  139837. /** Defines operator used for tonemapping */
  139838. export enum TonemappingOperator {
  139839. /** Hable */
  139840. Hable = 0,
  139841. /** Reinhard */
  139842. Reinhard = 1,
  139843. /** HejiDawson */
  139844. HejiDawson = 2,
  139845. /** Photographic */
  139846. Photographic = 3
  139847. }
  139848. /**
  139849. * Defines a post process to apply tone mapping
  139850. */
  139851. export class TonemapPostProcess extends PostProcess {
  139852. private _operator;
  139853. /** Defines the required exposure adjustement */
  139854. exposureAdjustment: number;
  139855. /**
  139856. * Creates a new TonemapPostProcess
  139857. * @param name defines the name of the postprocess
  139858. * @param _operator defines the operator to use
  139859. * @param exposureAdjustment defines the required exposure adjustement
  139860. * @param camera defines the camera to use (can be null)
  139861. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139862. * @param engine defines the hosting engine (can be ignore if camera is set)
  139863. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139864. */
  139865. constructor(name: string, _operator: TonemappingOperator,
  139866. /** Defines the required exposure adjustement */
  139867. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139868. }
  139869. }
  139870. declare module BABYLON {
  139871. /** @hidden */
  139872. export var volumetricLightScatteringPixelShader: {
  139873. name: string;
  139874. shader: string;
  139875. };
  139876. }
  139877. declare module BABYLON {
  139878. /** @hidden */
  139879. export var volumetricLightScatteringPassVertexShader: {
  139880. name: string;
  139881. shader: string;
  139882. };
  139883. }
  139884. declare module BABYLON {
  139885. /** @hidden */
  139886. export var volumetricLightScatteringPassPixelShader: {
  139887. name: string;
  139888. shader: string;
  139889. };
  139890. }
  139891. declare module BABYLON {
  139892. /**
  139893. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139894. */
  139895. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139896. private _volumetricLightScatteringPass;
  139897. private _volumetricLightScatteringRTT;
  139898. private _viewPort;
  139899. private _screenCoordinates;
  139900. private _cachedDefines;
  139901. /**
  139902. * If not undefined, the mesh position is computed from the attached node position
  139903. */
  139904. attachedNode: {
  139905. position: Vector3;
  139906. };
  139907. /**
  139908. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139909. */
  139910. customMeshPosition: Vector3;
  139911. /**
  139912. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139913. */
  139914. useCustomMeshPosition: boolean;
  139915. /**
  139916. * If the post-process should inverse the light scattering direction
  139917. */
  139918. invert: boolean;
  139919. /**
  139920. * The internal mesh used by the post-process
  139921. */
  139922. mesh: Mesh;
  139923. /**
  139924. * @hidden
  139925. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139926. */
  139927. get useDiffuseColor(): boolean;
  139928. set useDiffuseColor(useDiffuseColor: boolean);
  139929. /**
  139930. * Array containing the excluded meshes not rendered in the internal pass
  139931. */
  139932. excludedMeshes: AbstractMesh[];
  139933. /**
  139934. * Controls the overall intensity of the post-process
  139935. */
  139936. exposure: number;
  139937. /**
  139938. * Dissipates each sample's contribution in range [0, 1]
  139939. */
  139940. decay: number;
  139941. /**
  139942. * Controls the overall intensity of each sample
  139943. */
  139944. weight: number;
  139945. /**
  139946. * Controls the density of each sample
  139947. */
  139948. density: number;
  139949. /**
  139950. * @constructor
  139951. * @param name The post-process name
  139952. * @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)
  139953. * @param camera The camera that the post-process will be attached to
  139954. * @param mesh The mesh used to create the light scattering
  139955. * @param samples The post-process quality, default 100
  139956. * @param samplingModeThe post-process filtering mode
  139957. * @param engine The babylon engine
  139958. * @param reusable If the post-process is reusable
  139959. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139960. */
  139961. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139962. /**
  139963. * Returns the string "VolumetricLightScatteringPostProcess"
  139964. * @returns "VolumetricLightScatteringPostProcess"
  139965. */
  139966. getClassName(): string;
  139967. private _isReady;
  139968. /**
  139969. * Sets the new light position for light scattering effect
  139970. * @param position The new custom light position
  139971. */
  139972. setCustomMeshPosition(position: Vector3): void;
  139973. /**
  139974. * Returns the light position for light scattering effect
  139975. * @return Vector3 The custom light position
  139976. */
  139977. getCustomMeshPosition(): Vector3;
  139978. /**
  139979. * Disposes the internal assets and detaches the post-process from the camera
  139980. */
  139981. dispose(camera: Camera): void;
  139982. /**
  139983. * Returns the render target texture used by the post-process
  139984. * @return the render target texture used by the post-process
  139985. */
  139986. getPass(): RenderTargetTexture;
  139987. private _meshExcluded;
  139988. private _createPass;
  139989. private _updateMeshScreenCoordinates;
  139990. /**
  139991. * Creates a default mesh for the Volumeric Light Scattering post-process
  139992. * @param name The mesh name
  139993. * @param scene The scene where to create the mesh
  139994. * @return the default mesh
  139995. */
  139996. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139997. }
  139998. }
  139999. declare module BABYLON {
  140000. interface Scene {
  140001. /** @hidden (Backing field) */
  140002. _boundingBoxRenderer: BoundingBoxRenderer;
  140003. /** @hidden (Backing field) */
  140004. _forceShowBoundingBoxes: boolean;
  140005. /**
  140006. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  140007. */
  140008. forceShowBoundingBoxes: boolean;
  140009. /**
  140010. * Gets the bounding box renderer associated with the scene
  140011. * @returns a BoundingBoxRenderer
  140012. */
  140013. getBoundingBoxRenderer(): BoundingBoxRenderer;
  140014. }
  140015. interface AbstractMesh {
  140016. /** @hidden (Backing field) */
  140017. _showBoundingBox: boolean;
  140018. /**
  140019. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  140020. */
  140021. showBoundingBox: boolean;
  140022. }
  140023. /**
  140024. * Component responsible of rendering the bounding box of the meshes in a scene.
  140025. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  140026. */
  140027. export class BoundingBoxRenderer implements ISceneComponent {
  140028. /**
  140029. * The component name helpfull to identify the component in the list of scene components.
  140030. */
  140031. readonly name: string;
  140032. /**
  140033. * The scene the component belongs to.
  140034. */
  140035. scene: Scene;
  140036. /**
  140037. * Color of the bounding box lines placed in front of an object
  140038. */
  140039. frontColor: Color3;
  140040. /**
  140041. * Color of the bounding box lines placed behind an object
  140042. */
  140043. backColor: Color3;
  140044. /**
  140045. * Defines if the renderer should show the back lines or not
  140046. */
  140047. showBackLines: boolean;
  140048. /**
  140049. * @hidden
  140050. */
  140051. renderList: SmartArray<BoundingBox>;
  140052. private _colorShader;
  140053. private _vertexBuffers;
  140054. private _indexBuffer;
  140055. private _fillIndexBuffer;
  140056. private _fillIndexData;
  140057. /**
  140058. * Instantiates a new bounding box renderer in a scene.
  140059. * @param scene the scene the renderer renders in
  140060. */
  140061. constructor(scene: Scene);
  140062. /**
  140063. * Registers the component in a given scene
  140064. */
  140065. register(): void;
  140066. private _evaluateSubMesh;
  140067. private _activeMesh;
  140068. private _prepareRessources;
  140069. private _createIndexBuffer;
  140070. /**
  140071. * Rebuilds the elements related to this component in case of
  140072. * context lost for instance.
  140073. */
  140074. rebuild(): void;
  140075. /**
  140076. * @hidden
  140077. */
  140078. reset(): void;
  140079. /**
  140080. * Render the bounding boxes of a specific rendering group
  140081. * @param renderingGroupId defines the rendering group to render
  140082. */
  140083. render(renderingGroupId: number): void;
  140084. /**
  140085. * In case of occlusion queries, we can render the occlusion bounding box through this method
  140086. * @param mesh Define the mesh to render the occlusion bounding box for
  140087. */
  140088. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  140089. /**
  140090. * Dispose and release the resources attached to this renderer.
  140091. */
  140092. dispose(): void;
  140093. }
  140094. }
  140095. declare module BABYLON {
  140096. interface Scene {
  140097. /** @hidden (Backing field) */
  140098. _depthRenderer: {
  140099. [id: string]: DepthRenderer;
  140100. };
  140101. /**
  140102. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  140103. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  140104. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140105. * @returns the created depth renderer
  140106. */
  140107. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  140108. /**
  140109. * Disables a depth renderer for a given camera
  140110. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  140111. */
  140112. disableDepthRenderer(camera?: Nullable<Camera>): void;
  140113. }
  140114. /**
  140115. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  140116. * in several rendering techniques.
  140117. */
  140118. export class DepthRendererSceneComponent implements ISceneComponent {
  140119. /**
  140120. * The component name helpfull to identify the component in the list of scene components.
  140121. */
  140122. readonly name: string;
  140123. /**
  140124. * The scene the component belongs to.
  140125. */
  140126. scene: Scene;
  140127. /**
  140128. * Creates a new instance of the component for the given scene
  140129. * @param scene Defines the scene to register the component in
  140130. */
  140131. constructor(scene: Scene);
  140132. /**
  140133. * Registers the component in a given scene
  140134. */
  140135. register(): void;
  140136. /**
  140137. * Rebuilds the elements related to this component in case of
  140138. * context lost for instance.
  140139. */
  140140. rebuild(): void;
  140141. /**
  140142. * Disposes the component and the associated ressources
  140143. */
  140144. dispose(): void;
  140145. private _gatherRenderTargets;
  140146. private _gatherActiveCameraRenderTargets;
  140147. }
  140148. }
  140149. declare module BABYLON {
  140150. /** @hidden */
  140151. export var outlinePixelShader: {
  140152. name: string;
  140153. shader: string;
  140154. };
  140155. }
  140156. declare module BABYLON {
  140157. /** @hidden */
  140158. export var outlineVertexShader: {
  140159. name: string;
  140160. shader: string;
  140161. };
  140162. }
  140163. declare module BABYLON {
  140164. interface Scene {
  140165. /** @hidden */
  140166. _outlineRenderer: OutlineRenderer;
  140167. /**
  140168. * Gets the outline renderer associated with the scene
  140169. * @returns a OutlineRenderer
  140170. */
  140171. getOutlineRenderer(): OutlineRenderer;
  140172. }
  140173. interface AbstractMesh {
  140174. /** @hidden (Backing field) */
  140175. _renderOutline: boolean;
  140176. /**
  140177. * Gets or sets a boolean indicating if the outline must be rendered as well
  140178. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  140179. */
  140180. renderOutline: boolean;
  140181. /** @hidden (Backing field) */
  140182. _renderOverlay: boolean;
  140183. /**
  140184. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140185. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140186. */
  140187. renderOverlay: boolean;
  140188. }
  140189. /**
  140190. * This class is responsible to draw bothe outline/overlay of meshes.
  140191. * It should not be used directly but through the available method on mesh.
  140192. */
  140193. export class OutlineRenderer implements ISceneComponent {
  140194. /**
  140195. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140196. */
  140197. private static _StencilReference;
  140198. /**
  140199. * The name of the component. Each component must have a unique name.
  140200. */
  140201. name: string;
  140202. /**
  140203. * The scene the component belongs to.
  140204. */
  140205. scene: Scene;
  140206. /**
  140207. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140208. */
  140209. zOffset: number;
  140210. private _engine;
  140211. private _effect;
  140212. private _cachedDefines;
  140213. private _savedDepthWrite;
  140214. /**
  140215. * Instantiates a new outline renderer. (There could be only one per scene).
  140216. * @param scene Defines the scene it belongs to
  140217. */
  140218. constructor(scene: Scene);
  140219. /**
  140220. * Register the component to one instance of a scene.
  140221. */
  140222. register(): void;
  140223. /**
  140224. * Rebuilds the elements related to this component in case of
  140225. * context lost for instance.
  140226. */
  140227. rebuild(): void;
  140228. /**
  140229. * Disposes the component and the associated ressources.
  140230. */
  140231. dispose(): void;
  140232. /**
  140233. * Renders the outline in the canvas.
  140234. * @param subMesh Defines the sumesh to render
  140235. * @param batch Defines the batch of meshes in case of instances
  140236. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140237. */
  140238. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140239. /**
  140240. * Returns whether or not the outline renderer is ready for a given submesh.
  140241. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140242. * @param subMesh Defines the submesh to check readyness for
  140243. * @param useInstances Defines wheter wee are trying to render instances or not
  140244. * @returns true if ready otherwise false
  140245. */
  140246. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140247. private _beforeRenderingMesh;
  140248. private _afterRenderingMesh;
  140249. }
  140250. }
  140251. declare module BABYLON {
  140252. /**
  140253. * Defines the basic options interface of a Sprite Frame Source Size.
  140254. */
  140255. export interface ISpriteJSONSpriteSourceSize {
  140256. /**
  140257. * number of the original width of the Frame
  140258. */
  140259. w: number;
  140260. /**
  140261. * number of the original height of the Frame
  140262. */
  140263. h: number;
  140264. }
  140265. /**
  140266. * Defines the basic options interface of a Sprite Frame Data.
  140267. */
  140268. export interface ISpriteJSONSpriteFrameData {
  140269. /**
  140270. * number of the x offset of the Frame
  140271. */
  140272. x: number;
  140273. /**
  140274. * number of the y offset of the Frame
  140275. */
  140276. y: number;
  140277. /**
  140278. * number of the width of the Frame
  140279. */
  140280. w: number;
  140281. /**
  140282. * number of the height of the Frame
  140283. */
  140284. h: number;
  140285. }
  140286. /**
  140287. * Defines the basic options interface of a JSON Sprite.
  140288. */
  140289. export interface ISpriteJSONSprite {
  140290. /**
  140291. * string name of the Frame
  140292. */
  140293. filename: string;
  140294. /**
  140295. * ISpriteJSONSpriteFrame basic object of the frame data
  140296. */
  140297. frame: ISpriteJSONSpriteFrameData;
  140298. /**
  140299. * boolean to flag is the frame was rotated.
  140300. */
  140301. rotated: boolean;
  140302. /**
  140303. * boolean to flag is the frame was trimmed.
  140304. */
  140305. trimmed: boolean;
  140306. /**
  140307. * ISpriteJSONSpriteFrame basic object of the source data
  140308. */
  140309. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140310. /**
  140311. * ISpriteJSONSpriteFrame basic object of the source data
  140312. */
  140313. sourceSize: ISpriteJSONSpriteSourceSize;
  140314. }
  140315. /**
  140316. * Defines the basic options interface of a JSON atlas.
  140317. */
  140318. export interface ISpriteJSONAtlas {
  140319. /**
  140320. * Array of objects that contain the frame data.
  140321. */
  140322. frames: Array<ISpriteJSONSprite>;
  140323. /**
  140324. * object basic object containing the sprite meta data.
  140325. */
  140326. meta?: object;
  140327. }
  140328. }
  140329. declare module BABYLON {
  140330. /** @hidden */
  140331. export var spriteMapPixelShader: {
  140332. name: string;
  140333. shader: string;
  140334. };
  140335. }
  140336. declare module BABYLON {
  140337. /** @hidden */
  140338. export var spriteMapVertexShader: {
  140339. name: string;
  140340. shader: string;
  140341. };
  140342. }
  140343. declare module BABYLON {
  140344. /**
  140345. * Defines the basic options interface of a SpriteMap
  140346. */
  140347. export interface ISpriteMapOptions {
  140348. /**
  140349. * Vector2 of the number of cells in the grid.
  140350. */
  140351. stageSize?: Vector2;
  140352. /**
  140353. * Vector2 of the size of the output plane in World Units.
  140354. */
  140355. outputSize?: Vector2;
  140356. /**
  140357. * Vector3 of the position of the output plane in World Units.
  140358. */
  140359. outputPosition?: Vector3;
  140360. /**
  140361. * Vector3 of the rotation of the output plane.
  140362. */
  140363. outputRotation?: Vector3;
  140364. /**
  140365. * number of layers that the system will reserve in resources.
  140366. */
  140367. layerCount?: number;
  140368. /**
  140369. * number of max animation frames a single cell will reserve in resources.
  140370. */
  140371. maxAnimationFrames?: number;
  140372. /**
  140373. * number cell index of the base tile when the system compiles.
  140374. */
  140375. baseTile?: number;
  140376. /**
  140377. * boolean flip the sprite after its been repositioned by the framing data.
  140378. */
  140379. flipU?: boolean;
  140380. /**
  140381. * Vector3 scalar of the global RGB values of the SpriteMap.
  140382. */
  140383. colorMultiply?: Vector3;
  140384. }
  140385. /**
  140386. * Defines the IDisposable interface in order to be cleanable from resources.
  140387. */
  140388. export interface ISpriteMap extends IDisposable {
  140389. /**
  140390. * String name of the SpriteMap.
  140391. */
  140392. name: string;
  140393. /**
  140394. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140395. */
  140396. atlasJSON: ISpriteJSONAtlas;
  140397. /**
  140398. * Texture of the SpriteMap.
  140399. */
  140400. spriteSheet: Texture;
  140401. /**
  140402. * The parameters to initialize the SpriteMap with.
  140403. */
  140404. options: ISpriteMapOptions;
  140405. }
  140406. /**
  140407. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140408. */
  140409. export class SpriteMap implements ISpriteMap {
  140410. /** The Name of the spriteMap */
  140411. name: string;
  140412. /** The JSON file with the frame and meta data */
  140413. atlasJSON: ISpriteJSONAtlas;
  140414. /** The systems Sprite Sheet Texture */
  140415. spriteSheet: Texture;
  140416. /** Arguments passed with the Constructor */
  140417. options: ISpriteMapOptions;
  140418. /** Public Sprite Storage array, parsed from atlasJSON */
  140419. sprites: Array<ISpriteJSONSprite>;
  140420. /** Returns the Number of Sprites in the System */
  140421. get spriteCount(): number;
  140422. /** Returns the Position of Output Plane*/
  140423. get position(): Vector3;
  140424. /** Returns the Position of Output Plane*/
  140425. set position(v: Vector3);
  140426. /** Returns the Rotation of Output Plane*/
  140427. get rotation(): Vector3;
  140428. /** Returns the Rotation of Output Plane*/
  140429. set rotation(v: Vector3);
  140430. /** Sets the AnimationMap*/
  140431. get animationMap(): RawTexture;
  140432. /** Sets the AnimationMap*/
  140433. set animationMap(v: RawTexture);
  140434. /** Scene that the SpriteMap was created in */
  140435. private _scene;
  140436. /** Texture Buffer of Float32 that holds tile frame data*/
  140437. private _frameMap;
  140438. /** Texture Buffers of Float32 that holds tileMap data*/
  140439. private _tileMaps;
  140440. /** Texture Buffer of Float32 that holds Animation Data*/
  140441. private _animationMap;
  140442. /** Custom ShaderMaterial Central to the System*/
  140443. private _material;
  140444. /** Custom ShaderMaterial Central to the System*/
  140445. private _output;
  140446. /** Systems Time Ticker*/
  140447. private _time;
  140448. /**
  140449. * Creates a new SpriteMap
  140450. * @param name defines the SpriteMaps Name
  140451. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140452. * @param spriteSheet is the Texture that the Sprites are on.
  140453. * @param options a basic deployment configuration
  140454. * @param scene The Scene that the map is deployed on
  140455. */
  140456. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140457. /**
  140458. * Returns tileID location
  140459. * @returns Vector2 the cell position ID
  140460. */
  140461. getTileID(): Vector2;
  140462. /**
  140463. * Gets the UV location of the mouse over the SpriteMap.
  140464. * @returns Vector2 the UV position of the mouse interaction
  140465. */
  140466. getMousePosition(): Vector2;
  140467. /**
  140468. * Creates the "frame" texture Buffer
  140469. * -------------------------------------
  140470. * Structure of frames
  140471. * "filename": "Falling-Water-2.png",
  140472. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140473. * "rotated": true,
  140474. * "trimmed": true,
  140475. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140476. * "sourceSize": {"w":32,"h":32}
  140477. * @returns RawTexture of the frameMap
  140478. */
  140479. private _createFrameBuffer;
  140480. /**
  140481. * Creates the tileMap texture Buffer
  140482. * @param buffer normally and array of numbers, or a false to generate from scratch
  140483. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140484. * @returns RawTexture of the tileMap
  140485. */
  140486. private _createTileBuffer;
  140487. /**
  140488. * Modifies the data of the tileMaps
  140489. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140490. * @param pos is the iVector2 Coordinates of the Tile
  140491. * @param tile The SpriteIndex of the new Tile
  140492. */
  140493. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140494. /**
  140495. * Creates the animationMap texture Buffer
  140496. * @param buffer normally and array of numbers, or a false to generate from scratch
  140497. * @returns RawTexture of the animationMap
  140498. */
  140499. private _createTileAnimationBuffer;
  140500. /**
  140501. * Modifies the data of the animationMap
  140502. * @param cellID is the Index of the Sprite
  140503. * @param _frame is the target Animation frame
  140504. * @param toCell is the Target Index of the next frame of the animation
  140505. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140506. * @param speed is a global scalar of the time variable on the map.
  140507. */
  140508. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140509. /**
  140510. * Exports the .tilemaps file
  140511. */
  140512. saveTileMaps(): void;
  140513. /**
  140514. * Imports the .tilemaps file
  140515. * @param url of the .tilemaps file
  140516. */
  140517. loadTileMaps(url: string): void;
  140518. /**
  140519. * Release associated resources
  140520. */
  140521. dispose(): void;
  140522. }
  140523. }
  140524. declare module BABYLON {
  140525. /**
  140526. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140527. * @see http://doc.babylonjs.com/babylon101/sprites
  140528. */
  140529. export class SpritePackedManager extends SpriteManager {
  140530. /** defines the packed manager's name */
  140531. name: string;
  140532. /**
  140533. * Creates a new sprite manager from a packed sprite sheet
  140534. * @param name defines the manager's name
  140535. * @param imgUrl defines the sprite sheet url
  140536. * @param capacity defines the maximum allowed number of sprites
  140537. * @param scene defines the hosting scene
  140538. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140539. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140540. * @param samplingMode defines the smapling mode to use with spritesheet
  140541. * @param fromPacked set to true; do not alter
  140542. */
  140543. constructor(
  140544. /** defines the packed manager's name */
  140545. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140546. }
  140547. }
  140548. declare module BABYLON {
  140549. /**
  140550. * Defines the list of states available for a task inside a AssetsManager
  140551. */
  140552. export enum AssetTaskState {
  140553. /**
  140554. * Initialization
  140555. */
  140556. INIT = 0,
  140557. /**
  140558. * Running
  140559. */
  140560. RUNNING = 1,
  140561. /**
  140562. * Done
  140563. */
  140564. DONE = 2,
  140565. /**
  140566. * Error
  140567. */
  140568. ERROR = 3
  140569. }
  140570. /**
  140571. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140572. */
  140573. export abstract class AbstractAssetTask {
  140574. /**
  140575. * Task name
  140576. */ name: string;
  140577. /**
  140578. * Callback called when the task is successful
  140579. */
  140580. onSuccess: (task: any) => void;
  140581. /**
  140582. * Callback called when the task is not successful
  140583. */
  140584. onError: (task: any, message?: string, exception?: any) => void;
  140585. /**
  140586. * Creates a new AssetsManager
  140587. * @param name defines the name of the task
  140588. */
  140589. constructor(
  140590. /**
  140591. * Task name
  140592. */ name: string);
  140593. private _isCompleted;
  140594. private _taskState;
  140595. private _errorObject;
  140596. /**
  140597. * Get if the task is completed
  140598. */
  140599. get isCompleted(): boolean;
  140600. /**
  140601. * Gets the current state of the task
  140602. */
  140603. get taskState(): AssetTaskState;
  140604. /**
  140605. * Gets the current error object (if task is in error)
  140606. */
  140607. get errorObject(): {
  140608. message?: string;
  140609. exception?: any;
  140610. };
  140611. /**
  140612. * Internal only
  140613. * @hidden
  140614. */
  140615. _setErrorObject(message?: string, exception?: any): void;
  140616. /**
  140617. * Execute the current task
  140618. * @param scene defines the scene where you want your assets to be loaded
  140619. * @param onSuccess is a callback called when the task is successfully executed
  140620. * @param onError is a callback called if an error occurs
  140621. */
  140622. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140623. /**
  140624. * Execute the current task
  140625. * @param scene defines the scene where you want your assets to be loaded
  140626. * @param onSuccess is a callback called when the task is successfully executed
  140627. * @param onError is a callback called if an error occurs
  140628. */
  140629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140630. /**
  140631. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140632. * This can be used with failed tasks that have the reason for failure fixed.
  140633. */
  140634. reset(): void;
  140635. private onErrorCallback;
  140636. private onDoneCallback;
  140637. }
  140638. /**
  140639. * Define the interface used by progress events raised during assets loading
  140640. */
  140641. export interface IAssetsProgressEvent {
  140642. /**
  140643. * Defines the number of remaining tasks to process
  140644. */
  140645. remainingCount: number;
  140646. /**
  140647. * Defines the total number of tasks
  140648. */
  140649. totalCount: number;
  140650. /**
  140651. * Defines the task that was just processed
  140652. */
  140653. task: AbstractAssetTask;
  140654. }
  140655. /**
  140656. * Class used to share progress information about assets loading
  140657. */
  140658. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140659. /**
  140660. * Defines the number of remaining tasks to process
  140661. */
  140662. remainingCount: number;
  140663. /**
  140664. * Defines the total number of tasks
  140665. */
  140666. totalCount: number;
  140667. /**
  140668. * Defines the task that was just processed
  140669. */
  140670. task: AbstractAssetTask;
  140671. /**
  140672. * Creates a AssetsProgressEvent
  140673. * @param remainingCount defines the number of remaining tasks to process
  140674. * @param totalCount defines the total number of tasks
  140675. * @param task defines the task that was just processed
  140676. */
  140677. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140678. }
  140679. /**
  140680. * Define a task used by AssetsManager to load meshes
  140681. */
  140682. export class MeshAssetTask extends AbstractAssetTask {
  140683. /**
  140684. * Defines the name of the task
  140685. */
  140686. name: string;
  140687. /**
  140688. * Defines the list of mesh's names you want to load
  140689. */
  140690. meshesNames: any;
  140691. /**
  140692. * Defines the root url to use as a base to load your meshes and associated resources
  140693. */
  140694. rootUrl: string;
  140695. /**
  140696. * Defines the filename of the scene to load from
  140697. */
  140698. sceneFilename: string;
  140699. /**
  140700. * Gets the list of loaded meshes
  140701. */
  140702. loadedMeshes: Array<AbstractMesh>;
  140703. /**
  140704. * Gets the list of loaded particle systems
  140705. */
  140706. loadedParticleSystems: Array<IParticleSystem>;
  140707. /**
  140708. * Gets the list of loaded skeletons
  140709. */
  140710. loadedSkeletons: Array<Skeleton>;
  140711. /**
  140712. * Gets the list of loaded animation groups
  140713. */
  140714. loadedAnimationGroups: Array<AnimationGroup>;
  140715. /**
  140716. * Callback called when the task is successful
  140717. */
  140718. onSuccess: (task: MeshAssetTask) => void;
  140719. /**
  140720. * Callback called when the task is successful
  140721. */
  140722. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140723. /**
  140724. * Creates a new MeshAssetTask
  140725. * @param name defines the name of the task
  140726. * @param meshesNames defines the list of mesh's names you want to load
  140727. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140728. * @param sceneFilename defines the filename of the scene to load from
  140729. */
  140730. constructor(
  140731. /**
  140732. * Defines the name of the task
  140733. */
  140734. name: string,
  140735. /**
  140736. * Defines the list of mesh's names you want to load
  140737. */
  140738. meshesNames: any,
  140739. /**
  140740. * Defines the root url to use as a base to load your meshes and associated resources
  140741. */
  140742. rootUrl: string,
  140743. /**
  140744. * Defines the filename of the scene to load from
  140745. */
  140746. sceneFilename: string);
  140747. /**
  140748. * Execute the current task
  140749. * @param scene defines the scene where you want your assets to be loaded
  140750. * @param onSuccess is a callback called when the task is successfully executed
  140751. * @param onError is a callback called if an error occurs
  140752. */
  140753. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140754. }
  140755. /**
  140756. * Define a task used by AssetsManager to load text content
  140757. */
  140758. export class TextFileAssetTask extends AbstractAssetTask {
  140759. /**
  140760. * Defines the name of the task
  140761. */
  140762. name: string;
  140763. /**
  140764. * Defines the location of the file to load
  140765. */
  140766. url: string;
  140767. /**
  140768. * Gets the loaded text string
  140769. */
  140770. text: string;
  140771. /**
  140772. * Callback called when the task is successful
  140773. */
  140774. onSuccess: (task: TextFileAssetTask) => void;
  140775. /**
  140776. * Callback called when the task is successful
  140777. */
  140778. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140779. /**
  140780. * Creates a new TextFileAssetTask object
  140781. * @param name defines the name of the task
  140782. * @param url defines the location of the file to load
  140783. */
  140784. constructor(
  140785. /**
  140786. * Defines the name of the task
  140787. */
  140788. name: string,
  140789. /**
  140790. * Defines the location of the file to load
  140791. */
  140792. url: string);
  140793. /**
  140794. * Execute the current task
  140795. * @param scene defines the scene where you want your assets to be loaded
  140796. * @param onSuccess is a callback called when the task is successfully executed
  140797. * @param onError is a callback called if an error occurs
  140798. */
  140799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140800. }
  140801. /**
  140802. * Define a task used by AssetsManager to load binary data
  140803. */
  140804. export class BinaryFileAssetTask extends AbstractAssetTask {
  140805. /**
  140806. * Defines the name of the task
  140807. */
  140808. name: string;
  140809. /**
  140810. * Defines the location of the file to load
  140811. */
  140812. url: string;
  140813. /**
  140814. * Gets the lodaded data (as an array buffer)
  140815. */
  140816. data: ArrayBuffer;
  140817. /**
  140818. * Callback called when the task is successful
  140819. */
  140820. onSuccess: (task: BinaryFileAssetTask) => void;
  140821. /**
  140822. * Callback called when the task is successful
  140823. */
  140824. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140825. /**
  140826. * Creates a new BinaryFileAssetTask object
  140827. * @param name defines the name of the new task
  140828. * @param url defines the location of the file to load
  140829. */
  140830. constructor(
  140831. /**
  140832. * Defines the name of the task
  140833. */
  140834. name: string,
  140835. /**
  140836. * Defines the location of the file to load
  140837. */
  140838. url: string);
  140839. /**
  140840. * Execute the current task
  140841. * @param scene defines the scene where you want your assets to be loaded
  140842. * @param onSuccess is a callback called when the task is successfully executed
  140843. * @param onError is a callback called if an error occurs
  140844. */
  140845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140846. }
  140847. /**
  140848. * Define a task used by AssetsManager to load images
  140849. */
  140850. export class ImageAssetTask extends AbstractAssetTask {
  140851. /**
  140852. * Defines the name of the task
  140853. */
  140854. name: string;
  140855. /**
  140856. * Defines the location of the image to load
  140857. */
  140858. url: string;
  140859. /**
  140860. * Gets the loaded images
  140861. */
  140862. image: HTMLImageElement;
  140863. /**
  140864. * Callback called when the task is successful
  140865. */
  140866. onSuccess: (task: ImageAssetTask) => void;
  140867. /**
  140868. * Callback called when the task is successful
  140869. */
  140870. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140871. /**
  140872. * Creates a new ImageAssetTask
  140873. * @param name defines the name of the task
  140874. * @param url defines the location of the image to load
  140875. */
  140876. constructor(
  140877. /**
  140878. * Defines the name of the task
  140879. */
  140880. name: string,
  140881. /**
  140882. * Defines the location of the image to load
  140883. */
  140884. url: string);
  140885. /**
  140886. * Execute the current task
  140887. * @param scene defines the scene where you want your assets to be loaded
  140888. * @param onSuccess is a callback called when the task is successfully executed
  140889. * @param onError is a callback called if an error occurs
  140890. */
  140891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140892. }
  140893. /**
  140894. * Defines the interface used by texture loading tasks
  140895. */
  140896. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140897. /**
  140898. * Gets the loaded texture
  140899. */
  140900. texture: TEX;
  140901. }
  140902. /**
  140903. * Define a task used by AssetsManager to load 2D textures
  140904. */
  140905. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140906. /**
  140907. * Defines the name of the task
  140908. */
  140909. name: string;
  140910. /**
  140911. * Defines the location of the file to load
  140912. */
  140913. url: string;
  140914. /**
  140915. * Defines if mipmap should not be generated (default is false)
  140916. */
  140917. noMipmap?: boolean | undefined;
  140918. /**
  140919. * Defines if texture must be inverted on Y axis (default is false)
  140920. */
  140921. invertY?: boolean | undefined;
  140922. /**
  140923. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140924. */
  140925. samplingMode: number;
  140926. /**
  140927. * Gets the loaded texture
  140928. */
  140929. texture: Texture;
  140930. /**
  140931. * Callback called when the task is successful
  140932. */
  140933. onSuccess: (task: TextureAssetTask) => void;
  140934. /**
  140935. * Callback called when the task is successful
  140936. */
  140937. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140938. /**
  140939. * Creates a new TextureAssetTask object
  140940. * @param name defines the name of the task
  140941. * @param url defines the location of the file to load
  140942. * @param noMipmap defines if mipmap should not be generated (default is false)
  140943. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140944. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140945. */
  140946. constructor(
  140947. /**
  140948. * Defines the name of the task
  140949. */
  140950. name: string,
  140951. /**
  140952. * Defines the location of the file to load
  140953. */
  140954. url: string,
  140955. /**
  140956. * Defines if mipmap should not be generated (default is false)
  140957. */
  140958. noMipmap?: boolean | undefined,
  140959. /**
  140960. * Defines if texture must be inverted on Y axis (default is false)
  140961. */
  140962. invertY?: boolean | undefined,
  140963. /**
  140964. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140965. */
  140966. samplingMode?: number);
  140967. /**
  140968. * Execute the current task
  140969. * @param scene defines the scene where you want your assets to be loaded
  140970. * @param onSuccess is a callback called when the task is successfully executed
  140971. * @param onError is a callback called if an error occurs
  140972. */
  140973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140974. }
  140975. /**
  140976. * Define a task used by AssetsManager to load cube textures
  140977. */
  140978. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140979. /**
  140980. * Defines the name of the task
  140981. */
  140982. name: string;
  140983. /**
  140984. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140985. */
  140986. url: string;
  140987. /**
  140988. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140989. */
  140990. extensions?: string[] | undefined;
  140991. /**
  140992. * Defines if mipmaps should not be generated (default is false)
  140993. */
  140994. noMipmap?: boolean | undefined;
  140995. /**
  140996. * Defines the explicit list of files (undefined by default)
  140997. */
  140998. files?: string[] | undefined;
  140999. /**
  141000. * Gets the loaded texture
  141001. */
  141002. texture: CubeTexture;
  141003. /**
  141004. * Callback called when the task is successful
  141005. */
  141006. onSuccess: (task: CubeTextureAssetTask) => void;
  141007. /**
  141008. * Callback called when the task is successful
  141009. */
  141010. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  141011. /**
  141012. * Creates a new CubeTextureAssetTask
  141013. * @param name defines the name of the task
  141014. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141015. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141016. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141017. * @param files defines the explicit list of files (undefined by default)
  141018. */
  141019. constructor(
  141020. /**
  141021. * Defines the name of the task
  141022. */
  141023. name: string,
  141024. /**
  141025. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141026. */
  141027. url: string,
  141028. /**
  141029. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141030. */
  141031. extensions?: string[] | undefined,
  141032. /**
  141033. * Defines if mipmaps should not be generated (default is false)
  141034. */
  141035. noMipmap?: boolean | undefined,
  141036. /**
  141037. * Defines the explicit list of files (undefined by default)
  141038. */
  141039. files?: string[] | undefined);
  141040. /**
  141041. * Execute the current task
  141042. * @param scene defines the scene where you want your assets to be loaded
  141043. * @param onSuccess is a callback called when the task is successfully executed
  141044. * @param onError is a callback called if an error occurs
  141045. */
  141046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141047. }
  141048. /**
  141049. * Define a task used by AssetsManager to load HDR cube textures
  141050. */
  141051. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  141052. /**
  141053. * Defines the name of the task
  141054. */
  141055. name: string;
  141056. /**
  141057. * Defines the location of the file to load
  141058. */
  141059. url: string;
  141060. /**
  141061. * Defines the desired size (the more it increases the longer the generation will be)
  141062. */
  141063. size: number;
  141064. /**
  141065. * Defines if mipmaps should not be generated (default is false)
  141066. */
  141067. noMipmap: boolean;
  141068. /**
  141069. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141070. */
  141071. generateHarmonics: boolean;
  141072. /**
  141073. * 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)
  141074. */
  141075. gammaSpace: boolean;
  141076. /**
  141077. * Internal Use Only
  141078. */
  141079. reserved: boolean;
  141080. /**
  141081. * Gets the loaded texture
  141082. */
  141083. texture: HDRCubeTexture;
  141084. /**
  141085. * Callback called when the task is successful
  141086. */
  141087. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  141088. /**
  141089. * Callback called when the task is successful
  141090. */
  141091. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  141092. /**
  141093. * Creates a new HDRCubeTextureAssetTask object
  141094. * @param name defines the name of the task
  141095. * @param url defines the location of the file to load
  141096. * @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.
  141097. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141098. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141099. * @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)
  141100. * @param reserved Internal use only
  141101. */
  141102. constructor(
  141103. /**
  141104. * Defines the name of the task
  141105. */
  141106. name: string,
  141107. /**
  141108. * Defines the location of the file to load
  141109. */
  141110. url: string,
  141111. /**
  141112. * Defines the desired size (the more it increases the longer the generation will be)
  141113. */
  141114. size: number,
  141115. /**
  141116. * Defines if mipmaps should not be generated (default is false)
  141117. */
  141118. noMipmap?: boolean,
  141119. /**
  141120. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141121. */
  141122. generateHarmonics?: boolean,
  141123. /**
  141124. * 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)
  141125. */
  141126. gammaSpace?: boolean,
  141127. /**
  141128. * Internal Use Only
  141129. */
  141130. reserved?: boolean);
  141131. /**
  141132. * Execute the current task
  141133. * @param scene defines the scene where you want your assets to be loaded
  141134. * @param onSuccess is a callback called when the task is successfully executed
  141135. * @param onError is a callback called if an error occurs
  141136. */
  141137. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141138. }
  141139. /**
  141140. * Define a task used by AssetsManager to load Equirectangular cube textures
  141141. */
  141142. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  141143. /**
  141144. * Defines the name of the task
  141145. */
  141146. name: string;
  141147. /**
  141148. * Defines the location of the file to load
  141149. */
  141150. url: string;
  141151. /**
  141152. * Defines the desired size (the more it increases the longer the generation will be)
  141153. */
  141154. size: number;
  141155. /**
  141156. * Defines if mipmaps should not be generated (default is false)
  141157. */
  141158. noMipmap: boolean;
  141159. /**
  141160. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141161. * but the standard material would require them in Gamma space) (default is true)
  141162. */
  141163. gammaSpace: boolean;
  141164. /**
  141165. * Gets the loaded texture
  141166. */
  141167. texture: EquiRectangularCubeTexture;
  141168. /**
  141169. * Callback called when the task is successful
  141170. */
  141171. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  141172. /**
  141173. * Callback called when the task is successful
  141174. */
  141175. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  141176. /**
  141177. * Creates a new EquiRectangularCubeTextureAssetTask object
  141178. * @param name defines the name of the task
  141179. * @param url defines the location of the file to load
  141180. * @param size defines the desired size (the more it increases the longer the generation will be)
  141181. * If the size is omitted this implies you are using a preprocessed cubemap.
  141182. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141183. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141184. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141185. * (default is true)
  141186. */
  141187. constructor(
  141188. /**
  141189. * Defines the name of the task
  141190. */
  141191. name: string,
  141192. /**
  141193. * Defines the location of the file to load
  141194. */
  141195. url: string,
  141196. /**
  141197. * Defines the desired size (the more it increases the longer the generation will be)
  141198. */
  141199. size: number,
  141200. /**
  141201. * Defines if mipmaps should not be generated (default is false)
  141202. */
  141203. noMipmap?: boolean,
  141204. /**
  141205. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141206. * but the standard material would require them in Gamma space) (default is true)
  141207. */
  141208. gammaSpace?: boolean);
  141209. /**
  141210. * Execute the current task
  141211. * @param scene defines the scene where you want your assets to be loaded
  141212. * @param onSuccess is a callback called when the task is successfully executed
  141213. * @param onError is a callback called if an error occurs
  141214. */
  141215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141216. }
  141217. /**
  141218. * This class can be used to easily import assets into a scene
  141219. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141220. */
  141221. export class AssetsManager {
  141222. private _scene;
  141223. private _isLoading;
  141224. protected _tasks: AbstractAssetTask[];
  141225. protected _waitingTasksCount: number;
  141226. protected _totalTasksCount: number;
  141227. /**
  141228. * Callback called when all tasks are processed
  141229. */
  141230. onFinish: (tasks: AbstractAssetTask[]) => void;
  141231. /**
  141232. * Callback called when a task is successful
  141233. */
  141234. onTaskSuccess: (task: AbstractAssetTask) => void;
  141235. /**
  141236. * Callback called when a task had an error
  141237. */
  141238. onTaskError: (task: AbstractAssetTask) => void;
  141239. /**
  141240. * Callback called when a task is done (whatever the result is)
  141241. */
  141242. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141243. /**
  141244. * Observable called when all tasks are processed
  141245. */
  141246. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141247. /**
  141248. * Observable called when a task had an error
  141249. */
  141250. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141251. /**
  141252. * Observable called when all tasks were executed
  141253. */
  141254. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141255. /**
  141256. * Observable called when a task is done (whatever the result is)
  141257. */
  141258. onProgressObservable: Observable<IAssetsProgressEvent>;
  141259. /**
  141260. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141261. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141262. */
  141263. useDefaultLoadingScreen: boolean;
  141264. /**
  141265. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141266. * when all assets have been downloaded.
  141267. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141268. */
  141269. autoHideLoadingUI: boolean;
  141270. /**
  141271. * Creates a new AssetsManager
  141272. * @param scene defines the scene to work on
  141273. */
  141274. constructor(scene: Scene);
  141275. /**
  141276. * Add a MeshAssetTask to the list of active tasks
  141277. * @param taskName defines the name of the new task
  141278. * @param meshesNames defines the name of meshes to load
  141279. * @param rootUrl defines the root url to use to locate files
  141280. * @param sceneFilename defines the filename of the scene file
  141281. * @returns a new MeshAssetTask object
  141282. */
  141283. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141284. /**
  141285. * Add a TextFileAssetTask to the list of active tasks
  141286. * @param taskName defines the name of the new task
  141287. * @param url defines the url of the file to load
  141288. * @returns a new TextFileAssetTask object
  141289. */
  141290. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141291. /**
  141292. * Add a BinaryFileAssetTask to the list of active tasks
  141293. * @param taskName defines the name of the new task
  141294. * @param url defines the url of the file to load
  141295. * @returns a new BinaryFileAssetTask object
  141296. */
  141297. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141298. /**
  141299. * Add a ImageAssetTask to the list of active tasks
  141300. * @param taskName defines the name of the new task
  141301. * @param url defines the url of the file to load
  141302. * @returns a new ImageAssetTask object
  141303. */
  141304. addImageTask(taskName: string, url: string): ImageAssetTask;
  141305. /**
  141306. * Add a TextureAssetTask to the list of active tasks
  141307. * @param taskName defines the name of the new task
  141308. * @param url defines the url of the file to load
  141309. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141310. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141311. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141312. * @returns a new TextureAssetTask object
  141313. */
  141314. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141315. /**
  141316. * Add a CubeTextureAssetTask to the list of active tasks
  141317. * @param taskName defines the name of the new task
  141318. * @param url defines the url of the file to load
  141319. * @param extensions defines the extension to use to load the cube map (can be null)
  141320. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141321. * @param files defines the list of files to load (can be null)
  141322. * @returns a new CubeTextureAssetTask object
  141323. */
  141324. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141325. /**
  141326. *
  141327. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141328. * @param taskName defines the name of the new task
  141329. * @param url defines the url of the file to load
  141330. * @param size defines the size you want for the cubemap (can be null)
  141331. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141332. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141333. * @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)
  141334. * @param reserved Internal use only
  141335. * @returns a new HDRCubeTextureAssetTask object
  141336. */
  141337. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141338. /**
  141339. *
  141340. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141341. * @param taskName defines the name of the new task
  141342. * @param url defines the url of the file to load
  141343. * @param size defines the size you want for the cubemap (can be null)
  141344. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141345. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141346. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141347. * @returns a new EquiRectangularCubeTextureAssetTask object
  141348. */
  141349. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141350. /**
  141351. * Remove a task from the assets manager.
  141352. * @param task the task to remove
  141353. */
  141354. removeTask(task: AbstractAssetTask): void;
  141355. private _decreaseWaitingTasksCount;
  141356. private _runTask;
  141357. /**
  141358. * Reset the AssetsManager and remove all tasks
  141359. * @return the current instance of the AssetsManager
  141360. */
  141361. reset(): AssetsManager;
  141362. /**
  141363. * Start the loading process
  141364. * @return the current instance of the AssetsManager
  141365. */
  141366. load(): AssetsManager;
  141367. /**
  141368. * Start the loading process as an async operation
  141369. * @return a promise returning the list of failed tasks
  141370. */
  141371. loadAsync(): Promise<void>;
  141372. }
  141373. }
  141374. declare module BABYLON {
  141375. /**
  141376. * Wrapper class for promise with external resolve and reject.
  141377. */
  141378. export class Deferred<T> {
  141379. /**
  141380. * The promise associated with this deferred object.
  141381. */
  141382. readonly promise: Promise<T>;
  141383. private _resolve;
  141384. private _reject;
  141385. /**
  141386. * The resolve method of the promise associated with this deferred object.
  141387. */
  141388. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141389. /**
  141390. * The reject method of the promise associated with this deferred object.
  141391. */
  141392. get reject(): (reason?: any) => void;
  141393. /**
  141394. * Constructor for this deferred object.
  141395. */
  141396. constructor();
  141397. }
  141398. }
  141399. declare module BABYLON {
  141400. /**
  141401. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141402. */
  141403. export class MeshExploder {
  141404. private _centerMesh;
  141405. private _meshes;
  141406. private _meshesOrigins;
  141407. private _toCenterVectors;
  141408. private _scaledDirection;
  141409. private _newPosition;
  141410. private _centerPosition;
  141411. /**
  141412. * Explodes meshes from a center mesh.
  141413. * @param meshes The meshes to explode.
  141414. * @param centerMesh The mesh to be center of explosion.
  141415. */
  141416. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141417. private _setCenterMesh;
  141418. /**
  141419. * Get class name
  141420. * @returns "MeshExploder"
  141421. */
  141422. getClassName(): string;
  141423. /**
  141424. * "Exploded meshes"
  141425. * @returns Array of meshes with the centerMesh at index 0.
  141426. */
  141427. getMeshes(): Array<Mesh>;
  141428. /**
  141429. * Explodes meshes giving a specific direction
  141430. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141431. */
  141432. explode(direction?: number): void;
  141433. }
  141434. }
  141435. declare module BABYLON {
  141436. /**
  141437. * Class used to help managing file picking and drag'n'drop
  141438. */
  141439. export class FilesInput {
  141440. /**
  141441. * List of files ready to be loaded
  141442. */
  141443. static get FilesToLoad(): {
  141444. [key: string]: File;
  141445. };
  141446. /**
  141447. * Callback called when a file is processed
  141448. */
  141449. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141450. private _engine;
  141451. private _currentScene;
  141452. private _sceneLoadedCallback;
  141453. private _progressCallback;
  141454. private _additionalRenderLoopLogicCallback;
  141455. private _textureLoadingCallback;
  141456. private _startingProcessingFilesCallback;
  141457. private _onReloadCallback;
  141458. private _errorCallback;
  141459. private _elementToMonitor;
  141460. private _sceneFileToLoad;
  141461. private _filesToLoad;
  141462. /**
  141463. * Creates a new FilesInput
  141464. * @param engine defines the rendering engine
  141465. * @param scene defines the hosting scene
  141466. * @param sceneLoadedCallback callback called when scene is loaded
  141467. * @param progressCallback callback called to track progress
  141468. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141469. * @param textureLoadingCallback callback called when a texture is loading
  141470. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141471. * @param onReloadCallback callback called when a reload is requested
  141472. * @param errorCallback callback call if an error occurs
  141473. */
  141474. 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);
  141475. private _dragEnterHandler;
  141476. private _dragOverHandler;
  141477. private _dropHandler;
  141478. /**
  141479. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141480. * @param elementToMonitor defines the DOM element to track
  141481. */
  141482. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141483. /**
  141484. * Release all associated resources
  141485. */
  141486. dispose(): void;
  141487. private renderFunction;
  141488. private drag;
  141489. private drop;
  141490. private _traverseFolder;
  141491. private _processFiles;
  141492. /**
  141493. * Load files from a drop event
  141494. * @param event defines the drop event to use as source
  141495. */
  141496. loadFiles(event: any): void;
  141497. private _processReload;
  141498. /**
  141499. * Reload the current scene from the loaded files
  141500. */
  141501. reload(): void;
  141502. }
  141503. }
  141504. declare module BABYLON {
  141505. /**
  141506. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141507. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141508. */
  141509. export class SceneOptimization {
  141510. /**
  141511. * Defines the priority of this optimization (0 by default which means first in the list)
  141512. */
  141513. priority: number;
  141514. /**
  141515. * Gets a string describing the action executed by the current optimization
  141516. * @returns description string
  141517. */
  141518. getDescription(): string;
  141519. /**
  141520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141521. * @param scene defines the current scene where to apply this optimization
  141522. * @param optimizer defines the current optimizer
  141523. * @returns true if everything that can be done was applied
  141524. */
  141525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141526. /**
  141527. * Creates the SceneOptimization object
  141528. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141529. * @param desc defines the description associated with the optimization
  141530. */
  141531. constructor(
  141532. /**
  141533. * Defines the priority of this optimization (0 by default which means first in the list)
  141534. */
  141535. priority?: number);
  141536. }
  141537. /**
  141538. * Defines an optimization used to reduce the size of render target textures
  141539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141540. */
  141541. export class TextureOptimization extends SceneOptimization {
  141542. /**
  141543. * Defines the priority of this optimization (0 by default which means first in the list)
  141544. */
  141545. priority: number;
  141546. /**
  141547. * 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
  141548. */
  141549. maximumSize: number;
  141550. /**
  141551. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141552. */
  141553. step: number;
  141554. /**
  141555. * Gets a string describing the action executed by the current optimization
  141556. * @returns description string
  141557. */
  141558. getDescription(): string;
  141559. /**
  141560. * Creates the TextureOptimization object
  141561. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141562. * @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
  141563. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141564. */
  141565. constructor(
  141566. /**
  141567. * Defines the priority of this optimization (0 by default which means first in the list)
  141568. */
  141569. priority?: number,
  141570. /**
  141571. * 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
  141572. */
  141573. maximumSize?: number,
  141574. /**
  141575. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141576. */
  141577. step?: number);
  141578. /**
  141579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141580. * @param scene defines the current scene where to apply this optimization
  141581. * @param optimizer defines the current optimizer
  141582. * @returns true if everything that can be done was applied
  141583. */
  141584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141585. }
  141586. /**
  141587. * Defines an optimization used to increase or decrease the rendering resolution
  141588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141589. */
  141590. export class HardwareScalingOptimization extends SceneOptimization {
  141591. /**
  141592. * Defines the priority of this optimization (0 by default which means first in the list)
  141593. */
  141594. priority: number;
  141595. /**
  141596. * Defines the maximum scale to use (2 by default)
  141597. */
  141598. maximumScale: number;
  141599. /**
  141600. * Defines the step to use between two passes (0.5 by default)
  141601. */
  141602. step: number;
  141603. private _currentScale;
  141604. private _directionOffset;
  141605. /**
  141606. * Gets a string describing the action executed by the current optimization
  141607. * @return description string
  141608. */
  141609. getDescription(): string;
  141610. /**
  141611. * Creates the HardwareScalingOptimization object
  141612. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141613. * @param maximumScale defines the maximum scale to use (2 by default)
  141614. * @param step defines the step to use between two passes (0.5 by default)
  141615. */
  141616. constructor(
  141617. /**
  141618. * Defines the priority of this optimization (0 by default which means first in the list)
  141619. */
  141620. priority?: number,
  141621. /**
  141622. * Defines the maximum scale to use (2 by default)
  141623. */
  141624. maximumScale?: number,
  141625. /**
  141626. * Defines the step to use between two passes (0.5 by default)
  141627. */
  141628. step?: number);
  141629. /**
  141630. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141631. * @param scene defines the current scene where to apply this optimization
  141632. * @param optimizer defines the current optimizer
  141633. * @returns true if everything that can be done was applied
  141634. */
  141635. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141636. }
  141637. /**
  141638. * Defines an optimization used to remove shadows
  141639. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141640. */
  141641. export class ShadowsOptimization extends SceneOptimization {
  141642. /**
  141643. * Gets a string describing the action executed by the current optimization
  141644. * @return description string
  141645. */
  141646. getDescription(): string;
  141647. /**
  141648. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141649. * @param scene defines the current scene where to apply this optimization
  141650. * @param optimizer defines the current optimizer
  141651. * @returns true if everything that can be done was applied
  141652. */
  141653. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141654. }
  141655. /**
  141656. * Defines an optimization used to turn post-processes off
  141657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141658. */
  141659. export class PostProcessesOptimization extends SceneOptimization {
  141660. /**
  141661. * Gets a string describing the action executed by the current optimization
  141662. * @return description string
  141663. */
  141664. getDescription(): string;
  141665. /**
  141666. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141667. * @param scene defines the current scene where to apply this optimization
  141668. * @param optimizer defines the current optimizer
  141669. * @returns true if everything that can be done was applied
  141670. */
  141671. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141672. }
  141673. /**
  141674. * Defines an optimization used to turn lens flares off
  141675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141676. */
  141677. export class LensFlaresOptimization extends SceneOptimization {
  141678. /**
  141679. * Gets a string describing the action executed by the current optimization
  141680. * @return description string
  141681. */
  141682. getDescription(): string;
  141683. /**
  141684. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141685. * @param scene defines the current scene where to apply this optimization
  141686. * @param optimizer defines the current optimizer
  141687. * @returns true if everything that can be done was applied
  141688. */
  141689. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141690. }
  141691. /**
  141692. * Defines an optimization based on user defined callback.
  141693. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141694. */
  141695. export class CustomOptimization extends SceneOptimization {
  141696. /**
  141697. * Callback called to apply the custom optimization.
  141698. */
  141699. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141700. /**
  141701. * Callback called to get custom description
  141702. */
  141703. onGetDescription: () => string;
  141704. /**
  141705. * Gets a string describing the action executed by the current optimization
  141706. * @returns description string
  141707. */
  141708. getDescription(): string;
  141709. /**
  141710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141711. * @param scene defines the current scene where to apply this optimization
  141712. * @param optimizer defines the current optimizer
  141713. * @returns true if everything that can be done was applied
  141714. */
  141715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141716. }
  141717. /**
  141718. * Defines an optimization used to turn particles off
  141719. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141720. */
  141721. export class ParticlesOptimization extends SceneOptimization {
  141722. /**
  141723. * Gets a string describing the action executed by the current optimization
  141724. * @return description string
  141725. */
  141726. getDescription(): string;
  141727. /**
  141728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141729. * @param scene defines the current scene where to apply this optimization
  141730. * @param optimizer defines the current optimizer
  141731. * @returns true if everything that can be done was applied
  141732. */
  141733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141734. }
  141735. /**
  141736. * Defines an optimization used to turn render targets off
  141737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141738. */
  141739. export class RenderTargetsOptimization extends SceneOptimization {
  141740. /**
  141741. * Gets a string describing the action executed by the current optimization
  141742. * @return description string
  141743. */
  141744. getDescription(): string;
  141745. /**
  141746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141747. * @param scene defines the current scene where to apply this optimization
  141748. * @param optimizer defines the current optimizer
  141749. * @returns true if everything that can be done was applied
  141750. */
  141751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141752. }
  141753. /**
  141754. * Defines an optimization used to merge meshes with compatible materials
  141755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141756. */
  141757. export class MergeMeshesOptimization extends SceneOptimization {
  141758. private static _UpdateSelectionTree;
  141759. /**
  141760. * Gets or sets a boolean which defines if optimization octree has to be updated
  141761. */
  141762. static get UpdateSelectionTree(): boolean;
  141763. /**
  141764. * Gets or sets a boolean which defines if optimization octree has to be updated
  141765. */
  141766. static set UpdateSelectionTree(value: boolean);
  141767. /**
  141768. * Gets a string describing the action executed by the current optimization
  141769. * @return description string
  141770. */
  141771. getDescription(): string;
  141772. private _canBeMerged;
  141773. /**
  141774. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141775. * @param scene defines the current scene where to apply this optimization
  141776. * @param optimizer defines the current optimizer
  141777. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141778. * @returns true if everything that can be done was applied
  141779. */
  141780. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141781. }
  141782. /**
  141783. * Defines a list of options used by SceneOptimizer
  141784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141785. */
  141786. export class SceneOptimizerOptions {
  141787. /**
  141788. * Defines the target frame rate to reach (60 by default)
  141789. */
  141790. targetFrameRate: number;
  141791. /**
  141792. * Defines the interval between two checkes (2000ms by default)
  141793. */
  141794. trackerDuration: number;
  141795. /**
  141796. * Gets the list of optimizations to apply
  141797. */
  141798. optimizations: SceneOptimization[];
  141799. /**
  141800. * Creates a new list of options used by SceneOptimizer
  141801. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141802. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141803. */
  141804. constructor(
  141805. /**
  141806. * Defines the target frame rate to reach (60 by default)
  141807. */
  141808. targetFrameRate?: number,
  141809. /**
  141810. * Defines the interval between two checkes (2000ms by default)
  141811. */
  141812. trackerDuration?: number);
  141813. /**
  141814. * Add a new optimization
  141815. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141816. * @returns the current SceneOptimizerOptions
  141817. */
  141818. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141819. /**
  141820. * Add a new custom optimization
  141821. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141822. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141823. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141824. * @returns the current SceneOptimizerOptions
  141825. */
  141826. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141827. /**
  141828. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141829. * @param targetFrameRate defines the target frame rate (60 by default)
  141830. * @returns a SceneOptimizerOptions object
  141831. */
  141832. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141833. /**
  141834. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141835. * @param targetFrameRate defines the target frame rate (60 by default)
  141836. * @returns a SceneOptimizerOptions object
  141837. */
  141838. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141839. /**
  141840. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141841. * @param targetFrameRate defines the target frame rate (60 by default)
  141842. * @returns a SceneOptimizerOptions object
  141843. */
  141844. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141845. }
  141846. /**
  141847. * Class used to run optimizations in order to reach a target frame rate
  141848. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141849. */
  141850. export class SceneOptimizer implements IDisposable {
  141851. private _isRunning;
  141852. private _options;
  141853. private _scene;
  141854. private _currentPriorityLevel;
  141855. private _targetFrameRate;
  141856. private _trackerDuration;
  141857. private _currentFrameRate;
  141858. private _sceneDisposeObserver;
  141859. private _improvementMode;
  141860. /**
  141861. * Defines an observable called when the optimizer reaches the target frame rate
  141862. */
  141863. onSuccessObservable: Observable<SceneOptimizer>;
  141864. /**
  141865. * Defines an observable called when the optimizer enables an optimization
  141866. */
  141867. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141868. /**
  141869. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141870. */
  141871. onFailureObservable: Observable<SceneOptimizer>;
  141872. /**
  141873. * Gets a boolean indicating if the optimizer is in improvement mode
  141874. */
  141875. get isInImprovementMode(): boolean;
  141876. /**
  141877. * Gets the current priority level (0 at start)
  141878. */
  141879. get currentPriorityLevel(): number;
  141880. /**
  141881. * Gets the current frame rate checked by the SceneOptimizer
  141882. */
  141883. get currentFrameRate(): number;
  141884. /**
  141885. * Gets or sets the current target frame rate (60 by default)
  141886. */
  141887. get targetFrameRate(): number;
  141888. /**
  141889. * Gets or sets the current target frame rate (60 by default)
  141890. */
  141891. set targetFrameRate(value: number);
  141892. /**
  141893. * Gets or sets the current interval between two checks (every 2000ms by default)
  141894. */
  141895. get trackerDuration(): number;
  141896. /**
  141897. * Gets or sets the current interval between two checks (every 2000ms by default)
  141898. */
  141899. set trackerDuration(value: number);
  141900. /**
  141901. * Gets the list of active optimizations
  141902. */
  141903. get optimizations(): SceneOptimization[];
  141904. /**
  141905. * Creates a new SceneOptimizer
  141906. * @param scene defines the scene to work on
  141907. * @param options defines the options to use with the SceneOptimizer
  141908. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141909. * @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)
  141910. */
  141911. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141912. /**
  141913. * Stops the current optimizer
  141914. */
  141915. stop(): void;
  141916. /**
  141917. * Reset the optimizer to initial step (current priority level = 0)
  141918. */
  141919. reset(): void;
  141920. /**
  141921. * Start the optimizer. By default it will try to reach a specific framerate
  141922. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141923. */
  141924. start(): void;
  141925. private _checkCurrentState;
  141926. /**
  141927. * Release all resources
  141928. */
  141929. dispose(): void;
  141930. /**
  141931. * Helper function to create a SceneOptimizer with one single line of code
  141932. * @param scene defines the scene to work on
  141933. * @param options defines the options to use with the SceneOptimizer
  141934. * @param onSuccess defines a callback to call on success
  141935. * @param onFailure defines a callback to call on failure
  141936. * @returns the new SceneOptimizer object
  141937. */
  141938. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141939. }
  141940. }
  141941. declare module BABYLON {
  141942. /**
  141943. * Class used to serialize a scene into a string
  141944. */
  141945. export class SceneSerializer {
  141946. /**
  141947. * Clear cache used by a previous serialization
  141948. */
  141949. static ClearCache(): void;
  141950. /**
  141951. * Serialize a scene into a JSON compatible object
  141952. * @param scene defines the scene to serialize
  141953. * @returns a JSON compatible object
  141954. */
  141955. static Serialize(scene: Scene): any;
  141956. /**
  141957. * Serialize a mesh into a JSON compatible object
  141958. * @param toSerialize defines the mesh to serialize
  141959. * @param withParents defines if parents must be serialized as well
  141960. * @param withChildren defines if children must be serialized as well
  141961. * @returns a JSON compatible object
  141962. */
  141963. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141964. }
  141965. }
  141966. declare module BABYLON {
  141967. /**
  141968. * Class used to host texture specific utilities
  141969. */
  141970. export class TextureTools {
  141971. /**
  141972. * Uses the GPU to create a copy texture rescaled at a given size
  141973. * @param texture Texture to copy from
  141974. * @param width defines the desired width
  141975. * @param height defines the desired height
  141976. * @param useBilinearMode defines if bilinear mode has to be used
  141977. * @return the generated texture
  141978. */
  141979. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141980. }
  141981. }
  141982. declare module BABYLON {
  141983. /**
  141984. * This represents the different options available for the video capture.
  141985. */
  141986. export interface VideoRecorderOptions {
  141987. /** Defines the mime type of the video. */
  141988. mimeType: string;
  141989. /** Defines the FPS the video should be recorded at. */
  141990. fps: number;
  141991. /** Defines the chunk size for the recording data. */
  141992. recordChunckSize: number;
  141993. /** The audio tracks to attach to the recording. */
  141994. audioTracks?: MediaStreamTrack[];
  141995. }
  141996. /**
  141997. * This can help with recording videos from BabylonJS.
  141998. * This is based on the available WebRTC functionalities of the browser.
  141999. *
  142000. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  142001. */
  142002. export class VideoRecorder {
  142003. private static readonly _defaultOptions;
  142004. /**
  142005. * Returns whether or not the VideoRecorder is available in your browser.
  142006. * @param engine Defines the Babylon Engine.
  142007. * @returns true if supported otherwise false.
  142008. */
  142009. static IsSupported(engine: Engine): boolean;
  142010. private readonly _options;
  142011. private _canvas;
  142012. private _mediaRecorder;
  142013. private _recordedChunks;
  142014. private _fileName;
  142015. private _resolve;
  142016. private _reject;
  142017. /**
  142018. * True when a recording is already in progress.
  142019. */
  142020. get isRecording(): boolean;
  142021. /**
  142022. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  142023. * @param engine Defines the BabylonJS Engine you wish to record.
  142024. * @param options Defines options that can be used to customize the capture.
  142025. */
  142026. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  142027. /**
  142028. * Stops the current recording before the default capture timeout passed in the startRecording function.
  142029. */
  142030. stopRecording(): void;
  142031. /**
  142032. * Starts recording the canvas for a max duration specified in parameters.
  142033. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  142034. * If null no automatic download will start and you can rely on the promise to get the data back.
  142035. * @param maxDuration Defines the maximum recording time in seconds.
  142036. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  142037. * @return A promise callback at the end of the recording with the video data in Blob.
  142038. */
  142039. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  142040. /**
  142041. * Releases internal resources used during the recording.
  142042. */
  142043. dispose(): void;
  142044. private _handleDataAvailable;
  142045. private _handleError;
  142046. private _handleStop;
  142047. }
  142048. }
  142049. declare module BABYLON {
  142050. /**
  142051. * Class containing a set of static utilities functions for screenshots
  142052. */
  142053. export class ScreenshotTools {
  142054. /**
  142055. * Captures a screenshot of the current rendering
  142056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142057. * @param engine defines the rendering engine
  142058. * @param camera defines the source camera
  142059. * @param size This parameter can be set to a single number or to an object with the
  142060. * following (optional) properties: precision, width, height. If a single number is passed,
  142061. * it will be used for both width and height. If an object is passed, the screenshot size
  142062. * will be derived from the parameters. The precision property is a multiplier allowing
  142063. * rendering at a higher or lower resolution
  142064. * @param successCallback defines the callback receives a single parameter which contains the
  142065. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142066. * src parameter of an <img> to display it
  142067. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142068. * Check your browser for supported MIME types
  142069. */
  142070. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  142071. /**
  142072. * Captures a screenshot of the current rendering
  142073. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142074. * @param engine defines the rendering engine
  142075. * @param camera defines the source camera
  142076. * @param size This parameter can be set to a single number or to an object with the
  142077. * following (optional) properties: precision, width, height. If a single number is passed,
  142078. * it will be used for both width and height. If an object is passed, the screenshot size
  142079. * will be derived from the parameters. The precision property is a multiplier allowing
  142080. * rendering at a higher or lower resolution
  142081. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142082. * Check your browser for supported MIME types
  142083. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142084. * to the src parameter of an <img> to display it
  142085. */
  142086. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  142087. /**
  142088. * Generates an image screenshot from the specified camera.
  142089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142090. * @param engine The engine to use for rendering
  142091. * @param camera The camera to use for rendering
  142092. * @param size This parameter can be set to a single number or to an object with the
  142093. * following (optional) properties: precision, width, height. If a single number is passed,
  142094. * it will be used for both width and height. If an object is passed, the screenshot size
  142095. * will be derived from the parameters. The precision property is a multiplier allowing
  142096. * rendering at a higher or lower resolution
  142097. * @param successCallback The callback receives a single parameter which contains the
  142098. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142099. * src parameter of an <img> to display it
  142100. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142101. * Check your browser for supported MIME types
  142102. * @param samples Texture samples (default: 1)
  142103. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142104. * @param fileName A name for for the downloaded file.
  142105. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142106. */
  142107. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  142108. /**
  142109. * Generates an image screenshot from the specified camera.
  142110. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142111. * @param engine The engine to use for rendering
  142112. * @param camera The camera to use for rendering
  142113. * @param size This parameter can be set to a single number or to an object with the
  142114. * following (optional) properties: precision, width, height. If a single number is passed,
  142115. * it will be used for both width and height. If an object is passed, the screenshot size
  142116. * will be derived from the parameters. The precision property is a multiplier allowing
  142117. * rendering at a higher or lower resolution
  142118. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142119. * Check your browser for supported MIME types
  142120. * @param samples Texture samples (default: 1)
  142121. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142122. * @param fileName A name for for the downloaded file.
  142123. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142124. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142125. * to the src parameter of an <img> to display it
  142126. */
  142127. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  142128. /**
  142129. * Gets height and width for screenshot size
  142130. * @private
  142131. */
  142132. private static _getScreenshotSize;
  142133. }
  142134. }
  142135. declare module BABYLON {
  142136. /**
  142137. * Interface for a data buffer
  142138. */
  142139. export interface IDataBuffer {
  142140. /**
  142141. * Reads bytes from the data buffer.
  142142. * @param byteOffset The byte offset to read
  142143. * @param byteLength The byte length to read
  142144. * @returns A promise that resolves when the bytes are read
  142145. */
  142146. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  142147. /**
  142148. * The byte length of the buffer.
  142149. */
  142150. readonly byteLength: number;
  142151. }
  142152. /**
  142153. * Utility class for reading from a data buffer
  142154. */
  142155. export class DataReader {
  142156. /**
  142157. * The data buffer associated with this data reader.
  142158. */
  142159. readonly buffer: IDataBuffer;
  142160. /**
  142161. * The current byte offset from the beginning of the data buffer.
  142162. */
  142163. byteOffset: number;
  142164. private _dataView;
  142165. private _dataByteOffset;
  142166. /**
  142167. * Constructor
  142168. * @param buffer The buffer to read
  142169. */
  142170. constructor(buffer: IDataBuffer);
  142171. /**
  142172. * Loads the given byte length.
  142173. * @param byteLength The byte length to load
  142174. * @returns A promise that resolves when the load is complete
  142175. */
  142176. loadAsync(byteLength: number): Promise<void>;
  142177. /**
  142178. * Read a unsigned 32-bit integer from the currently loaded data range.
  142179. * @returns The 32-bit integer read
  142180. */
  142181. readUint32(): number;
  142182. /**
  142183. * Read a byte array from the currently loaded data range.
  142184. * @param byteLength The byte length to read
  142185. * @returns The byte array read
  142186. */
  142187. readUint8Array(byteLength: number): Uint8Array;
  142188. /**
  142189. * Read a string from the currently loaded data range.
  142190. * @param byteLength The byte length to read
  142191. * @returns The string read
  142192. */
  142193. readString(byteLength: number): string;
  142194. /**
  142195. * Skips the given byte length the currently loaded data range.
  142196. * @param byteLength The byte length to skip
  142197. */
  142198. skipBytes(byteLength: number): void;
  142199. }
  142200. }
  142201. declare module BABYLON {
  142202. /**
  142203. * Class for storing data to local storage if available or in-memory storage otherwise
  142204. */
  142205. export class DataStorage {
  142206. private static _Storage;
  142207. private static _GetStorage;
  142208. /**
  142209. * Reads a string from the data storage
  142210. * @param key The key to read
  142211. * @param defaultValue The value if the key doesn't exist
  142212. * @returns The string value
  142213. */
  142214. static ReadString(key: string, defaultValue: string): string;
  142215. /**
  142216. * Writes a string to the data storage
  142217. * @param key The key to write
  142218. * @param value The value to write
  142219. */
  142220. static WriteString(key: string, value: string): void;
  142221. /**
  142222. * Reads a boolean from the data storage
  142223. * @param key The key to read
  142224. * @param defaultValue The value if the key doesn't exist
  142225. * @returns The boolean value
  142226. */
  142227. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  142228. /**
  142229. * Writes a boolean to the data storage
  142230. * @param key The key to write
  142231. * @param value The value to write
  142232. */
  142233. static WriteBoolean(key: string, value: boolean): void;
  142234. /**
  142235. * Reads a number from the data storage
  142236. * @param key The key to read
  142237. * @param defaultValue The value if the key doesn't exist
  142238. * @returns The number value
  142239. */
  142240. static ReadNumber(key: string, defaultValue: number): number;
  142241. /**
  142242. * Writes a number to the data storage
  142243. * @param key The key to write
  142244. * @param value The value to write
  142245. */
  142246. static WriteNumber(key: string, value: number): void;
  142247. }
  142248. }
  142249. declare module BABYLON {
  142250. /**
  142251. * Options used for hit testing
  142252. */
  142253. export interface IWebXRHitTestOptions {
  142254. /**
  142255. * Only test when user interacted with the scene. Default - hit test every frame
  142256. */
  142257. testOnPointerDownOnly?: boolean;
  142258. /**
  142259. * The node to use to transform the local results to world coordinates
  142260. */
  142261. worldParentNode?: TransformNode;
  142262. }
  142263. /**
  142264. * Interface defining the babylon result of raycasting/hit-test
  142265. */
  142266. export interface IWebXRHitResult {
  142267. /**
  142268. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142269. */
  142270. transformationMatrix: Matrix;
  142271. /**
  142272. * The native hit test result
  142273. */
  142274. xrHitResult: XRHitResult;
  142275. }
  142276. /**
  142277. * The currently-working hit-test module.
  142278. * Hit test (or Ray-casting) is used to interact with the real world.
  142279. * For further information read here - https://github.com/immersive-web/hit-test
  142280. */
  142281. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142282. /**
  142283. * options to use when constructing this feature
  142284. */
  142285. readonly options: IWebXRHitTestOptions;
  142286. private _direction;
  142287. private _mat;
  142288. private _onSelectEnabled;
  142289. private _origin;
  142290. /**
  142291. * The module's name
  142292. */
  142293. static readonly Name: string;
  142294. /**
  142295. * The (Babylon) version of this module.
  142296. * This is an integer representing the implementation version.
  142297. * This number does not correspond to the WebXR specs version
  142298. */
  142299. static readonly Version: number;
  142300. /**
  142301. * Populated with the last native XR Hit Results
  142302. */
  142303. lastNativeXRHitResults: XRHitResult[];
  142304. /**
  142305. * Triggered when new babylon (transformed) hit test results are available
  142306. */
  142307. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142308. /**
  142309. * Creates a new instance of the (legacy version) hit test feature
  142310. * @param _xrSessionManager an instance of WebXRSessionManager
  142311. * @param options options to use when constructing this feature
  142312. */
  142313. constructor(_xrSessionManager: WebXRSessionManager,
  142314. /**
  142315. * options to use when constructing this feature
  142316. */
  142317. options?: IWebXRHitTestOptions);
  142318. /**
  142319. * execute a hit test with an XR Ray
  142320. *
  142321. * @param xrSession a native xrSession that will execute this hit test
  142322. * @param xrRay the ray (position and direction) to use for ray-casting
  142323. * @param referenceSpace native XR reference space to use for the hit-test
  142324. * @param filter filter function that will filter the results
  142325. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142326. */
  142327. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142328. /**
  142329. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142330. * @param event the (select) event to use to select with
  142331. * @param referenceSpace the reference space to use for this hit test
  142332. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142333. */
  142334. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142335. /**
  142336. * attach this feature
  142337. * Will usually be called by the features manager
  142338. *
  142339. * @returns true if successful.
  142340. */
  142341. attach(): boolean;
  142342. /**
  142343. * detach this feature.
  142344. * Will usually be called by the features manager
  142345. *
  142346. * @returns true if successful.
  142347. */
  142348. detach(): boolean;
  142349. /**
  142350. * Dispose this feature and all of the resources attached
  142351. */
  142352. dispose(): void;
  142353. protected _onXRFrame(frame: XRFrame): void;
  142354. private _onHitTestResults;
  142355. private _onSelect;
  142356. }
  142357. }
  142358. declare module BABYLON {
  142359. /**
  142360. * Options used in the plane detector module
  142361. */
  142362. export interface IWebXRPlaneDetectorOptions {
  142363. /**
  142364. * The node to use to transform the local results to world coordinates
  142365. */
  142366. worldParentNode?: TransformNode;
  142367. }
  142368. /**
  142369. * A babylon interface for a WebXR plane.
  142370. * A Plane is actually a polygon, built from N points in space
  142371. *
  142372. * Supported in chrome 79, not supported in canary 81 ATM
  142373. */
  142374. export interface IWebXRPlane {
  142375. /**
  142376. * a babylon-assigned ID for this polygon
  142377. */
  142378. id: number;
  142379. /**
  142380. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142381. */
  142382. polygonDefinition: Array<Vector3>;
  142383. /**
  142384. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142385. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142386. */
  142387. transformationMatrix: Matrix;
  142388. /**
  142389. * the native xr-plane object
  142390. */
  142391. xrPlane: XRPlane;
  142392. }
  142393. /**
  142394. * The plane detector is used to detect planes in the real world when in AR
  142395. * For more information see https://github.com/immersive-web/real-world-geometry/
  142396. */
  142397. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142398. private _options;
  142399. private _detectedPlanes;
  142400. private _enabled;
  142401. private _lastFrameDetected;
  142402. /**
  142403. * The module's name
  142404. */
  142405. static readonly Name: string;
  142406. /**
  142407. * The (Babylon) version of this module.
  142408. * This is an integer representing the implementation version.
  142409. * This number does not correspond to the WebXR specs version
  142410. */
  142411. static readonly Version: number;
  142412. /**
  142413. * Observers registered here will be executed when a new plane was added to the session
  142414. */
  142415. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142416. /**
  142417. * Observers registered here will be executed when a plane is no longer detected in the session
  142418. */
  142419. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142420. /**
  142421. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142422. * This can execute N times every frame
  142423. */
  142424. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142425. /**
  142426. * construct a new Plane Detector
  142427. * @param _xrSessionManager an instance of xr Session manager
  142428. * @param _options configuration to use when constructing this feature
  142429. */
  142430. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142431. /**
  142432. * Dispose this feature and all of the resources attached
  142433. */
  142434. dispose(): void;
  142435. protected _onXRFrame(frame: XRFrame): void;
  142436. private _init;
  142437. private _updatePlaneWithXRPlane;
  142438. /**
  142439. * avoiding using Array.find for global support.
  142440. * @param xrPlane the plane to find in the array
  142441. */
  142442. private findIndexInPlaneArray;
  142443. }
  142444. }
  142445. declare module BABYLON {
  142446. /**
  142447. * Configuration options of the anchor system
  142448. */
  142449. export interface IWebXRAnchorSystemOptions {
  142450. /**
  142451. * Should a new anchor be added every time a select event is triggered
  142452. */
  142453. addAnchorOnSelect?: boolean;
  142454. /**
  142455. * should the anchor system use plane detection.
  142456. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142457. */
  142458. usePlaneDetection?: boolean;
  142459. /**
  142460. * a node that will be used to convert local to world coordinates
  142461. */
  142462. worldParentNode?: TransformNode;
  142463. }
  142464. /**
  142465. * A babylon container for an XR Anchor
  142466. */
  142467. export interface IWebXRAnchor {
  142468. /**
  142469. * A babylon-assigned ID for this anchor
  142470. */
  142471. id: number;
  142472. /**
  142473. * Transformation matrix to apply to an object attached to this anchor
  142474. */
  142475. transformationMatrix: Matrix;
  142476. /**
  142477. * The native anchor object
  142478. */
  142479. xrAnchor: XRAnchor;
  142480. }
  142481. /**
  142482. * An implementation of the anchor system of WebXR.
  142483. * Note that the current documented implementation is not available in any browser. Future implementations
  142484. * will use the frame to create an anchor and not the session or a detected plane
  142485. * For further information see https://github.com/immersive-web/anchors/
  142486. */
  142487. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142488. private _options;
  142489. private _enabled;
  142490. private _hitTestModule;
  142491. private _lastFrameDetected;
  142492. private _onSelect;
  142493. private _planeDetector;
  142494. private _trackedAnchors;
  142495. /**
  142496. * The module's name
  142497. */
  142498. static readonly Name: string;
  142499. /**
  142500. * The (Babylon) version of this module.
  142501. * This is an integer representing the implementation version.
  142502. * This number does not correspond to the WebXR specs version
  142503. */
  142504. static readonly Version: number;
  142505. /**
  142506. * Observers registered here will be executed when a new anchor was added to the session
  142507. */
  142508. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142509. /**
  142510. * Observers registered here will be executed when an anchor was removed from the session
  142511. */
  142512. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142513. /**
  142514. * Observers registered here will be executed when an existing anchor updates
  142515. * This can execute N times every frame
  142516. */
  142517. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142518. /**
  142519. * constructs a new anchor system
  142520. * @param _xrSessionManager an instance of WebXRSessionManager
  142521. * @param _options configuration object for this feature
  142522. */
  142523. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142524. /**
  142525. * Add anchor at a specific XR point.
  142526. *
  142527. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142528. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142529. * @returns a promise the fulfills when the anchor was created
  142530. */
  142531. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142532. /**
  142533. * attach this feature
  142534. * Will usually be called by the features manager
  142535. *
  142536. * @returns true if successful.
  142537. */
  142538. attach(): boolean;
  142539. /**
  142540. * detach this feature.
  142541. * Will usually be called by the features manager
  142542. *
  142543. * @returns true if successful.
  142544. */
  142545. detach(): boolean;
  142546. /**
  142547. * Dispose this feature and all of the resources attached
  142548. */
  142549. dispose(): void;
  142550. /**
  142551. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142552. * @param hitTestModule the hit-test module to use.
  142553. */
  142554. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142555. /**
  142556. * set the plane detector to use in order to create anchors from frames
  142557. * @param planeDetector the plane-detector module to use
  142558. * @param enable enable plane-anchors. default is true
  142559. */
  142560. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142561. protected _onXRFrame(frame: XRFrame): void;
  142562. /**
  142563. * avoiding using Array.find for global support.
  142564. * @param xrAnchor the plane to find in the array
  142565. */
  142566. private _findIndexInAnchorArray;
  142567. private _updateAnchorWithXRFrame;
  142568. }
  142569. }
  142570. declare module BABYLON {
  142571. /**
  142572. * Options interface for the background remover plugin
  142573. */
  142574. export interface IWebXRBackgroundRemoverOptions {
  142575. /**
  142576. * Further background meshes to disable when entering AR
  142577. */
  142578. backgroundMeshes?: AbstractMesh[];
  142579. /**
  142580. * flags to configure the removal of the environment helper.
  142581. * If not set, the entire background will be removed. If set, flags should be set as well.
  142582. */
  142583. environmentHelperRemovalFlags?: {
  142584. /**
  142585. * Should the skybox be removed (default false)
  142586. */
  142587. skyBox?: boolean;
  142588. /**
  142589. * Should the ground be removed (default false)
  142590. */
  142591. ground?: boolean;
  142592. };
  142593. /**
  142594. * don't disable the environment helper
  142595. */
  142596. ignoreEnvironmentHelper?: boolean;
  142597. }
  142598. /**
  142599. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142600. */
  142601. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142602. /**
  142603. * read-only options to be used in this module
  142604. */
  142605. readonly options: IWebXRBackgroundRemoverOptions;
  142606. /**
  142607. * The module's name
  142608. */
  142609. static readonly Name: string;
  142610. /**
  142611. * The (Babylon) version of this module.
  142612. * This is an integer representing the implementation version.
  142613. * This number does not correspond to the WebXR specs version
  142614. */
  142615. static readonly Version: number;
  142616. /**
  142617. * registered observers will be triggered when the background state changes
  142618. */
  142619. onBackgroundStateChangedObservable: Observable<boolean>;
  142620. /**
  142621. * constructs a new background remover module
  142622. * @param _xrSessionManager the session manager for this module
  142623. * @param options read-only options to be used in this module
  142624. */
  142625. constructor(_xrSessionManager: WebXRSessionManager,
  142626. /**
  142627. * read-only options to be used in this module
  142628. */
  142629. options?: IWebXRBackgroundRemoverOptions);
  142630. /**
  142631. * attach this feature
  142632. * Will usually be called by the features manager
  142633. *
  142634. * @returns true if successful.
  142635. */
  142636. attach(): boolean;
  142637. /**
  142638. * detach this feature.
  142639. * Will usually be called by the features manager
  142640. *
  142641. * @returns true if successful.
  142642. */
  142643. detach(): boolean;
  142644. /**
  142645. * Dispose this feature and all of the resources attached
  142646. */
  142647. dispose(): void;
  142648. protected _onXRFrame(_xrFrame: XRFrame): void;
  142649. private _setBackgroundState;
  142650. }
  142651. }
  142652. declare module BABYLON {
  142653. /**
  142654. * Options for the controller physics feature
  142655. */
  142656. export class IWebXRControllerPhysicsOptions {
  142657. /**
  142658. * Should the headset get its own impostor
  142659. */
  142660. enableHeadsetImpostor?: boolean;
  142661. /**
  142662. * Optional parameters for the headset impostor
  142663. */
  142664. headsetImpostorParams?: {
  142665. /**
  142666. * The type of impostor to create. Default is sphere
  142667. */
  142668. impostorType: number;
  142669. /**
  142670. * the size of the impostor. Defaults to 10cm
  142671. */
  142672. impostorSize?: number | {
  142673. width: number;
  142674. height: number;
  142675. depth: number;
  142676. };
  142677. /**
  142678. * Friction definitions
  142679. */
  142680. friction?: number;
  142681. /**
  142682. * Restitution
  142683. */
  142684. restitution?: number;
  142685. };
  142686. /**
  142687. * The physics properties of the future impostors
  142688. */
  142689. physicsProperties?: {
  142690. /**
  142691. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142692. * Note that this requires a physics engine that supports mesh impostors!
  142693. */
  142694. useControllerMesh?: boolean;
  142695. /**
  142696. * The type of impostor to create. Default is sphere
  142697. */
  142698. impostorType?: number;
  142699. /**
  142700. * the size of the impostor. Defaults to 10cm
  142701. */
  142702. impostorSize?: number | {
  142703. width: number;
  142704. height: number;
  142705. depth: number;
  142706. };
  142707. /**
  142708. * Friction definitions
  142709. */
  142710. friction?: number;
  142711. /**
  142712. * Restitution
  142713. */
  142714. restitution?: number;
  142715. };
  142716. /**
  142717. * the xr input to use with this pointer selection
  142718. */
  142719. xrInput: WebXRInput;
  142720. }
  142721. /**
  142722. * Add physics impostor to your webxr controllers,
  142723. * including naive calculation of their linear and angular velocity
  142724. */
  142725. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142726. private readonly _options;
  142727. private _attachController;
  142728. private _controllers;
  142729. private _debugMode;
  142730. private _delta;
  142731. private _headsetImpostor?;
  142732. private _headsetMesh?;
  142733. private _lastTimestamp;
  142734. private _tmpQuaternion;
  142735. private _tmpVector;
  142736. /**
  142737. * The module's name
  142738. */
  142739. static readonly Name: string;
  142740. /**
  142741. * The (Babylon) version of this module.
  142742. * This is an integer representing the implementation version.
  142743. * This number does not correspond to the webxr specs version
  142744. */
  142745. static readonly Version: number;
  142746. /**
  142747. * Construct a new Controller Physics Feature
  142748. * @param _xrSessionManager the corresponding xr session manager
  142749. * @param _options options to create this feature with
  142750. */
  142751. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142752. /**
  142753. * @hidden
  142754. * enable debugging - will show console outputs and the impostor mesh
  142755. */
  142756. _enablePhysicsDebug(): void;
  142757. /**
  142758. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142759. * @param xrController the controller to add
  142760. */
  142761. addController(xrController: WebXRInputSource): void;
  142762. /**
  142763. * attach this feature
  142764. * Will usually be called by the features manager
  142765. *
  142766. * @returns true if successful.
  142767. */
  142768. attach(): boolean;
  142769. /**
  142770. * detach this feature.
  142771. * Will usually be called by the features manager
  142772. *
  142773. * @returns true if successful.
  142774. */
  142775. detach(): boolean;
  142776. /**
  142777. * Get the headset impostor, if enabled
  142778. * @returns the impostor
  142779. */
  142780. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142781. /**
  142782. * Get the physics impostor of a specific controller.
  142783. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142784. * @param controller the controller or the controller id of which to get the impostor
  142785. * @returns the impostor or null
  142786. */
  142787. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142788. /**
  142789. * Update the physics properties provided in the constructor
  142790. * @param newProperties the new properties object
  142791. */
  142792. setPhysicsProperties(newProperties: {
  142793. impostorType?: number;
  142794. impostorSize?: number | {
  142795. width: number;
  142796. height: number;
  142797. depth: number;
  142798. };
  142799. friction?: number;
  142800. restitution?: number;
  142801. }): void;
  142802. protected _onXRFrame(_xrFrame: any): void;
  142803. private _detachController;
  142804. }
  142805. }
  142806. declare module BABYLON {
  142807. /**
  142808. * The motion controller class for all microsoft mixed reality controllers
  142809. */
  142810. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142811. protected readonly _mapping: {
  142812. defaultButton: {
  142813. "valueNodeName": string;
  142814. "unpressedNodeName": string;
  142815. "pressedNodeName": string;
  142816. };
  142817. defaultAxis: {
  142818. "valueNodeName": string;
  142819. "minNodeName": string;
  142820. "maxNodeName": string;
  142821. };
  142822. buttons: {
  142823. "xr-standard-trigger": {
  142824. "rootNodeName": string;
  142825. "componentProperty": string;
  142826. "states": string[];
  142827. };
  142828. "xr-standard-squeeze": {
  142829. "rootNodeName": string;
  142830. "componentProperty": string;
  142831. "states": string[];
  142832. };
  142833. "xr-standard-touchpad": {
  142834. "rootNodeName": string;
  142835. "labelAnchorNodeName": string;
  142836. "touchPointNodeName": string;
  142837. };
  142838. "xr-standard-thumbstick": {
  142839. "rootNodeName": string;
  142840. "componentProperty": string;
  142841. "states": string[];
  142842. };
  142843. };
  142844. axes: {
  142845. "xr-standard-touchpad": {
  142846. "x-axis": {
  142847. "rootNodeName": string;
  142848. };
  142849. "y-axis": {
  142850. "rootNodeName": string;
  142851. };
  142852. };
  142853. "xr-standard-thumbstick": {
  142854. "x-axis": {
  142855. "rootNodeName": string;
  142856. };
  142857. "y-axis": {
  142858. "rootNodeName": string;
  142859. };
  142860. };
  142861. };
  142862. };
  142863. /**
  142864. * The base url used to load the left and right controller models
  142865. */
  142866. static MODEL_BASE_URL: string;
  142867. /**
  142868. * The name of the left controller model file
  142869. */
  142870. static MODEL_LEFT_FILENAME: string;
  142871. /**
  142872. * The name of the right controller model file
  142873. */
  142874. static MODEL_RIGHT_FILENAME: string;
  142875. profileId: string;
  142876. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142877. protected _getFilenameAndPath(): {
  142878. filename: string;
  142879. path: string;
  142880. };
  142881. protected _getModelLoadingConstraints(): boolean;
  142882. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142883. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142884. protected _updateModel(): void;
  142885. }
  142886. }
  142887. declare module BABYLON {
  142888. /**
  142889. * The motion controller class for oculus touch (quest, rift).
  142890. * This class supports legacy mapping as well the standard xr mapping
  142891. */
  142892. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142893. private _forceLegacyControllers;
  142894. private _modelRootNode;
  142895. /**
  142896. * The base url used to load the left and right controller models
  142897. */
  142898. static MODEL_BASE_URL: string;
  142899. /**
  142900. * The name of the left controller model file
  142901. */
  142902. static MODEL_LEFT_FILENAME: string;
  142903. /**
  142904. * The name of the right controller model file
  142905. */
  142906. static MODEL_RIGHT_FILENAME: string;
  142907. /**
  142908. * Base Url for the Quest controller model.
  142909. */
  142910. static QUEST_MODEL_BASE_URL: string;
  142911. profileId: string;
  142912. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142913. protected _getFilenameAndPath(): {
  142914. filename: string;
  142915. path: string;
  142916. };
  142917. protected _getModelLoadingConstraints(): boolean;
  142918. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142919. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142920. protected _updateModel(): void;
  142921. /**
  142922. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142923. * between the touch and touch 2.
  142924. */
  142925. private _isQuest;
  142926. }
  142927. }
  142928. declare module BABYLON {
  142929. /**
  142930. * The motion controller class for the standard HTC-Vive controllers
  142931. */
  142932. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142933. private _modelRootNode;
  142934. /**
  142935. * The base url used to load the left and right controller models
  142936. */
  142937. static MODEL_BASE_URL: string;
  142938. /**
  142939. * File name for the controller model.
  142940. */
  142941. static MODEL_FILENAME: string;
  142942. profileId: string;
  142943. /**
  142944. * Create a new Vive motion controller object
  142945. * @param scene the scene to use to create this controller
  142946. * @param gamepadObject the corresponding gamepad object
  142947. * @param handness the handness of the controller
  142948. */
  142949. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142950. protected _getFilenameAndPath(): {
  142951. filename: string;
  142952. path: string;
  142953. };
  142954. protected _getModelLoadingConstraints(): boolean;
  142955. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142956. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142957. protected _updateModel(): void;
  142958. }
  142959. }
  142960. declare module BABYLON {
  142961. /**
  142962. * A cursor which tracks a point on a path
  142963. */
  142964. export class PathCursor {
  142965. private path;
  142966. /**
  142967. * Stores path cursor callbacks for when an onchange event is triggered
  142968. */
  142969. private _onchange;
  142970. /**
  142971. * The value of the path cursor
  142972. */
  142973. value: number;
  142974. /**
  142975. * The animation array of the path cursor
  142976. */
  142977. animations: Animation[];
  142978. /**
  142979. * Initializes the path cursor
  142980. * @param path The path to track
  142981. */
  142982. constructor(path: Path2);
  142983. /**
  142984. * Gets the cursor point on the path
  142985. * @returns A point on the path cursor at the cursor location
  142986. */
  142987. getPoint(): Vector3;
  142988. /**
  142989. * Moves the cursor ahead by the step amount
  142990. * @param step The amount to move the cursor forward
  142991. * @returns This path cursor
  142992. */
  142993. moveAhead(step?: number): PathCursor;
  142994. /**
  142995. * Moves the cursor behind by the step amount
  142996. * @param step The amount to move the cursor back
  142997. * @returns This path cursor
  142998. */
  142999. moveBack(step?: number): PathCursor;
  143000. /**
  143001. * Moves the cursor by the step amount
  143002. * If the step amount is greater than one, an exception is thrown
  143003. * @param step The amount to move the cursor
  143004. * @returns This path cursor
  143005. */
  143006. move(step: number): PathCursor;
  143007. /**
  143008. * Ensures that the value is limited between zero and one
  143009. * @returns This path cursor
  143010. */
  143011. private ensureLimits;
  143012. /**
  143013. * Runs onchange callbacks on change (used by the animation engine)
  143014. * @returns This path cursor
  143015. */
  143016. private raiseOnChange;
  143017. /**
  143018. * Executes a function on change
  143019. * @param f A path cursor onchange callback
  143020. * @returns This path cursor
  143021. */
  143022. onchange(f: (cursor: PathCursor) => void): PathCursor;
  143023. }
  143024. }
  143025. declare module BABYLON {
  143026. /** @hidden */
  143027. export var blurPixelShader: {
  143028. name: string;
  143029. shader: string;
  143030. };
  143031. }
  143032. declare module BABYLON {
  143033. /** @hidden */
  143034. export var pointCloudVertexDeclaration: {
  143035. name: string;
  143036. shader: string;
  143037. };
  143038. }
  143039. // Mixins
  143040. interface Window {
  143041. mozIndexedDB: IDBFactory;
  143042. webkitIndexedDB: IDBFactory;
  143043. msIndexedDB: IDBFactory;
  143044. webkitURL: typeof URL;
  143045. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  143046. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  143047. WebGLRenderingContext: WebGLRenderingContext;
  143048. MSGesture: MSGesture;
  143049. CANNON: any;
  143050. AudioContext: AudioContext;
  143051. webkitAudioContext: AudioContext;
  143052. PointerEvent: any;
  143053. Math: Math;
  143054. Uint8Array: Uint8ArrayConstructor;
  143055. Float32Array: Float32ArrayConstructor;
  143056. mozURL: typeof URL;
  143057. msURL: typeof URL;
  143058. VRFrameData: any; // WebVR, from specs 1.1
  143059. DracoDecoderModule: any;
  143060. setImmediate(handler: (...args: any[]) => void): number;
  143061. }
  143062. interface HTMLCanvasElement {
  143063. requestPointerLock(): void;
  143064. msRequestPointerLock?(): void;
  143065. mozRequestPointerLock?(): void;
  143066. webkitRequestPointerLock?(): void;
  143067. /** Track wether a record is in progress */
  143068. isRecording: boolean;
  143069. /** Capture Stream method defined by some browsers */
  143070. captureStream(fps?: number): MediaStream;
  143071. }
  143072. interface CanvasRenderingContext2D {
  143073. msImageSmoothingEnabled: boolean;
  143074. }
  143075. interface MouseEvent {
  143076. mozMovementX: number;
  143077. mozMovementY: number;
  143078. webkitMovementX: number;
  143079. webkitMovementY: number;
  143080. msMovementX: number;
  143081. msMovementY: number;
  143082. }
  143083. interface Navigator {
  143084. mozGetVRDevices: (any: any) => any;
  143085. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143086. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143087. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143088. webkitGetGamepads(): Gamepad[];
  143089. msGetGamepads(): Gamepad[];
  143090. webkitGamepads(): Gamepad[];
  143091. }
  143092. interface HTMLVideoElement {
  143093. mozSrcObject: any;
  143094. }
  143095. interface Math {
  143096. fround(x: number): number;
  143097. imul(a: number, b: number): number;
  143098. }
  143099. interface WebGLRenderingContext {
  143100. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  143101. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  143102. vertexAttribDivisor(index: number, divisor: number): void;
  143103. createVertexArray(): any;
  143104. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  143105. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  143106. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  143107. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  143108. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  143109. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  143110. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  143111. // Queries
  143112. createQuery(): WebGLQuery;
  143113. deleteQuery(query: WebGLQuery): void;
  143114. beginQuery(target: number, query: WebGLQuery): void;
  143115. endQuery(target: number): void;
  143116. getQueryParameter(query: WebGLQuery, pname: number): any;
  143117. getQuery(target: number, pname: number): any;
  143118. MAX_SAMPLES: number;
  143119. RGBA8: number;
  143120. READ_FRAMEBUFFER: number;
  143121. DRAW_FRAMEBUFFER: number;
  143122. UNIFORM_BUFFER: number;
  143123. HALF_FLOAT_OES: number;
  143124. RGBA16F: number;
  143125. RGBA32F: number;
  143126. R32F: number;
  143127. RG32F: number;
  143128. RGB32F: number;
  143129. R16F: number;
  143130. RG16F: number;
  143131. RGB16F: number;
  143132. RED: number;
  143133. RG: number;
  143134. R8: number;
  143135. RG8: number;
  143136. UNSIGNED_INT_24_8: number;
  143137. DEPTH24_STENCIL8: number;
  143138. MIN: number;
  143139. MAX: number;
  143140. /* Multiple Render Targets */
  143141. drawBuffers(buffers: number[]): void;
  143142. readBuffer(src: number): void;
  143143. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  143144. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  143145. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  143146. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  143147. // Occlusion Query
  143148. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  143149. ANY_SAMPLES_PASSED: number;
  143150. QUERY_RESULT_AVAILABLE: number;
  143151. QUERY_RESULT: number;
  143152. }
  143153. interface WebGLProgram {
  143154. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  143155. }
  143156. interface EXT_disjoint_timer_query {
  143157. QUERY_COUNTER_BITS_EXT: number;
  143158. TIME_ELAPSED_EXT: number;
  143159. TIMESTAMP_EXT: number;
  143160. GPU_DISJOINT_EXT: number;
  143161. QUERY_RESULT_EXT: number;
  143162. QUERY_RESULT_AVAILABLE_EXT: number;
  143163. queryCounterEXT(query: WebGLQuery, target: number): void;
  143164. createQueryEXT(): WebGLQuery;
  143165. beginQueryEXT(target: number, query: WebGLQuery): void;
  143166. endQueryEXT(target: number): void;
  143167. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  143168. deleteQueryEXT(query: WebGLQuery): void;
  143169. }
  143170. interface WebGLUniformLocation {
  143171. _currentState: any;
  143172. }
  143173. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  143174. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  143175. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  143176. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143177. interface WebGLRenderingContext {
  143178. readonly RASTERIZER_DISCARD: number;
  143179. readonly DEPTH_COMPONENT24: number;
  143180. readonly TEXTURE_3D: number;
  143181. readonly TEXTURE_2D_ARRAY: number;
  143182. readonly TEXTURE_COMPARE_FUNC: number;
  143183. readonly TEXTURE_COMPARE_MODE: number;
  143184. readonly COMPARE_REF_TO_TEXTURE: number;
  143185. readonly TEXTURE_WRAP_R: number;
  143186. readonly HALF_FLOAT: number;
  143187. readonly RGB8: number;
  143188. readonly RED_INTEGER: number;
  143189. readonly RG_INTEGER: number;
  143190. readonly RGB_INTEGER: number;
  143191. readonly RGBA_INTEGER: number;
  143192. readonly R8_SNORM: number;
  143193. readonly RG8_SNORM: number;
  143194. readonly RGB8_SNORM: number;
  143195. readonly RGBA8_SNORM: number;
  143196. readonly R8I: number;
  143197. readonly RG8I: number;
  143198. readonly RGB8I: number;
  143199. readonly RGBA8I: number;
  143200. readonly R8UI: number;
  143201. readonly RG8UI: number;
  143202. readonly RGB8UI: number;
  143203. readonly RGBA8UI: number;
  143204. readonly R16I: number;
  143205. readonly RG16I: number;
  143206. readonly RGB16I: number;
  143207. readonly RGBA16I: number;
  143208. readonly R16UI: number;
  143209. readonly RG16UI: number;
  143210. readonly RGB16UI: number;
  143211. readonly RGBA16UI: number;
  143212. readonly R32I: number;
  143213. readonly RG32I: number;
  143214. readonly RGB32I: number;
  143215. readonly RGBA32I: number;
  143216. readonly R32UI: number;
  143217. readonly RG32UI: number;
  143218. readonly RGB32UI: number;
  143219. readonly RGBA32UI: number;
  143220. readonly RGB10_A2UI: number;
  143221. readonly R11F_G11F_B10F: number;
  143222. readonly RGB9_E5: number;
  143223. readonly RGB10_A2: number;
  143224. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  143225. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  143226. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  143227. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  143228. readonly DEPTH_COMPONENT32F: number;
  143229. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143230. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143231. 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;
  143232. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143233. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143234. readonly TRANSFORM_FEEDBACK: number;
  143235. readonly INTERLEAVED_ATTRIBS: number;
  143236. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143237. createTransformFeedback(): WebGLTransformFeedback;
  143238. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143239. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143240. beginTransformFeedback(primitiveMode: number): void;
  143241. endTransformFeedback(): void;
  143242. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143243. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143244. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143245. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143246. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143247. }
  143248. interface ImageBitmap {
  143249. readonly width: number;
  143250. readonly height: number;
  143251. close(): void;
  143252. }
  143253. interface WebGLQuery extends WebGLObject {
  143254. }
  143255. declare var WebGLQuery: {
  143256. prototype: WebGLQuery;
  143257. new(): WebGLQuery;
  143258. };
  143259. interface WebGLSampler extends WebGLObject {
  143260. }
  143261. declare var WebGLSampler: {
  143262. prototype: WebGLSampler;
  143263. new(): WebGLSampler;
  143264. };
  143265. interface WebGLSync extends WebGLObject {
  143266. }
  143267. declare var WebGLSync: {
  143268. prototype: WebGLSync;
  143269. new(): WebGLSync;
  143270. };
  143271. interface WebGLTransformFeedback extends WebGLObject {
  143272. }
  143273. declare var WebGLTransformFeedback: {
  143274. prototype: WebGLTransformFeedback;
  143275. new(): WebGLTransformFeedback;
  143276. };
  143277. interface WebGLVertexArrayObject extends WebGLObject {
  143278. }
  143279. declare var WebGLVertexArrayObject: {
  143280. prototype: WebGLVertexArrayObject;
  143281. new(): WebGLVertexArrayObject;
  143282. };
  143283. // Type definitions for WebVR API
  143284. // Project: https://w3c.github.io/webvr/
  143285. // Definitions by: six a <https://github.com/lostfictions>
  143286. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143287. interface VRDisplay extends EventTarget {
  143288. /**
  143289. * Dictionary of capabilities describing the VRDisplay.
  143290. */
  143291. readonly capabilities: VRDisplayCapabilities;
  143292. /**
  143293. * z-depth defining the far plane of the eye view frustum
  143294. * enables mapping of values in the render target depth
  143295. * attachment to scene coordinates. Initially set to 10000.0.
  143296. */
  143297. depthFar: number;
  143298. /**
  143299. * z-depth defining the near plane of the eye view frustum
  143300. * enables mapping of values in the render target depth
  143301. * attachment to scene coordinates. Initially set to 0.01.
  143302. */
  143303. depthNear: number;
  143304. /**
  143305. * An identifier for this distinct VRDisplay. Used as an
  143306. * association point in the Gamepad API.
  143307. */
  143308. readonly displayId: number;
  143309. /**
  143310. * A display name, a user-readable name identifying it.
  143311. */
  143312. readonly displayName: string;
  143313. readonly isConnected: boolean;
  143314. readonly isPresenting: boolean;
  143315. /**
  143316. * If this VRDisplay supports room-scale experiences, the optional
  143317. * stage attribute contains details on the room-scale parameters.
  143318. */
  143319. readonly stageParameters: VRStageParameters | null;
  143320. /**
  143321. * Passing the value returned by `requestAnimationFrame` to
  143322. * `cancelAnimationFrame` will unregister the callback.
  143323. * @param handle Define the hanle of the request to cancel
  143324. */
  143325. cancelAnimationFrame(handle: number): void;
  143326. /**
  143327. * Stops presenting to the VRDisplay.
  143328. * @returns a promise to know when it stopped
  143329. */
  143330. exitPresent(): Promise<void>;
  143331. /**
  143332. * Return the current VREyeParameters for the given eye.
  143333. * @param whichEye Define the eye we want the parameter for
  143334. * @returns the eye parameters
  143335. */
  143336. getEyeParameters(whichEye: string): VREyeParameters;
  143337. /**
  143338. * Populates the passed VRFrameData with the information required to render
  143339. * the current frame.
  143340. * @param frameData Define the data structure to populate
  143341. * @returns true if ok otherwise false
  143342. */
  143343. getFrameData(frameData: VRFrameData): boolean;
  143344. /**
  143345. * Get the layers currently being presented.
  143346. * @returns the list of VR layers
  143347. */
  143348. getLayers(): VRLayer[];
  143349. /**
  143350. * Return a VRPose containing the future predicted pose of the VRDisplay
  143351. * when the current frame will be presented. The value returned will not
  143352. * change until JavaScript has returned control to the browser.
  143353. *
  143354. * The VRPose will contain the position, orientation, velocity,
  143355. * and acceleration of each of these properties.
  143356. * @returns the pose object
  143357. */
  143358. getPose(): VRPose;
  143359. /**
  143360. * Return the current instantaneous pose of the VRDisplay, with no
  143361. * prediction applied.
  143362. * @returns the current instantaneous pose
  143363. */
  143364. getImmediatePose(): VRPose;
  143365. /**
  143366. * The callback passed to `requestAnimationFrame` will be called
  143367. * any time a new frame should be rendered. When the VRDisplay is
  143368. * presenting the callback will be called at the native refresh
  143369. * rate of the HMD. When not presenting this function acts
  143370. * identically to how window.requestAnimationFrame acts. Content should
  143371. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143372. * asynchronously from other displays and at differing refresh rates.
  143373. * @param callback Define the eaction to run next frame
  143374. * @returns the request handle it
  143375. */
  143376. requestAnimationFrame(callback: FrameRequestCallback): number;
  143377. /**
  143378. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143379. * Repeat calls while already presenting will update the VRLayers being displayed.
  143380. * @param layers Define the list of layer to present
  143381. * @returns a promise to know when the request has been fulfilled
  143382. */
  143383. requestPresent(layers: VRLayer[]): Promise<void>;
  143384. /**
  143385. * Reset the pose for this display, treating its current position and
  143386. * orientation as the "origin/zero" values. VRPose.position,
  143387. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143388. * updated when calling resetPose(). This should be called in only
  143389. * sitting-space experiences.
  143390. */
  143391. resetPose(): void;
  143392. /**
  143393. * The VRLayer provided to the VRDisplay will be captured and presented
  143394. * in the HMD. Calling this function has the same effect on the source
  143395. * canvas as any other operation that uses its source image, and canvases
  143396. * created without preserveDrawingBuffer set to true will be cleared.
  143397. * @param pose Define the pose to submit
  143398. */
  143399. submitFrame(pose?: VRPose): void;
  143400. }
  143401. declare var VRDisplay: {
  143402. prototype: VRDisplay;
  143403. new(): VRDisplay;
  143404. };
  143405. interface VRLayer {
  143406. leftBounds?: number[] | Float32Array | null;
  143407. rightBounds?: number[] | Float32Array | null;
  143408. source?: HTMLCanvasElement | null;
  143409. }
  143410. interface VRDisplayCapabilities {
  143411. readonly canPresent: boolean;
  143412. readonly hasExternalDisplay: boolean;
  143413. readonly hasOrientation: boolean;
  143414. readonly hasPosition: boolean;
  143415. readonly maxLayers: number;
  143416. }
  143417. interface VREyeParameters {
  143418. /** @deprecated */
  143419. readonly fieldOfView: VRFieldOfView;
  143420. readonly offset: Float32Array;
  143421. readonly renderHeight: number;
  143422. readonly renderWidth: number;
  143423. }
  143424. interface VRFieldOfView {
  143425. readonly downDegrees: number;
  143426. readonly leftDegrees: number;
  143427. readonly rightDegrees: number;
  143428. readonly upDegrees: number;
  143429. }
  143430. interface VRFrameData {
  143431. readonly leftProjectionMatrix: Float32Array;
  143432. readonly leftViewMatrix: Float32Array;
  143433. readonly pose: VRPose;
  143434. readonly rightProjectionMatrix: Float32Array;
  143435. readonly rightViewMatrix: Float32Array;
  143436. readonly timestamp: number;
  143437. }
  143438. interface VRPose {
  143439. readonly angularAcceleration: Float32Array | null;
  143440. readonly angularVelocity: Float32Array | null;
  143441. readonly linearAcceleration: Float32Array | null;
  143442. readonly linearVelocity: Float32Array | null;
  143443. readonly orientation: Float32Array | null;
  143444. readonly position: Float32Array | null;
  143445. readonly timestamp: number;
  143446. }
  143447. interface VRStageParameters {
  143448. sittingToStandingTransform?: Float32Array;
  143449. sizeX?: number;
  143450. sizeY?: number;
  143451. }
  143452. interface Navigator {
  143453. getVRDisplays(): Promise<VRDisplay[]>;
  143454. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143455. }
  143456. interface Window {
  143457. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143458. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143459. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143460. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143461. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143462. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143463. }
  143464. interface Gamepad {
  143465. readonly displayId: number;
  143466. }
  143467. type XRSessionMode =
  143468. | "inline"
  143469. | "immersive-vr"
  143470. | "immersive-ar";
  143471. type XRReferenceSpaceType =
  143472. | "viewer"
  143473. | "local"
  143474. | "local-floor"
  143475. | "bounded-floor"
  143476. | "unbounded";
  143477. type XREnvironmentBlendMode =
  143478. | "opaque"
  143479. | "additive"
  143480. | "alpha-blend";
  143481. type XRVisibilityState =
  143482. | "visible"
  143483. | "visible-blurred"
  143484. | "hidden";
  143485. type XRHandedness =
  143486. | "none"
  143487. | "left"
  143488. | "right";
  143489. type XRTargetRayMode =
  143490. | "gaze"
  143491. | "tracked-pointer"
  143492. | "screen";
  143493. type XREye =
  143494. | "none"
  143495. | "left"
  143496. | "right";
  143497. interface XRSpace extends EventTarget {
  143498. }
  143499. interface XRRenderState {
  143500. depthNear?: number;
  143501. depthFar?: number;
  143502. inlineVerticalFieldOfView?: number;
  143503. baseLayer?: XRWebGLLayer;
  143504. }
  143505. interface XRInputSource {
  143506. handedness: XRHandedness;
  143507. targetRayMode: XRTargetRayMode;
  143508. targetRaySpace: XRSpace;
  143509. gripSpace: XRSpace | undefined;
  143510. gamepad: Gamepad | undefined;
  143511. profiles: Array<string>;
  143512. }
  143513. interface XRSessionInit {
  143514. optionalFeatures?: XRReferenceSpaceType[];
  143515. requiredFeatures?: XRReferenceSpaceType[];
  143516. }
  143517. interface XRSession extends XRAnchorCreator {
  143518. addEventListener: Function;
  143519. removeEventListener: Function;
  143520. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143521. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143522. requestAnimationFrame: Function;
  143523. end(): Promise<void>;
  143524. renderState: XRRenderState;
  143525. inputSources: Array<XRInputSource>;
  143526. // AR hit test
  143527. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143528. updateWorldTrackingState(options: {
  143529. planeDetectionState?: { enabled: boolean; }
  143530. }): void;
  143531. }
  143532. interface XRReferenceSpace extends XRSpace {
  143533. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143534. onreset: any;
  143535. }
  143536. type XRPlaneSet = Set<XRPlane>;
  143537. type XRAnchorSet = Set<XRAnchor>;
  143538. interface XRFrame {
  143539. session: XRSession;
  143540. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143541. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143542. // Anchors
  143543. trackedAnchors?: XRAnchorSet;
  143544. // Planes
  143545. worldInformation: {
  143546. detectedPlanes?: XRPlaneSet;
  143547. };
  143548. }
  143549. interface XRViewerPose extends XRPose {
  143550. views: Array<XRView>;
  143551. }
  143552. interface XRPose {
  143553. transform: XRRigidTransform;
  143554. emulatedPosition: boolean;
  143555. }
  143556. interface XRWebGLLayerOptions {
  143557. antialias?: boolean;
  143558. depth?: boolean;
  143559. stencil?: boolean;
  143560. alpha?: boolean;
  143561. multiview?: boolean;
  143562. framebufferScaleFactor?: number;
  143563. }
  143564. declare var XRWebGLLayer: {
  143565. prototype: XRWebGLLayer;
  143566. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143567. };
  143568. interface XRWebGLLayer {
  143569. framebuffer: WebGLFramebuffer;
  143570. framebufferWidth: number;
  143571. framebufferHeight: number;
  143572. getViewport: Function;
  143573. }
  143574. declare class XRRigidTransform {
  143575. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143576. position: DOMPointReadOnly;
  143577. orientation: DOMPointReadOnly;
  143578. matrix: Float32Array;
  143579. inverse: XRRigidTransform;
  143580. }
  143581. interface XRView {
  143582. eye: XREye;
  143583. projectionMatrix: Float32Array;
  143584. transform: XRRigidTransform;
  143585. }
  143586. interface XRInputSourceChangeEvent {
  143587. session: XRSession;
  143588. removed: Array<XRInputSource>;
  143589. added: Array<XRInputSource>;
  143590. }
  143591. interface XRInputSourceEvent extends Event {
  143592. readonly frame: XRFrame;
  143593. readonly inputSource: XRInputSource;
  143594. }
  143595. // Experimental(er) features
  143596. declare class XRRay {
  143597. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143598. origin: DOMPointReadOnly;
  143599. direction: DOMPointReadOnly;
  143600. matrix: Float32Array;
  143601. }
  143602. interface XRHitResult {
  143603. hitMatrix: Float32Array;
  143604. }
  143605. interface XRAnchor {
  143606. // remove?
  143607. id?: string;
  143608. anchorSpace: XRSpace;
  143609. lastChangedTime: number;
  143610. detach(): void;
  143611. }
  143612. interface XRPlane extends XRAnchorCreator {
  143613. orientation: "Horizontal" | "Vertical";
  143614. planeSpace: XRSpace;
  143615. polygon: Array<DOMPointReadOnly>;
  143616. lastChangedTime: number;
  143617. }
  143618. interface XRAnchorCreator {
  143619. // AR Anchors
  143620. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143621. }